fixes for dynamic updates from Mike Schwartz@washington
authorKevin Dunlap <kjd@ucbvax.Berkeley.EDU>
Tue, 11 Nov 1986 07:36:14 +0000 (23:36 -0800)
committerKevin Dunlap <kjd@ucbvax.Berkeley.EDU>
Tue, 11 Nov 1986 07:36:14 +0000 (23:36 -0800)
SCCS-vsn: lib/libc/net/res_debug.c 5.15
SCCS-vsn: lib/libc/net/res_mkquery.c 6.4

usr/src/lib/libc/net/res_debug.c
usr/src/lib/libc/net/res_mkquery.c

index b1cca5b..2a3c9ee 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_debug.c        5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)res_debug.c        5.15 (Berkeley) %G%";
 #endif LIBC_SCCS and not lint
 
 #if defined(lint) && !defined(DEBUG)
 #endif LIBC_SCCS and not lint
 
 #if defined(lint) && !defined(DEBUG)
@@ -30,8 +30,6 @@ char *opcodes[] = {
        "6",
        "7",
        "8",
        "6",
        "7",
        "8",
-       "9",
-       "10",
        "UPDATEA",
        "UPDATED",
        "UPDATEM",
        "UPDATEA",
        "UPDATED",
        "UPDATEM",
@@ -318,6 +316,24 @@ p_rr(cp, msg, file)
                putc('\n',file);
                break;
 
                putc('\n',file);
                break;
 
+#ifdef ALLOW_T_UNSPEC
+        case T_UNSPEC:
+                {
+                        int NumBytes = 8;
+                        char *DataPtr;
+                        int i;
+
+                        if (dlen < NumBytes) NumBytes = dlen;
+                        fprintf(file, "\tFirst %d bytes of hex data:",
+                                NumBytes);
+                        for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
+                                fprintf(file, " %x", *DataPtr);
+                        fputs("\n", file);
+                        cp += dlen;
+                }
+                break;
+#endif ALLOW_T_UNSPEC
+
        default:
                fprintf(file,"\t???\n");
                cp += dlen;
        default:
                fprintf(file,"\t???\n");
                cp += dlen;
@@ -386,6 +402,10 @@ p_type(type)
                return("UID");
        case T_GID:
                return("GID");
                return("UID");
        case T_GID:
                return("GID");
+#ifdef ALLOW_T_UNSPEC
+        case T_UNSPEC:
+                return("UNSPEC");
+#endif ALLOW_T_UNSPEC
        default:
                return (sprintf(nbuf, "%d", type));
        }
        default:
                return (sprintf(nbuf, "%d", type));
        }
index 4e1e360..e529c29 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.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)res_mkquery.c      6.4 (Berkeley) %G%";
 #endif LIBC_SCCS and not lint
 
 #include <stdio.h>
 #endif LIBC_SCCS and not lint
 
 #include <stdio.h>
@@ -133,69 +133,64 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
                hp->ancount = htons(1);
                break;
 
                hp->ancount = htons(1);
                break;
 
-#ifdef notdef
-       case UPDATED:
-               /*
-                * Put record to be added or deleted in additional section
-                */
-               buflen -= RRFIXEDSZ + datalen;
-               if ((n = dn_comp(dname, cp, buflen, NULL, NULL)) < 0)
-                       return (-1);
-               cp += n;
-               *((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);
-               *((u_short *)cp) = htons(datalen);
-               cp += sizeof(u_short);
-               if (datalen) {
-                       bcopy(data, cp, datalen);
-                       cp += datalen;
-               }
-               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 UPDATEM:
+       case UPDATEMA:
+
+       case UPDATED:
                /*
                /*
-                * Record to be modified followed by its replacement
+                * 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.
                 */
                 */
+       case UPDATEDA:
                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;
-               *((u_short *)cp) = htons(type);
-               cp += sizeof(u_short);
-               *((u_short *)cp) = htons(class);
-               cp += sizeof(u_short);
-               *((u_long *)cp) = 0;
+               putshort(type, cp);
+                cp += sizeof(u_short);
+                putshort(class, cp);
+                cp += sizeof(u_short);
+               putlong(0, cp);
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               *((u_short *)cp) = htons(datalen);
-               cp += sizeof(u_short);
+               putshort(datalen, cp);
+                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 */
 
 
-       case UPDATEA:
-               buflen -= RRFIXEDSZ + newrr->r_size;
+       case UPDATEA:   /* Add new resource record */
+               buflen -= RRFIXEDSZ + datalen;
                if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
                        return (-1);
                cp += n;
                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);
+               putshort(newrr->r_type, cp);
+                cp += sizeof(u_short);
+                putshort(newrr->r_class, cp);
+                cp += sizeof(u_short);
+               putlong(0, cp);
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               *((u_short *)cp) = htons(newrr->r_size);
-               cp += sizeof(u_short);
+               putshort(newrr->r_size, cp);
+                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
+
+#endif ALLOW_UPDATES
        }
        return (cp - buf);
 }
        }
        return (cp - buf);
 }