]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_10] symbolic option names for dig +ednsopt
authorEvan Hunt <each@isc.org>
Tue, 16 May 2017 17:16:33 +0000 (10:16 -0700)
committerEvan Hunt <each@isc.org>
Tue, 16 May 2017 17:16:33 +0000 (10:16 -0700)
4555. [func] dig +ednsopt: EDNS options can now be specified by
name in addition to numeric value. [RT #44461]

(cherry picked from commit 25a9b90369f2de5c9921fae84a27c94c83f156be)
(cherry picked from commit 403e7b451207fe6514a5d641562713b1af233b9c)

CHANGES
bin/dig/dig.docbook
bin/dig/dighost.c
bin/tests/system/digdelv/ns3/named.conf
bin/tests/system/digdelv/tests.sh
doc/arm/notes.xml

diff --git a/CHANGES b/CHANGES
index a7ea97bb16ceaf018259073ec53660599a2583a2..d3ea2e9f4e9379d4bfc4a21b757ffb195e2e9b01 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -94,6 +94,9 @@
 4574.  [bug]           Dig leaked memory with multiple +subnet options.
                        [RT #44683]
 
+4555.  [func]          dig +ednsopt: EDNS options can now be specified by
+                       name in addition to numeric value. [RT #44461]
+
        --- 9.10.5 released ---
 
        --- 9.10.5rc3 released ---
index 577d6d0d2326c958a984a57e7a980833967d6208..dbe0765b7abed48d41a478c08e28ccff6dd2efc1 100644 (file)
            <para>
              Specify EDNS option with code point <option>code</option>
              and optionally payload of <option>value</option> as a
-             hexadecimal string.  <option>+noednsopt</option>
-             clears the EDNS options to to be sent.
+             hexadecimal string.  <option>code</option> can be 
+             either an EDNS option name (for example,
+             <literal>NSID</literal> or <literal>ECS</literal>),
+             or an arbitrary numeric value.  <option>+noednsopt</option>
+             clears the EDNS options to be sent.
            </para>
          </listitem>
        </varlistentry>
index 6ecbc7baa5103f96b60ffa3fc8c0feecfe4970ce..6f355409457d9101ecaf117de5f38cf63aa23ea0 100644 (file)
@@ -1539,18 +1539,52 @@ setup_libs(void) {
 static dns_ednsopt_t ednsopts[EDNSOPTS];
 static unsigned char ednsoptscnt = 0;
 
+typedef struct dig_ednsoptname {
+       isc_uint32_t code;
+       const char  *name;
+} dig_ednsoptname_t;
+
+dig_ednsoptname_t optnames[] = {
+       { 3, "NSID" },          /* RFC 5001 */
+       { 5, "DAU" },           /* RFC 6975 */
+       { 6, "DHU" },           /* RFC 6975 */
+       { 7, "N3U" },           /* RFC 6975 */
+       { 8, "ECS" },           /* RFC 7871 */
+       { 9, "EXPIRE" },        /* RFC 7314 */
+       { 10, "COOKIE" },       /* RFC 7873 */
+       { 11, "KEEPALIVE" },    /* RFC 7828 */
+       { 12, "PADDING" },      /* RFC 7830 */
+       { 12, "PAD" },          /* shorthand */
+       { 13, "CHAIN" },        /* RFC 7901 */
+       { 26946, "DEVICEID" },  /* Brian Hartvigsen */
+};
+
+#define N_EDNS_OPTNAMES  (sizeof(optnames) / sizeof(optnames[0]))
+
 void
 save_opt(dig_lookup_t *lookup, char *code, char *value) {
+       isc_result_t result;
        isc_uint32_t num;
        isc_buffer_t b;
-       isc_result_t result;
+       isc_boolean_t found = ISC_FALSE;
+       unsigned int i;
 
        if (ednsoptscnt == EDNSOPTS)
                fatal("too many ednsopts");
 
-       result = parse_uint(&num, code, 65535, "ednsopt");
-       if (result != ISC_R_SUCCESS)
-               fatal("bad edns code point: %s", code);
+       for (i = 0; i < N_EDNS_OPTNAMES; i++) {
+               if (strcasecmp(code, optnames[i].name) == 0) {
+                       num = optnames[i].code;
+                       found = ISC_TRUE;
+                       break;
+               }
+       }
+
+       if (!found) {
+               result = parse_uint(&num, code, 65535, "ednsopt");
+               if (result != ISC_R_SUCCESS)
+                       fatal("bad edns code point: %s", code);
+       }
 
        ednsopts[ednsoptscnt].code = num;
        ednsopts[ednsoptscnt].length = 0;
index 0b64784d4cae0a3a7ebbd29f4a350ea43cf1aa3b..fb565e616c8fbfba4eb7aca515450d7254f62598 100644 (file)
@@ -14,8 +14,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-// NS4
-
 controls { /* empty */ };
 
 options {
@@ -28,6 +26,7 @@ options {
        acache-enable yes;
        dnssec-enable no;
        dnssec-validation no;
+       server-id "ns3";
 };
 
 zone "." {
index 7530b6075b260f5b4dcab125e4a9445d82cf006f..cc2aaf130fa45ace2ea2e9c2291c2745948ab62c 100644 (file)
@@ -247,6 +247,22 @@ if [ -x ${DIG} ] ; then
   if [ $ret != 0 ]; then echo "I:failed"; fi 
   status=`expr $status + $ret`
 
+  n=`expr $n + 1`
+  echo "I:checking dig +ednsopt with option number ($n)"
+  ret=0
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep 'NSID: .* ("ns3")' dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking dig +ednsopt with option name ($n)"
+  ret=0
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=nsid a.example > dig.out.test$n 2>&1 || ret=1
+  grep 'NSID: .* ("ns3")' dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
   n=`expr $n + 1`
   if $FEATURETEST --with-idn
   then
index f25f2b11dafa567e69016912ac091afa45e0ac69..7625e27c33f3f47c3ae447966ce94b3100be82f1 100644 (file)
 
   <section xml:id="relnotes_changes"><info><title>Feature Changes</title></info>
     <itemizedlist>
+      <listitem>
+       <para>
+         <command>dig +ednsopt</command> now accepts the names
+         for EDNS options in addition to numeric values. For example, 
+         an EDNS Client-Subnet option could be sent using
+         <command>dig +ednsopt=ecs:...</command>. Thanks to
+         John Worley of Secure64 for the contribution. [RT #44461]
+       </para>
+      </listitem>
       <listitem>
        <para>
          Threads in <command>named</command> are now set to human-readable