]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add a -h flag, and only attempt to recognize 802.11s mesh headers if it's set.
authorGuy Harris <[email protected]>
Fri, 28 May 2010 06:58:01 +0000 (23:58 -0700)
committerGuy Harris <[email protected]>
Fri, 28 May 2010 06:58:01 +0000 (23:58 -0700)
I give up.  I have no access to the 802.11s drafts, I can't find
anything that suggests whether a heuristic check for an 802.11s header
should check for To DS and From DS both being set or either being set or
unset, or whether it should check for a QoS frame type (the examples in
all the documentation I can find have To DS and From DS set, and have a
QoS field, in the 802.11 header, but that might just be an example
802.11 header showing all the fields), so I'm just adding a -h
command-line flag; you need to specify it to get tcpdump to try to guess
whether a frame has a mesh header or not.  I'll leave it up to somebody
else to figure out what the best heuristic for detecting the presence of
mesh headers is (note that tcpdump and Wireshark have different
heuristics, both of which can probably get false positives, especially
with encrypted frames where the first payload byte just *happens* not to
have any of the reserved bits in the mesh header flags set).

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

index 6e04b058c21c83579071d983f1cf7f376a6fc7ad..58ccbfce2525f2d64ed44311e481ddb593c531c9 100644 (file)
@@ -384,6 +384,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 snaplen     gndo->ndo_snaplen
 #define snapend     gndo->ndo_snapend
 
index 757cd7bf6acb7d3d462b5d374747b99e016c4c0a..dbdb1377d563d07ca9e5e9cefc2481c5d4f0efee 100644 (file)
@@ -116,6 +116,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_suppress_default_print; /* don't use default_print() for unknown packet types */
   const char *ndo_dltname;
 
index 088840ab138489fde9c65e522f60931cf63e5e8e..e29b8fb846f69c18d372ff46736264533b1f2c51 100644 (file)
@@ -1321,7 +1321,8 @@ 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 (FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
+       if (hflag && FC_TYPE(fc) == T_DATA &&
+           DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
                meshdrlen = extract_mesh_header_length(p+hdrlen);
                hdrlen += meshdrlen;
        } else
index 5e1a00f82848e95a58324ef52dcdbd2bd6cc91bc..8760afee3f0ccee8da645e02b0528f57c4cdd7b0 100644 (file)
@@ -29,7 +29,7 @@ tcpdump \- dump traffic on a network
 .na
 .B tcpdump
 [
-.B \-AbdDefIKlLnNOpqRStuUvxX
+.B \-AbdDefhIKlLnNOpqRStuUvxX
 ] [
 .B \-B
 .I buffer_size
@@ -319,6 +319,9 @@ If used in conjunction with the
 .B \-C
 option, filenames will take the form of `\fIfile\fP<count>'.
 .TP
+.B \-h
+Attempt to detect 802.11s draft mesh headers.
+.TP
 .B \-i
 Listen on \fIinterface\fP.
 If unspecified, \fItcpdump\fP searches the system interface list for the
index a051e4d4f8150ca348e22f9499e7456265a6fd38..b26188f56399af252407977b7c989708c5bd89c2 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -603,7 +603,7 @@ main(int argc, char **argv)
 
        opterr = 0;
        while (
-           (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_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:hi:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1)
                switch (op) {
 
                case 'a':
@@ -696,6 +696,10 @@ main(int argc, char **argv)
                        }
                        break;
 
+               case 'h':
+                       ++hflag;
+                       break;
+
                case 'i':
                        if (optarg[0] == '0' && optarg[1] == 0)
                                error("Invalid adapter index");