<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -359,3 +359,18 @@
 	ui: dnstrace uses a ``start'' IP address for the root glue.
 20010121
 	version: djbdns 1.04.
+20010206
+	internal: response_query() takes a class argument.
+	internal: query_start() takes a class argument.
+	internal: packetquery() takes a class argument.
+	ui: tinydns et al., axfrdns, and dnscache repeat qclass * in
+		response to bogus * queries. tnx Mike Batchelor.
+	ui: axfrdns rejects queries for weird classes.
+	ui: axfrdns uses query ID instead of ID 0 in the series of AXFR
+		response messages between the SOAs, to support the AXFR
+		client in BIND 9.
+	ui: axfrdns sets AA in the series of AXFR response messages.
+20010211
+	ui: servers print starting message.
+	internal: some respond() declarations.
+	version: djbdns 1.05.</diff>
      <filename>CHANGES</filename>
    </modified>
    <modified>
      <diff>@@ -771,9 +771,10 @@ choose compile trysysel.c select.h1 select.h2
 	./choose c trysysel select.h1 select.h2 &gt; select.h
 
 server.o: \
-compile server.c byte.h case.h env.h strerr.h ip4.h uint16.h ndelay.h \
-socket.h uint16.h droproot.h qlog.h uint16.h response.h uint32.h \
-dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h
+compile server.c byte.h case.h env.h buffer.h strerr.h ip4.h uint16.h \
+ndelay.h socket.h uint16.h droproot.h qlog.h uint16.h response.h \
+uint32.h dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h \
+taia.h
 	./compile server.c
 
 setup: \</diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
-djbdns 1.04
-20010121
+djbdns 1.05
+20010211
 Copyright 2001
 D. J. Bernstein
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-djbdns 1.04
+djbdns 1.05</diff>
      <filename>VERSION</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,8 @@
 #include &quot;qlog.h&quot;
 #include &quot;response.h&quot;
 
+extern int respond(char *,char *,char *);
+
 #define FATAL &quot;axfrdns: fatal: &quot;
 
 void nomem()
@@ -144,7 +146,7 @@ void doname(stralloc *sa)
   if (!stralloc_catb(sa,d,dns_domain_length(d))) nomem();
 }
 
