*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.82 2007-01-14 21:22:05 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.83 2007-01-14 21:29:22 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
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);
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;
}