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;
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;
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;
}
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;
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;
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);
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;
}
#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
*/
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 */
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;
}
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: