Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHCP: Add support for option 108 "IPv6-Only Preferred" (RFC 8925) #1305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions print-bootp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 }
};

Expand Down Expand Up @@ -1035,6 +1038,18 @@ rfc1048_print(netdissect_options *ndo,
}
break;

case TAG_IPV6_ONLY_PREFERRED:
/* this option should be 4 bytes long */
if (len != 4) {
ND_PRINT("[ERROR: length != 4 bytes]");
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);
Expand Down
1 change: 1 addition & 0 deletions tests/TESTLIST
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -v
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-108 dhcp-option-108.pcapng dhcp-option-108.out -v

# VXLAN tests
vxlan vxlan.pcap vxlan.out -e
Expand Down
31 changes: 31 additions & 0 deletions tests/dhcp-option-108.out
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/dhcp-option-108.pcapng
Binary file not shown.