]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DHCPv6 decoder update
authorfxlb <[email protected]>
Thu, 25 Apr 2013 15:44:14 +0000 (17:44 +0200)
committerGuy Harris <[email protected]>
Mon, 6 May 2013 01:59:40 +0000 (18:59 -0700)
- Rename option 31 as SNTP_SERVERS (see RFC4075)
- Add decoder for option 56 (NTP_SERVER) from RFC5908

print-dhcp6.c
tests/TESTLIST
tests/dhcpv6-ntp-server.out [new file with mode: 0644]
tests/dhcpv6-ntp-server.pcap [new file with mode: 0644]

index 35de278d4487520afbf22914c256131835037320..9bfe6e7028bfa31c893d224ec4c16941f99db0fe 100644 (file)
@@ -36,6 +36,7 @@
  *  RFC4075: Simple Network Time Protocol (SNTP) Configuration option,
  *  RFC4242: Information Refresh Time option,
  *  RFC4280: Broadcast and Multicast Control Servers options,
+ *  RFC5908: Network Time Protocol (NTP) Server Option for DHCPv6
  *  RFC6334: Dual-Stack Lite option,
  */
 
@@ -154,7 +155,7 @@ struct dhcp6_relay {
 #define DH6OPT_NISP_SERVERS 28
 #define DH6OPT_NIS_NAME 29
 #define DH6OPT_NISP_NAME 30
-#define DH6OPT_NTP_SERVERS 31
+#define DH6OPT_SNTP_SERVERS 31
 #define DH6OPT_LIFETIME 32
 #define DH6OPT_BCMCS_SERVER_D 33
 #define DH6OPT_BCMCS_SERVER_A 34
@@ -171,6 +172,10 @@ struct dhcp6_relay {
 #define DH6OPT_CLT_TIME 46
 #define DH6OPT_LQ_RELAY_DATA 47
 #define DH6OPT_LQ_CLIENT_LINK 48
+#define DH6OPT_NTP_SERVER 56
+#  define DH6OPT_NTP_SUBOPTION_SRV_ADDR 1
+#  define DH6OPT_NTP_SUBOPTION_MC_ADDR 2
+#  define DH6OPT_NTP_SUBOPTION_SRV_FQDN 3
 #define DH6OPT_AFTR_NAME 64
 
 struct dhcp6opt {
@@ -238,8 +243,8 @@ dhcp6opt_name(int type)
                return "IA_PD";
        case DH6OPT_IA_PD_PREFIX:
                return "IA_PD-prefix";
-       case DH6OPT_NTP_SERVERS:
-               return "NTP-server";
+       case DH6OPT_SNTP_SERVERS:
+               return "SNTP-servers";
        case DH6OPT_LIFETIME:
                return "lifetime";
        case DH6OPT_NIS_SERVERS:
@@ -280,6 +285,8 @@ dhcp6opt_name(int type)
                return "LQ-relay-data";
        case DH6OPT_LQ_CLIENT_LINK:
                return "LQ-client-link";
+       case DH6OPT_NTP_SERVER:
+               return "NTP-server";
        case DH6OPT_AFTR_NAME:
                return "AFTR-Name";
        default:
@@ -337,6 +344,8 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
        u_int authinfolen, authrealmlen;
        int remain_len;  /* Length of remaining options */
        int label_len;   /* Label length */
+       u_int16_t subopt_code;
+       u_int16_t subopt_len;
 
        if (cp == ep)
                return;
@@ -581,7 +590,7 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                        break;
                case DH6OPT_SIP_SERVER_A:
                case DH6OPT_DNS:
-               case DH6OPT_NTP_SERVERS:
+               case DH6OPT_SNTP_SERVERS:
                case DH6OPT_NIS_SERVERS:
                case DH6OPT_NISP_SERVERS:
                case DH6OPT_BCMCS_SERVER_A:
@@ -719,6 +728,40 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                                printf("%02x", tp[i]);
                        printf("...)");
                        break;
+               case DH6OPT_NTP_SERVER:
+                       if (optlen < 4) {
+                               printf(" ?)");
+                               break;
+                       }
+                       tp = (u_char *)(dh6o + 1);
+                       while (tp < ep - 4) {
+                               subopt_code = EXTRACT_16BITS(tp);
+                               tp += 2;
+                               subopt_len = EXTRACT_16BITS(tp);
+                               tp += 2;
+                               printf(" subopt:%d", subopt_code);
+                               switch (subopt_code) {
+                               case DH6OPT_NTP_SUBOPTION_SRV_ADDR:
+                               case DH6OPT_NTP_SUBOPTION_MC_ADDR:
+                                       if (subopt_len != 16) {
+                                               printf(" ?");
+                                               break;
+                                       }
+                                       printf(" %s", ip6addr_string(&tp[0]));
+                                       tp += subopt_len;
+                                       break;
+                               case DH6OPT_NTP_SUBOPTION_SRV_FQDN:
+                                       putchar(' ');
+                                       ns_nprint(tp, ep);
+                                       tp += subopt_len;
+                                       break;
+                               default:
+                                       printf(" ?");
+                                       break;
+                               }
+                       }
+                       printf(")");
+                       break;
                case DH6OPT_AFTR_NAME:
                        if (optlen < 3) {
                                printf(" ?)");
index fc6bcb9057246258a106bd772a05a8320b2ffd25..2e2f74dbd818f5f84316ce3ba35b1f8800c17b53 100644 (file)
@@ -88,6 +88,7 @@ dhcpv6-aftr-name      dhcpv6-AFTR-Name-RFC6334.pcap   dhcpv6-AFTR-Name-RFC6334.out    -t -
 dhcpv6-ia-na   dhcpv6-ia-na.pcap       dhcpv6-ia-na.out        -t -v
 dhcpv6-ia-pd   dhcpv6-ia-pd.pcap       dhcpv6-ia-pd.out        -t -v
 dhcpv6-ia-ta   dhcpv6-ia-ta.pcap       dhcpv6-ia-ta.out        -t -v
+dhcpv6-ntp-server      dhcpv6-ntp-server.pcap  dhcpv6-ntp-server.out   -t -v
 
 # ZeroMQ/PGM tests
 # ZMTP/1.0 over TCP
diff --git a/tests/dhcpv6-ntp-server.out b/tests/dhcpv6-ntp-server.out
new file mode 100644 (file)
index 0000000..23db5bd
--- /dev/null
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header UDP (17) payload length: 113) fe80::20c:29ff:fe9b:a15d.547 > fe80::20c:29ff:fe38:f368.546: [udp sum ok] dhcp6 reply (xid=f69b57 (client-ID hwaddr/time type 1 time 418384703 000c2938f368) (server-ID hwaddr/time type 1 time 418354459 000c299ba153) (NTP-server subopt:1 2a01::1 subopt:2 ff05::101 subopt:3 ntp.example.com.))
diff --git a/tests/dhcpv6-ntp-server.pcap b/tests/dhcpv6-ntp-server.pcap
new file mode 100644 (file)
index 0000000..5657692
Binary files /dev/null and b/tests/dhcpv6-ntp-server.pcap differ