]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-bootp.c
Patch sent to Debian by Roderick Schertler <[email protected]> to print
[tcpdump] / print-bootp.c
index a5fb25524a8c50e24d5adf0cbbb5ce079701d21f..531ca84b8126075617cd09dd86a01cfd8fadb1ad 100644 (file)
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.46 1999-10-07 23:47:11 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.53 2000-10-27 23:26:30 guy Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/socket.h>
 
-#if __STDC__
 struct mbuf;
 struct rtentry;
-#endif
-#include <net/if.h>
 
 #include <netinet/in.h>
-#include <netinet/if_ether.h>
 
 #include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
 #include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
+#include "ether.h"
 #include "bootp.h"
 
 static void rfc1048_print(const u_char *, u_int);
@@ -102,6 +100,8 @@ bootp_print(register const u_char *cp, u_int length,
                printf(" xid:0x%x", (u_int32_t)ntohl(bp->bp_xid));
        if (bp->bp_secs)
                printf(" secs:%d", ntohs(bp->bp_secs));
+       if (bp->bp_flags)
+               printf(" flags:0x%x", ntohs(bp->bp_flags));
 
        /* Client's ip address */
        TCHECK(bp->bp_ciaddr);
@@ -188,7 +188,7 @@ static struct tok tag2str[] = {
 /* RFC1048 tags */
        { TAG_PAD,              " PAD" },
        { TAG_SUBNET_MASK,      "iSM" },        /* subnet mask (RFC950) */
-       { TAG_TIME_OFFSET,      "lTZ" },        /* seconds from UTC */
+       { TAG_TIME_OFFSET,      "LTZ" },        /* seconds from UTC */
        { TAG_GATEWAY,          "iDG" },        /* default gateway */
        { TAG_TIME_SERVER,      "iTS" },        /* time servers (RFC868) */
        { TAG_NAME_SERVER,      "iIEN" },       /* IEN name servers (IEN116) */
@@ -207,6 +207,63 @@ static struct tok tag2str[] = {
        { TAG_SWAP_SERVER,      "iSS" },
        { TAG_ROOTPATH,         "aRP" },
        { TAG_EXTPATH,          "aEP" },
+/* RFC2132 tags */
+       { TAG_IP_FORWARD,       "BIPF" },
+       { TAG_NL_SRCRT,         "BSRT" },
+       { TAG_PFILTERS,         "pPF" },
+       { TAG_REASS_SIZE,       "sRSZ" },
+       { TAG_DEF_TTL,          "bTTL" },
+       { TAG_MTU_TIMEOUT,      "lMA" },
+       { TAG_MTU_TABLE,        "sMT" },
+       { TAG_INT_MTU,          "sMTU" },
+       { TAG_LOCAL_SUBNETS,    "BLSN" },
+       { TAG_BROAD_ADDR,       "iBR" },
+       { TAG_DO_MASK_DISC,     "BMD" },
+       { TAG_SUPPLY_MASK,      "BMS" },
+       { TAG_DO_RDISC,         "BRD" },
+       { TAG_RTR_SOL_ADDR,     "iRSA" },
+       { TAG_STATIC_ROUTE,     "pSR" },
+       { TAG_USE_TRAILERS,     "BUT" },
+       { TAG_ARP_TIMEOUT,      "lAT" },
+       { TAG_ETH_ENCAP,        "BIE" },
+       { TAG_TCP_TTL,          "bTT" },
+       { TAG_TCP_KEEPALIVE,    "lKI" },
+       { TAG_KEEPALIVE_GO,     "BKG" },
+       { TAG_NIS_DOMAIN,       "aYD" },
+       { TAG_NIS_SERVERS,      "iYS" },
+       { TAG_NTP_SERVERS,      "iNTP" },
+       { TAG_VENDOR_OPTS,      "bVO" },
+       { TAG_NETBIOS_NS,       "iWNS" },
+       { TAG_NETBIOS_DDS,      "iWDD" },
+       { TAG_NETBIOS_NODE,     "bWNT" },
+       { TAG_NETBIOS_SCOPE,    "aWSC" },
+       { TAG_XWIN_FS,          "iXFS" },
+       { TAG_XWIN_DM,          "iXDM" },
+       { TAG_NIS_P_DOMAIN,     "sN+D" },
+       { TAG_NIS_P_SERVERS,    "iN+S" },
+       { TAG_MOBILE_HOME,      "iMH" },
+       { TAG_SMPT_SERVER,      "iSMTP" },
+       { TAG_POP3_SERVER,      "iPOP3" },
+       { TAG_NNTP_SERVER,      "iNNTP" },
+       { TAG_WWW_SERVER,       "iWWW" },
+       { TAG_FINGER_SERVER,    "iFG" },
+       { TAG_IRC_SERVER,       "iIRC" },
+       { TAG_STREETTALK_SRVR,  "iSTS" },
+       { TAG_STREETTALK_STDA,  "iSTDA" },
+       { TAG_REQUESTED_IP,     "iRQ" },
+       { TAG_IP_LEASE,         "lLT" },
+       { TAG_OPT_OVERLOAD,     "bOO" },
+       { TAG_TFTP_SERVER,      "aTFTP" },
+       { TAG_BOOTFILENAME,     "aBF" },
+       { TAG_DHCP_MESSAGE,     " DHCP" },
+       { TAG_SERVER_ID,        "iSID" },
+       { TAG_PARM_REQUEST,     "bPR" },
+       { TAG_MESSAGE,          "aMSG" },
+       { TAG_MAX_MSG_SIZE,     "sMSZ" },
+       { TAG_RENEWAL_TIME,     "lRN" },
+       { TAG_REBIND_TIME,      "lRB" },
+       { TAG_VENDOR_CLASS,     "bVC" },
+       { TAG_CLIENT_ID,        "xCID" },
        { 0,                    NULL }
 };
 
@@ -248,6 +305,35 @@ rfc1048_print(register const u_char *bp, register u_int length)
                        return;
                }
 
+               if (tag == TAG_DHCP_MESSAGE && len == 1) {
+                       c = *bp++;
+                       switch (c) {
+                       case DHCPDISCOVER:      printf("DISCOVER");     break;
+                       case DHCPOFFER:         printf("OFFER");        break;
+                       case DHCPREQUEST:       printf("REQUEST");      break;
+                       case DHCPDECLINE:       printf("DECLINE");      break;
+                       case DHCPACK:           printf("ACK");          break;
+                       case DHCPNAK:           printf("NACK");         break;
+                       case DHCPRELEASE:       printf("RELEASE");      break;
+                       case DHCPINFORM:        printf("INFORM");       break;
+                       default:                printf("%u", c);        break;
+                       }
+                       continue;
+               }
+
+               if (tag == TAG_PARM_REQUEST) {
+                       first = 1;
+                       while (len-- > 0) {
+                               c = *bp++;
+                               cp = tok2str(tag2str, "?%d", c);
+                               if (!first)
+                                       putchar('+');
+                               printf("%s", cp + 1);
+                               first = 0;
+                       }
+                       continue;
+               }
+
                /* Print data */
                size = len;
                if (c == '?') {
@@ -273,6 +359,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
 
                case 'i':
                case 'l':
+               case 'L':
                        /* ip addresses/32-bit words */
                        while (size >= sizeof(ul)) {
                                if (!first)
@@ -280,6 +367,8 @@ rfc1048_print(register const u_char *bp, register u_int length)
                                memcpy((char *)&ul, (char *)bp, sizeof(ul));
                                if (c == 'i')
                                        printf("%s", ipaddr_string(&ul));
+                               else if (c == 'L')
+                                       printf("%d", ul);
                                else
                                        printf("%u", ul);
                                bp += sizeof(ul);
@@ -288,6 +377,22 @@ rfc1048_print(register const u_char *bp, register u_int length)
                        }
                        break;
 
+               case 'p':
+                       /* IP address pairs */
+                       while (size >= 2*sizeof(ul)) {
+                               if (!first)
+                                       putchar(',');
+                               memcpy((char *)&ul, (char *)bp, sizeof(ul));
+                               printf("(%s:", ipaddr_string(&ul));
+                               bp += sizeof(ul);
+                               memcpy((char *)&ul, (char *)bp, sizeof(ul));
+                               printf("%s)", ipaddr_string(&ul));
+                               bp += sizeof(ul);
+                               size -= 2*sizeof(ul);
+                               first = 0;
+                       }
+                       break;
+
                case 's':
                        /* shorts */
                        while (size >= sizeof(us)) {
@@ -301,13 +406,36 @@ rfc1048_print(register const u_char *bp, register u_int length)
                        }
                        break;
 
+               case 'B':
+                       /* boolean */
+                       while (size > 0) {
+                               if (!first)
+                                       putchar(',');
+                               switch (*bp) {
+                               case 0:
+                                       putchar('N');
+                                       break;
+                               case 1:
+                                       putchar('Y');
+                                       break;
+                               default:
+                                       printf("%d?", *bp);
+                                       break;
+                               }
+                               ++bp;
+                               --size;
+                               first = 0;
+                       }
+                       break;
+
                case 'b':
+               case 'x':
                default:
                        /* Bytes */
                        while (size > 0) {
                                if (!first)
-                                       putchar('.');
-                               printf("%d", *bp);
+                                       putchar (c == 'x' ? ':' : '.');
+                               printf (c == 'x' ? "%02x" : "%d", *bp);
                                ++bp;
                                --size;
                                first = 0;