From: Francois-Xavier Le Bail Date: Thu, 25 Jan 2018 13:17:57 +0000 (+0100) Subject: No more need for ndo_invalid_header in struct netdissect_options X-Git-Tag: tcpdump-4.99-bp~1357 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/a8c1b2a33947ea2f811a82960ecd785d2609f2fa No more need for ndo_invalid_header in struct netdissect_options Because we now stop decoding packet when header length(s) is/are invalid, there is no more need to keep the invalid header flag out of pretty_print_packet function. --- diff --git a/netdissect.h b/netdissect.h index 8d6c0fb7..2bbfda30 100644 --- a/netdissect.h +++ b/netdissect.h @@ -191,7 +191,6 @@ struct netdissect_options { * LF, CR and SPACE as graphical chars */ int ndo_Hflag; /* dissect 802.11s draft mesh standard */ - int ndo_invalid_header; int ndo_packet_number; /* print a packet number in the beginning of line */ int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */ int ndo_tstamp_precision; /* requested time stamp precision */ diff --git a/print.c b/print.c index 7ab74727..70a0043c 100644 --- a/print.c +++ b/print.c @@ -313,32 +313,32 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *sp, u_int packets_captured) { u_int hdrlen; + int invalid_header = 0; if(ndo->ndo_packet_number) ND_PRINT("%5u ", packets_captured); /* Sanity checks on packet length / capture length */ - ndo->ndo_invalid_header = 0; if(h->caplen == 0) { - ndo->ndo_invalid_header = 1; + invalid_header = 1; ND_PRINT("[Invalid header: caplen==0"); } if (h->len == 0) { - if (!ndo->ndo_invalid_header) { - ndo->ndo_invalid_header = 1; + if (!invalid_header) { + invalid_header = 1; ND_PRINT("[Invalid header:"); } else ND_PRINT(","); ND_PRINT(" len==0"); } else if (h->len < h->caplen) { - if (!ndo->ndo_invalid_header) { - ndo->ndo_invalid_header = 1; + if (!invalid_header) { + invalid_header = 1; ND_PRINT("[Invalid header:"); } else ND_PRINT(","); ND_PRINT(" len(%u) < caplen(%u)", h->len, h->caplen); } - if (ndo->ndo_invalid_header) { + if (invalid_header) { ND_PRINT("]\n"); return; }