]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DHCP: decoder for the User Class option (RFC3004)
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 28 Nov 2014 10:10:24 +0000 (11:10 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 28 Nov 2014 10:10:24 +0000 (11:10 +0100)
print-bootp.c
tests/TESTLIST
tests/dhcp-rfc3004-v.out [new file with mode: 0644]
tests/dhcp-rfc3004.pcap [new file with mode: 0644]

index 48c3aedbc082716114f7f0848d3747956d482a82..9210c20a1eea37a4b38982c5e12cfbbb4287e53e 100644 (file)
@@ -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));
index 094f0f2f6bc48ea779ca25fabef3cdc06512d561..25437068d416867eab0ec492a9add754801d69f1 100644 (file)
@@ -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 (file)
index 0000000..2032817
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..11806c3
Binary files /dev/null and b/tests/dhcp-rfc3004.pcap differ