/* \summary: IEEE 802.11 printer */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
#define IEEE802_11_STATUS_LEN 2
#define IEEE802_11_REASON_LEN 2
-/* Length of previous AP in reassocation frame */
+/* Length of previous AP in reassociation frame */
#define IEEE802_11_AP_LEN 6
#define T_MGMT 0x0 /* management */
struct mgmt_header_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr da;
- nd_mac_addr sa;
- nd_mac_addr bssid;
+ nd_mac48 da;
+ nd_mac48 sa;
+ nd_mac48 bssid;
nd_uint16_t seq_ctrl;
};
#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
struct ssid_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
u_char ssid[33]; /* 32 + 1 for null */
};
struct rates_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint8_t rate[16];
};
struct challenge_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint8_t text[254]; /* 1-253 + 1 for null */
};
struct fh_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint16_t dwell_time;
uint8_t hop_set;
uint8_t hop_pattern;
};
struct ds_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint8_t channel;
};
struct cf_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint8_t count;
uint8_t period;
uint16_t max_duration;
};
struct tim_t {
- uint8_t element_id;
- uint8_t length;
+ u_int length;
uint8_t count;
uint8_t period;
uint8_t bitmap_control;
uint8_t bitmap[251];
};
+struct meshid_t {
+ u_int length;
+ u_char meshid[33]; /* 32 + 1 for null */
+};
+
#define E_SSID 0
#define E_RATES 1
#define E_FH 2
/* reserved 19 */
/* reserved 16 */
/* reserved 16 */
+#define E_MESHID 114
struct mgmt_body_t {
struct fh_t fh;
int tim_present;
struct tim_t tim;
+ int meshid_present;
+ struct meshid_t meshid;
};
struct ctrl_control_wrapper_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr addr1;
+ nd_mac48 addr1;
nd_uint16_t carried_fc[IEEE802_11_CARRIED_FC_LEN];
nd_uint16_t ht_control[IEEE802_11_HT_CONTROL_LEN];
};
struct ctrl_rts_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
- nd_mac_addr ta;
+ nd_mac48 ra;
+ nd_mac48 ta;
};
#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
struct ctrl_cts_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
+ nd_mac48 ra;
};
#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
struct ctrl_ack_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
+ nd_mac48 ra;
};
#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
struct ctrl_ps_poll_hdr_t {
nd_uint16_t fc;
nd_uint16_t aid;
- nd_mac_addr bssid;
- nd_mac_addr ta;
+ nd_mac48 bssid;
+ nd_mac48 ta;
};
#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
struct ctrl_end_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
- nd_mac_addr bssid;
+ nd_mac48 ra;
+ nd_mac48 bssid;
};
#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
struct ctrl_end_ack_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
- nd_mac_addr bssid;
+ nd_mac48 ra;
+ nd_mac48 bssid;
};
#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
struct ctrl_ba_hdr_t {
nd_uint16_t fc;
nd_uint16_t duration;
- nd_mac_addr ra;
+ nd_mac48 ra;
+ nd_mac48 ta;
};
-#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
struct ctrl_bar_hdr_t {
nd_uint16_t fc;
nd_uint16_t dur;
- nd_mac_addr ra;
- nd_mac_addr ta;
+ nd_mac48 ra;
+ nd_mac48 ta;
nd_uint16_t ctl;
nd_uint16_t seq;
};
nd_uint8_t flags;
nd_uint8_t ttl;
nd_uint32_t seq;
- nd_mac_addr addr4;
- nd_mac_addr addr5;
- nd_mac_addr addr6;
+ nd_mac48 addr4;
+ nd_mac48 addr5;
+ nd_mac48 addr6;
};
#define IV_IV(iv) ((iv) & 0xFFFFFF)
ND_PRINT("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
#define PRINT_RATES(p) \
if (p.rates_present) { \
- int z; \
const char *sep = " ["; \
- for (z = 0; z < p.rates.length ; z++) { \
- PRINT_RATE(sep, p.rates.rate[z], \
- (p.rates.rate[z] & 0x80 ? "*" : "")); \
- sep = " "; \
- } \
- if (p.rates.length != 0) \
+ if (p.rates.length != 0) { \
+ for (u_int z = 0; z < p.rates.length ; z++) { \
+ PRINT_RATE(sep, p.rates.rate[z], \
+ (p.rates.rate[z] & 0x80 ? "*" : "")); \
+ sep = " "; \
+ } \
ND_PRINT(" Mbit]"); \
+ } \
}
#define PRINT_DS_CHANNEL(p) \
ND_PRINT("%s", \
CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "");
+#define PRINT_MESHID(p) \
+ if (p.meshid_present) { \
+ ND_PRINT(" (MESHID: "); \
+ fn_print_str(ndo, p.meshid.meshid); \
+ ND_PRINT(")"); \
+ }
+
#define MAX_MCS_INDEX 76
/*
"Reserved", /* 69 */
"Reserved", /* 70 */
"Reserved", /* 71 */
- "Invalid contents of RSNE", /* 72 */
- "U-APSD coexistence is not supported", /* 73 */
+ "Invalid contents of RSNE", /* 72 */
+ "U-APSD coexistence is not supported", /* 73 */
"Requested U-APSD coexistence mode is not supported", /* 74 */
"Requested Interval/Duration value cannot be "
"supported with U-APSD coexistence", /* 75 */
"Spectrum Management field is unacceptable", /* 103 */
"Association denied because the requesting STA "
"does not support VHT features", /* 104 */
- "Enablement denied", /* 105 */
+ "Enablement denied", /* 105 */
"Enablement denied due to restriction from an "
"authorized GDB", /* 106 */
"Authorization deenabled", /* 107 */
struct ds_t ds;
struct cf_t cf;
struct tim_t tim;
+ struct meshid_t meshid;
/*
* We haven't seen any elements yet.
pbody->ds_present = 0;
pbody->cf_present = 0;
pbody->tim_present = 0;
+ pbody->meshid_present = 0;
while (length != 0) {
/* Make sure we at least have the element ID and length. */
switch (GET_U_1(p + offset)) {
case E_SSID:
- memcpy(&ssid, p + offset, 2);
+ ssid.length = elementlen;
offset += 2;
length -= 2;
if (ssid.length != 0) {
}
break;
case E_CHALLENGE:
- memcpy(&challenge, p + offset, 2);
+ challenge.length = elementlen;
offset += 2;
length -= 2;
if (challenge.length != 0) {
}
break;
case E_RATES:
- memcpy(&rates, p + offset, 2);
+ rates.length = elementlen;
offset += 2;
length -= 2;
if (rates.length != 0) {
}
break;
case E_DS:
- memcpy(&ds, p + offset, 2);
+ ds.length = elementlen;
offset += 2;
length -= 2;
if (ds.length != 1) {
}
break;
case E_CF:
- memcpy(&cf, p + offset, 2);
+ cf.length = elementlen;
offset += 2;
length -= 2;
if (cf.length != 6) {
length -= cf.length;
break;
}
- memcpy(&cf.count, p + offset, 6);
- offset += 6;
- length -= 6;
+ cf.count = GET_U_1(p + offset);
+ offset += 1;
+ length -= 1;
+ cf.period = GET_U_1(p + offset);
+ offset += 1;
+ length -= 1;
+ cf.max_duration = GET_LE_U_2(p + offset);
+ offset += 2;
+ length -= 2;
+ cf.dur_remaining = GET_LE_U_2(p + offset);
+ offset += 2;
+ length -= 2;
/*
* Present and not truncated.
*
}
break;
case E_TIM:
- memcpy(&tim, p + offset, 2);
+ tim.length = elementlen;
offset += 2;
length -= 2;
if (tim.length <= 3U) {
}
if (tim.length - 3U > sizeof(tim.bitmap))
return 0;
- memcpy(&tim.count, p + offset, 3);
- offset += 3;
- length -= 3;
-
+ tim.count = GET_U_1(p + offset);
+ offset += 1;
+ length -= 1;
+ tim.period = GET_U_1(p + offset);
+ offset += 1;
+ length -= 1;
+ tim.bitmap_control = GET_U_1(p + offset);
+ offset += 1;
+ length -= 1;
memcpy(tim.bitmap, p + offset, tim.length - 3);
offset += tim.length - 3;
length -= tim.length - 3;
pbody->tim_present = 1;
}
break;
+ case E_MESHID:
+ meshid.length = elementlen;
+ offset += 2;
+ length -= 2;
+ if (meshid.length != 0) {
+ if (meshid.length > sizeof(meshid.meshid) - 1)
+ return 0;
+ memcpy(&meshid.meshid, p + offset, meshid.length);
+ offset += meshid.length;
+ length -= meshid.length;
+ }
+ meshid.meshid[meshid.length] = '\0';
+ /*
+ * Present and not truncated.
+ *
+ * If we haven't already seen a MESHID IE,
+ * copy this one, otherwise ignore this one,
+ * so we later report the first one we saw.
+ */
+ if (!pbody->meshid_present) {
+ pbody->meshid = meshid;
+ pbody->meshid_present = 1;
+ }
+ break;
default:
#if 0
ND_PRINT("(1) unhandled element_id (%u) ",
ND_PRINT(" %s",
CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
PRINT_DS_CHANNEL(pbody);
+ PRINT_MESHID(pbody);
return ret;
trunc:
ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
- ND_PRINT(" AP : %s", etheraddr_string(ndo, pbody.ap ));
+ ND_PRINT(" AP : %s", mac48_string(ndo, pbody.ap ));
return ret;
trunc:
PRINT_SSID(pbody);
PRINT_RATES(pbody);
PRINT_DS_CHANNEL(pbody);
+ PRINT_MESHID(pbody);
return ret;
trunc:
if (ndo->ndo_eflag) {
ND_PRINT(": %s", reason);
} else {
- ND_PRINT(" (%s): %s", GET_ETHERADDR_STRING(src), reason);
+ ND_PRINT(" (%s): %s", GET_MAC48_STRING(src), reason);
}
return 1;
trunc:
return 0;
}
-#define PRINT_HT_ACTION(v) (\
- (v) == 0 ? ND_PRINT("TxChWidth"): \
- (v) == 1 ? ND_PRINT("MIMOPwrSave"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_BA_ACTION(v) (\
- (v) == 0 ? ND_PRINT("ADDBA Request"): \
- (v) == 1 ? ND_PRINT("ADDBA Response"): \
- (v) == 2 ? ND_PRINT("DELBA"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_MESHLINK_ACTION(v) (\
- (v) == 0 ? ND_PRINT("Request"): \
- (v) == 1 ? ND_PRINT("Report"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_MESHPEERING_ACTION(v) (\
- (v) == 0 ? ND_PRINT("Open"): \
- (v) == 1 ? ND_PRINT("Confirm"): \
- (v) == 2 ? ND_PRINT("Close"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_MESHPATH_ACTION(v) (\
- (v) == 0 ? ND_PRINT("Request"): \
- (v) == 1 ? ND_PRINT("Report"): \
- (v) == 2 ? ND_PRINT("Error"): \
- (v) == 3 ? ND_PRINT("RootAnnouncement"): \
- ND_PRINT("Act#%u", (v)))
-
-#define PRINT_MESH_ACTION(v) (\
- (v) == 0 ? ND_PRINT("MeshLink"): \
- (v) == 1 ? ND_PRINT("HWMP"): \
- (v) == 2 ? ND_PRINT("Gate Announcement"): \
- (v) == 3 ? ND_PRINT("Congestion Control"): \
- (v) == 4 ? ND_PRINT("MCCA Setup Request"): \
- (v) == 5 ? ND_PRINT("MCCA Setup Reply"): \
- (v) == 6 ? ND_PRINT("MCCA Advertisement Request"): \
- (v) == 7 ? ND_PRINT("MCCA Advertisement"): \
- (v) == 8 ? ND_PRINT("MCCA Teardown"): \
- (v) == 9 ? ND_PRINT("TBTT Adjustment Request"): \
- (v) == 10 ? ND_PRINT("TBTT Adjustment Response"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_MULTIHOP_ACTION(v) (\
- (v) == 0 ? ND_PRINT("Proxy Update"): \
- (v) == 1 ? ND_PRINT("Proxy Update Confirmation"): \
- ND_PRINT("Act#%u", (v)))
-#define PRINT_SELFPROT_ACTION(v) (\
- (v) == 1 ? ND_PRINT("Peering Open"): \
- (v) == 2 ? ND_PRINT("Peering Confirm"): \
- (v) == 3 ? ND_PRINT("Peering Close"): \
- (v) == 4 ? ND_PRINT("Group Key Inform"): \
- (v) == 5 ? ND_PRINT("Group Key Acknowledge"): \
- ND_PRINT("Act#%u", (v)))
+static const struct tok category_str[] = {
+ { 0, "Spectrum Management" },
+ { 1, "QoS" },
+ { 2, "DLS" },
+ { 3, "BA" },
+ { 7, "HT" },
+ { 13, "MeshAction" },
+ { 14, "MultihopAction" },
+ { 15, "SelfprotectAction" },
+ { 127, "Vendor" },
+ { 0, NULL }
+};
+
+static const struct tok act_ba_str[] = {
+ { 0, "ADDBA Request" },
+ { 1, "ADDBA Response" },
+ { 2, "DELBA" },
+ { 0, NULL }
+};
+
+static const struct tok act_ht_str[] = {
+ { 0, "TxChWidth" },
+ { 1, "MIMOPwrSave" },
+ { 0, NULL }
+};
+
+static const struct tok act_mesh_str[] = {
+ { 0, "MeshLink" },
+ { 1, "HWMP" },
+ { 2, "Gate Announcement" },
+ { 3, "Congestion Control" },
+ { 4, "MCCA Setup Request" },
+ { 5, "MCCA Setup Reply" },
+ { 6, "MCCA Advertisement Request" },
+ { 7, "MCCA Advertisement" },
+ { 8, "MCCA Teardown" },
+ { 9, "TBTT Adjustment Request" },
+ { 10, "TBTT Adjustment Response" },
+ { 0, NULL }
+};
+
+static const struct tok act_mhop_str[] = {
+ { 0, "Proxy Update" },
+ { 1, "Proxy Update Confirmation" },
+ { 0, NULL }
+};
+
+static const struct tok act_selfpr_str[] = {
+ { 1, "Peering Open" },
+ { 2, "Peering Confirm" },
+ { 3, "Peering Close" },
+ { 4, "Group Key Inform" },
+ { 5, "Group Key Acknowledge" },
+ { 0, NULL }
+};
+
+static const struct uint_tokary category2tokary[] = {
+ { 3, act_ba_str },
+ { 7, act_ht_str },
+ { 13, act_mesh_str },
+ { 14, act_mhop_str },
+ { 15, act_selfpr_str },
+ /* uint2tokary() does not use array termination. */
+};
static int
handle_action(netdissect_options *ndo,
const uint8_t *src, const u_char *p, u_int length)
{
+ uint8_t category, action;
+ const struct tok *action_str;
+
ND_TCHECK_2(p);
if (length < 2)
goto trunc;
if (ndo->ndo_eflag) {
ND_PRINT(": ");
} else {
- ND_PRINT(" (%s): ", GET_ETHERADDR_STRING(src));
- }
- switch (GET_U_1(p)) {
- case 0: ND_PRINT("Spectrum Management Act#%u", GET_U_1(p + 1)); break;
- case 1: ND_PRINT("QoS Act#%u", GET_U_1(p + 1)); break;
- case 2: ND_PRINT("DLS Act#%u", GET_U_1(p + 1)); break;
- case 3: ND_PRINT("BA "); PRINT_BA_ACTION(GET_U_1(p + 1)); break;
- case 7: ND_PRINT("HT "); PRINT_HT_ACTION(GET_U_1(p + 1)); break;
- case 13: ND_PRINT("MeshAction "); PRINT_MESH_ACTION(GET_U_1(p + 1)); break;
- case 14:
- ND_PRINT("MultiohopAction ");
- PRINT_MULTIHOP_ACTION(GET_U_1(p + 1)); break;
- case 15:
- ND_PRINT("SelfprotectAction ");
- PRINT_SELFPROT_ACTION(GET_U_1(p + 1)); break;
- case 127: ND_PRINT("Vendor Act#%u", GET_U_1(p + 1)); break;
- default:
- ND_PRINT("Reserved(%u) Act#%u", GET_U_1(p), GET_U_1(p + 1));
- break;
+ ND_PRINT(" (%s): ", GET_MAC48_STRING(src));
}
+ category = GET_U_1(p);
+ ND_PRINT("%s ", tok2str(category_str, "Reserved(%u)", category));
+ action = GET_U_1(p + 1);
+ action_str = uint2tokary(category2tokary, category);
+ if (!action_str)
+ ND_PRINT("Act#%u", action);
+ else
+ ND_PRINT("%s", tok2str(action_str, "Act#%u", action));
+
return 1;
trunc:
return 0;
ND_TCHECK_LEN(p, CTRL_BAR_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- GET_ETHERADDR_STRING(((const struct ctrl_bar_hdr_t *)p)->ra),
- GET_ETHERADDR_STRING(((const struct ctrl_bar_hdr_t *)p)->ta),
+ GET_MAC48_STRING(((const struct ctrl_bar_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_bar_hdr_t *)p)->ta),
GET_LE_U_2(((const struct ctrl_bar_hdr_t *)p)->ctl),
GET_LE_U_2(((const struct ctrl_bar_hdr_t *)p)->seq));
break;
ND_TCHECK_LEN(p, CTRL_BA_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_ba_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_ba_hdr_t *)p)->ra));
break;
case CTRL_PS_POLL:
ND_TCHECK_LEN(p, CTRL_PS_POLL_HDRLEN);
ND_TCHECK_LEN(p, CTRL_RTS_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" TA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_rts_hdr_t *)p)->ta));
+ GET_MAC48_STRING(((const struct ctrl_rts_hdr_t *)p)->ta));
break;
case CTRL_CTS:
ND_TCHECK_LEN(p, CTRL_CTS_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_cts_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_cts_hdr_t *)p)->ra));
break;
case CTRL_ACK:
ND_TCHECK_LEN(p, CTRL_ACK_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_ack_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_ack_hdr_t *)p)->ra));
break;
case CTRL_CF_END:
ND_TCHECK_LEN(p, CTRL_END_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_end_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_end_hdr_t *)p)->ra));
break;
case CTRL_END_ACK:
ND_TCHECK_LEN(p, CTRL_END_ACK_HDRLEN);
if (!ndo->ndo_eflag)
ND_PRINT(" RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_end_ack_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_end_ack_hdr_t *)p)->ra));
break;
}
return 1;
}
} else {
if (!FC_FROM_DS(fc)) {
- /* From DS and not To DS */
+ /* To DS and not From DS */
*srcp = ADDR2;
*dstp = ADDR3;
} else {
if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
ND_PRINT("DA:%s SA:%s BSSID:%s ",
- GET_ETHERADDR_STRING(ADDR1), GET_ETHERADDR_STRING(ADDR2),
- GET_ETHERADDR_STRING(ADDR3));
+ GET_MAC48_STRING(ADDR1), GET_MAC48_STRING(ADDR2),
+ GET_MAC48_STRING(ADDR3));
} else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
ND_PRINT("DA:%s BSSID:%s SA:%s ",
- GET_ETHERADDR_STRING(ADDR1), GET_ETHERADDR_STRING(ADDR2),
- GET_ETHERADDR_STRING(ADDR3));
+ GET_MAC48_STRING(ADDR1), GET_MAC48_STRING(ADDR2),
+ GET_MAC48_STRING(ADDR3));
} else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
ND_PRINT("BSSID:%s SA:%s DA:%s ",
- GET_ETHERADDR_STRING(ADDR1), GET_ETHERADDR_STRING(ADDR2),
- GET_ETHERADDR_STRING(ADDR3));
+ GET_MAC48_STRING(ADDR1), GET_MAC48_STRING(ADDR2),
+ GET_MAC48_STRING(ADDR3));
} else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
ND_PRINT("RA:%s TA:%s DA:%s SA:%s ",
- GET_ETHERADDR_STRING(ADDR1), GET_ETHERADDR_STRING(ADDR2),
- GET_ETHERADDR_STRING(ADDR3), GET_ETHERADDR_STRING(ADDR4));
+ GET_MAC48_STRING(ADDR1), GET_MAC48_STRING(ADDR2),
+ GET_MAC48_STRING(ADDR3), GET_MAC48_STRING(ADDR4));
}
#undef ADDR1
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
ND_PRINT("BSSID:%s DA:%s SA:%s ",
- GET_ETHERADDR_STRING((hp)->bssid), GET_ETHERADDR_STRING((hp)->da),
- GET_ETHERADDR_STRING((hp)->sa));
+ GET_MAC48_STRING((hp)->bssid), GET_MAC48_STRING((hp)->da),
+ GET_MAC48_STRING((hp)->sa));
}
static void
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
ND_PRINT(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- GET_ETHERADDR_STRING(((const struct ctrl_bar_hdr_t *)p)->ra),
- GET_ETHERADDR_STRING(((const struct ctrl_bar_hdr_t *)p)->ta),
+ GET_MAC48_STRING(((const struct ctrl_bar_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_bar_hdr_t *)p)->ta),
GET_LE_U_2(((const struct ctrl_bar_hdr_t *)p)->ctl),
GET_LE_U_2(((const struct ctrl_bar_hdr_t *)p)->seq));
break;
case CTRL_BA:
- ND_PRINT("RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_ba_hdr_t *)p)->ra));
+ ND_PRINT("RA:%s TA:%s ",
+ GET_MAC48_STRING(((const struct ctrl_ba_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_ba_hdr_t *)p)->ta));
break;
case CTRL_PS_POLL:
ND_PRINT("BSSID:%s TA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_ps_poll_hdr_t *)p)->bssid),
- GET_ETHERADDR_STRING(((const struct ctrl_ps_poll_hdr_t *)p)->ta));
+ GET_MAC48_STRING(((const struct ctrl_ps_poll_hdr_t *)p)->bssid),
+ GET_MAC48_STRING(((const struct ctrl_ps_poll_hdr_t *)p)->ta));
break;
case CTRL_RTS:
ND_PRINT("RA:%s TA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_rts_hdr_t *)p)->ra),
- GET_ETHERADDR_STRING(((const struct ctrl_rts_hdr_t *)p)->ta));
+ GET_MAC48_STRING(((const struct ctrl_rts_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_rts_hdr_t *)p)->ta));
break;
case CTRL_CTS:
ND_PRINT("RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_cts_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_cts_hdr_t *)p)->ra));
break;
case CTRL_ACK:
ND_PRINT("RA:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_ack_hdr_t *)p)->ra));
+ GET_MAC48_STRING(((const struct ctrl_ack_hdr_t *)p)->ra));
break;
case CTRL_CF_END:
ND_PRINT("RA:%s BSSID:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_end_hdr_t *)p)->ra),
- GET_ETHERADDR_STRING(((const struct ctrl_end_hdr_t *)p)->bssid));
+ GET_MAC48_STRING(((const struct ctrl_end_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_end_hdr_t *)p)->bssid));
break;
case CTRL_END_ACK:
ND_PRINT("RA:%s BSSID:%s ",
- GET_ETHERADDR_STRING(((const struct ctrl_end_ack_hdr_t *)p)->ra),
- GET_ETHERADDR_STRING(((const struct ctrl_end_ack_hdr_t *)p)->bssid));
+ GET_MAC48_STRING(((const struct ctrl_end_ack_hdr_t *)p)->ra),
+ GET_MAC48_STRING(((const struct ctrl_end_ack_hdr_t *)p)->bssid));
break;
default:
/* We shouldn't get here - we should already have quit */
ND_PRINT("MeshData (AE %u TTL %u seq %u", ae,
GET_U_1(mc->ttl), GET_LE_U_4(mc->seq));
if (ae > 0)
- ND_PRINT(" A4:%s", GET_ETHERADDR_STRING(mc->addr4));
+ ND_PRINT(" A4:%s", GET_MAC48_STRING(mc->addr4));
if (ae > 1)
- ND_PRINT(" A5:%s", GET_ETHERADDR_STRING(mc->addr5));
+ ND_PRINT(" A5:%s", GET_MAC48_STRING(mc->addr5));
if (ae > 2)
- ND_PRINT(" A6:%s", GET_ETHERADDR_STRING(mc->addr6));
+ ND_PRINT(" A6:%s", GET_MAC48_STRING(mc->addr6));
ND_PRINT(") ");
}
caplen -= hdrlen;
p += hdrlen;
- src.addr_string = etheraddr_string;
- dst.addr_string = etheraddr_string;
+ src.addr_string = mac48_string;
+ dst.addr_string = mac48_string;
switch (FC_TYPE(fc)) {
case T_MGMT:
get_mgmt_src_dst_mac(p - hdrlen, &src.addr, &dst.addr);
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
-u_int
+void
ieee802_11_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- ndo->ndo_protocol = "802.11_if";
- return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
+ ndo->ndo_protocol = "802.11";
+ ndo->ndo_ll_hdr_len += ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
}
case IEEE80211_RADIOTAP_TSFT: {
uint64_t tsft;
- rc = cpack_uint64(ndo, s, &tsft);
+ rc = nd_cpack_uint64(ndo, s, &tsft);
if (rc != 0)
goto trunc;
ND_PRINT("%" PRIu64 "us tsft ", tsft);
case IEEE80211_RADIOTAP_FLAGS: {
uint8_t flagsval;
- rc = cpack_uint8(ndo, s, &flagsval);
+ rc = nd_cpack_uint8(ndo, s, &flagsval);
if (rc != 0)
goto trunc;
*flagsp = flagsval;
case IEEE80211_RADIOTAP_RATE: {
uint8_t rate;
- rc = cpack_uint8(ndo, s, &rate);
+ rc = nd_cpack_uint8(ndo, s, &rate);
if (rc != 0)
goto trunc;
/*
uint16_t frequency;
uint16_t flags;
- rc = cpack_uint16(ndo, s, &frequency);
+ rc = nd_cpack_uint16(ndo, s, &frequency);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(ndo, s, &flags);
+ rc = nd_cpack_uint16(ndo, s, &flags);
if (rc != 0)
goto trunc;
/*
uint8_t hopset;
uint8_t hoppat;
- rc = cpack_uint8(ndo, s, &hopset);
+ rc = nd_cpack_uint8(ndo, s, &hopset);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &hoppat);
+ rc = nd_cpack_uint8(ndo, s, &hoppat);
if (rc != 0)
goto trunc;
ND_PRINT("fhset %u fhpat %u ", hopset, hoppat);
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: {
int8_t dbm_antsignal;
- rc = cpack_int8(ndo, s, &dbm_antsignal);
+ rc = nd_cpack_int8(ndo, s, &dbm_antsignal);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm signal ", dbm_antsignal);
case IEEE80211_RADIOTAP_DBM_ANTNOISE: {
int8_t dbm_antnoise;
- rc = cpack_int8(ndo, s, &dbm_antnoise);
+ rc = nd_cpack_int8(ndo, s, &dbm_antnoise);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm noise ", dbm_antnoise);
case IEEE80211_RADIOTAP_LOCK_QUALITY: {
uint16_t lock_quality;
- rc = cpack_uint16(ndo, s, &lock_quality);
+ rc = nd_cpack_uint16(ndo, s, &lock_quality);
if (rc != 0)
goto trunc;
ND_PRINT("%u sq ", lock_quality);
case IEEE80211_RADIOTAP_TX_ATTENUATION: {
int16_t tx_attenuation;
- rc = cpack_int16(ndo, s, &tx_attenuation);
+ rc = nd_cpack_int16(ndo, s, &tx_attenuation);
if (rc != 0)
goto trunc;
ND_PRINT("%d tx power ", -tx_attenuation);
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: {
int8_t db_tx_attenuation;
- rc = cpack_int8(ndo, s, &db_tx_attenuation);
+ rc = nd_cpack_int8(ndo, s, &db_tx_attenuation);
if (rc != 0)
goto trunc;
ND_PRINT("%ddB tx attenuation ", -db_tx_attenuation);
case IEEE80211_RADIOTAP_DBM_TX_POWER: {
int8_t dbm_tx_power;
- rc = cpack_int8(ndo, s, &dbm_tx_power);
+ rc = nd_cpack_int8(ndo, s, &dbm_tx_power);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm tx power ", dbm_tx_power);
case IEEE80211_RADIOTAP_ANTENNA: {
uint8_t antenna;
- rc = cpack_uint8(ndo, s, &antenna);
+ rc = nd_cpack_uint8(ndo, s, &antenna);
if (rc != 0)
goto trunc;
ND_PRINT("antenna %u ", antenna);
case IEEE80211_RADIOTAP_DB_ANTSIGNAL: {
uint8_t db_antsignal;
- rc = cpack_uint8(ndo, s, &db_antsignal);
+ rc = nd_cpack_uint8(ndo, s, &db_antsignal);
if (rc != 0)
goto trunc;
ND_PRINT("%udB signal ", db_antsignal);
case IEEE80211_RADIOTAP_DB_ANTNOISE: {
uint8_t db_antnoise;
- rc = cpack_uint8(ndo, s, &db_antnoise);
+ rc = nd_cpack_uint8(ndo, s, &db_antnoise);
if (rc != 0)
goto trunc;
ND_PRINT("%udB noise ", db_antnoise);
case IEEE80211_RADIOTAP_RX_FLAGS: {
uint16_t rx_flags;
- rc = cpack_uint16(ndo, s, &rx_flags);
+ rc = nd_cpack_uint16(ndo, s, &rx_flags);
if (rc != 0)
goto trunc;
/* Do nothing for now */
uint8_t channel;
uint8_t maxpower;
- rc = cpack_uint32(ndo, s, &flags);
+ rc = nd_cpack_uint32(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(ndo, s, &frequency);
+ rc = nd_cpack_uint16(ndo, s, &frequency);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &channel);
+ rc = nd_cpack_uint8(ndo, s, &channel);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &maxpower);
+ rc = nd_cpack_uint8(ndo, s, &maxpower);
if (rc != 0)
goto trunc;
print_chaninfo(ndo, frequency, flags, presentflags);
};
float htrate;
- rc = cpack_uint8(ndo, s, &known);
+ rc = nd_cpack_uint8(ndo, s, &known);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &flags);
+ rc = nd_cpack_uint8(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &mcs_index);
+ rc = nd_cpack_uint8(ndo, s, &mcs_index);
if (rc != 0)
goto trunc;
if (known & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
uint8_t delim_crc;
uint8_t reserved;
- rc = cpack_uint32(ndo, s, &reference_num);
+ rc = nd_cpack_uint32(ndo, s, &reference_num);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(ndo, s, &flags);
+ rc = nd_cpack_uint16(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &delim_crc);
+ rc = nd_cpack_uint8(ndo, s, &delim_crc);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &reserved);
+ rc = nd_cpack_uint8(ndo, s, &reserved);
if (rc != 0)
goto trunc;
/* Do nothing for now */
"unknown (31)"
};
- rc = cpack_uint16(ndo, s, &known);
+ rc = nd_cpack_uint16(ndo, s, &known);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &flags);
+ rc = nd_cpack_uint8(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &bandwidth);
+ rc = nd_cpack_uint8(ndo, s, &bandwidth);
if (rc != 0)
goto trunc;
for (i = 0; i < 4; i++) {
- rc = cpack_uint8(ndo, s, &mcs_nss[i]);
+ rc = nd_cpack_uint8(ndo, s, &mcs_nss[i]);
if (rc != 0)
goto trunc;
}
- rc = cpack_uint8(ndo, s, &coding);
+ rc = nd_cpack_uint8(ndo, s, &coding);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(ndo, s, &group_id);
+ rc = nd_cpack_uint8(ndo, s, &group_id);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(ndo, s, &partial_aid);
+ rc = nd_cpack_uint16(ndo, s, &partial_aid);
if (rc != 0)
goto trunc;
for (i = 0; i < 4; i++) {
nd_print_trunc(ndo);
return caplen;
}
- cpack_init(&cpacker, (const uint8_t *)hdr, len); /* align against header start */
- cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */
+ nd_cpack_init(&cpacker, (const uint8_t *)hdr, len); /* align against header start */
+ nd_cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */
for (last_presentp = &hdr->it_present;
(const u_char*)(last_presentp + 1) <= p + len &&
IS_EXTENDED(last_presentp);
last_presentp++)
- cpack_advance(&cpacker, sizeof(hdr->it_present)); /* more bitmaps */
+ nd_cpack_advance(&cpacker, sizeof(hdr->it_present)); /* more bitmaps */
/* are there more bitmap extensions than bytes in header? */
if ((const u_char*)(last_presentp + 1) > p + len) {
* it'd be added here; use vendor_oui and
* vendor_subnamespace to interpret the fields.
*/
- if (cpack_advance(&cpacker, skip_length) != 0) {
+ if (nd_cpack_advance(&cpacker, skip_length) != 0) {
/*
* Ran out of space in the packet.
*/
*/
bit0 = 0;
vendor_namespace = 1;
- if ((cpack_align_and_reserve(&cpacker, 2)) == NULL) {
+ if ((nd_cpack_align_and_reserve(&cpacker, 2)) == NULL) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(ndo, &cpacker, &vendor_oui[0]) != 0) {
+ if (nd_cpack_uint8(ndo, &cpacker, &vendor_oui[0]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(ndo, &cpacker, &vendor_oui[1]) != 0) {
+ if (nd_cpack_uint8(ndo, &cpacker, &vendor_oui[1]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(ndo, &cpacker, &vendor_oui[2]) != 0) {
+ if (nd_cpack_uint8(ndo, &cpacker, &vendor_oui[2]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(ndo, &cpacker, &vendor_subnamespace) != 0) {
+ if (nd_cpack_uint8(ndo, &cpacker, &vendor_subnamespace) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint16(ndo, &cpacker, &skip_length) != 0) {
+ if (nd_cpack_uint16(ndo, &cpacker, &skip_length) != 0) {
nd_print_trunc(ndo);
break;
}
* the AVS header, and the first 4 bytes of the header are used to
* indicate whether it's a Prism header or an AVS header).
*/
-u_int
+void
prism_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
uint32_t msgcode;
- ndo->ndo_protocol = "prism_if";
+ ndo->ndo_protocol = "prism";
if (caplen < 4) {
nd_print_trunc(ndo);
- return caplen;
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
}
msgcode = GET_BE_U_4(p);
if (msgcode == WLANCAP_MAGIC_COOKIE_V1 ||
- msgcode == WLANCAP_MAGIC_COOKIE_V2)
- return ieee802_11_radio_avs_print(ndo, p, length, caplen);
+ msgcode == WLANCAP_MAGIC_COOKIE_V2) {
+ ndo->ndo_ll_hdr_len += ieee802_11_radio_avs_print(ndo, p, length, caplen);
+ return;
+ }
if (caplen < PRISM_HDR_LEN) {
nd_print_trunc(ndo);
- return caplen;
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
}
- return PRISM_HDR_LEN + ieee802_11_print(ndo, p + PRISM_HDR_LEN,
- length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0);
+ p += PRISM_HDR_LEN;
+ length -= PRISM_HDR_LEN;
+ caplen -= PRISM_HDR_LEN;
+ ndo->ndo_ll_hdr_len += PRISM_HDR_LEN;
+ ndo->ndo_ll_hdr_len += ieee802_11_print(ndo, p, length, caplen, 0, 0);
}
/*
* For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra
* header, containing information such as radio information.
*/
-u_int
+void
ieee802_11_radio_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- ndo->ndo_protocol = "802.11_radio_if";
- return ieee802_11_radio_print(ndo, p, h->len, h->caplen);
+ ndo->ndo_protocol = "802.11_radio";
+ ndo->ndo_ll_hdr_len += ieee802_11_radio_print(ndo, p, h->len, h->caplen);
}
/*
* extra header, containing information such as radio information,
* which we currently ignore.
*/
-u_int
+void
ieee802_11_radio_avs_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- ndo->ndo_protocol = "802.11_radio_avs_if";
- return ieee802_11_radio_avs_print(ndo, p, h->len, h->caplen);
+ ndo->ndo_protocol = "802.11_radio_avs";
+ ndo->ndo_ll_hdr_len += ieee802_11_radio_avs_print(ndo, p, h->len, h->caplen);
}