chiark / gitweb /
src/, client/: Support for AAAA lookups.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Oct 2014 20:09:54 +0000 (21:09 +0100)
I've added a couple of simple test cases.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
client/adh-main.c
client/adh-opts.c
regress/case-aaaa-simple.err [new file with mode: 0644]
regress/case-aaaa-simple.out [new file with mode: 0644]
regress/case-aaaa-simple.sys [new file with mode: 0644]
regress/case-aaaa-sort.err [new file with mode: 0644]
regress/case-aaaa-sort.out [new file with mode: 0644]
regress/case-aaaa-sort.sys [new file with mode: 0644]
regress/init-distorted.text
src/adns.h
src/types.c

index b6f3bd4..dc9c46d 100644 (file)
@@ -99,6 +99,7 @@ void of_type(const struct optioninfo *oi, const char *arg, const char *arg2) {
     
     /* raw versions */
     { adns_r_a,        "a"    },
+    { adns_r_aaaa,     "aaaa" },
     { adns_r_ns_raw,   "ns-"  },
     { adns_r_soa_raw,  "soa-" },
     { adns_r_ptr_raw,  "ptr-" },
index 08310e0..34ce334 100644 (file)
@@ -262,10 +262,10 @@ static void printusage(void) {
        " 11   usage problems\n"
        "\n"
        "Query types (see adns.h; default is addr):\n"
-       "  ns  soa  ptr  mx  rp  srv  addr       - enhanced versions\n"
-       "  cname  hinfo  txt                     - types with only one version\n"
-       "  a  ns-  soa-  ptr-  mx-  rp-  srv-    - _raw versions\n"
-       "  type<number>                          - `unknown' type, RFC3597\n"
+       "  ns  soa  ptr  mx  rp  srv  addr           - enhanced versions\n"
+       "  cname  hinfo  txt                         - types with only one version\n"
+       "  a  aaaa  ns-  soa-  ptr-  mx-  rp-  srv-  - _raw versions\n"
+       "  type<number>                              - `unknown' type, RFC3597\n"
        "Default is addr, or ptr for -i/--ptr queries\n",
        stdout);
   if (ferror(stdout)) sysfail("write usage message",errno);
diff --git a/regress/case-aaaa-simple.err b/regress/case-aaaa-simple.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/regress/case-aaaa-simple.out b/regress/case-aaaa-simple.out
new file mode 100644 (file)
index 0000000..86ee6c0
--- /dev/null
@@ -0,0 +1,5 @@
+adns debug: using nameserver 172.29.199.224
+stratocaster.distorted.org.uk flags 0 type 28 AAAA(-) submitted
+stratocaster.distorted.org.uk flags 0 type AAAA(-): OK; nrrs=1; cname=$; owner=$; ttl=14400
+ 2001:ba8:1d9:2::4
+rc=0
diff --git a/regress/case-aaaa-simple.sys b/regress/case-aaaa-simple.sys
new file mode 100644 (file)
index 0000000..d7b904e
--- /dev/null
@@ -0,0 +1,40 @@
+./adnstest distorted
+:28 stratocaster.distorted.org.uk
+ start 1401870460.843715
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000022
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000010
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000009
+ sendto fd=6 addr=172.29.199.224:53
+     311f0100 00010000 00000000 0c737472 61746f63 61737465 72096469 73746f72
+     74656403 6f726702 756b0000 1c0001.
+ sendto=47
+ +0.000072
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999928
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.001805
+ recvfrom fd=6 buflen=512
+ recvfrom=OK addr=172.29.199.224:53
+     311f8580 00010001 00040008 0c737472 61746f63 61737465 72096469 73746f72
+     74656403 6f726702 756b0000 1c0001c0 0c001c00 01000038 40001020 010ba801
+     d9000200 00000000 000004c0 19000200 01000038 40000d07 76616d70 69726502
+     6e73c019 c0190002 00010000 3840000d 0a74656c 65636173 746572c0 5fc01900
+     02000100 00384000 0c097072 65636973 696f6ec0 5fc01900 02000100 00384000
+     09067261 64697573 c05fc0a1 00010001 00003840 0004ac1d c701c0a1 001c0001
+     00003840 00102001 04709740 00010000 00000000 0001c057 00010001 00003840
+     0004ac1d c705c057 001c0001 00003840 00102001 04709740 00010000 00000000
+     0005c089 00010001 00003840 0004ac1d c7b2c089 001c0001 00003840 00102001
+     0ba801d9 00020000 00000000 0002c070 00010001 00003840 0004ac1d c7b3c070
+     001c0001 00003840 00102001 0ba801d9 00020000 00000000 0003.
+ +0.000125
+ recvfrom fd=6 buflen=512
+ recvfrom=EAGAIN
+ +0.000021
+ close fd=6
+ close=OK
+ +0.000029
diff --git a/regress/case-aaaa-sort.err b/regress/case-aaaa-sort.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/regress/case-aaaa-sort.out b/regress/case-aaaa-sort.out
new file mode 100644 (file)
index 0000000..9b36750
--- /dev/null
@@ -0,0 +1,10 @@
+adns debug: using nameserver 172.29.199.224
+maddr.dnserr.distorted.org.uk flags 0 type 28 AAAA(-) submitted
+maddr.dnserr.distorted.org.uk flags 0 type AAAA(-): OK; nrrs=6; cname=$; owner=$; ttl=14400
+ 2001:db8:2::1
+ 2001:db8:2::2
+ 2001:db8:3::2
+ 2001:db8:1::1
+ 2001:db8:1::2
+ 2001:db8:3::1
+rc=0
diff --git a/regress/case-aaaa-sort.sys b/regress/case-aaaa-sort.sys
new file mode 100644 (file)
index 0000000..cb59cb3
--- /dev/null
@@ -0,0 +1,45 @@
+./adnstest distorted
+:28 maddr.dnserr.distorted.org.uk
+ start 1401871954.600653
+ socket type=SOCK_DGRAM
+ socket=6
+ +0.000061
+ fcntl fd=6 cmd=F_GETFL
+ fcntl=~O_NONBLOCK&...
+ +0.000032
+ fcntl fd=6 cmd=F_SETFL O_NONBLOCK|...
+ fcntl=OK
+ +0.000026
+ sendto fd=6 addr=172.29.199.224:53
+     311f0100 00010000 00000000 056d6164 64720664 6e736572 72096469 73746f72
+     74656403 6f726702 756b0000 1c0001.
+ sendto=47
+ +0.000195
+ select max=7 rfds=[6] wfds=[] efds=[] to=1.999805
+ select=1 rfds=[6] wfds=[] efds=[]
+ +0.004328
+ recvfrom fd=6 buflen=512
+ recvfrom=OK addr=172.29.199.224:53
+     311f8580 00010006 00040008 056d6164 64720664 6e736572 72096469 73746f72
+     74656403 6f726702 756b0000 1c0001c0 0c001c00 01000038 40001020 010db800
+     03000000 00000000 000002c0 0c001c00 01000038 40001020 010db800 01000000
+     00000000 000001c0 0c001c00 01000038 40001020 010db800 01000000 00000000
+     000002c0 0c001c00 01000038 40001020 010db800 02000000 00000000 000001c0
+     0c001c00 01000038 40001020 010db800 02000000 00000000 000002c0 0c001c00
+     01000038 40001020 010db800 03000000 00000000 000001c0 12000200 01000038
+     40000d07 76616d70 69726502 6e73c012 c0120002 00010000 38400009 06726164
+     697573c0 ebc01200 02000100 00384000 0d0a7465 6c656361 73746572 c0ebc012
+     00020001 00003840 000c0970 72656369 73696f6e c0ebc0fc 00010001 00003840
+     00043e31 cc92c0fc 001c0001 00003840 00102001 04701f09 1b980000 00000000
+     0002c0e3 00010001 00003840 00043e31 cc96c0e3 001c0001 00003840 00102001
+     04701f09 1b980000 00000000 0006c12a 00010001 00003840 0004d40d c646c12a
+     001c0001 00003840 00102001 0ba80000 01d90000 00000000 0006c111 00010001
+     00003840 0004d40d c647c111 001c0001 00003840 00102001 0ba80000 01d90000
+     00000000 0007.
+ +0.000428
+ recvfrom fd=6 buflen=512
+ recvfrom=EAGAIN
+ +0.000092
+ close fd=6
+ close=OK
+ +0.000520
index 3d99050..a35a854 100644 (file)
@@ -1,3 +1,3 @@
 nameserver 172.29.199.224
-sortlist 198.51.100.0/24 0/0
+sortlist 198.51.100.0/24 2001:db8:2::/48 0/0 ::/0
 search dnserr.distorted.org.uk distorted.org.uk
index d978d60..568395c 100644 (file)
@@ -162,6 +162,8 @@ typedef enum {
  adns_r_rp_raw=          17,
  adns_r_rp=                  adns_r_rp_raw|adns__qtf_mail822,
 
+ adns_r_aaaa=           28,
+
  /* For SRV records, query domain without _qf_quoteok_query must look
   * as expected from SRV RFC with hostname-like Name.  _With_
   * _quoteok_query, any query domain is allowed. */
@@ -380,6 +382,7 @@ typedef struct {
     adns_rr_intstr *(*manyistr);     /* txt (list strs ends with i=-1, str=0)*/
     adns_rr_addr *addr;              /* addr */
     struct in_addr *inaddr;          /* a */
+    struct in6_addr *in6addr;       /* aaaa */
     adns_rr_hostaddr *hostaddr;      /* ns */
     adns_rr_intstrpair *intstrpair;  /* hinfo */
     adns_rr_strpair *strpair;        /* rp, rp_raw */
index 17cb910..abe0c88 100644 (file)
@@ -49,6 +49,7 @@
  * _txt                       (pa)
  * _inaddr                    (pa,di,cs
  *                             +search_sortlist, dip_genaddr, csp_genaddr)
+ * _in6addr                  (pa,di,cs)
  * _addr                      (pa,di,div,csp,cs,gsz
  *                             +search_sortlist_sa, dip_sockaddr)
  * _domain                    (pap,csp,cs)
@@ -302,6 +303,28 @@ static adns_status cs_inaddr(vbuf *vb, const void *datap) {
 }
 
 /*
+ * _in6addr   (pa,di,cs)
+ */
+
+static adns_status pa_in6addr(const parseinfo *pai, int cbyte,
+                            int max, void *datap) {
+  struct in6_addr *storeto= datap;
+
+  if (max-cbyte != 16) return adns_s_invaliddata;
+  memcpy(storeto->s6_addr, pai->dgram + cbyte, 16);
+  return adns_s_ok;
+}
+
+static int di_in6addr(adns_state ads,
+                    const void *datap_a, const void *datap_b) {
+  return dip_genaddr(ads,AF_INET6,datap_a,datap_b);
+}
+
+static adns_status cs_in6addr(vbuf *vb, const void *datap) {
+  return csp_genaddr(vb,AF_INET6,datap);
+}
+
+/*
  * _addr   (pa,di,div,csp,cs,gsz +search_sortlist_sa, dip_sockaddr)
  */
 
@@ -1280,6 +1303,7 @@ DEEP_TYPE(hinfo,  "HINFO", 0,   intstrpair,hinfo,   0,     hinfo           ),
 DEEP_TYPE(mx_raw, "MX",   "raw",intstr,    mx_raw,  mx_raw,inthost         ),
 DEEP_TYPE(txt,    "TXT",   0,   manyistr,  txt,     0,     txt             ),
 DEEP_TYPE(rp_raw, "RP",   "raw",strpair,   rp,      0,     rp              ),
+FLAT_TYPE(aaaa,          "AAAA",  0,   in6addr,   in6addr, in6addr,in6addr        ),
 DEEP_TYPE(srv_raw,"SRV",  "raw",srvraw ,   srvraw,  srv,   srvraw,
                              .checklabel= ckl_srv, .postsort= postsort_srv),