#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.33 2005-07-07 01:22:16 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.34 2005-07-30 00:05:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
} while (0)
static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
-static const char *subtype_text[]={
+#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
+
+static const char *subtype_text[16]={
"Assoc Request",
"Assoc Response",
"ReAssoc Request",
"ReAssoc Response",
"Probe Request",
"Probe Response",
- "",
- "",
+ NULL,
+ NULL,
"Beacon",
"ATIM",
"Disassociation",
"Authentication",
"DeAuthentication",
- "",
- ""
+ NULL,
+ NULL,
+ NULL
};
static const char *status_text[] = {
"Association denied because AP is unable to handle additional associated stations", /* 17 */
"Association denied due to requesting station not supporting all of the " \
"data rates in BSSBasicRateSet parameter", /* 18 */
- NULL
};
+#define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
static const char *reason_text[] = {
"Reserved", /* 0 */
"Deauthenticated because sending station is leaving (or has left) IBSS or ESS", /* 3 */
"Disassociated due to inactivity", /* 4 */
"Disassociated because AP is unable to handle all currently associated stations", /* 5 */
- "Class 2 frame receivedfrom nonauthenticated station", /* 6 */
+ "Class 2 frame received from nonauthenticated station", /* 6 */
"Class 3 frame received from nonassociated station", /* 7 */
"Disassociated because sending station is leaving (or has left) BSS", /* 8 */
"Station requesting (re)association is not authenticated with responding station", /* 9 */
- NULL
};
+#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
static int
wep_print(const u_char *p)
printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
- (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a"));
+ (pbody.status_code < NUM_STATUSES
+ ? status_text[pbody.status_code]
+ : "n/a"));
return 1;
}
pbody.reason_code = EXTRACT_LE_16BITS(p);
printf(": %s",
- (pbody.reason_code < 10) ? reason_text[pbody.reason_code]
- : "Reserved" );
+ (pbody.reason_code < NUM_REASONS)
+ ? reason_text[pbody.reason_code]
+ : "Reserved" );
return 1;
}
((pbody.auth_trans_seq_num == 2) ||
(pbody.auth_trans_seq_num == 3))) {
printf(" (%s)-%x [Challenge Text] %s",
- (pbody.auth_alg < 4) ? auth_alg_text[pbody.auth_alg]
- : "Reserved",
+ (pbody.auth_alg < NUM_AUTH_ALGS)
+ ? auth_alg_text[pbody.auth_alg]
+ : "Reserved",
pbody.auth_trans_seq_num,
((pbody.auth_trans_seq_num % 2)
- ? ((pbody.status_code < 19)
+ ? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a") : ""));
return 1;
}
printf(" (%s)-%x: %s",
- (pbody.auth_alg < 4) ? auth_alg_text[pbody.auth_alg] : "Reserved",
+ (pbody.auth_alg < NUM_AUTH_ALGS)
+ ? auth_alg_text[pbody.auth_alg]
+ : "Reserved",
pbody.auth_trans_seq_num,
(pbody.auth_trans_seq_num % 2)
- ? ((pbody.status_code < 19) ? status_text[pbody.status_code]
- : "n/a")
+ ? ((pbody.status_code < NUM_STATUSES)
+ ? status_text[pbody.status_code]
+ : "n/a")
: "");
return 1;
pbody.reason_code = EXTRACT_LE_16BITS(p);
offset += IEEE802_11_REASON_LEN;
- reason = (pbody.reason_code < 10) ? reason_text[pbody.reason_code]
- : "Reserved";
+ reason = (pbody.reason_code < NUM_REASONS)
+ ? reason_text[pbody.reason_code]
+ : "Reserved";
if (eflag) {
printf(": %s", reason);
mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
- printf("%s", subtype_text[FC_SUBTYPE(fc)]);
+ if (subtype_text[FC_SUBTYPE(fc)] != NULL)
+ printf("%s", subtype_text[FC_SUBTYPE(fc)]);
+ else
+ printf("Unknown subtype %u", FC_SUBTYPE(fc));
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST: