From: Guy Harris Date: Wed, 22 Jun 2011 01:15:50 +0000 (-0700) Subject: Use "-H", not "-h", for the 802.11s option, and improve error reporting. X-Git-Tag: tcpdump-4.2.1~34 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/4cc892cbff1843cd735ff71297b0ee006a74ceab Use "-H", not "-h", for the 802.11s option, and improve error reporting. I was rudely surprised to find that "tcpdump -h" wasn't printing a usage message, and I'm the person who *added* the "-h" option. Make it "-H", and add an explicit "-h" option to print a usage message, so nobody else makes the same mistake. Also, don't clear opterr, so that if you give an illegal command-line option, you get an explanatory error message. --- diff --git a/interface.h b/interface.h index 9109a453..ae1cc2f9 100644 --- a/interface.h +++ b/interface.h @@ -383,7 +383,7 @@ extern netdissect_options *gndo; #define Cflag_count gndo->ndo_Cflag_count #define Gflag_count gndo->ndo_Gflag_count #define Gflag_time gndo->ndo_Gflag_time -#define hflag gndo->ndo_hflag +#define Hflag gndo->ndo_Hflag #define snaplen gndo->ndo_snaplen #define snapend gndo->ndo_snapend diff --git a/netdissect.h b/netdissect.h index 700c71a4..6770cd11 100644 --- a/netdissect.h +++ b/netdissect.h @@ -117,7 +117,7 @@ struct netdissect_options { time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */ int ndo_Wflag; /* recycle output files after this number of files */ int ndo_WflagChars; - int ndo_hflag; /* dissect 802.11s draft mesh standard */ + int ndo_Hflag; /* dissect 802.11s draft mesh standard */ int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */ const char *ndo_dltname; diff --git a/print-802_11.c b/print-802_11.c index a94ade2e..24ab625a 100644 --- a/print-802_11.c +++ b/print-802_11.c @@ -1709,7 +1709,7 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad, hdrlen = extract_header_length(fc); if (pad) hdrlen = roundup2(hdrlen, 4); - if (hflag && FC_TYPE(fc) == T_DATA && + if (Hflag && FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) { meshdrlen = extract_mesh_header_length(p+hdrlen); hdrlen += meshdrlen; diff --git a/tcpdump.1.in b/tcpdump.1.in index 9418ad9d..6871b67c 100644 --- a/tcpdump.1.in +++ b/tcpdump.1.in @@ -29,7 +29,7 @@ tcpdump \- dump traffic on a network .na .B tcpdump [ -.B \-AbdDefhIJKlLnNOpqRStuUvxX +.B \-AbdDefhHIJKlLnNOpqRStuUvxX ] [ .B \-B .I buffer_size @@ -324,6 +324,10 @@ If used in conjunction with the option, filenames will take the form of `\fIfile\fP'. .TP .B \-h +Print the tcpdump and libpcap version strings, print a usage message, +and exit. +.TP +.B \-H Attempt to detect 802.11s draft mesh headers. .TP .B \-i diff --git a/tcpdump.c b/tcpdump.c index 10b6239d..a9afa8fe 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -651,9 +651,8 @@ main(int argc, char **argv) smiInit("tcpdump"); #endif - opterr = 0; while ( - (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) + (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) switch (op) { case 'a': @@ -747,7 +746,11 @@ main(int argc, char **argv) break; case 'h': - ++hflag; + usage(); + break; + + case 'H': + ++Hflag; break; case 'i': @@ -1894,7 +1897,7 @@ usage(void) #endif /* WIN32 */ #endif /* HAVE_PCAP_LIB_VERSION */ (void)fprintf(stderr, -"Usage: %s [-aAbd" D_FLAG "efh" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); +"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); (void)fprintf(stderr, "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n"); (void)fprintf(stderr,