From b4f7ec2263b2f9055bc48c5a35980f9659f253a2 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Tue, 18 Mar 2025 09:50:06 +0100 Subject: [PATCH] DHCP: Add support for option 108 "IPv6-Only Preferred" (RFC 8925) Add a test file with DHCP option 108 in both the request and the reply, provided by Bill. --- print-bootp.c | 16 ++++++++++++++++ tests/TESTLIST | 1 + tests/dhcp-option-108.out | 31 +++++++++++++++++++++++++++++++ tests/dhcp-option-108.pcapng | Bin 0 -> 1220 bytes 4 files changed, 48 insertions(+) create mode 100644 tests/dhcp-option-108.out create mode 100644 tests/dhcp-option-108.pcapng diff --git a/print-bootp.c b/print-bootp.c index 5630b19cd..0e47ef508 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -183,6 +183,8 @@ struct bootp { /* RFC 2610 */ #define TAG_SLP_DA ((uint8_t) 78) #define TAG_SLP_SCOPE ((uint8_t) 79) +/* RFC 8925 */ +#define TAG_IPV6_ONLY_PREFERRED ((uint8_t) 108) /* RFC 2937 */ #define TAG_NS_SEARCH ((uint8_t) 117) /* RFC 3004 - The User Class Option for DHCP */ @@ -530,6 +532,7 @@ static const struct tok tag2str[] = { { TAG_NETINFO_PARENT_TAG, "aNITAG" }, { TAG_URL, "aURL" }, { TAG_MUDURL, "aMUD-URL" }, + { TAG_IPV6_ONLY_PREFERRED, "$IPv6-Only-Preferred" }, { 0, NULL } }; @@ -1057,6 +1060,19 @@ rfc1048_print(netdissect_options *ndo, } break; + case TAG_IPV6_ONLY_PREFERRED: + /* this option should be 4 bytes long */ + if (len != 4) { + ND_PRINT("[length != 4 bytes]"); + nd_print_invalid(ndo); + bp += len; + len = 0; + } + ND_PRINT("%u", GET_BE_U_4(bp)); + bp += 4; + len -= 4; + break; + default: ND_PRINT("[unknown special tag %u, size %u]", tag, len); diff --git a/tests/TESTLIST b/tests/TESTLIST index 6ef83d2a6..9c0bfcadb 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -525,6 +525,7 @@ dhcp-rfc4388 dhcp-rfc4388.pcap dhcp-rfc4388.out -v dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -v dhcp-mud dhcp-mud.pcap dhcp-mud.out -vv dhcp-option-33 dhcp-option-33.pcap dhcp-option-33.out -vvv +dhcp-option-108 dhcp-option-108.pcapng dhcp-option-108.out -v # VXLAN tests vxlan vxlan.pcap vxlan.out -e diff --git a/tests/dhcp-option-108.out b/tests/dhcp-option-108.out new file mode 100644 index 000000000..25d3942af --- /dev/null +++ b/tests/dhcp-option-108.out @@ -0,0 +1,31 @@ + 1 2025-03-18 09:43:45.393317 IP (tos 0x0, ttl 255, id 50068, offset 0, flags [none], proto UDP (17), length 328) + 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 42:b4:44:b4:f0:ee, length 300, xid 0x9edf45b0, Flags [none] + Client-Ethernet-Address 42:b4:44:b4:f0:ee + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message (53), length 1: Discover + Parameter-Request (55), length 12: + Subnet-Mask (1), Classless-Static-Route (121), Default-Gateway (3), Domain-Name-Server (6) + Domain-Name (15), IPv6-Only-Preferred (108), URL (114), Unknown (119) + Unknown (252), LDAP (95), Netbios-Name-Server (44), Netbios-Node (46) + MSZ (57), length 2: 1500 + Client-ID (61), length 7: ether 42:b4:44:b4:f0:ee + Lease-Time (51), length 4: 7776000 + Hostname (12), length 10: "MacBookPro" + 2 2025-03-18 09:43:45.399056 IP (tos 0x0, ttl 64, id 64867, offset 0, flags [none], proto UDP (17), length 351) + 10.56.0.2.67 > 10.56.42.232.68: BOOTP/DHCP, Reply, length 323, hops 1, xid 0x9edf45b0, Flags [none] + Your-IP 10.56.42.232 + Gateway-IP 10.56.0.2 + Client-Ethernet-Address 42:b4:44:b4:f0:ee + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message (53), length 1: Offer + Subnet-Mask (1), length 4: 255.255.0.0 + Default-Gateway (3), length 4: 10.56.0.1 + Domain-Name-Server (6), length 8: 31.130.229.6,31.130.229.7 + Hostname (12), length 10: "macbookpro" + Domain-Name (15), length 16: "meeting.ietf.org" + Lease-Time (51), length 4: 3600 + Server-ID (54), length 4: 31.130.229.6 + Client-ID (61), length 7: ether 42:b4:44:b4:f0:ee + IPv6-Only-Preferred (108), length 4: 900 diff --git a/tests/dhcp-option-108.pcapng b/tests/dhcp-option-108.pcapng new file mode 100644 index 0000000000000000000000000000000000000000..11026ba1e8f25fd5dd8d1bda66d7caade5370460 GIT binary patch literal 1220 zcmds1y>HV{5Wi=Vgez7+Iw+?(rz8gN$2x@ynA=Q^I3|=rH=qmUA%CL zpxm7h2L)K|1$IZisnD|P+w!fdLY;gvrR56Om-Do|cAJ)HTFq$7EBC29a)J$7t5tM0 zt?-~g*R*cbXez5_)bs*v44h7rrgfu`qOxK7Bd3QN`ZNXa6d(=8pzB$tN9DTX+x-pG zZ!1(+bycJCa4eHrvZZN7GnLEed99IU2a#CqtnNn>2@nMic(8jKJ|j?fl2;t`9m6OQ z<#9L%Flc(zbNzreTsQD6>iTrQsSmM3_JFC!HLyGGv4W7EX(GJ%`D*75>Wo8Zm$r@V zAK#-;0kZPp30miVC0I1`f&pcs_s$R^!t*bcx6FQ!!t)2MM_0GDYF3tze2i@J;%vts z{aIg7i(KUMr5O_Tnh{|55@J%-w3b}Az2>{S``TrAGu$6f;hu=U-sz&wILz{Nb^hdh zX^i{&Ukji#xA;ja04EjBe}gg@``Cw>S=|4LJ4Xck?0^@rMIuJeZhaMz zXJQgAFm6ZN^WE7**R}(v*HRrjxU0H;3kL!x5;=iI|C>?=jr>D488(Lq$__Fkwg(Tc zy?IaIG?d)|{#E=w#l%CWX*X$OlQzTU=Wusf?B#m#9Y1-$i06dyPKUW7_&!bSjy;5F B#Iyha literal 0 HcmV?d00001