X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/52ad9e15b42a87c7477cd305d9cfd3afb5128976..a63600a1fc28dbc7ae7ce9f996829c49a25fb33c:/print-802_11.c diff --git a/print-802_11.c b/print-802_11.c index 270870e6..ca49e09e 100644 --- a/print-802_11.c +++ b/print-802_11.c @@ -193,26 +193,22 @@ struct mgmt_header_t { #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; @@ -220,14 +216,12 @@ struct fh_t { }; 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; @@ -235,14 +229,18 @@ struct cf_t { }; 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 @@ -267,6 +265,7 @@ struct tim_t { /* reserved 19 */ /* reserved 16 */ /* reserved 16 */ +#define E_MESHID 114 struct mgmt_body_t { @@ -294,6 +293,8 @@ 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 { @@ -369,9 +370,11 @@ struct ctrl_ba_hdr_t { nd_uint16_t fc; nd_uint16_t duration; nd_mac_addr ra; + nd_mac_addr 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; @@ -410,15 +413,15 @@ struct meshcntl_t { 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) \ @@ -427,6 +430,13 @@ struct meshcntl_t { 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 /* @@ -949,8 +959,8 @@ static const char *status_text[] = { "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 */ @@ -997,7 +1007,7 @@ static const char *status_text[] = { "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 */ @@ -1145,6 +1155,7 @@ parse_elements(netdissect_options *ndo, struct ds_t ds; struct cf_t cf; struct tim_t tim; + struct meshid_t meshid; /* * We haven't seen any elements yet. @@ -1155,6 +1166,7 @@ parse_elements(netdissect_options *ndo, 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. */ @@ -1170,7 +1182,7 @@ parse_elements(netdissect_options *ndo, 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) { @@ -1194,7 +1206,7 @@ parse_elements(netdissect_options *ndo, } break; case E_CHALLENGE: - memcpy(&challenge, p + offset, 2); + challenge.length = elementlen; offset += 2; length -= 2; if (challenge.length != 0) { @@ -1220,7 +1232,7 @@ parse_elements(netdissect_options *ndo, } break; case E_RATES: - memcpy(&rates, p + offset, 2); + rates.length = elementlen; offset += 2; length -= 2; if (rates.length != 0) { @@ -1252,7 +1264,7 @@ parse_elements(netdissect_options *ndo, } break; case E_DS: - memcpy(&ds, p + offset, 2); + ds.length = elementlen; offset += 2; length -= 2; if (ds.length != 1) { @@ -1276,7 +1288,7 @@ parse_elements(netdissect_options *ndo, } break; case E_CF: - memcpy(&cf, p + offset, 2); + cf.length = elementlen; offset += 2; length -= 2; if (cf.length != 6) { @@ -1284,9 +1296,18 @@ parse_elements(netdissect_options *ndo, 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. * @@ -1300,7 +1321,7 @@ parse_elements(netdissect_options *ndo, } break; case E_TIM: - memcpy(&tim, p + offset, 2); + tim.length = elementlen; offset += 2; length -= 2; if (tim.length <= 3U) { @@ -1310,10 +1331,15 @@ parse_elements(netdissect_options *ndo, } 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; @@ -1329,6 +1355,30 @@ parse_elements(netdissect_options *ndo, 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) ", @@ -1382,6 +1432,7 @@ handle_beacon(netdissect_options *ndo, ND_PRINT(" %s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"); PRINT_DS_CHANNEL(pbody); + PRINT_MESHID(pbody); return ret; trunc: @@ -1546,6 +1597,7 @@ handle_probe_response(netdissect_options *ndo, PRINT_SSID(pbody); PRINT_RATES(pbody); PRINT_DS_CHANNEL(pbody); + PRINT_MESHID(pbody); return ret; trunc: @@ -1665,60 +1717,78 @@ 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, "MultiohopAction" }, + { 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; @@ -1727,24 +1797,15 @@ handle_action(netdissect_options *ndo, } 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; - } + 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; @@ -1899,7 +1960,7 @@ get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp, } } else { if (!FC_FROM_DS(fc)) { - /* From DS and not To DS */ + /* To DS and not From DS */ *srcp = ADDR2; *dstp = ADDR3; } else { @@ -2003,8 +2064,9 @@ ctrl_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p) 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_ETHERADDR_STRING(((const struct ctrl_ba_hdr_t *)p)->ra), + GET_ETHERADDR_STRING(((const struct ctrl_ba_hdr_t *)p)->ta)); break; case CTRL_PS_POLL: ND_PRINT("BSSID:%s TA:%s ", @@ -2265,12 +2327,12 @@ ieee802_11_print(netdissect_options *ndo, * '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); } @@ -2699,7 +2761,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2709,7 +2771,7 @@ print_radiotap_field(netdissect_options *ndo, 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; @@ -2729,7 +2791,7 @@ print_radiotap_field(netdissect_options *ndo, 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; /* @@ -2780,10 +2842,10 @@ print_radiotap_field(netdissect_options *ndo, 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; /* @@ -2800,10 +2862,10 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2813,7 +2875,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2823,7 +2885,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2833,7 +2895,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2843,7 +2905,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2853,7 +2915,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2863,7 +2925,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2873,7 +2935,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2883,7 +2945,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2893,7 +2955,7 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2903,7 +2965,7 @@ print_radiotap_field(netdissect_options *ndo, 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 */ @@ -2916,16 +2978,16 @@ print_radiotap_field(netdissect_options *ndo, 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); @@ -2944,13 +3006,13 @@ print_radiotap_field(netdissect_options *ndo, }; 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) { @@ -3032,16 +3094,16 @@ print_radiotap_field(netdissect_options *ndo, 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 */ @@ -3091,27 +3153,27 @@ print_radiotap_field(netdissect_options *ndo, "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++) { @@ -3252,13 +3314,13 @@ ieee802_11_radio_print(netdissect_options *ndo, 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) { @@ -3294,7 +3356,7 @@ ieee802_11_radio_print(netdissect_options *ndo, * 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. */ @@ -3357,27 +3419,27 @@ ieee802_11_radio_print(netdissect_options *ndo, */ 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; } @@ -3458,7 +3520,7 @@ ieee802_11_radio_avs_print(netdissect_options *ndo, * 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) { @@ -3466,36 +3528,43 @@ prism_if_print(netdissect_options *ndo, 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); } /* @@ -3503,10 +3572,10 @@ ieee802_11_radio_if_print(netdissect_options *ndo, * 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); }