]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add "$" format, meaning to escape to a special printer (from LBL)
authorfenner <fenner>
Wed, 4 Jul 2001 21:18:12 +0000 (21:18 +0000)
committerfenner <fenner>
Wed, 4 Jul 2001 21:18:12 +0000 (21:18 +0000)
Add "$" printers for NetBIOS Node Type (WNT), DHCP Option Overload (OO),
 Client Identifier (CID), Client FQDN (FQDN)
Change Vendor Class (VC) from decimal string to ASCII string

print-bootp.c

index 2c823f4e181895344a18380c86778f03eb2a38e5..04f767ee1994703d0a601b2e93380ded9f69b509 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.58 2001-04-27 02:17:10 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.59 2001-07-04 21:18:12 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -184,7 +184,19 @@ trunc:
        fputs(tstr, stdout);
 }
 
-/* The first character specifies the format to print */
+/*
+ * The first character specifies the format to print:
+ *     i - ip address (32 bits)
+ *     p - ip address pairs (32 bits + 32 bits)
+ *     l - long (32 bits)
+ *     L - unsigned long (32 bits)
+ *     s - short (16 bits)
+ *     b - period-seperated decimal bytes (variable length)
+ *     x - colon-seperated hex bytes (variable length)
+ *     a - ascii string (variable length)
+ *     B - on/off (8 bits)
+ *     $ - special (explicit code to handle)
+ */
 static struct tok tag2str[] = {
 /* RFC1048 tags */
        { TAG_PAD,              " PAD" },
@@ -236,7 +248,7 @@ static struct tok tag2str[] = {
        { TAG_VENDOR_OPTS,      "bVO" },
        { TAG_NETBIOS_NS,       "iWNS" },
        { TAG_NETBIOS_DDS,      "iWDD" },
-       { TAG_NETBIOS_NODE,     "bWNT" },
+       { TAG_NETBIOS_NODE,     "$WNT" },
        { TAG_NETBIOS_SCOPE,    "aWSC" },
        { TAG_XWIN_FS,          "iXFS" },
        { TAG_XWIN_DM,          "iXDM" },
@@ -253,7 +265,7 @@ static struct tok tag2str[] = {
        { TAG_STREETTALK_STDA,  "iSTDA" },
        { TAG_REQUESTED_IP,     "iRQ" },
        { TAG_IP_LEASE,         "lLT" },
-       { TAG_OPT_OVERLOAD,     "bOO" },
+       { TAG_OPT_OVERLOAD,     "$OO" },
        { TAG_TFTP_SERVER,      "aTFTP" },
        { TAG_BOOTFILENAME,     "aBF" },
        { TAG_DHCP_MESSAGE,     " DHCP" },
@@ -263,8 +275,8 @@ static struct tok tag2str[] = {
        { TAG_MAX_MSG_SIZE,     "sMSZ" },
        { TAG_RENEWAL_TIME,     "lRN" },
        { TAG_REBIND_TIME,      "lRB" },
-       { TAG_VENDOR_CLASS,     "bVC" },
-       { TAG_CLIENT_ID,        "xCID" },
+       { TAG_VENDOR_CLASS,     "aVC" },
+       { TAG_CLIENT_ID,        "$CID" },
 /* RFC 2485 */
        { TAG_OPEN_GROUP_UAP,   "aUAP" },
 /* RFC 2563 */
@@ -279,7 +291,7 @@ static struct tok tag2str[] = {
 /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
        { TAG_USER_CLASS,       "aCLASS" },
        { TAG_SLP_NAMING_AUTH,  "aSLP-NA" },
-       { TAG_CLIENT_FQDN,      "bFQDN" },      /* XXX 'b' */
+       { TAG_CLIENT_FQDN,      "$FQDN" },
        { TAG_AGENT_CIRCUIT,    "bACKT" },
        { TAG_AGENT_REMOTE,     "bARMT" },
        { TAG_AGENT_MASK,       "bAMSK" },
@@ -307,6 +319,34 @@ static struct tok xtag2str[] = {
        { 0,                    NULL }
 };
 
+/* DHCP "options overload" types */
+static struct tok oo2str[] = {
+       { 1,                    "file" },
+       { 2,                    "sname" },
+       { 3,                    "file+sname" },
+       { 0,                    NULL }
+};
+
+/* NETBIOS over TCP/IP node type options */
+static struct tok nbo2str[] = {
+       { 0x1,                  "b-node" },
+       { 0x2,                  "p-node" },
+       { 0x4,                  "m-node" },
+       { 0x8,                  "h-node" },
+       { 0,                    NULL }
+};
+
+/* ARP Hardware types, for Client-ID option */
+static struct tok arp2str[] = {
+       { 0x1,                  "ether" },
+       { 0x6,                  "ieee802" },
+       { 0x7,                  "arcnet" },
+       { 0xf,                  "frelay" },
+       { 0x17,                 "strip" },
+       { 0x18,                 "ieee1394" },
+       { 0,                    NULL }
+};
+
 static void
 rfc1048_print(register const u_char *bp, register u_int length)
 {
@@ -508,6 +548,66 @@ rfc1048_print(register const u_char *bp, register u_int length)
                                first = 0;
                        }
                        break;
+
+               case '$':
+                       /* Guys we can't handle with one of the usual cases */
+                       switch (tag) {
+
+                       case TAG_NETBIOS_NODE:
+                               tag = *bp++;
+                               --size;
+                               fputs(tok2str(nbo2str, NULL, tag), stdout);
+                               break;
+
+                       case TAG_OPT_OVERLOAD:
+                               tag = *bp++;
+                               --size;
+                               fputs(tok2str(oo2str, NULL, tag), stdout);
+                               break;
+
+                       case TAG_CLIENT_FQDN:
+                               if (*bp++)
+                                       printf("[svrreg]");
+                               if (*bp)
+                                       printf("%d/%d/", *bp, *(bp+1));
+                               bp += 2;
+                               putchar('"');
+                               (void)fn_printn(bp, size - 3, NULL);
+                               putchar('"');
+                               bp += size - 3;
+                               size = 0;
+                               break;
+
+                       case TAG_CLIENT_ID:
+                           {   int type = *bp++;
+                               size--;
+                               if (type == 0) {
+                                       putchar('"');
+                                       (void)fn_printn(bp, size, NULL);  
+                                       putchar('"');
+                                       break;
+                               } else {
+                                       printf("[%s]", tok2str(arp2str, "type-%d", type));
+                               }
+                               while (size > 0) {
+                                       if (!first)
+                                               putchar(':');
+                                       printf("%02x", *bp);
+                                       ++bp;
+                                       --size;
+                                       first = 0;
+                               }
+                               break;
+                           }
+
+                       default:
+                               printf("[unknown special tag %d, size %d]",
+                                   tag, size);
+                               bp += size;
+                               size = 0;
+                               break;
+                       }
+                       break;
                }
                /* Data left over? */
                if (size)