Skip to content

Commit 7506397

Browse files
committed
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.
1 parent e80cc07 commit 7506397

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

print-bootp.c

+15
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ struct bootp {
183183
/* RFC 2610 */
184184
#define TAG_SLP_DA ((uint8_t) 78)
185185
#define TAG_SLP_SCOPE ((uint8_t) 79)
186+
/* RFC 8925 */
187+
#define TAG_IPV6_ONLY_PREFERRED ((uint8_t) 108)
186188
/* RFC 2937 */
187189
#define TAG_NS_SEARCH ((uint8_t) 117)
188190
/* RFC 3004 - The User Class Option for DHCP */
@@ -530,6 +532,7 @@ static const struct tok tag2str[] = {
530532
{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
531533
{ TAG_URL, "aURL" },
532534
{ TAG_MUDURL, "aMUD-URL" },
535+
{ TAG_IPV6_ONLY_PREFERRED, "$IPv6-Only-Preferred" },
533536
{ 0, NULL }
534537
};
535538

@@ -1030,6 +1033,18 @@ rfc1048_print(netdissect_options *ndo,
10301033
}
10311034
break;
10321035

1036+
case TAG_IPV6_ONLY_PREFERRED:
1037+
/* this option should be 4 bytes long */
1038+
if (len != 4) {
1039+
ND_PRINT("[ERROR: length != 4 bytes]");
1040+
bp += len;
1041+
len = 0;
1042+
}
1043+
ND_PRINT("%u", GET_BE_U_4(bp));
1044+
bp += 4;
1045+
len -= 4;
1046+
break;
1047+
10331048
default:
10341049
ND_PRINT("[unknown special tag %u, size %u]",
10351050
tag, len);

tests/TESTLIST

+1
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -v
522522
dhcp-rfc4388 dhcp-rfc4388.pcap dhcp-rfc4388.out -v
523523
dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -v
524524
dhcp-mud dhcp-mud.pcap dhcp-mud.out -vv
525+
dhcp-option-108 dhcp-option-108.pcapng dhcp-option-108.out -v
525526

526527
# VXLAN tests
527528
vxlan vxlan.pcap vxlan.out -e

tests/dhcp-option-108.out

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
1 2025-03-18 09:43:45.393317 IP (tos 0x0, ttl 255, id 50068, offset 0, flags [none], proto UDP (17), length 328)
2+
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]
3+
Client-Ethernet-Address 42:b4:44:b4:f0:ee
4+
Vendor-rfc1048 Extensions
5+
Magic Cookie 0x63825363
6+
DHCP-Message (53), length 1: Discover
7+
Parameter-Request (55), length 12:
8+
Subnet-Mask (1), Classless-Static-Route (121), Default-Gateway (3), Domain-Name-Server (6)
9+
Domain-Name (15), IPv6-Only-Preferred (108), URL (114), Unknown (119)
10+
Unknown (252), LDAP (95), Netbios-Name-Server (44), Netbios-Node (46)
11+
MSZ (57), length 2: 1500
12+
Client-ID (61), length 7: ether 42:b4:44:b4:f0:ee
13+
Lease-Time (51), length 4: 7776000
14+
Hostname (12), length 10: "MacBookPro"
15+
2 2025-03-18 09:43:45.399056 IP (tos 0x0, ttl 64, id 64867, offset 0, flags [none], proto UDP (17), length 351)
16+
10.56.0.2.67 > 10.56.42.232.68: BOOTP/DHCP, Reply, length 323, hops 1, xid 0x9edf45b0, Flags [none]
17+
Your-IP 10.56.42.232
18+
Gateway-IP 10.56.0.2
19+
Client-Ethernet-Address 42:b4:44:b4:f0:ee
20+
Vendor-rfc1048 Extensions
21+
Magic Cookie 0x63825363
22+
DHCP-Message (53), length 1: Offer
23+
Subnet-Mask (1), length 4: 255.255.0.0
24+
Default-Gateway (3), length 4: 10.56.0.1
25+
Domain-Name-Server (6), length 8: 31.130.229.6,31.130.229.7
26+
Hostname (12), length 10: "macbookpro"
27+
Domain-Name (15), length 16: "meeting.ietf.org"
28+
Lease-Time (51), length 4: 3600
29+
Server-ID (54), length 4: 31.130.229.6
30+
Client-ID (61), length 7: ether 42:b4:44:b4:f0:ee
31+
IPv6-Only-Preferred (108), length 4: 900

tests/dhcp-option-108.pcapng

1.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)