b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Received Data frame processing |
| 3 | * Copyright (c) 2010-2015, Jouni Malinen <j@w1.fi> |
| 4 | * |
| 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "common/defs.h" |
| 13 | #include "common/ieee802_11_defs.h" |
| 14 | #include "wlantest.h" |
| 15 | |
| 16 | |
| 17 | static const char * data_stype(u16 stype) |
| 18 | { |
| 19 | switch (stype) { |
| 20 | case WLAN_FC_STYPE_DATA: |
| 21 | return "DATA"; |
| 22 | case WLAN_FC_STYPE_DATA_CFACK: |
| 23 | return "DATA-CFACK"; |
| 24 | case WLAN_FC_STYPE_DATA_CFPOLL: |
| 25 | return "DATA-CFPOLL"; |
| 26 | case WLAN_FC_STYPE_DATA_CFACKPOLL: |
| 27 | return "DATA-CFACKPOLL"; |
| 28 | case WLAN_FC_STYPE_NULLFUNC: |
| 29 | return "NULLFUNC"; |
| 30 | case WLAN_FC_STYPE_CFACK: |
| 31 | return "CFACK"; |
| 32 | case WLAN_FC_STYPE_CFPOLL: |
| 33 | return "CFPOLL"; |
| 34 | case WLAN_FC_STYPE_CFACKPOLL: |
| 35 | return "CFACKPOLL"; |
| 36 | case WLAN_FC_STYPE_QOS_DATA: |
| 37 | return "QOSDATA"; |
| 38 | case WLAN_FC_STYPE_QOS_DATA_CFACK: |
| 39 | return "QOSDATA-CFACK"; |
| 40 | case WLAN_FC_STYPE_QOS_DATA_CFPOLL: |
| 41 | return "QOSDATA-CFPOLL"; |
| 42 | case WLAN_FC_STYPE_QOS_DATA_CFACKPOLL: |
| 43 | return "QOSDATA-CFACKPOLL"; |
| 44 | case WLAN_FC_STYPE_QOS_NULL: |
| 45 | return "QOS-NULL"; |
| 46 | case WLAN_FC_STYPE_QOS_CFPOLL: |
| 47 | return "QOS-CFPOLL"; |
| 48 | case WLAN_FC_STYPE_QOS_CFACKPOLL: |
| 49 | return "QOS-CFACKPOLL"; |
| 50 | } |
| 51 | return "??"; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | static void rx_data_eth(struct wlantest *wt, const u8 *bssid, |
| 56 | const u8 *sta_addr, const u8 *dst, const u8 *src, |
| 57 | u16 ethertype, const u8 *data, size_t len, int prot, |
| 58 | const u8 *peer_addr); |
| 59 | |
| 60 | static void rx_data_vlan(struct wlantest *wt, const u8 *bssid, |
| 61 | const u8 *sta_addr, const u8 *dst, const u8 *src, |
| 62 | const u8 *data, size_t len, int prot, |
| 63 | const u8 *peer_addr) |
| 64 | { |
| 65 | u16 tag; |
| 66 | |
| 67 | if (len < 4) |
| 68 | return; |
| 69 | tag = WPA_GET_BE16(data); |
| 70 | wpa_printf(MSG_MSGDUMP, "VLAN tag: Priority=%u ID=%u", |
| 71 | tag >> 12, tag & 0x0ffff); |
| 72 | /* ignore VLAN information and process the original frame */ |
| 73 | rx_data_eth(wt, bssid, sta_addr, dst, src, WPA_GET_BE16(data + 2), |
| 74 | data + 4, len - 4, prot, peer_addr); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | static void rx_data_eth(struct wlantest *wt, const u8 *bssid, |
| 79 | const u8 *sta_addr, const u8 *dst, const u8 *src, |
| 80 | u16 ethertype, const u8 *data, size_t len, int prot, |
| 81 | const u8 *peer_addr) |
| 82 | { |
| 83 | switch (ethertype) { |
| 84 | case ETH_P_PAE: |
| 85 | rx_data_eapol(wt, bssid, sta_addr, dst, src, data, len, prot); |
| 86 | break; |
| 87 | case ETH_P_IP: |
| 88 | rx_data_ip(wt, bssid, sta_addr, dst, src, data, len, |
| 89 | peer_addr); |
| 90 | break; |
| 91 | case 0x890d: |
| 92 | rx_data_80211_encap(wt, bssid, sta_addr, dst, src, data, len); |
| 93 | break; |
| 94 | case ETH_P_8021Q: |
| 95 | rx_data_vlan(wt, bssid, sta_addr, dst, src, data, len, prot, |
| 96 | peer_addr); |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | static void rx_data_process(struct wlantest *wt, struct wlantest_bss *bss, |
| 103 | const u8 *bssid, |
| 104 | const u8 *sta_addr, |
| 105 | const u8 *dst, const u8 *src, |
| 106 | const u8 *data, size_t len, int prot, |
| 107 | const u8 *peer_addr, const u8 *qos) |
| 108 | { |
| 109 | if (len == 0) |
| 110 | return; |
| 111 | |
| 112 | if (bss && bss->mesh && qos && !(qos[0] & BIT(7)) && |
| 113 | (qos[1] & BIT(0))) { |
| 114 | u8 addr_ext_mode; |
| 115 | size_t mesh_control_len = 6; |
| 116 | |
| 117 | /* Skip Mesh Control field if this is not an A-MSDU */ |
| 118 | if (len < mesh_control_len) { |
| 119 | wpa_printf(MSG_DEBUG, |
| 120 | "Not enough room for Mesh Control field"); |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | addr_ext_mode = data[0] & 0x03; |
| 125 | if (addr_ext_mode == 3) { |
| 126 | wpa_printf(MSG_DEBUG, |
| 127 | "Reserved Mesh Control :: Address Extension Mode"); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | mesh_control_len += addr_ext_mode * ETH_ALEN; |
| 132 | if (len < mesh_control_len) { |
| 133 | wpa_printf(MSG_DEBUG, |
| 134 | "Not enough room for Mesh Address Extension"); |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | len -= mesh_control_len; |
| 139 | data += mesh_control_len; |
| 140 | } |
| 141 | |
| 142 | if (len >= 8 && os_memcmp(data, "\xaa\xaa\x03\x00\x00\x00", 6) == 0) { |
| 143 | rx_data_eth(wt, bssid, sta_addr, dst, src, |
| 144 | WPA_GET_BE16(data + 6), data + 8, len - 8, prot, |
| 145 | peer_addr); |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | wpa_hexdump(MSG_DEBUG, "Unrecognized LLC", data, len > 8 ? 8 : len); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | static u8 * try_ptk(struct wlantest *wt, int pairwise_cipher, |
| 154 | struct wpa_ptk *ptk, const struct ieee80211_hdr *hdr, |
| 155 | const u8 *a1, const u8 *a2, const u8 *a3, |
| 156 | const u8 *data, size_t data_len, size_t *decrypted_len) |
| 157 | { |
| 158 | u8 *decrypted; |
| 159 | unsigned int tk_len = ptk->tk_len; |
| 160 | |
| 161 | decrypted = NULL; |
| 162 | if ((pairwise_cipher == WPA_CIPHER_CCMP || |
| 163 | pairwise_cipher == 0) && tk_len == 16) { |
| 164 | decrypted = ccmp_decrypt(ptk->tk, hdr, a1, a2, a3, data, |
| 165 | data_len, decrypted_len); |
| 166 | } else if ((pairwise_cipher == WPA_CIPHER_CCMP_256 || |
| 167 | pairwise_cipher == 0) && tk_len == 32) { |
| 168 | decrypted = ccmp_256_decrypt(ptk->tk, hdr, a1, a2, a3, data, |
| 169 | data_len, decrypted_len); |
| 170 | } else if ((pairwise_cipher == WPA_CIPHER_GCMP || |
| 171 | pairwise_cipher == WPA_CIPHER_GCMP_256 || |
| 172 | pairwise_cipher == 0) && |
| 173 | (tk_len == 16 || tk_len == 32)) { |
| 174 | decrypted = gcmp_decrypt(ptk->tk, tk_len, hdr, a1, a2, a3, |
| 175 | data, data_len, decrypted_len); |
| 176 | } else if ((pairwise_cipher == WPA_CIPHER_TKIP || |
| 177 | pairwise_cipher == 0) && tk_len == 32) { |
| 178 | enum michael_mic_result mic_res; |
| 179 | |
| 180 | decrypted = tkip_decrypt(ptk->tk, hdr, data, data_len, |
| 181 | decrypted_len, &mic_res, |
| 182 | &wt->tkip_frag); |
| 183 | if (decrypted && mic_res == MICHAEL_MIC_INCORRECT) |
| 184 | add_note(wt, MSG_INFO, "Invalid Michael MIC"); |
| 185 | else if (decrypted && mic_res == MICHAEL_MIC_NOT_VERIFIED) |
| 186 | add_note(wt, MSG_DEBUG, "Michael MIC not verified"); |
| 187 | } |
| 188 | |
| 189 | return decrypted; |
| 190 | } |
| 191 | |
| 192 | |
| 193 | static u8 * try_all_ptk(struct wlantest *wt, int pairwise_cipher, |
| 194 | const struct ieee80211_hdr *hdr, |
| 195 | const u8 *a1, const u8 *a2, const u8 *a3, int keyid, |
| 196 | const u8 *data, size_t data_len, size_t *decrypted_len) |
| 197 | { |
| 198 | struct wlantest_ptk *ptk; |
| 199 | u8 *decrypted; |
| 200 | int prev_level = wpa_debug_level; |
| 201 | |
| 202 | wpa_debug_level = MSG_WARNING; |
| 203 | dl_list_for_each(ptk, &wt->ptk, struct wlantest_ptk, list) { |
| 204 | decrypted = try_ptk(wt, pairwise_cipher, &ptk->ptk, hdr, a1, a2, |
| 205 | a3, data, data_len, decrypted_len); |
| 206 | if (decrypted) { |
| 207 | wpa_debug_level = prev_level; |
| 208 | add_note(wt, MSG_DEBUG, |
| 209 | "Found PTK match from list of all known PTKs"); |
| 210 | write_decrypted_note(wt, decrypted, ptk->ptk.tk, |
| 211 | ptk->ptk.tk_len, keyid); |
| 212 | return decrypted; |
| 213 | } |
| 214 | } |
| 215 | wpa_debug_level = prev_level; |
| 216 | |
| 217 | return NULL; |
| 218 | } |
| 219 | |
| 220 | |
| 221 | static void check_plaintext_prot(struct wlantest *wt, |
| 222 | const struct ieee80211_hdr *hdr, |
| 223 | const u8 *data, size_t len) |
| 224 | { |
| 225 | if (len < 8 + 3 || data[8] != 0xaa || data[9] != 0xaa || |
| 226 | data[10] != 0x03) |
| 227 | return; |
| 228 | |
| 229 | add_note(wt, MSG_DEBUG, |
| 230 | "Plaintext payload in protected frame"); |
| 231 | wpa_printf(MSG_INFO, "Plaintext payload in protected frame #%u: A2=" |
| 232 | MACSTR " seq=%u", |
| 233 | wt->frame_num, MAC2STR(hdr->addr2), |
| 234 | WLAN_GET_SEQ_SEQ(le_to_host16(hdr->seq_ctrl))); |
| 235 | } |
| 236 | |
| 237 | |
| 238 | static void rx_data_bss_prot_group(struct wlantest *wt, |
| 239 | const struct ieee80211_hdr *hdr, |
| 240 | size_t hdrlen, |
| 241 | const u8 *qos, const u8 *dst, const u8 *src, |
| 242 | const u8 *data, size_t len) |
| 243 | { |
| 244 | struct wlantest_bss *bss; |
| 245 | int keyid; |
| 246 | u8 *decrypted = NULL; |
| 247 | size_t dlen; |
| 248 | u8 pn[6]; |
| 249 | int replay = 0; |
| 250 | |
| 251 | bss = bss_get(wt, hdr->addr2); |
| 252 | if (bss == NULL) |
| 253 | return; |
| 254 | if (len < 4) { |
| 255 | add_note(wt, MSG_INFO, "Too short group addressed data frame"); |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | if (bss->group_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP) && |
| 260 | !(data[3] & 0x20)) { |
| 261 | add_note(wt, MSG_INFO, "Expected TKIP/CCMP frame from " |
| 262 | MACSTR " did not have ExtIV bit set to 1", |
| 263 | MAC2STR(bss->bssid)); |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | if (bss->group_cipher == WPA_CIPHER_TKIP) { |
| 268 | if (data[3] & 0x1f) { |
| 269 | add_note(wt, MSG_INFO, "TKIP frame from " MACSTR |
| 270 | " used non-zero reserved bit", |
| 271 | MAC2STR(bss->bssid)); |
| 272 | } |
| 273 | if (data[1] != ((data[0] | 0x20) & 0x7f)) { |
| 274 | add_note(wt, MSG_INFO, "TKIP frame from " MACSTR |
| 275 | " used incorrect WEPSeed[1] (was 0x%x, " |
| 276 | "expected 0x%x)", |
| 277 | MAC2STR(bss->bssid), data[1], |
| 278 | (data[0] | 0x20) & 0x7f); |
| 279 | } |
| 280 | } else if (bss->group_cipher == WPA_CIPHER_CCMP) { |
| 281 | if (data[2] != 0 || (data[3] & 0x1f) != 0) { |
| 282 | add_note(wt, MSG_INFO, "CCMP frame from " MACSTR |
| 283 | " used non-zero reserved bit", |
| 284 | MAC2STR(bss->bssid)); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | check_plaintext_prot(wt, hdr, data, len); |
| 289 | keyid = data[3] >> 6; |
| 290 | if (bss->gtk_len[keyid] == 0 && |
| 291 | (bss->group_cipher != WPA_CIPHER_WEP40 || |
| 292 | dl_list_empty(&wt->wep))) { |
| 293 | decrypted = try_all_ptk(wt, bss->group_cipher, hdr, NULL, NULL, |
| 294 | NULL, keyid, data, len, &dlen); |
| 295 | if (decrypted) |
| 296 | goto process; |
| 297 | add_note(wt, MSG_MSGDUMP, |
| 298 | "No GTK known to decrypt the frame (A2=" MACSTR |
| 299 | " KeyID=%d)", |
| 300 | MAC2STR(hdr->addr2), keyid); |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | if (bss->group_cipher == WPA_CIPHER_TKIP) |
| 305 | tkip_get_pn(pn, data); |
| 306 | else if (bss->group_cipher == WPA_CIPHER_WEP40) |
| 307 | goto skip_replay_det; |
| 308 | else |
| 309 | ccmp_get_pn(pn, data); |
| 310 | if (os_memcmp(pn, bss->rsc[keyid], 6) <= 0) { |
| 311 | u16 seq_ctrl = le_to_host16(hdr->seq_ctrl); |
| 312 | char pn_hex[6 * 2 + 1], rsc_hex[6 * 2 + 1]; |
| 313 | |
| 314 | wpa_snprintf_hex(pn_hex, sizeof(pn_hex), pn, 6); |
| 315 | wpa_snprintf_hex(rsc_hex, sizeof(rsc_hex), bss->rsc[keyid], 6); |
| 316 | add_note(wt, MSG_INFO, "replay detected: A1=" MACSTR |
| 317 | " A2=" MACSTR " A3=" MACSTR |
| 318 | " seq=%u frag=%u%s keyid=%d #%u %s<=%s", |
| 319 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 320 | MAC2STR(hdr->addr3), |
| 321 | WLAN_GET_SEQ_SEQ(seq_ctrl), |
| 322 | WLAN_GET_SEQ_FRAG(seq_ctrl), |
| 323 | (le_to_host16(hdr->frame_control) & WLAN_FC_RETRY) ? |
| 324 | " Retry" : "", |
| 325 | keyid, wt->frame_num, pn_hex, rsc_hex); |
| 326 | replay = 1; |
| 327 | } |
| 328 | |
| 329 | skip_replay_det: |
| 330 | if (bss->group_cipher == WPA_CIPHER_TKIP) { |
| 331 | enum michael_mic_result mic_res; |
| 332 | |
| 333 | decrypted = tkip_decrypt(bss->gtk[keyid], hdr, data, len, |
| 334 | &dlen, &mic_res, &wt->tkip_frag); |
| 335 | if (decrypted && mic_res == MICHAEL_MIC_INCORRECT) |
| 336 | add_note(wt, MSG_INFO, "Invalid Michael MIC"); |
| 337 | else if (decrypted && mic_res == MICHAEL_MIC_NOT_VERIFIED) |
| 338 | add_note(wt, MSG_DEBUG, "Michael MIC not verified"); |
| 339 | } else if (bss->group_cipher == WPA_CIPHER_WEP40) { |
| 340 | decrypted = wep_decrypt(wt, hdr, data, len, &dlen); |
| 341 | } else if (bss->group_cipher == WPA_CIPHER_CCMP) { |
| 342 | decrypted = ccmp_decrypt(bss->gtk[keyid], hdr, NULL, NULL, NULL, |
| 343 | data, len, &dlen); |
| 344 | } else if (bss->group_cipher == WPA_CIPHER_CCMP_256) { |
| 345 | decrypted = ccmp_256_decrypt(bss->gtk[keyid], hdr, |
| 346 | NULL, NULL, NULL, |
| 347 | data, len, &dlen); |
| 348 | } else if (bss->group_cipher == WPA_CIPHER_GCMP || |
| 349 | bss->group_cipher == WPA_CIPHER_GCMP_256) { |
| 350 | decrypted = gcmp_decrypt(bss->gtk[keyid], bss->gtk_len[keyid], |
| 351 | hdr, NULL, NULL, NULL, |
| 352 | data, len, &dlen); |
| 353 | } |
| 354 | |
| 355 | if (decrypted) { |
| 356 | char gtk[65]; |
| 357 | |
| 358 | wpa_snprintf_hex(gtk, sizeof(gtk), bss->gtk[keyid], |
| 359 | bss->gtk_len[keyid]); |
| 360 | add_note(wt, MSG_EXCESSIVE, "GTK[%d] %s", keyid, gtk); |
| 361 | process: |
| 362 | rx_data_process(wt, bss, bss->bssid, NULL, dst, src, decrypted, |
| 363 | dlen, 1, NULL, qos); |
| 364 | if (!replay) |
| 365 | os_memcpy(bss->rsc[keyid], pn, 6); |
| 366 | write_pcap_decrypted(wt, (const u8 *) hdr, hdrlen, |
| 367 | decrypted, dlen); |
| 368 | } else { |
| 369 | wpa_printf(MSG_DEBUG, "Failed to decrypt frame (group) #%u A2=" |
| 370 | MACSTR " seq=%u", |
| 371 | wt->frame_num, MAC2STR(hdr->addr2), |
| 372 | WLAN_GET_SEQ_SEQ(le_to_host16(hdr->seq_ctrl))); |
| 373 | add_note(wt, MSG_DEBUG, "Failed to decrypt frame (group)"); |
| 374 | } |
| 375 | os_free(decrypted); |
| 376 | } |
| 377 | |
| 378 | |
| 379 | static u8 * try_ptk_decrypt(struct wlantest *wt, struct wlantest_sta *sta, |
| 380 | const struct ieee80211_hdr *hdr, int keyid, |
| 381 | const u8 *data, size_t len, |
| 382 | const u8 *tk, size_t tk_len, size_t *dlen) |
| 383 | { |
| 384 | u8 *decrypted = NULL; |
| 385 | u16 fc = le_to_host16(hdr->frame_control); |
| 386 | const u8 *a1 = NULL, *a2 = NULL, *a3 = NULL; |
| 387 | |
| 388 | if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) && |
| 389 | !is_zero_ether_addr(sta->mld_mac_addr) && |
| 390 | !is_zero_ether_addr(sta->bss->mld_mac_addr)) { |
| 391 | if (os_memcmp(hdr->addr1, sta->addr, ETH_ALEN) == 0) { |
| 392 | a1 = sta->mld_mac_addr; |
| 393 | a2 = sta->bss->mld_mac_addr; |
| 394 | } else { |
| 395 | a1 = sta->bss->mld_mac_addr; |
| 396 | a2 = sta->mld_mac_addr; |
| 397 | } |
| 398 | |
| 399 | if (os_memcmp(hdr->addr3, sta->bss->bssid, ETH_ALEN) == 0) |
| 400 | a3 = sta->bss->mld_mac_addr; |
| 401 | } |
| 402 | |
| 403 | if (sta->pairwise_cipher == WPA_CIPHER_CCMP_256) |
| 404 | decrypted = ccmp_256_decrypt(tk, hdr, a1, a2, a3, |
| 405 | data, len, dlen); |
| 406 | else if (sta->pairwise_cipher == WPA_CIPHER_GCMP || |
| 407 | sta->pairwise_cipher == WPA_CIPHER_GCMP_256) |
| 408 | decrypted = gcmp_decrypt(tk, tk_len, hdr, a1, a2, a3, |
| 409 | data, len, dlen); |
| 410 | else |
| 411 | decrypted = ccmp_decrypt(tk, hdr, a1, a2, a3, data, len, dlen); |
| 412 | write_decrypted_note(wt, decrypted, tk, tk_len, keyid); |
| 413 | |
| 414 | return decrypted; |
| 415 | } |
| 416 | |
| 417 | |
| 418 | static void rx_data_bss_prot(struct wlantest *wt, |
| 419 | const struct ieee80211_hdr *hdr, size_t hdrlen, |
| 420 | const u8 *qos, const u8 *dst, const u8 *src, |
| 421 | const u8 *data, size_t len) |
| 422 | { |
| 423 | struct wlantest_bss *bss, *bss2; |
| 424 | struct wlantest_sta *sta, *sta2; |
| 425 | int keyid; |
| 426 | u16 fc = le_to_host16(hdr->frame_control); |
| 427 | u8 *decrypted = NULL; |
| 428 | size_t dlen; |
| 429 | int tid; |
| 430 | u8 pn[6], *rsc = NULL; |
| 431 | struct wlantest_tdls *tdls = NULL, *found; |
| 432 | const u8 *tk = NULL; |
| 433 | int ptk_iter_done = 0; |
| 434 | int try_ptk_iter = 0; |
| 435 | int replay = 0; |
| 436 | int only_zero_tk = 0; |
| 437 | u16 seq_ctrl = le_to_host16(hdr->seq_ctrl); |
| 438 | const u8 *a1 = NULL, *a2 = NULL, *a3 = NULL; |
| 439 | |
| 440 | if (hdr->addr1[0] & 0x01) { |
| 441 | rx_data_bss_prot_group(wt, hdr, hdrlen, qos, dst, src, |
| 442 | data, len); |
| 443 | return; |
| 444 | } |
| 445 | |
| 446 | if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) == |
| 447 | (WLAN_FC_TODS | WLAN_FC_FROMDS)) { |
| 448 | bss = bss_find(wt, hdr->addr1); |
| 449 | if (bss) { |
| 450 | sta = sta_find(bss, hdr->addr2); |
| 451 | if (sta) { |
| 452 | sta->counters[ |
| 453 | WLANTEST_STA_COUNTER_PROT_DATA_TX]++; |
| 454 | } |
| 455 | if (!sta || !sta->ptk_set) { |
| 456 | bss2 = bss_find(wt, hdr->addr2); |
| 457 | if (bss2) { |
| 458 | sta2 = sta_find(bss2, hdr->addr1); |
| 459 | if (sta2 && (!sta || sta2->ptk_set)) { |
| 460 | bss = bss2; |
| 461 | sta = sta2; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | } else { |
| 466 | bss = bss_find(wt, hdr->addr2); |
| 467 | if (!bss) |
| 468 | return; |
| 469 | sta = sta_find(bss, hdr->addr1); |
| 470 | } |
| 471 | } else if (fc & WLAN_FC_TODS) { |
| 472 | bss = bss_get(wt, hdr->addr1); |
| 473 | if (bss == NULL) |
| 474 | return; |
| 475 | sta = sta_find_mlo(wt, bss, hdr->addr2); |
| 476 | if (!sta) |
| 477 | sta = sta_get(bss, hdr->addr2); |
| 478 | if (sta) |
| 479 | sta->counters[WLANTEST_STA_COUNTER_PROT_DATA_TX]++; |
| 480 | } else if (fc & WLAN_FC_FROMDS) { |
| 481 | bss = bss_get(wt, hdr->addr2); |
| 482 | if (bss == NULL) |
| 483 | return; |
| 484 | sta = sta_find_mlo(wt, bss, hdr->addr1); |
| 485 | if (!sta) |
| 486 | sta = sta_get(bss, hdr->addr1); |
| 487 | } else { |
| 488 | bss = bss_get(wt, hdr->addr3); |
| 489 | if (bss == NULL) |
| 490 | return; |
| 491 | sta = sta_find(bss, hdr->addr2); |
| 492 | sta2 = sta_find(bss, hdr->addr1); |
| 493 | if (sta == NULL || sta2 == NULL) |
| 494 | return; |
| 495 | found = NULL; |
| 496 | dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) |
| 497 | { |
| 498 | if ((tdls->init == sta && tdls->resp == sta2) || |
| 499 | (tdls->init == sta2 && tdls->resp == sta)) { |
| 500 | found = tdls; |
| 501 | if (tdls->link_up) |
| 502 | break; |
| 503 | } |
| 504 | } |
| 505 | if (found) { |
| 506 | if (!found->link_up) |
| 507 | add_note(wt, MSG_DEBUG, |
| 508 | "TDLS: Link not up, but Data " |
| 509 | "frame seen"); |
| 510 | tk = found->tpk.tk; |
| 511 | tdls = found; |
| 512 | } |
| 513 | } |
| 514 | check_plaintext_prot(wt, hdr, data, len); |
| 515 | if ((sta == NULL || |
| 516 | (!sta->ptk_set && sta->pairwise_cipher != WPA_CIPHER_WEP40)) && |
| 517 | tk == NULL) { |
| 518 | add_note(wt, MSG_MSGDUMP, "No PTK known to decrypt the frame"); |
| 519 | if (dl_list_empty(&wt->ptk)) { |
| 520 | if (len >= 4 && sta) { |
| 521 | keyid = data[3] >> 6; |
| 522 | only_zero_tk = 1; |
| 523 | goto check_zero_tk; |
| 524 | } |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | try_ptk_iter = 1; |
| 529 | } |
| 530 | |
| 531 | if (len < 4) { |
| 532 | add_note(wt, MSG_INFO, "Too short encrypted data frame"); |
| 533 | return; |
| 534 | } |
| 535 | |
| 536 | if (sta == NULL) |
| 537 | return; |
| 538 | if (sta->pairwise_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP | |
| 539 | WPA_CIPHER_GCMP | WPA_CIPHER_GCMP_256 | |
| 540 | WPA_CIPHER_CCMP_256) && |
| 541 | !(data[3] & 0x20)) { |
| 542 | add_note(wt, MSG_INFO, "Expected TKIP/CCMP/GCMP frame from " |
| 543 | MACSTR " did not have ExtIV bit set to 1", |
| 544 | MAC2STR(src)); |
| 545 | return; |
| 546 | } |
| 547 | |
| 548 | if (tk == NULL && sta->pairwise_cipher == WPA_CIPHER_TKIP) { |
| 549 | if (data[3] & 0x1f) { |
| 550 | add_note(wt, MSG_INFO, "TKIP frame from " MACSTR |
| 551 | " used non-zero reserved bit", |
| 552 | MAC2STR(hdr->addr2)); |
| 553 | } |
| 554 | if (data[1] != ((data[0] | 0x20) & 0x7f)) { |
| 555 | add_note(wt, MSG_INFO, "TKIP frame from " MACSTR |
| 556 | " used incorrect WEPSeed[1] (was 0x%x, " |
| 557 | "expected 0x%x)", |
| 558 | MAC2STR(hdr->addr2), data[1], |
| 559 | (data[0] | 0x20) & 0x7f); |
| 560 | } |
| 561 | } else if (tk || sta->pairwise_cipher == WPA_CIPHER_CCMP || |
| 562 | sta->pairwise_cipher == WPA_CIPHER_GCMP || |
| 563 | sta->pairwise_cipher == WPA_CIPHER_GCMP_256 || |
| 564 | sta->pairwise_cipher == WPA_CIPHER_CCMP_256) { |
| 565 | if (data[2] != 0 || (data[3] & 0x1f) != 0) { |
| 566 | add_note(wt, MSG_INFO, "CCMP/GCMP frame from " MACSTR |
| 567 | " used non-zero reserved bit", |
| 568 | MAC2STR(hdr->addr2)); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | keyid = data[3] >> 6; |
| 573 | if (keyid != 0 && |
| 574 | (!(sta->rsn_capab & WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST) || |
| 575 | !(bss->rsn_capab & WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST) || |
| 576 | keyid != 1)) { |
| 577 | add_note(wt, MSG_INFO, |
| 578 | "Unexpected KeyID %d in individually addressed Data frame from " |
| 579 | MACSTR, |
| 580 | keyid, MAC2STR(hdr->addr2)); |
| 581 | } |
| 582 | |
| 583 | if (qos) { |
| 584 | tid = qos[0] & 0x0f; |
| 585 | if (fc & WLAN_FC_TODS) |
| 586 | sta->tx_tid[tid]++; |
| 587 | else |
| 588 | sta->rx_tid[tid]++; |
| 589 | } else { |
| 590 | tid = 0; |
| 591 | if (fc & WLAN_FC_TODS) |
| 592 | sta->tx_tid[16]++; |
| 593 | else |
| 594 | sta->rx_tid[16]++; |
| 595 | } |
| 596 | if (tk) { |
| 597 | if (os_memcmp(hdr->addr2, tdls->init->addr, ETH_ALEN) == 0) |
| 598 | rsc = tdls->rsc_init[tid]; |
| 599 | else |
| 600 | rsc = tdls->rsc_resp[tid]; |
| 601 | } else if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) == |
| 602 | (WLAN_FC_TODS | WLAN_FC_FROMDS)) { |
| 603 | if (os_memcmp(sta->addr, hdr->addr2, ETH_ALEN) == 0) |
| 604 | rsc = sta->rsc_tods[tid]; |
| 605 | else |
| 606 | rsc = sta->rsc_fromds[tid]; |
| 607 | } else if (fc & WLAN_FC_TODS) |
| 608 | rsc = sta->rsc_tods[tid]; |
| 609 | else |
| 610 | rsc = sta->rsc_fromds[tid]; |
| 611 | |
| 612 | |
| 613 | if (tk == NULL && sta->pairwise_cipher == WPA_CIPHER_TKIP) |
| 614 | tkip_get_pn(pn, data); |
| 615 | else if (sta->pairwise_cipher == WPA_CIPHER_WEP40) |
| 616 | goto skip_replay_det; |
| 617 | else |
| 618 | ccmp_get_pn(pn, data); |
| 619 | if (os_memcmp(pn, rsc, 6) <= 0) { |
| 620 | char pn_hex[6 * 2 + 1], rsc_hex[6 * 2 + 1]; |
| 621 | |
| 622 | wpa_snprintf_hex(pn_hex, sizeof(pn_hex), pn, 6); |
| 623 | wpa_snprintf_hex(rsc_hex, sizeof(rsc_hex), rsc, 6); |
| 624 | add_note(wt, MSG_INFO, "replay detected: A1=" MACSTR |
| 625 | " A2=" MACSTR " A3=" MACSTR |
| 626 | " seq=%u frag=%u%s keyid=%d tid=%d #%u %s<=%s", |
| 627 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 628 | MAC2STR(hdr->addr3), |
| 629 | WLAN_GET_SEQ_SEQ(seq_ctrl), |
| 630 | WLAN_GET_SEQ_FRAG(seq_ctrl), |
| 631 | (le_to_host16(hdr->frame_control) & WLAN_FC_RETRY) ? |
| 632 | " Retry" : "", |
| 633 | keyid, tid, wt->frame_num, pn_hex, rsc_hex); |
| 634 | replay = 1; |
| 635 | } |
| 636 | |
| 637 | skip_replay_det: |
| 638 | if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) && |
| 639 | !is_zero_ether_addr(sta->mld_mac_addr) && |
| 640 | !is_zero_ether_addr(bss->mld_mac_addr)) { |
| 641 | if (os_memcmp(hdr->addr1, sta->addr, ETH_ALEN) == 0) { |
| 642 | a1 = sta->mld_mac_addr; |
| 643 | a2 = bss->mld_mac_addr; |
| 644 | } else { |
| 645 | a1 = bss->mld_mac_addr; |
| 646 | a2 = sta->mld_mac_addr; |
| 647 | } |
| 648 | |
| 649 | if (os_memcmp(hdr->addr3, bss->bssid, ETH_ALEN) == 0) |
| 650 | a3 = bss->mld_mac_addr; |
| 651 | } |
| 652 | |
| 653 | if (tk) { |
| 654 | if (sta->pairwise_cipher == WPA_CIPHER_CCMP_256) { |
| 655 | decrypted = ccmp_256_decrypt(tk, hdr, a1, a2, a3, |
| 656 | data, len, &dlen); |
| 657 | write_decrypted_note(wt, decrypted, tk, 32, keyid); |
| 658 | } else if (sta->pairwise_cipher == WPA_CIPHER_GCMP || |
| 659 | sta->pairwise_cipher == WPA_CIPHER_GCMP_256) { |
| 660 | decrypted = gcmp_decrypt(tk, sta->ptk.tk_len, hdr, |
| 661 | a1, a2, a3, data, len, &dlen); |
| 662 | write_decrypted_note(wt, decrypted, tk, sta->ptk.tk_len, |
| 663 | keyid); |
| 664 | } else { |
| 665 | decrypted = ccmp_decrypt(tk, hdr, a1, a2, a3, data, len, |
| 666 | &dlen); |
| 667 | write_decrypted_note(wt, decrypted, tk, 16, keyid); |
| 668 | } |
| 669 | } else if (sta->pairwise_cipher == WPA_CIPHER_TKIP) { |
| 670 | enum michael_mic_result mic_res; |
| 671 | |
| 672 | decrypted = tkip_decrypt(sta->ptk.tk, hdr, data, len, &dlen, |
| 673 | &mic_res, &wt->tkip_frag); |
| 674 | if (decrypted && mic_res == MICHAEL_MIC_INCORRECT) |
| 675 | add_note(wt, MSG_INFO, "Invalid Michael MIC"); |
| 676 | else if (decrypted && mic_res == MICHAEL_MIC_NOT_VERIFIED) |
| 677 | add_note(wt, MSG_DEBUG, "Michael MIC not verified"); |
| 678 | write_decrypted_note(wt, decrypted, sta->ptk.tk, 32, keyid); |
| 679 | } else if (sta->pairwise_cipher == WPA_CIPHER_WEP40) { |
| 680 | decrypted = wep_decrypt(wt, hdr, data, len, &dlen); |
| 681 | } else if (sta->ptk_set) { |
| 682 | decrypted = try_ptk_decrypt(wt, sta, hdr, keyid, data, len, |
| 683 | sta->ptk.tk, sta->ptk.tk_len, |
| 684 | &dlen); |
| 685 | } else { |
| 686 | decrypted = try_all_ptk(wt, sta->pairwise_cipher, hdr, |
| 687 | a1, a2, a3, |
| 688 | keyid, data, len, &dlen); |
| 689 | ptk_iter_done = 1; |
| 690 | } |
| 691 | if (!decrypted && !ptk_iter_done) { |
| 692 | decrypted = try_all_ptk(wt, sta->pairwise_cipher, hdr, |
| 693 | a1, a2, a3, |
| 694 | keyid, data, len, &dlen); |
| 695 | if (decrypted) { |
| 696 | add_note(wt, MSG_DEBUG, "Current PTK did not work, but found a match from all known PTKs"); |
| 697 | } |
| 698 | } |
| 699 | check_zero_tk: |
| 700 | if (!decrypted) { |
| 701 | struct wpa_ptk zero_ptk; |
| 702 | int old_debug_level = wpa_debug_level; |
| 703 | |
| 704 | os_memset(&zero_ptk, 0, sizeof(zero_ptk)); |
| 705 | zero_ptk.tk_len = wpa_cipher_key_len(sta->pairwise_cipher); |
| 706 | wpa_debug_level = MSG_ERROR; |
| 707 | decrypted = try_ptk(wt, sta->pairwise_cipher, &zero_ptk, hdr, |
| 708 | a1, a2, a3, data, len, &dlen); |
| 709 | wpa_debug_level = old_debug_level; |
| 710 | if (decrypted) { |
| 711 | add_note(wt, MSG_DEBUG, |
| 712 | "Frame was encrypted with zero TK"); |
| 713 | wpa_printf(MSG_INFO, "Zero TK used in frame #%u: A2=" |
| 714 | MACSTR " seq=%u", |
| 715 | wt->frame_num, MAC2STR(hdr->addr2), |
| 716 | WLAN_GET_SEQ_SEQ( |
| 717 | le_to_host16(hdr->seq_ctrl))); |
| 718 | write_decrypted_note(wt, decrypted, zero_ptk.tk, |
| 719 | zero_ptk.tk_len, keyid); |
| 720 | } |
| 721 | } |
| 722 | if (decrypted) { |
| 723 | u16 fc = le_to_host16(hdr->frame_control); |
| 724 | const u8 *peer_addr = NULL; |
| 725 | if (!(fc & (WLAN_FC_FROMDS | WLAN_FC_TODS))) |
| 726 | peer_addr = hdr->addr1; |
| 727 | if (!replay && rsc) |
| 728 | os_memcpy(rsc, pn, 6); |
| 729 | rx_data_process(wt, bss, bss->bssid, sta->addr, dst, src, |
| 730 | decrypted, dlen, 1, peer_addr, qos); |
| 731 | write_pcap_decrypted(wt, (const u8 *) hdr, hdrlen, |
| 732 | decrypted, dlen); |
| 733 | } else if (sta->tptk_set) { |
| 734 | /* Check whether TPTK has a matching TK that could be used to |
| 735 | * decrypt the frame. That could happen if EAPOL-Key msg 4/4 |
| 736 | * was missing in the capture and this was PTK rekeying. */ |
| 737 | decrypted = try_ptk_decrypt(wt, sta, hdr, keyid, data, len, |
| 738 | sta->tptk.tk, sta->tptk.tk_len, |
| 739 | &dlen); |
| 740 | if (decrypted) { |
| 741 | add_note(wt, MSG_DEBUG, |
| 742 | "Update PTK (rekeying; no valid EAPOL-Key msg 4/4 seen)"); |
| 743 | os_memcpy(&sta->ptk, &sta->tptk, sizeof(sta->ptk)); |
| 744 | sta->ptk_set = 1; |
| 745 | sta->tptk_set = 0; |
| 746 | os_memset(sta->rsc_tods, 0, sizeof(sta->rsc_tods)); |
| 747 | os_memset(sta->rsc_fromds, 0, sizeof(sta->rsc_fromds)); |
| 748 | } |
| 749 | } else { |
| 750 | if (!try_ptk_iter && !only_zero_tk) { |
| 751 | wpa_printf(MSG_DEBUG, |
| 752 | "Failed to decrypt frame #%u A2=" MACSTR |
| 753 | " seq=%u", |
| 754 | wt->frame_num, MAC2STR(hdr->addr2), |
| 755 | WLAN_GET_SEQ_SEQ(seq_ctrl)); |
| 756 | add_note(wt, MSG_DEBUG, "Failed to decrypt frame"); |
| 757 | } |
| 758 | |
| 759 | /* Assume the frame was corrupted and there was no FCS to check. |
| 760 | * Allow retry of this particular frame to be processed so that |
| 761 | * it could end up getting decrypted if it was received without |
| 762 | * corruption. */ |
| 763 | sta->allow_duplicate = 1; |
| 764 | } |
| 765 | os_free(decrypted); |
| 766 | } |
| 767 | |
| 768 | |
| 769 | static void rx_data_bss(struct wlantest *wt, const struct ieee80211_hdr *hdr, |
| 770 | size_t hdrlen, const u8 *qos, const u8 *dst, |
| 771 | const u8 *src, const u8 *data, size_t len) |
| 772 | { |
| 773 | u16 fc = le_to_host16(hdr->frame_control); |
| 774 | int prot = !!(fc & WLAN_FC_ISWEP); |
| 775 | |
| 776 | if (qos) { |
| 777 | u8 ack = (qos[0] & 0x60) >> 5; |
| 778 | wpa_printf(MSG_MSGDUMP, "BSS DATA: " MACSTR " -> " MACSTR |
| 779 | " len=%u%s tid=%u%s%s", |
| 780 | MAC2STR(src), MAC2STR(dst), (unsigned int) len, |
| 781 | prot ? " Prot" : "", qos[0] & 0x0f, |
| 782 | (qos[0] & 0x10) ? " EOSP" : "", |
| 783 | ack == 0 ? "" : |
| 784 | (ack == 1 ? " NoAck" : |
| 785 | (ack == 2 ? " NoExpAck" : " BA"))); |
| 786 | } else { |
| 787 | wpa_printf(MSG_MSGDUMP, "BSS DATA: " MACSTR " -> " MACSTR |
| 788 | " len=%u%s", |
| 789 | MAC2STR(src), MAC2STR(dst), (unsigned int) len, |
| 790 | prot ? " Prot" : ""); |
| 791 | } |
| 792 | |
| 793 | if (prot) |
| 794 | rx_data_bss_prot(wt, hdr, hdrlen, qos, dst, src, data, len); |
| 795 | else { |
| 796 | const u8 *bssid, *sta_addr, *peer_addr; |
| 797 | struct wlantest_bss *bss; |
| 798 | |
| 799 | if (fc & WLAN_FC_TODS) { |
| 800 | bssid = hdr->addr1; |
| 801 | sta_addr = hdr->addr2; |
| 802 | peer_addr = NULL; |
| 803 | } else if (fc & WLAN_FC_FROMDS) { |
| 804 | bssid = hdr->addr2; |
| 805 | sta_addr = hdr->addr1; |
| 806 | peer_addr = NULL; |
| 807 | } else { |
| 808 | bssid = hdr->addr3; |
| 809 | sta_addr = hdr->addr2; |
| 810 | peer_addr = hdr->addr1; |
| 811 | } |
| 812 | |
| 813 | bss = bss_get(wt, bssid); |
| 814 | if (bss) { |
| 815 | struct wlantest_sta *sta; |
| 816 | |
| 817 | sta = sta_find_mlo(wt, bss, sta_addr); |
| 818 | if (!sta) |
| 819 | sta = sta_get(bss, sta_addr); |
| 820 | |
| 821 | if (sta) { |
| 822 | if (qos) { |
| 823 | int tid = qos[0] & 0x0f; |
| 824 | if (fc & WLAN_FC_TODS) |
| 825 | sta->tx_tid[tid]++; |
| 826 | else |
| 827 | sta->rx_tid[tid]++; |
| 828 | } else { |
| 829 | if (fc & WLAN_FC_TODS) |
| 830 | sta->tx_tid[16]++; |
| 831 | else |
| 832 | sta->rx_tid[16]++; |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | rx_data_process(wt, bss, bssid, sta_addr, dst, src, data, len, |
| 838 | 0, peer_addr, qos); |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | |
| 843 | static struct wlantest_tdls * get_tdls(struct wlantest *wt, const u8 *bssid, |
| 844 | const u8 *sta1_addr, |
| 845 | const u8 *sta2_addr) |
| 846 | { |
| 847 | struct wlantest_bss *bss; |
| 848 | struct wlantest_sta *sta1, *sta2; |
| 849 | struct wlantest_tdls *tdls, *found = NULL; |
| 850 | |
| 851 | bss = bss_find(wt, bssid); |
| 852 | if (bss == NULL) |
| 853 | return NULL; |
| 854 | sta1 = sta_find(bss, sta1_addr); |
| 855 | if (sta1 == NULL) |
| 856 | return NULL; |
| 857 | sta2 = sta_find(bss, sta2_addr); |
| 858 | if (sta2 == NULL) |
| 859 | return NULL; |
| 860 | |
| 861 | dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) { |
| 862 | if ((tdls->init == sta1 && tdls->resp == sta2) || |
| 863 | (tdls->init == sta2 && tdls->resp == sta1)) { |
| 864 | found = tdls; |
| 865 | if (tdls->link_up) |
| 866 | break; |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | return found; |
| 871 | } |
| 872 | |
| 873 | |
| 874 | static void add_direct_link(struct wlantest *wt, const u8 *bssid, |
| 875 | const u8 *sta1_addr, const u8 *sta2_addr) |
| 876 | { |
| 877 | struct wlantest_tdls *tdls; |
| 878 | |
| 879 | tdls = get_tdls(wt, bssid, sta1_addr, sta2_addr); |
| 880 | if (tdls == NULL) |
| 881 | return; |
| 882 | |
| 883 | if (tdls->link_up) |
| 884 | tdls->counters[WLANTEST_TDLS_COUNTER_VALID_DIRECT_LINK]++; |
| 885 | else |
| 886 | tdls->counters[WLANTEST_TDLS_COUNTER_INVALID_DIRECT_LINK]++; |
| 887 | } |
| 888 | |
| 889 | |
| 890 | static void add_ap_path(struct wlantest *wt, const u8 *bssid, |
| 891 | const u8 *sta1_addr, const u8 *sta2_addr) |
| 892 | { |
| 893 | struct wlantest_tdls *tdls; |
| 894 | |
| 895 | tdls = get_tdls(wt, bssid, sta1_addr, sta2_addr); |
| 896 | if (tdls == NULL) |
| 897 | return; |
| 898 | |
| 899 | if (tdls->link_up) |
| 900 | tdls->counters[WLANTEST_TDLS_COUNTER_INVALID_AP_PATH]++; |
| 901 | else |
| 902 | tdls->counters[WLANTEST_TDLS_COUNTER_VALID_AP_PATH]++; |
| 903 | } |
| 904 | |
| 905 | |
| 906 | void rx_data(struct wlantest *wt, const u8 *data, size_t len) |
| 907 | { |
| 908 | const struct ieee80211_hdr *hdr; |
| 909 | u16 fc, stype; |
| 910 | size_t hdrlen; |
| 911 | const u8 *qos = NULL; |
| 912 | |
| 913 | if (len < 24) |
| 914 | return; |
| 915 | |
| 916 | hdr = (const struct ieee80211_hdr *) data; |
| 917 | fc = le_to_host16(hdr->frame_control); |
| 918 | stype = WLAN_FC_GET_STYPE(fc); |
| 919 | hdrlen = 24; |
| 920 | if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) == |
| 921 | (WLAN_FC_TODS | WLAN_FC_FROMDS)) |
| 922 | hdrlen += ETH_ALEN; |
| 923 | if (stype & 0x08) { |
| 924 | qos = data + hdrlen; |
| 925 | hdrlen += 2; |
| 926 | } |
| 927 | if ((fc & WLAN_FC_HTC) && (stype & 0x08)) |
| 928 | hdrlen += 4; /* HT Control field */ |
| 929 | if (len < hdrlen) |
| 930 | return; |
| 931 | wt->rx_data++; |
| 932 | |
| 933 | switch (fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) { |
| 934 | case 0: |
| 935 | wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s IBSS DA=" MACSTR " SA=" |
| 936 | MACSTR " BSSID=" MACSTR, |
| 937 | data_stype(WLAN_FC_GET_STYPE(fc)), |
| 938 | fc & WLAN_FC_PWRMGT ? " PwrMgt" : "", |
| 939 | fc & WLAN_FC_ISWEP ? " Prot" : "", |
| 940 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 941 | MAC2STR(hdr->addr3)); |
| 942 | add_direct_link(wt, hdr->addr3, hdr->addr1, hdr->addr2); |
| 943 | rx_data_bss(wt, hdr, hdrlen, qos, hdr->addr1, hdr->addr2, |
| 944 | data + hdrlen, len - hdrlen); |
| 945 | break; |
| 946 | case WLAN_FC_FROMDS: |
| 947 | wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s FromDS DA=" MACSTR |
| 948 | " BSSID=" MACSTR " SA=" MACSTR, |
| 949 | data_stype(WLAN_FC_GET_STYPE(fc)), |
| 950 | fc & WLAN_FC_PWRMGT ? " PwrMgt" : "", |
| 951 | fc & WLAN_FC_ISWEP ? " Prot" : "", |
| 952 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 953 | MAC2STR(hdr->addr3)); |
| 954 | add_ap_path(wt, hdr->addr2, hdr->addr1, hdr->addr3); |
| 955 | rx_data_bss(wt, hdr, hdrlen, qos, hdr->addr1, hdr->addr3, |
| 956 | data + hdrlen, len - hdrlen); |
| 957 | break; |
| 958 | case WLAN_FC_TODS: |
| 959 | wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s ToDS BSSID=" MACSTR |
| 960 | " SA=" MACSTR " DA=" MACSTR, |
| 961 | data_stype(WLAN_FC_GET_STYPE(fc)), |
| 962 | fc & WLAN_FC_PWRMGT ? " PwrMgt" : "", |
| 963 | fc & WLAN_FC_ISWEP ? " Prot" : "", |
| 964 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 965 | MAC2STR(hdr->addr3)); |
| 966 | add_ap_path(wt, hdr->addr1, hdr->addr3, hdr->addr2); |
| 967 | rx_data_bss(wt, hdr, hdrlen, qos, hdr->addr3, hdr->addr2, |
| 968 | data + hdrlen, len - hdrlen); |
| 969 | break; |
| 970 | case WLAN_FC_TODS | WLAN_FC_FROMDS: |
| 971 | wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s WDS RA=" MACSTR " TA=" |
| 972 | MACSTR " DA=" MACSTR " SA=" MACSTR, |
| 973 | data_stype(WLAN_FC_GET_STYPE(fc)), |
| 974 | fc & WLAN_FC_PWRMGT ? " PwrMgt" : "", |
| 975 | fc & WLAN_FC_ISWEP ? " Prot" : "", |
| 976 | MAC2STR(hdr->addr1), MAC2STR(hdr->addr2), |
| 977 | MAC2STR(hdr->addr3), |
| 978 | MAC2STR((const u8 *) (hdr + 1))); |
| 979 | rx_data_bss(wt, hdr, hdrlen, qos, hdr->addr1, hdr->addr2, |
| 980 | data + hdrlen, len - hdrlen); |
| 981 | break; |
| 982 | } |
| 983 | } |