DHCPv6 decoder update

- Rename option 31 as SNTP_SERVERS (see RFC4075)
- Add decoder for option 56 (NTP_SERVER) from RFC5908
This commit is contained in:
fxlb 2013-04-25 17:44:14 +02:00 committed by Guy Harris
parent abdd4e1905
commit ea6238710a
4 changed files with 49 additions and 4 deletions

View 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(" ?)");

View 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

View File

@ -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.))

Binary file not shown.