SCCS-vsn: lib/libc/net/res_debug.c 5.15
SCCS-vsn: lib/libc/net/res_mkquery.c 6.4
*/
#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)
"UPDATEA",
"UPDATED",
"UPDATEM",
"UPDATEA",
"UPDATED",
"UPDATEM",
+#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;
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));
}
*/
#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>
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 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.
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);
- *((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);
- *((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);