-int build(stralloc *sa,char *q,int flagsoa)
+int build(stralloc *sa,char *q,int flagsoa,char id[2])
 {
   unsigned int rdatapos;
   char misc[20];
@@ -159,7 +161,8 @@ int build(stralloc *sa,char *q,int flagsoa)
   if (flagsoa) if (byte_diff(type,2,DNS_T_SOA)) return 0;
   if (!flagsoa) if (byte_equal(type,2,DNS_T_SOA)) return 0;
 
-  if (!stralloc_copyb(sa,&quot;\0\0\200\200\0\0\0\1\0\0\0\0&quot;,12)) nomem();
+  if (!stralloc_copyb(sa,id,2)) nomem();
+  if (!stralloc_catb(sa,&quot;\204\000\0\0\0\1\0\0\0\0&quot;,10)) nomem();
   copy(misc,1);
   if ((misc[0] == '=' + 1) || (misc[0] == '*' + 1)) {
     --misc[0];
@@ -217,7 +220,7 @@ static char *q;
 static stralloc soa;
 static stralloc message;
 
-void doaxfr(void)
+void doaxfr(char id[2])
 {
   char key[512];
   uint32 klen;
@@ -252,7 +255,7 @@ void doaxfr(void)
     dlen = cdb_datalen(&amp;c);
     if (dlen &gt; sizeof data) die_cdbformat();
     if (cdb_read(&amp;c,data,dlen,cdb_datapos(&amp;c)) == -1) die_cdbformat();
-    if (build(&amp;soa,zone,1)) break;
+    if (build(&amp;soa,zone,1,id)) break;
   }
 
   cdb_free(&amp;c);
@@ -286,7 +289,7 @@ void doaxfr(void)
     if (klen &lt; 1) die_cdbformat();
     if (dns_packet_getname(key,klen,0,&amp;q) != klen) die_cdbformat();
     if (!dns_domain_suffix(q,zone)) continue;
-    if (!build(&amp;message,q,0)) continue;
+    if (!build(&amp;message,q,0,id)) continue;
     print(message.s,message.len);
   }
 
@@ -316,6 +319,7 @@ int main()
   unsigned int pos;
   char header[12];
   char qtype[2];
+  char qclass[2];
   const char *x;
 
   droproot(FATAL);
@@ -346,6 +350,10 @@ int main()
     pos = dns_packet_getname(buf,len,pos,&amp;zone); if (!pos) die_truncated();
     zonelen = dns_domain_length(zone);
     pos = dns_packet_copy(buf,len,pos,qtype,2); if (!pos) die_truncated();
+    pos = dns_packet_copy(buf,len,pos,qclass,2); if (!pos) die_truncated();
+
+    if (byte_diff(qclass,2,DNS_C_IN) &amp;&amp; byte_diff(qclass,2,DNS_C_ANY))
+      strerr_die2x(111,FATAL,&quot;bogus query: bad class&quot;);
 
     qlog(ip,port,header,zone,qtype,&quot; &quot;);
 
@@ -353,11 +361,11 @@ int main()
       case_lowerb(zone,zonelen);
       fdcdb = open_read(&quot;data.cdb&quot;);
       if (fdcdb == -1) die_cdbread();
-      doaxfr();
+      doaxfr(header);
       close(fdcdb);
     }
     else {
-      if (!response_query(zone,qtype)) nomem();
+      if (!response_query(zone,qtype,qclass)) nomem();
       response[2] |= 4;
       case_lowerb(zone,zonelen);
       response_id(header);</diff>
      <filename>axfrdns.c</filename>
    </modified>
    <modified>
      <diff>@@ -23,10 +23,9 @@
 #include &quot;okclient.h&quot;
 #include &quot;droproot.h&quot;
 
-static int packetquery(char *buf,unsigned int len,char **q,char qtype[2],char id[2])
+static int packetquery(char *buf,unsigned int len,char **q,char qtype[2],char qclass[2],char id[2])
 {
   unsigned int pos;
-  char qclass[2];
   char header[12];
 
   errno = error_proto;
@@ -92,6 +91,7 @@ void u_new(void)
   int len;
   static char *q = 0;
   char qtype[2];
+  char qclass[2];
 
   for (j = 0;j &lt; MAXUDP;++j)
     if (!u[j].active)
@@ -115,11 +115,11 @@ void u_new(void)
   if (x-&gt;port &lt; 1024) if (x-&gt;port != 53) return;
   if (!okclient(x-&gt;ip)) return;
 
-  if (!packetquery(buf,len,&amp;q,qtype,x-&gt;id)) return;
+  if (!packetquery(buf,len,&amp;q,qtype,qclass,x-&gt;id)) return;
 
   x-&gt;active = ++numqueries; ++uactive;
   log_query(&amp;x-&gt;active,x-&gt;ip,x-&gt;port,x-&gt;id,q,qtype);
-  switch(query_start(&amp;x-&gt;q,q,qtype,myipoutgoing)) {
+  switch(query_start(&amp;x-&gt;q,q,qtype,qclass,myipoutgoing)) {
     case -1:
       u_drop(j);
       return;
@@ -210,6 +210,7 @@ void t_rw(int j)
   char ch;
   static char *q = 0;
   char qtype[2];
+  char qclass[2];
   int r;
 
   x = t + j;
@@ -249,11 +250,11 @@ void t_rw(int j)
   x-&gt;buf[x-&gt;pos++] = ch;
   if (x-&gt;pos &lt; x-&gt;len) return;
 
-  if (!packetquery(x-&gt;buf,x-&gt;len,&amp;q,qtype,x-&gt;id)) { t_close(j); return; }
+  if (!packetquery(x-&gt;buf,x-&gt;len,&amp;q,qtype,qclass,x-&gt;id)) { t_close(j); return; }
 
   x-&gt;active = ++numqueries;
   log_query(&amp;x-&gt;active,x-&gt;ip,x-&gt;port,x-&gt;id,q,qtype);
-  switch(query_start(&amp;x-&gt;q,q,qtype,myipoutgoing)) {
+  switch(query_start(&amp;x-&gt;q,q,qtype,qclass,myipoutgoing)) {
     case -1:
       t_drop(j);
       return;</diff>
      <filename>dnscache.c</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@
 #include &quot;response.h&quot;
 
 const char *fatal = &quot;pickdns: fatal: &quot;;
+const char *starting = &quot;starting pickdns\n&quot;;
 
 static char seed[128];
 </diff>
      <filename>pickdns.c</filename>
    </modified>
    <modified>
      <diff>@@ -97,7 +97,7 @@ static int rqa(struct query *z)
 
   for (i = QUERY_MAXALIAS - 1;i &gt;= 0;--i)
     if (z-&gt;alias[i]) {
-      if (!response_query(z-&gt;alias[i],z-&gt;type)) return 0;
+      if (!response_query(z-&gt;alias[i],z-&gt;type,z-&gt;class)) return 0;
       while (i &gt; 0) {
         if (!response_cname(z-&gt;alias[i],z-&gt;alias[i - 1],z-&gt;aliasttl[i])) return 0;
         --i;
@@ -106,7 +106,7 @@ static int rqa(struct query *z)
       return 1;
     }
 
-  if (!response_query(z-&gt;name[0],z-&gt;type)) return 0;
+  if (!response_query(z-&gt;name[0],z-&gt;type,z-&gt;class)) return 0;
   return 1;
 }
 
@@ -818,7 +818,7 @@ static int doit(struct query *z,int state)
   return -1;
 }
 
-int query_start(struct query *z,char *dn,char type[2],char localip[4])
+int query_start(struct query *z,char *dn,char type[2],char class[2],char localip[4])
 {
   if (byte_equal(type,2,DNS_T_AXFR)) { errno = error_perm; return -1; }
 
@@ -828,6 +828,7 @@ int query_start(struct query *z,char *dn,char type[2],char localip[4])
 
   if (!dns_domain_copy(&amp;z-&gt;name[0],dn)) return -1;
   byte_copy(z-&gt;type,2,type);
+  byte_copy(z-&gt;class,2,class);
   byte_copy(z-&gt;localip,4,localip);
 
   return doit(z,0);</diff>
      <filename>query.c</filename>
    </modified>
    <modified>
      <diff>@@ -19,10 +19,11 @@ struct query {
   uint32 aliasttl[QUERY_MAXALIAS];
   char localip[4];
   char type[2];
+  char class[2];
   struct dns_transmit dt;
 } ;
 
-extern int query_start(struct query *,char *,char *,char *);
+extern int query_start(struct query *,char *,char *,char *,char *);
 extern void query_io(struct query *,iopause_fd *,struct taia *);
 extern int query_get(struct query *,iopause_fd *,struct taia *);
 </diff>
      <filename>query.h</filename>
    </modified>
    <modified>
      <diff>@@ -102,6 +102,7 @@ int respond(char *q,char qtype[2],char ip[4])
 }
 
 const char *fatal = &quot;rbldns: fatal: &quot;;
+const char *starting = &quot;starting rbldns\n&quot;;
 
 void initialize(void)
 {</diff>
      <filename>rbldns.c</filename>
    </modified>
    <modified>
      <diff>@@ -49,14 +49,14 @@ int response_addname(const char *d)
   return response_addbytes(d,1);
 }
 
-int response_query(const char *q,const char qtype[2])
+int response_query(const char *q,const char qtype[2],const char qclass[2])
 {
   response_len = 0;
   name_num = 0;
   if (!response_addbytes(&quot;\0\0\201\200\0\1\0\0\0\0\0\0&quot;,12)) return 0;
   if (!response_addname(q)) return 0;
   if (!response_addbytes(qtype,2)) return 0;
-  if (!response_addbytes(DNS_C_IN,2)) return 0;
+  if (!response_addbytes(qclass,2)) return 0;
   tctarget = response_len;
   return 1;
 }</diff>
      <filename>response.c</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@
 extern char response[];
 extern unsigned int response_len;
 
-extern int response_query(const char *,const char *);
+extern int response_query(const char *,const char *,const char *);
 extern void response_nxdomain(void);
 extern void response_servfail(void);
 extern void response_id(const char *);</diff>
      <filename>response.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #include &quot;byte.h&quot;
 #include &quot;case.h&quot;
 #include &quot;env.h&quot;
+#include &quot;buffer.h&quot;
 #include &quot;strerr.h&quot;
 #include &quot;ip4.h&quot;
 #include &quot;uint16.h&quot;
@@ -12,6 +13,7 @@
 #include &quot;dns.h&quot;
 
 extern char *fatal;
+extern char *starting;
 extern int respond(char *,char *,char *);
 extern void initialize(void);
 
@@ -40,7 +42,7 @@ static int doit(void)
   pos = dns_packet_copy(buf,len,pos,qtype,2); if (!pos) goto NOQ;
   pos = dns_packet_copy(buf,len,pos,qclass,2); if (!pos) goto NOQ;
 
-  if (!response_query(q,qtype)) goto NOQ;
+  if (!response_query(q,qtype,qclass)) goto NOQ;
   response_id(header);
   if (byte_equal(qclass,2,DNS_C_IN))
     response[2] |= 4;
@@ -69,7 +71,6 @@ static int doit(void)
   WEIRDCLASS:
   response[3] &amp;= ~15;
   response[3] |= 1;
-  byte_copy(response + response_len - 2,2,qclass);
   qlog(ip,port,header,q,qtype,&quot; C &quot;);
   return 1;
 
@@ -102,6 +103,8 @@ int main()
   ndelay_off(udp53);
   socket_tryreservein(udp53,65536);
 
+  buffer_putsflush(buffer_2,starting);
+
   for (;;) {
     len = socket_recv4(udp53,buf,sizeof buf,ip,&amp;port);
     if (len &lt; 0) continue;</diff>
      <filename>server.c</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,8 @@
 #include &quot;ip4.h&quot;
 #include &quot;dns.h&quot;
 
+extern int respond(char *,char *,char *);
+
 #define FATAL &quot;tinydns-get: fatal: &quot;
 
 void usage(void)
@@ -53,7 +55,7 @@ int main(int argc,char **argv)
   if (!dns_domain_todot_cat(&amp;out,q)) oops();
   if (!stralloc_cats(&amp;out,&quot;:\n&quot;)) oops();
 
-  if (!response_query(q,type)) oops();
+  if (!response_query(q,type,DNS_C_IN)) oops();
   response[3] &amp;= ~128;
   response[2] &amp;= ~1;
   response[2] |= 4;</diff>
      <filename>tinydns-get.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #include &quot;dns.h&quot;
 
 const char *fatal = &quot;tinydns: fatal: &quot;;
+const char *starting = &quot;starting tinydns\n&quot;;
 
 static char seed[128];
 </diff>
      <filename>tinydns.c</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@
 #include &quot;response.h&quot;
 
 const char *fatal = &quot;walldns: fatal: &quot;;
+const char *starting = &quot;starting walldns\n&quot;;
 
 void initialize(void)
 {</diff>
      <filename>walldns.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bdde5c4d5ef62f5f2186de3e8432d294da14997c</id>
    </parent>
  </parents>
  <author>
    <name>Nick Andrew</name>
    <email>nick@nick-andrew.net</email>
  </author>
  <url>http://github.com/nickandrew/djbdns/commit/58f7c724a394f2f848591efe6f289ce3890ea86c</url>
  <id>58f7c724a394f2f848591efe6f289ce3890ea86c</id>
  <committed-date>2009-06-07T05:36:24-07:00</committed-date>
  <authored-date>2009-06-07T05:36:24-07:00</authored-date>
  <message>djbdns 1.05</message>
  <tree>97b95b74c9618d85da9aa9451a55a819cd7b1c2e</tree>
  <committer>
    <name>Nick Andrew</name>
    <email>nick@nick-andrew.net</email>
  </committer>
</commit>
