X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/86518728ca4b173227063975d960d01398a98eba..bd00116d80c18b782f4cb15dfc90cd5bf993d4f5:/print-802_11.c diff --git a/print-802_11.c b/print-802_11.c index 8649f520..2b4463ec 100644 --- a/print-802_11.c +++ b/print-802_11.c @@ -1290,7 +1290,7 @@ wep_print(netdissect_options *ndo, return 0; iv = EXTRACT_LE_32BITS(p); - ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv), + ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv), IV_KEYID(iv))); return 1; @@ -1808,7 +1808,7 @@ handle_auth(netdissect_options *ndo, static int handle_deauth(netdissect_options *ndo, - const struct mgmt_header_t *pmh, const u_char *p, u_int length) + const uint8_t *src, const u_char *p, u_int length) { struct mgmt_body_t pbody; const char *reason = NULL; @@ -1828,7 +1828,7 @@ handle_deauth(netdissect_options *ndo, if (ndo->ndo_eflag) { ND_PRINT((ndo, ": %s", reason)); } else { - ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason)); + ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason)); } return 1; } @@ -1893,7 +1893,7 @@ handle_deauth(netdissect_options *ndo, static int handle_action(netdissect_options *ndo, - const struct mgmt_header_t *pmh, const u_char *p, u_int length) + const uint8_t *src, const u_char *p, u_int length) { if (!ND_TTEST2(*p, 2)) return 0; @@ -1902,7 +1902,7 @@ handle_action(netdissect_options *ndo, if (ndo->ndo_eflag) { ND_PRINT((ndo, ": ")); } else { - ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa))); + ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src))); } switch (p[0]) { case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break; @@ -1933,10 +1933,13 @@ handle_action(netdissect_options *ndo, static int mgmt_body_print(netdissect_options *ndo, - uint16_t fc, const struct mgmt_header_t *pmh, - const u_char *p, u_int length) + uint16_t fc, const uint8_t *src, const u_char *p, u_int length) { ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc)))); + + /* There may be a problem w/ AP not having this bit set */ + if (FC_PROTECTED(fc)) + return wep_print(ndo, p); switch (FC_SUBTYPE(fc)) { case ST_ASSOC_REQUEST: return handle_assoc_request(ndo, p, length); @@ -1957,17 +1960,11 @@ mgmt_body_print(netdissect_options *ndo, case ST_DISASSOC: return handle_disassoc(ndo, p, length); case ST_AUTH: - if (!ND_TTEST2(*p, 3)) - return 0; - if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) { - ND_PRINT((ndo, "Authentication (Shared-Key)-3 ")); - return wep_print(ndo, p); - } return handle_auth(ndo, p, length); case ST_DEAUTH: - return handle_deauth(ndo, pmh, p, length); + return handle_deauth(ndo, src, p, length); case ST_ACTION: - return handle_action(ndo, pmh, p, length); + return handle_action(ndo, src, p, length); default: return 1; } @@ -2091,6 +2088,17 @@ get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp, #undef ADDR4 } +static void +get_mgmt_src_dst_mac(const u_char *p, const uint8_t **srcp, const uint8_t **dstp) +{ + const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p; + + if (srcp != NULL) + *srcp = hp->sa; + if (dstp != NULL) + *dstp = hp->da; +} + /* * Print Header funcs */ @@ -2324,7 +2332,7 @@ ieee802_11_print(netdissect_options *ndo, uint16_t fc; u_int caplen, hdrlen, meshdrlen; const uint8_t *src, *dst; - u_short extracted_ethertype; + int llc_hdrlen; caplen = orig_caplen; /* Remove FCS, if present */ @@ -2377,12 +2385,8 @@ ieee802_11_print(netdissect_options *ndo, switch (FC_TYPE(fc)) { case T_MGMT: - if (FC_PROTECTED(fc)) { - if (!ndo->ndo_eflag) - ND_PRINT((ndo, "Protected ")); - } - if (!mgmt_body_print(ndo, fc, - (const struct mgmt_header_t *)(p - hdrlen), p, length)) { + get_mgmt_src_dst_mac(p - hdrlen, &src, &dst); + if (!mgmt_body_print(ndo, fc, src, p, length)) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } @@ -2398,29 +2402,24 @@ ieee802_11_print(netdissect_options *ndo, return hdrlen; /* no-data frame */ /* There may be a problem w/ AP not having this bit set */ if (FC_PROTECTED(fc)) { + ND_PRINT((ndo, "Data")); if (!wep_print(ndo, p)) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } } else { get_data_src_dst_mac(fc, p - hdrlen, &src, &dst); - if (llc_print(ndo, p, length, caplen, dst, src, - &extracted_ethertype) == 0) { + llc_hdrlen = llc_print(ndo, p, length, caplen, dst, src); + if (llc_hdrlen < 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ - if (!ndo->ndo_eflag) { - ieee_802_11_hdr_print(ndo, fc, p - hdrlen, - hdrlen, meshdrlen); - } - if (extracted_ethertype) - ND_PRINT((ndo, "(LLC %s) ", - etherproto_string( - htons(extracted_ethertype)))); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); + llc_hdrlen = -llc_hdrlen; } + hdrlen += llc_hdrlen; } break; default: