]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3895. [func] Add the ability to set the DSCP code point to dig.
authorMark Andrews <marka@isc.org>
Tue, 15 Jul 2014 13:27:14 +0000 (23:27 +1000)
committerMark Andrews <marka@isc.org>
Tue, 15 Jul 2014 13:27:14 +0000 (23:27 +1000)
                        [RT #36546]

CHANGES
bin/dig/dig.c
bin/dig/dig.docbook
bin/dig/dighost.c
bin/dig/include/dig/dig.h

diff --git a/CHANGES b/CHANGES
index 13c70dce7bea6d6c7a4c04833d161bba403d5e71..cc6be576edb77d4ba42119037a582cc0c279be09 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3895.  [func]          Add the ability to set the DSCP code point to dig.
+                       [RT #36546]
+
 3894.  [bug]           Buffers in isc_print_vsnprintf were not properly
                        initialized leading to potential overflows when
                        printing out quad values. [RT #36505]
index 6aea48d9713d2d0e8842c440067bdd72d506c35b..1158c483aba87f337abbddbb6abfef162e85d689 100644 (file)
@@ -243,6 +243,7 @@ help(void) {
 "                 +[no]multiline      (Print records in an expanded format)\n"
 "                 +[no]onesoa         (AXFR prints only one soa record)\n"
 "                 +[no]keepopen       (Keep the TCP socket open between queries)\n"
+"                 +[no]dscp[=###]     (Set the DSCP value to ### [0..63])\n"
 "        global d-opts and servers (before host name) affect all queries.\n"
 "        local d-opts and servers (after host name) affect only that lookup.\n"
 "        -h                           (print help and exit)\n"
@@ -920,6 +921,19 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                        strncpy(domainopt, value, sizeof(domainopt));
                        domainopt[sizeof(domainopt)-1] = '\0';
                        break;
+               case 's': /* dscp */
+                       FULLCHECK("dscp");
+                       if (!state) {
+                               lookup->dscp = -1;
+                               break;
+                       }
+                       if (value == NULL)
+                               goto need_value;
+                       result = parse_uint(&num, value, 0x3f, "DSCP");
+                       if (result != ISC_R_SUCCESS)
+                               fatal("Couldn't parse DSCP value");
+                       lookup->dscp = num;
+                       break;
                default:
                        goto invalid_option;
                }
index 0a299dbccd48f4770ffbc3ca5e11711edc6805e0..6b2b7850a8d4ed5f429a1c624d1da87649c415fa 100644 (file)
          </listitem>
        </varlistentry>
 
+       <varlistentry>
+         <term><option>+dscp=value</option></term> <listitem>
+           <para>
+             Set the DSCP code point to be used when sending the
+             query.  Valid DSCP code points are in the range
+             [0..63].  By default no code point is explictly set.
+           </para>
+         </listitem>
+       </varlistentry>
+
        <varlistentry>
          <term><option>+[no]edns[=#]</option></term>
          <listitem>
index d4a13d737af3ad963ef6a797662264e1361825e6..9ef4a8806ac424c0baa53f4e562b0c02f61f2a49 100644 (file)
@@ -813,6 +813,7 @@ make_empty_lookup(void) {
 #endif
        looknew->ednsopts = NULL;
        looknew->ednsoptscnt = 0;
+       looknew->dscp = -1;
        dns_fixedname_init(&looknew->fdomain);
        ISC_LINK_INIT(looknew, link);
        ISC_LIST_INIT(looknew->q);
@@ -898,6 +899,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        looknew->tsigctx = NULL;
        looknew->need_search = lookold->need_search;
        looknew->done_as_is = lookold->done_as_is;
+       looknew->dscp = lookold->dscp;
 
        if (lookold->ecs_addr != NULL) {
                size_t len = sizeof(isc_sockaddr_t);
@@ -2781,6 +2783,8 @@ send_tcp_connect(dig_query_t *query) {
        check_result(result, "isc_socket_create");
        sockcount++;
        debug("sockcount=%d", sockcount);
+       if (query->lookup->dscp != -1)
+               isc_socket_dscp(query->sock, query->lookup->dscp);
        if (specified_source)
                result = isc_socket_bind(query->sock, &bind_address,
                                         ISC_SOCKET_REUSEADDRESS);
@@ -2857,6 +2861,8 @@ send_udp(dig_query_t *query) {
                check_result(result, "isc_socket_create");
                sockcount++;
                debug("sockcount=%d", sockcount);
+               if (query->lookup->dscp != -1)
+                       isc_socket_dscp(query->sock, query->lookup->dscp);
                if (specified_source) {
                        result = isc_socket_bind(query->sock, &bind_address,
                                                 ISC_SOCKET_REUSEADDRESS);
index aeab0e5dfaea542218d0ac7031f44297df685989..c978eefddf14074b6d120f0707d7ad77a213ba33 100644 (file)
@@ -195,6 +195,7 @@ isc_boolean_t       sigchase;
 #endif
        dns_ednsopt_t *ednsopts;
        unsigned int ednsoptscnt;
+       isc_dscp_t dscp;
 };
 
 /*% The dig_query structure */