BSD 4_3 release
[unix-history] / usr / src / lib / libc / net / res_mkquery.c
index e529c29..5267cc1 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_mkquery.c      6.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)res_mkquery.c      6.3 (Berkeley) 3/17/86";
 #endif LIBC_SCCS and not lint
 
 #include <stdio.h>
 #endif LIBC_SCCS and not lint
 
 #include <stdio.h>
@@ -133,64 +133,69 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
                hp->ancount = htons(1);
                break;
 
                hp->ancount = htons(1);
                break;
 
-#ifdef ALLOW_UPDATES
-       /*
-        * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA
-        * (Record to be modified is followed by its replacement in msg.)
-        */
-       case UPDATEM:
-       case UPDATEMA:
-
+#ifdef notdef
        case UPDATED:
                /*
        case UPDATED:
                /*
-                * The res code for UPDATED and UPDATEDA is the same; user
-                * calls them differently: specifies data for UPDATED; server
-                * ignores data if specified for UPDATEDA.
+                * Put record to be added or deleted in additional section
                 */
                 */
-       case UPDATEDA:
                buflen -= RRFIXEDSZ + datalen;
                buflen -= RRFIXEDSZ + datalen;
-               if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+               if ((n = dn_comp(dname, cp, buflen, NULL, NULL)) < 0)
                        return (-1);
                cp += n;
                        return (-1);
                cp += n;
-               putshort(type, cp);
-                cp += sizeof(u_short);
-                putshort(class, cp);
-                cp += sizeof(u_short);
-               putlong(0, cp);
+               *((u_short *)cp) = htons(type);
+               cp += sizeof(u_short);
+               *((u_short *)cp) = htons(class);
+               cp += sizeof(u_short);
+               *((u_long *)cp) = 0;
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               putshort(datalen, cp);
-                cp += sizeof(u_short);
+               *((u_short *)cp) = htons(datalen);
+               cp += sizeof(u_short);
                if (datalen) {
                        bcopy(data, cp, datalen);
                        cp += datalen;
                }
                if (datalen) {
                        bcopy(data, cp, datalen);
                        cp += datalen;
                }
-               if ( (op == UPDATED) || (op == UPDATEDA) ) {
-                       hp->ancount = htons(0);
-                       break;
-               }
-               /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */
+               break;
 
 
-       case UPDATEA:   /* Add new resource record */
+       case UPDATEM:
+               /*
+                * Record to be modified followed by its replacement
+                */
                buflen -= RRFIXEDSZ + datalen;
                if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
                        return (-1);
                cp += n;
                buflen -= RRFIXEDSZ + datalen;
                if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
                        return (-1);
                cp += n;
-               putshort(newrr->r_type, cp);
-                cp += sizeof(u_short);
-                putshort(newrr->r_class, cp);
-                cp += sizeof(u_short);
-               putlong(0, cp);
+               *((u_short *)cp) = htons(type);
+               cp += sizeof(u_short);
+               *((u_short *)cp) = htons(class);
+               cp += sizeof(u_short);
+               *((u_long *)cp) = 0;
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               putshort(newrr->r_size, cp);
-                cp += sizeof(u_short);
+               *((u_short *)cp) = htons(datalen);
+               cp += sizeof(u_short);
+               if (datalen) {
+                       bcopy(data, cp, datalen);
+                       cp += datalen;
+               }
+
+       case UPDATEA:
+               buflen -= RRFIXEDSZ + newrr->r_size;
+               if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+                       return (-1);
+               cp += n;
+               *((u_short *)cp) = htons(newrr->r_type);
+               cp += sizeof(u_short);
+               *((u_short *)cp) = htons(newrr->r_type);
+               cp += sizeof(u_short);
+               *((u_long *)cp) = htonl(newrr->r_ttl);
+               cp += sizeof(u_long);
+               *((u_short *)cp) = htons(newrr->r_size);
+               cp += sizeof(u_short);
                if (newrr->r_size) {
                        bcopy(newrr->r_data, cp, newrr->r_size);
                        cp += newrr->r_size;
                }
                if (newrr->r_size) {
                        bcopy(newrr->r_data, cp, newrr->r_size);
                        cp += newrr->r_size;
                }
-               hp->ancount = htons(0);
                break;
                break;
-
-#endif ALLOW_UPDATES
+#endif
        }
        return (cp - buf);
 }
        }
        return (cp - buf);
 }