diff options
-rw-r--r-- | print-bootp.c | 48 | ||||
-rw-r--r-- | tests/TESTLIST | 3 | ||||
-rw-r--r-- | tests/dhcp-rfc3004-v.out | 55 | ||||
-rw-r--r-- | tests/dhcp-rfc3004.pcap | bin | 0 -> 1420 bytes |
4 files changed, 104 insertions, 2 deletions
diff --git a/print-bootp.c b/print-bootp.c index 48c3aedb..9210c20a 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -189,13 +189,14 @@ struct bootp { #define TAG_SLP_SCOPE ((uint8_t) 79) /* RFC 2937 */ #define TAG_NS_SEARCH ((uint8_t) 117) +/* RFC 3004 - The User Class Option for DHCP */ +#define TAG_USER_CLASS ((uint8_t) 77) /* RFC 3011 */ #define TAG_IP4_SUBNET_SELECT ((uint8_t) 118) /* RFC 3442 */ #define TAG_CLASSLESS_STATIC_RT ((uint8_t) 121) #define TAG_CLASSLESS_STA_RT_MS ((uint8_t) 249) /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */ -#define TAG_USER_CLASS ((uint8_t) 77) #define TAG_SLP_NAMING_AUTH ((uint8_t) 80) #define TAG_CLIENT_FQDN ((uint8_t) 81) #define TAG_AGENT_CIRCUIT ((uint8_t) 82) @@ -495,13 +496,14 @@ static const struct tok tag2str[] = { { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ /* RFC 2937 */ { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ +/* RFC 3004 - The User Class Option for DHCP */ + { TAG_USER_CLASS, "$User-Class" }, /* RFC 3011 */ { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, /* RFC 3442 */ { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" }, { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" }, /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ - { TAG_USER_CLASS, "aCLASS" }, { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, { TAG_CLIENT_FQDN, "$FQDN" }, { TAG_AGENT_CIRCUIT, "$Agent-Information" }, @@ -969,6 +971,48 @@ rfc1048_print(netdissect_options *ndo, } break; + case TAG_USER_CLASS: + { + u_int suboptnumber = 1; + + first = 1; + if (len < 2) { + ND_PRINT((ndo, "ERROR: length < 2 bytes")); + bp += len; + len = 0; + break; + } + while (len > 0) { + suboptlen = *bp++; + len--; + ND_PRINT((ndo, "\n\t ")); + ND_PRINT((ndo, "instance#%u: ", suboptnumber)); + if (suboptlen == 0) { + ND_PRINT((ndo, "ERROR: suboption length must be non-zero")); + bp += len; + len = 0; + break; + } + if (len < suboptlen) { + ND_PRINT((ndo, "ERROR: malformed option")); + bp += len; + len = 0; + break; + } + ND_PRINT((ndo, "\"")); + if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) { + ND_PRINT((ndo, "\"")); + goto trunc; + } + ND_PRINT((ndo, "\"")); + ND_PRINT((ndo, ", length %d", suboptlen)); + suboptnumber++; + len -= suboptlen; + bp += suboptlen; + } + } + break; + default: ND_PRINT((ndo, "[unknown special tag %u, size %u]", tag, len)); diff --git a/tests/TESTLIST b/tests/TESTLIST index 094f0f2f..25437068 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -260,3 +260,6 @@ aoe_1-v AoE_Linux.pcap aoe_1-v.out -t -v # Geneve tests geneve-v geneve.pcap geneve-vv.out -t -vv + +# DHCP tests +dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -t -v diff --git a/tests/dhcp-rfc3004-v.out b/tests/dhcp-rfc3004-v.out new file mode 100644 index 00000000..2032817c --- /dev/null +++ b/tests/dhcp-rfc3004-v.out @@ -0,0 +1,55 @@ +IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328) + 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 300, xid 0x6e32864, Flags [none] + Client-Ethernet-Address 00:0c:29:1f:74:06 + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message Option 53, length 1: Discover + Requested-IP Option 50, length 4: 192.168.1.4 + Parameter-Request Option 55, length 7: + Subnet-Mask, BR, Time-Zone, Default-Gateway + Domain-Name, Domain-Name-Server, Hostname + User-Class Option 77, length 37: + instance#1: "subopt1", length 7 + instance#2: "subopt2-123456789", length 17 + instance#3: "subopt3-12", length 10 +IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 308) + 192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 280, xid 0x6e32864, Flags [none] + Your-IP 192.168.1.4 + Client-Ethernet-Address 00:0c:29:1f:74:06 + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message Option 53, length 1: Offer + Server-ID Option 54, length 4: 192.168.1.1 + Lease-Time Option 51, length 4: 86400 + Subnet-Mask Option 1, length 4: 255.255.255.0 + Default-Gateway Option 3, length 4: 192.168.1.1 + Domain-Name-Server Option 6, length 4: 192.168.1.1 + Domain-Name Option 15, length 4: "Home" +IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 332) + 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 304, xid 0x6e32864, Flags [none] + Client-Ethernet-Address 00:0c:29:1f:74:06 + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message Option 53, length 1: Request + Server-ID Option 54, length 4: 192.168.1.1 + Requested-IP Option 50, length 4: 192.168.1.4 + Parameter-Request Option 55, length 7: + Subnet-Mask, BR, Time-Zone, Default-Gateway + Domain-Name, Domain-Name-Server, Hostname + User-Class Option 77, length 37: + instance#1: "subopt1", length 7 + instance#2: "subopt2-123456789", length 17 + instance#3: "subopt3-12", length 10 +IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 308) + 192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 280, xid 0x6e32864, Flags [none] + Your-IP 192.168.1.4 + Client-Ethernet-Address 00:0c:29:1f:74:06 + Vendor-rfc1048 Extensions + Magic Cookie 0x63825363 + DHCP-Message Option 53, length 1: ACK + Server-ID Option 54, length 4: 192.168.1.1 + Lease-Time Option 51, length 4: 86400 + Subnet-Mask Option 1, length 4: 255.255.255.0 + Default-Gateway Option 3, length 4: 192.168.1.1 + Domain-Name-Server Option 6, length 4: 192.168.1.1 + Domain-Name Option 15, length 4: "Home" diff --git a/tests/dhcp-rfc3004.pcap b/tests/dhcp-rfc3004.pcap Binary files differnew file mode 100644 index 00000000..11806c31 --- /dev/null +++ b/tests/dhcp-rfc3004.pcap |