]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use "-H", not "-h", for the 802.11s option, and improve error reporting.
authorGuy Harris <[email protected]>
Wed, 22 Jun 2011 01:15:50 +0000 (18:15 -0700)
committerGuy Harris <[email protected]>
Wed, 22 Jun 2011 01:15:50 +0000 (18:15 -0700)
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.

interface.h
netdissect.h
print-802_11.c
tcpdump.1.in
tcpdump.c

index 9109a4532219fda14836a4fe38cb30527a39f85b..ae1cc2f9231aac3cf337dd4bad9afab8a44af4d1 100644 (file)
@@ -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
 
index 700c71a424e08c098baef4b26cc44c0409d763fe..6770cd11e42ad7474939944fd1cc5e025eb9328e 100644 (file)
@@ -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;
 
index a94ade2eb3079e61b5592837b299753f04eb9888..24ab625a61e3a18fafe52e5f00e46243428ed249 100644 (file)
@@ -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;
index 9418ad9d9ab14acd80b98f7ee7c69db7b9d27f6c..6871b67c0489508c08e4f55cbbadf4bccc811f2a 100644 (file)
@@ -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<count>'.
 .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
index 10b6239d5793d3c39c14f31c9aca007bce244a7e..a9afa8fe16b1aec728c0ad94fa2d000a990dbacd 100644 (file)
--- 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,