From: fxlb Date: Thu, 25 Apr 2013 15:44:14 +0000 (+0200) Subject: DHCPv6 decoder update X-Git-Tag: tcpdump-4.5.0~87^2 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/af7a65c643c8025b6f1e83d4556c9fcf4ac46b4d?hp=5937079df9d8bf0865b8db9fac9603327fa87d1d DHCPv6 decoder update - Rename option 31 as SNTP_SERVERS (see RFC4075) - Add decoder for option 56 (NTP_SERVER) from RFC5908 --- diff --git a/print-dhcp6.c b/print-dhcp6.c index 35de278d..9bfe6e70 100644 --- a/print-dhcp6.c +++ b/print-dhcp6.c @@ -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(" ?)"); diff --git a/tests/TESTLIST b/tests/TESTLIST index fc6bcb90..2e2f74db 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -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 index 00000000..23db5bd6 --- /dev/null +++ b/tests/dhcpv6-ntp-server.out @@ -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 index 00000000..5657692e Binary files /dev/null and b/tests/dhcpv6-ntp-server.pcap differ