]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-802_11.c
Update .gitignore for other configurations
[tcpdump] / print-802_11.c
index a3d376b6a79daaf09ec63966275a2d0670db0813..548893f551d5bf2f65fae36449eb32d024233c1c 100644 (file)
@@ -245,10 +245,10 @@ struct tim_t {
 
 #define        E_SSID          0
 #define        E_RATES         1
-#define        E_FH            2
+#define        E_FH            2
 #define        E_DS            3
-#define        E_CF            4
-#define        E_TIM           5
+#define        E_CF            4
+#define        E_TIM           5
 #define        E_IBSS          6
 /* reserved            7 */
 /* reserved            8 */
@@ -402,7 +402,7 @@ struct meshcntl_t {
 #define PRINT_SSID(p) \
        if (p.ssid_present) { \
                ND_PRINT(" ("); \
-               fn_print(ndo, p.ssid.ssid, NULL); \
+               fn_print_str(ndo, p.ssid.ssid); \
                ND_PRINT(")"); \
        }
 
@@ -840,7 +840,7 @@ static const char *status_text[] = {
        "Reserved",                                             /*  8 */
        "Reserved",                                             /*  9 */
        "Cannot Support all requested capabilities in the Capability "
-         "Information field",                                  /* 10 */
+         "Information field",                                  /* 10 */
        "Reassociation denied due to inability to confirm that association "
          "exists",                                             /* 11 */
        "Association denied due to reason outside the scope of the "
@@ -851,9 +851,9 @@ static const char *status_text[] = {
          "sequence number out of expected sequence",           /* 14 */
        "Authentication rejected because of challenge failure", /* 15 */
        "Authentication rejected due to timeout waiting for next frame in "
-         "sequence",                                           /* 16 */
+         "sequence",                                           /* 16 */
        "Association denied because AP is unable to handle additional"
-         "associated stations",                                /* 17 */
+         "associated stations",                                /* 17 */
        "Association denied due to requesting station not supporting all of "
          "the data rates in BSSBasicRateSet parameter",        /* 18 */
        "Association denied due to requesting station not supporting "
@@ -2000,12 +2000,6 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
        }
 }
 
-#ifndef roundup2
-#define        roundup2(x, y)  (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
-#endif
-
-static const char tstr[] = "[|802.11]";
-
 static u_int
 ieee802_11_print(netdissect_options *ndo,
                  const u_char *p, u_int length, u_int orig_caplen, int pad,
@@ -2020,7 +2014,7 @@ ieee802_11_print(netdissect_options *ndo,
        caplen = orig_caplen;
        /* Remove FCS, if present */
        if (length < fcslen) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
        length -= fcslen;
@@ -2032,7 +2026,7 @@ ieee802_11_print(netdissect_options *ndo,
        }
 
        if (caplen < IEEE802_11_FC_LEN) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return orig_caplen;
        }
 
@@ -2046,13 +2040,17 @@ ieee802_11_print(netdissect_options *ndo,
                hdrlen = roundup2(hdrlen, 4);
        if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
            DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
+               if(!ND_TTEST_1(p + hdrlen)) {
+                       nd_print_trunc(ndo);
+                       return hdrlen;
+               }
                meshdrlen = extract_mesh_header_length(p+hdrlen);
                hdrlen += meshdrlen;
        } else
                meshdrlen = 0;
 
        if (caplen < hdrlen) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return hdrlen;
        }
 
@@ -2072,13 +2070,13 @@ ieee802_11_print(netdissect_options *ndo,
        case T_MGMT:
                get_mgmt_src_dst_mac(p - hdrlen, &src.addr, &dst.addr);
                if (!mgmt_body_print(ndo, fc, src.addr, p, length)) {
-                       ND_PRINT("%s", tstr);
+                       nd_print_trunc(ndo);
                        return hdrlen;
                }
                break;
        case T_CTRL:
                if (!ctrl_body_print(ndo, fc, p - hdrlen)) {
-                       ND_PRINT("%s", tstr);
+                       nd_print_trunc(ndo);
                        return hdrlen;
                }
                break;
@@ -2089,7 +2087,7 @@ ieee802_11_print(netdissect_options *ndo,
                if (FC_PROTECTED(fc)) {
                        ND_PRINT("Data");
                        if (!wep_print(ndo, p)) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                return hdrlen;
                        }
                } else {
@@ -3007,7 +3005,7 @@ print_radiotap_field(netdissect_options *ndo,
        return 0;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return rc;
 }
 
@@ -3084,19 +3082,28 @@ ieee802_11_radio_print(netdissect_options *ndo,
 
        ndo->ndo_protocol = "802.11_radio";
        if (caplen < sizeof(*hdr)) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
        hdr = (const struct ieee80211_radiotap_header *)p;
 
        len = EXTRACT_LE_U_2(hdr->it_len);
+       if (len < sizeof(*hdr)) {
+               /*
+                * The length is the length of the entire header, so
+                * it must be as large as the fixed-length part of
+                * the header.
+                */
+               nd_print_trunc(ndo);
+               return caplen;
+       }
 
        /*
         * If we don't have the entire radiotap header, just give up.
         */
        if (caplen < len) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
        cpack_init(&cpacker, (const uint8_t *)hdr, len); /* align against header start */
@@ -3109,7 +3116,7 @@ ieee802_11_radio_print(netdissect_options *ndo,
 
        /* are there more bitmap extensions than bytes in header? */
        if ((const u_char*)(last_presentp + 1) > p + len) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
@@ -3205,27 +3212,27 @@ ieee802_11_radio_print(netdissect_options *ndo,
                        bit0 = 0;
                        vendor_namespace = 1;
                        if ((cpack_align_and_reserve(&cpacker, 2)) == NULL) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        if (cpack_uint8(&cpacker, &vendor_oui[0]) != 0) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        if (cpack_uint8(&cpacker, &vendor_oui[1]) != 0) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        if (cpack_uint8(&cpacker, &vendor_oui[2]) != 0) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        if (cpack_uint8(&cpacker, &vendor_subnamespace) != 0) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        if (cpack_uint16(&cpacker, &skip_length) != 0) {
-                               ND_PRINT("%s", tstr);
+                               nd_print_trunc(ndo);
                                break;
                        }
                        break;
@@ -3262,7 +3269,7 @@ ieee802_11_radio_avs_print(netdissect_options *ndo,
 
        ndo->ndo_protocol = "802.11_radio_avs";
        if (caplen < 8) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
@@ -3273,12 +3280,12 @@ ieee802_11_radio_avs_print(netdissect_options *ndo,
                 * to be large enough to include even the version
                 * cookie or capture header length!
                 */
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
        if (caplen < caphdr_len) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
@@ -3315,7 +3322,7 @@ prism_if_print(netdissect_options *ndo,
 
        ndo->ndo_protocol = "prism_if";
        if (caplen < 4) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }
 
@@ -3325,7 +3332,7 @@ prism_if_print(netdissect_options *ndo,
                return ieee802_11_radio_avs_print(ndo, p, length, caplen);
 
        if (caplen < PRISM_HDR_LEN) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return caplen;
        }