summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcr <mcr>1999-10-17 23:35:46 +0000
committermcr <mcr>1999-10-17 23:35:46 +0000
commitce751501abbddbe91d683d13b5cd845a5d551d8f (patch)
tree0b851d1a91216a9a8c3daf00e5fc4d63cd248a0a
parent19069efd610a1ee69deefeca85c20e08f4a85aea (diff)
downloadtcpdump-dhcp.tar.gz
now prints DHCP optionsdhcp
-rw-r--r--bootp.h73
-rw-r--r--print-bootp.c128
2 files changed, 197 insertions, 4 deletions
diff --git a/bootp.h b/bootp.h
index 7365ad35..c09c6ddd 100644
--- a/bootp.h
+++ b/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.7 1999-10-07 23:47:09 mcr Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.8 1999-10-17 23:35:46 mcr Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -27,7 +27,7 @@ struct bootp {
unsigned char bp_hops; /* gateway hops */
u_int32_t bp_xid; /* transaction ID */
unsigned short bp_secs; /* seconds since boot began */
- unsigned short bp_unused;
+ unsigned short bp_flags; /* flags: 0x8000 is broadcast */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
@@ -86,7 +86,74 @@ struct bootp {
#define TAG_SWAP_SERVER ((unsigned char) 16)
#define TAG_ROOTPATH ((unsigned char) 17)
#define TAG_EXTPATH ((unsigned char) 18)
-
+/* RFC2132 */
+#define TAG_IP_FORWARD ((unsigned char) 19)
+#define TAG_NL_SRCRT ((unsigned char) 20)
+#define TAG_PFILTERS ((unsigned char) 21)
+#define TAG_REASS_SIZE ((unsigned char) 22)
+#define TAG_DEF_TTL ((unsigned char) 23)
+#define TAG_MTU_TIMEOUT ((unsigned char) 24)
+#define TAG_MTU_TABLE ((unsigned char) 25)
+#define TAG_INT_MTU ((unsigned char) 26)
+#define TAG_LOCAL_SUBNETS ((unsigned char) 27)
+#define TAG_BROAD_ADDR ((unsigned char) 28)
+#define TAG_DO_MASK_DISC ((unsigned char) 29)
+#define TAG_SUPPLY_MASK ((unsigned char) 30)
+#define TAG_DO_RDISC ((unsigned char) 31)
+#define TAG_RTR_SOL_ADDR ((unsigned char) 32)
+#define TAG_STATIC_ROUTE ((unsigned char) 33)
+#define TAG_USE_TRAILERS ((unsigned char) 34)
+#define TAG_ARP_TIMEOUT ((unsigned char) 35)
+#define TAG_ETH_ENCAP ((unsigned char) 36)
+#define TAG_TCP_TTL ((unsigned char) 37)
+#define TAG_TCP_KEEPALIVE ((unsigned char) 38)
+#define TAG_KEEPALIVE_GO ((unsigned char) 39)
+#define TAG_NIS_DOMAIN ((unsigned char) 40)
+#define TAG_NIS_SERVERS ((unsigned char) 41)
+#define TAG_NTP_SERVERS ((unsigned char) 42)
+#define TAG_VENDOR_OPTS ((unsigned char) 43)
+#define TAG_NETBIOS_NS ((unsigned char) 44)
+#define TAG_NETBIOS_DDS ((unsigned char) 45)
+#define TAG_NETBIOS_NODE ((unsigned char) 46)
+#define TAG_NETBIOS_SCOPE ((unsigned char) 47)
+#define TAG_XWIN_FS ((unsigned char) 48)
+#define TAG_XWIN_DM ((unsigned char) 49)
+#define TAG_NIS_P_DOMAIN ((unsigned char) 64)
+#define TAG_NIS_P_SERVERS ((unsigned char) 65)
+#define TAG_MOBILE_HOME ((unsigned char) 68)
+#define TAG_SMPT_SERVER ((unsigned char) 69)
+#define TAG_POP3_SERVER ((unsigned char) 70)
+#define TAG_NNTP_SERVER ((unsigned char) 71)
+#define TAG_WWW_SERVER ((unsigned char) 72)
+#define TAG_FINGER_SERVER ((unsigned char) 73)
+#define TAG_IRC_SERVER ((unsigned char) 74)
+#define TAG_STREETTALK_SRVR ((unsigned char) 75)
+#define TAG_STREETTALK_STDA ((unsigned char) 76)
+/* DHCP options */
+#define TAG_REQUESTED_IP ((unsigned char) 50)
+#define TAG_IP_LEASE ((unsigned char) 51)
+#define TAG_OPT_OVERLOAD ((unsigned char) 52)
+#define TAG_TFTP_SERVER ((unsigned char) 66)
+#define TAG_BOOTFILENAME ((unsigned char) 67)
+#define TAG_DHCP_MESSAGE ((unsigned char) 53)
+#define TAG_SERVER_ID ((unsigned char) 54)
+#define TAG_PARM_REQUEST ((unsigned char) 55)
+#define TAG_MESSAGE ((unsigned char) 56)
+#define TAG_MAX_MSG_SIZE ((unsigned char) 57)
+#define TAG_RENEWAL_TIME ((unsigned char) 58)
+#define TAG_REBIND_TIME ((unsigned char) 59)
+#define TAG_VENDOR_CLASS ((unsigned char) 60)
+#define TAG_CLIENT_ID ((unsigned char) 61)
+
+/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
+#define DHCPDISCOVER 1
+#define DHCPOFFER 2
+#define DHCPREQUEST 3
+#define DHCPDECLINE 4
+#define DHCPACK 5
+#define DHCPNAK 6
+#define DHCPRELEASE 7
+#define DHCPINFORM 8
/*
diff --git a/print-bootp.c b/print-bootp.c
index a5fb2552..fb1329e2 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -22,7 +22,7 @@
*/
#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.47 1999-10-17 23:35:47 mcr Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -102,6 +102,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);
@@ -207,6 +209,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, "bCID" },
{ 0, NULL }
};
@@ -248,6 +307,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 == '?') {
@@ -288,6 +376,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,6 +405,28 @@ 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':
default:
/* Bytes */