From 1e3b959bf0e292101654a084437b93fdad47d8eb Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Fri, 7 Jul 2023 16:00:28 +0200 Subject: [PATCH] DHCPv6: Add DUID-UUID printing (RFC6355) Define DUID_LLT, DUID_EN, DUID_LL and DUID_UUID. Add a test file. --- print-dhcp6.c | 23 ++++++++++++++++++++--- tests/TESTLIST | 1 + tests/dhcpv6-rfc6355-duid-uuid.out | 2 ++ tests/dhcpv6-rfc6355-duid-uuid.pcap | Bin 0 -> 416 bytes 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/dhcpv6-rfc6355-duid-uuid.out create mode 100644 tests/dhcpv6-rfc6355-duid-uuid.pcap diff --git a/print-dhcp6.c b/print-dhcp6.c index 533e34d9..ba9569e3 100644 --- a/print-dhcp6.c +++ b/print-dhcp6.c @@ -121,6 +121,10 @@ struct dhcp6_relay { /* options */ #define DH6OPT_CLIENTID 1 #define DH6OPT_SERVERID 2 +# define DUID_LLT 1 /* RFC8415 */ +# define DUID_EN 2 /* RFC8415 */ +# define DUID_LL 3 /* RFC8415 */ +# define DUID_UUID 4 /* RFC6355 */ #define DH6OPT_IA_NA 3 #define DH6OPT_IA_TA 4 #define DH6OPT_IA_ADDR 5 @@ -320,7 +324,7 @@ dhcp6opt_print(netdissect_options *ndo, } tp = (const u_char *)(dh6o + 1); switch (GET_BE_U_2(tp)) { - case 1: + case DUID_LLT: if (optlen >= 2 + 6) { ND_PRINT(" hwaddr/time type %u time %u ", GET_BE_U_2(tp + 2), @@ -335,7 +339,7 @@ dhcp6opt_print(netdissect_options *ndo, ND_PRINT(" ?)"); } break; - case 2: + case DUID_EN: if (optlen >= 2 + 4) { ND_PRINT(" enterprise %u ", GET_BE_U_4(tp + 2)); for (i = 2 + 4; i < optlen; i++) @@ -348,7 +352,7 @@ dhcp6opt_print(netdissect_options *ndo, ND_PRINT(" ?)"); } break; - case 3: + case DUID_LL: if (optlen >= 2 + 2) { ND_PRINT(" hwaddr type %u ", GET_BE_U_2(tp + 2)); @@ -362,6 +366,19 @@ dhcp6opt_print(netdissect_options *ndo, ND_PRINT(" ?)"); } break; + case DUID_UUID: + ND_PRINT(" uuid "); + if (optlen == 2 + 16) { + for (i = 2; i < optlen; i++) + ND_PRINT("%02x", + GET_U_1(tp + i)); + /*(*/ + ND_PRINT(")"); + } else { + /*(*/ + ND_PRINT(" ?)"); + } + break; default: ND_PRINT(" type %u)", GET_BE_U_2(tp)); break; diff --git a/tests/TESTLIST b/tests/TESTLIST index c590f67c..6f478e53 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -259,6 +259,7 @@ dhcpv6-ntp-server dhcpv6-ntp-server.pcap dhcpv6-ntp-server.out -v dhcpv6-sip-server-d dhcpv6-sip-server-d.pcap dhcpv6-sip-server-d.out -v dhcpv6-domain-list dhcpv6-domain-list.pcap dhcpv6-domain-list.out -v dhcpv6-mud dhcpv6-mud.pcap dhcpv6-mud.out -vv +dhcpv6-rfc6355-duid-uuid dhcpv6-rfc6355-duid-uuid.pcap dhcpv6-rfc6355-duid-uuid.out -v # ZeroMQ/PGM tests # ZMTP/1.0 over TCP diff --git a/tests/dhcpv6-rfc6355-duid-uuid.out b/tests/dhcpv6-rfc6355-duid-uuid.out new file mode 100644 index 00000000..87acd046 --- /dev/null +++ b/tests/dhcpv6-rfc6355-duid-uuid.out @@ -0,0 +1,2 @@ + 1 11:19:08.826971 IP6 (flowlabel 0xd92bc, hlim 1, next-header UDP (17) payload length: 112) fe80::7e39:bc67:f367:8def.546 > ff02::1:2.547: [udp sum ok] dhcp6 renew (xid=9f56b (client-ID uuid a256e92e40abd0d2a3ab3b3ff2ff8998) (server-ID hwaddr type 1 a021b7e0d871) (option-request DNS-server DNS-search-list DNS-server DNS-search-list client-ID) (elapsed-time 0) (IA_NA IAID:971445380 T1:3600 T2:5400 (IA_ADDR 2a02:2788:7c8:4dd:4a5b:39ff:fee7:1484 pltime:7200 vltime:7500))) + 2 11:19:08.827665 IP6 (hlim 128, next-header UDP (17) payload length: 140) fe80::a221:b7ff:fee0:d871.547 > fe80::7e39:bc67:f367:8def.546: [udp sum ok] dhcp6 reply (xid=9f56b (client-ID uuid a256e92e40abd0d2a3ab3b3ff2ff8998) (IA_NA IAID:971445380 T1:15 T2:45 (IA_ADDR 2a02:2788:7c8:4dd:4a5b:39ff:fee7:1484 pltime:30 vltime:60)) (DNS-server 2a02:2788:fff0:7::3 2a02:2788:fff0:5::140) (DNS-search-list voo.be.) (server-ID hwaddr type 1 a021b7e0d871)) diff --git a/tests/dhcpv6-rfc6355-duid-uuid.pcap b/tests/dhcpv6-rfc6355-duid-uuid.pcap new file mode 100644 index 0000000000000000000000000000000000000000..dea8967725ade7563f1ba180323b82ea266a26bb GIT binary patch literal 416 zcmca|c+)~A1{MYcU}0bca&&%NijJPg!>|m<24Q1kpfHn1wB>V=mbSYIyp#4Y6bLf@ zYXC|CL7nBE^v~(N@BcGF_+S#Ko=J&GnW3Qi4=d-_Y@mK229`x(FZCQ&U%0e*wYB}H z|D7`!m>9Sim>C!sC~kjnqmY3O$P;If0Aof54xlUpP*wwED+2?c00V=l1OqFBgcg%} z2m1+@yI#?j|NnvIWE2<}WPL!c7F@`~a0sXkgdy&Qm<@C_P=ujJumR@kMT*=1{{z|z zZwasUu8L;0)_E~5j` R#~jRM`T0yqsSKzg0sxERZ2ABI literal 0 HcmV?d00001