tcpdump mailing list archives
print-bootp.c: enhancement to print END, PAD options
From: Kevin Steves <stevesk () pobox com>
Date: Wed, 10 Jan 2007 13:06:53 -0800
The following patch does the following: 0) use TTEST/TCHECK macros vs. snapend comparisons 1) when -vvv display PAD and END options (multiple PAD options are summarized) 2) change a trunc string from bootp to rfc1048 because I think that is what is intended (matches trunc label) It may make sense to split these into separate diffs and I would be glad to do that. Example output: 11:34:18.663078 IP (tos 0x0, ttl 128, id 1362, offset 0, flags [none], proto: UDP (17), length: 328) 0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 00:01:6c:eb:20:b9, length 300, xid 0x599292b3, Flags [ none ] (0x0000) Client-Ethernet-Address 00:01:6c:eb:20:b9 Vendor-rfc1048 Extensions Magic Cookie 0x63825363 DHCP-Message Option 53, length 1: Discover NOAUTO Option 116, length 1: Y Client-ID Option 61, length 7: ether 00:01:6c:eb:20:b9 Hostname Option 12, length 10: "ksteves-xp" Vendor-Class Option 60, length 8: "MSFT 5.0" Parameter-Request Option 55, length 11: Subnet-Mask, Domain-Name, Default-Gateway, Domain-Name-Server Netbios-Name-Server, Netbios-Node, Netbios-Scope, Router-Discovery Static-Route, Option 249, Vendor-Option END Option 255, length 0 PAD Option 0, length 0, occurs 9 Index: print-bootp.c =================================================================== RCS file: /tcpdump/master/tcpdump/print-bootp.c,v retrieving revision 1.81 diff -u -r1.81 print-bootp.c --- print-bootp.c 13 Feb 2006 18:59:29 -0000 1.81 +++ print-bootp.c 10 Jan 2007 20:52:22 -0000 @@ -374,11 +374,11 @@ bp += sizeof(int32_t); /* Loop while we there is a tag left in the buffer */ - while (bp + 1 < snapend) { + while (TTEST2(*bp, 1)) { tag = *bp++; - if (tag == TAG_PAD) + if (tag == TAG_PAD && vflag < 3) continue; - if (tag == TAG_END) + if (tag == TAG_END && vflag < 3) return; if (tag == TAG_EXTENDED_OPTION) { TCHECK2(*(bp + 1), 2); @@ -392,17 +392,29 @@ cp = tok2str(tag2str, "?T%u", tag); c = *cp++; - /* Get the length; check for truncation */ - if (bp + 1 >= snapend) { - fputs(tstr, stdout); - return; + if (tag == TAG_PAD || tag == TAG_END) + len = 0; + else { + /* Get the length; check for truncation */ + TCHECK2(*bp, 1); + len = *bp++; } - len = *bp++; - printf("\n\t %s Option %u, length %u: ", cp, tag, len); + printf("\n\t %s Option %u, length %u%s", cp, tag, len, + len > 0 ? ": " : ""); + + if (tag == TAG_PAD && vflag > 2) { + u_int ntag = 1; + while (TTEST2(*bp, 1) && *bp == TAG_PAD) { + bp++; + ntag++; + } + if (ntag > 1) + printf(", occurs %u", ntag); + } - if (bp + len >= snapend) { - printf("[|bootp %u]", len); + if (!TTEST2(*bp, len)) { + printf("[|rfc1048 %u]", len); return; } - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- print-bootp.c: enhancement to print END, PAD options Kevin Steves (Jan 10)
- Re: print-bootp.c: enhancement to print END, PAD Guy Harris (Jan 14)