rx_data.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * Received Data frame processing
  3. * Copyright (c) 2010, 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. #include "utils/includes.h"
  9. #include <linux/if_ether.h>
  10. #include "utils/common.h"
  11. #include "common/defs.h"
  12. #include "common/ieee802_11_defs.h"
  13. #include "wlantest.h"
  14. extern int wpa_debug_level;
  15. static const char * data_stype(u16 stype)
  16. {
  17. switch (stype) {
  18. case WLAN_FC_STYPE_DATA:
  19. return "DATA";
  20. case WLAN_FC_STYPE_DATA_CFACK:
  21. return "DATA-CFACK";
  22. case WLAN_FC_STYPE_DATA_CFPOLL:
  23. return "DATA-CFPOLL";
  24. case WLAN_FC_STYPE_DATA_CFACKPOLL:
  25. return "DATA-CFACKPOLL";
  26. case WLAN_FC_STYPE_NULLFUNC:
  27. return "NULLFUNC";
  28. case WLAN_FC_STYPE_CFACK:
  29. return "CFACK";
  30. case WLAN_FC_STYPE_CFPOLL:
  31. return "CFPOLL";
  32. case WLAN_FC_STYPE_CFACKPOLL:
  33. return "CFACKPOLL";
  34. case WLAN_FC_STYPE_QOS_DATA:
  35. return "QOSDATA";
  36. case WLAN_FC_STYPE_QOS_DATA_CFACK:
  37. return "QOSDATA-CFACK";
  38. case WLAN_FC_STYPE_QOS_DATA_CFPOLL:
  39. return "QOSDATA-CFPOLL";
  40. case WLAN_FC_STYPE_QOS_DATA_CFACKPOLL:
  41. return "QOSDATA-CFACKPOLL";
  42. case WLAN_FC_STYPE_QOS_NULL:
  43. return "QOS-NULL";
  44. case WLAN_FC_STYPE_QOS_CFPOLL:
  45. return "QOS-CFPOLL";
  46. case WLAN_FC_STYPE_QOS_CFACKPOLL:
  47. return "QOS-CFACKPOLL";
  48. }
  49. return "??";
  50. }
  51. static void rx_data_eth(struct wlantest *wt, const u8 *bssid,
  52. const u8 *sta_addr, const u8 *dst, const u8 *src,
  53. u16 ethertype, const u8 *data, size_t len, int prot,
  54. const u8 *peer_addr)
  55. {
  56. switch (ethertype) {
  57. case ETH_P_PAE:
  58. rx_data_eapol(wt, dst, src, data, len, prot);
  59. break;
  60. case ETH_P_IP:
  61. rx_data_ip(wt, bssid, sta_addr, dst, src, data, len,
  62. peer_addr);
  63. break;
  64. case 0x890d:
  65. rx_data_80211_encap(wt, bssid, sta_addr, dst, src, data, len);
  66. break;
  67. }
  68. }
  69. static void rx_data_process(struct wlantest *wt, const u8 *bssid,
  70. const u8 *sta_addr,
  71. const u8 *dst, const u8 *src,
  72. const u8 *data, size_t len, int prot,
  73. const u8 *peer_addr)
  74. {
  75. if (len == 0)
  76. return;
  77. if (len >= 8 && os_memcmp(data, "\xaa\xaa\x03\x00\x00\x00", 6) == 0) {
  78. rx_data_eth(wt, bssid, sta_addr, dst, src,
  79. WPA_GET_BE16(data + 6), data + 8, len - 8, prot,
  80. peer_addr);
  81. return;
  82. }
  83. wpa_hexdump(MSG_DEBUG, "Unrecognized LLC", data, len > 8 ? 8 : len);
  84. }
  85. static u8 * try_all_ptk(struct wlantest *wt, int pairwise_cipher,
  86. const struct ieee80211_hdr *hdr,
  87. const u8 *data, size_t data_len, size_t *decrypted_len)
  88. {
  89. struct wlantest_ptk *ptk;
  90. u8 *decrypted;
  91. int prev_level = wpa_debug_level;
  92. wpa_debug_level = MSG_WARNING;
  93. dl_list_for_each(ptk, &wt->ptk, struct wlantest_ptk, list) {
  94. decrypted = NULL;
  95. if ((pairwise_cipher == WPA_CIPHER_CCMP ||
  96. pairwise_cipher == 0) && ptk->ptk_len == 48) {
  97. decrypted = ccmp_decrypt(ptk->ptk.tk1, hdr, data,
  98. data_len, decrypted_len);
  99. }
  100. if ((pairwise_cipher == WPA_CIPHER_TKIP ||
  101. pairwise_cipher == 0) && ptk->ptk_len == 64) {
  102. decrypted = tkip_decrypt(ptk->ptk.tk1, hdr, data,
  103. data_len, decrypted_len);
  104. }
  105. if (decrypted) {
  106. wpa_debug_level = prev_level;
  107. add_note(wt, MSG_DEBUG, "Found PTK match from list of all known PTKs");
  108. return decrypted;
  109. }
  110. }
  111. wpa_debug_level = prev_level;
  112. return NULL;
  113. }
  114. static void rx_data_bss_prot_group(struct wlantest *wt,
  115. const struct ieee80211_hdr *hdr,
  116. const u8 *qos, const u8 *dst, const u8 *src,
  117. const u8 *data, size_t len)
  118. {
  119. struct wlantest_bss *bss;
  120. int keyid;
  121. u8 *decrypted;
  122. size_t dlen;
  123. u8 pn[6];
  124. bss = bss_get(wt, hdr->addr2);
  125. if (bss == NULL)
  126. return;
  127. if (len < 4) {
  128. add_note(wt, MSG_INFO, "Too short group addressed data frame");
  129. return;
  130. }
  131. if (bss->group_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP) &&
  132. !(data[3] & 0x20)) {
  133. add_note(wt, MSG_INFO, "Expected TKIP/CCMP frame from "
  134. MACSTR " did not have ExtIV bit set to 1",
  135. MAC2STR(bss->bssid));
  136. return;
  137. }
  138. if (bss->group_cipher == WPA_CIPHER_TKIP) {
  139. if (data[3] & 0x1f) {
  140. add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
  141. " used non-zero reserved bit",
  142. MAC2STR(bss->bssid));
  143. }
  144. if (data[1] != ((data[0] | 0x20) & 0x7f)) {
  145. add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
  146. " used incorrect WEPSeed[1] (was 0x%x, "
  147. "expected 0x%x)",
  148. MAC2STR(bss->bssid), data[1],
  149. (data[0] | 0x20) & 0x7f);
  150. }
  151. } else if (bss->group_cipher == WPA_CIPHER_CCMP) {
  152. if (data[2] != 0 || (data[3] & 0x1f) != 0) {
  153. add_note(wt, MSG_INFO, "CCMP frame from " MACSTR
  154. " used non-zero reserved bit",
  155. MAC2STR(bss->bssid));
  156. }
  157. }
  158. keyid = data[3] >> 6;
  159. if (bss->gtk_len[keyid] == 0 && bss->group_cipher != WPA_CIPHER_WEP40)
  160. {
  161. add_note(wt, MSG_MSGDUMP, "No GTK known to decrypt the frame "
  162. "(A2=" MACSTR " KeyID=%d)",
  163. MAC2STR(hdr->addr2), keyid);
  164. return;
  165. }
  166. if (bss->group_cipher == WPA_CIPHER_TKIP)
  167. tkip_get_pn(pn, data);
  168. else if (bss->group_cipher == WPA_CIPHER_WEP40)
  169. goto skip_replay_det;
  170. else
  171. ccmp_get_pn(pn, data);
  172. if (os_memcmp(pn, bss->rsc[keyid], 6) <= 0) {
  173. u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
  174. add_note(wt, MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
  175. " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
  176. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  177. MAC2STR(hdr->addr3),
  178. WLAN_GET_SEQ_SEQ(seq_ctrl),
  179. WLAN_GET_SEQ_FRAG(seq_ctrl));
  180. wpa_hexdump(MSG_INFO, "RX PN", pn, 6);
  181. wpa_hexdump(MSG_INFO, "RSC", bss->rsc[keyid], 6);
  182. }
  183. skip_replay_det:
  184. if (bss->group_cipher == WPA_CIPHER_TKIP)
  185. decrypted = tkip_decrypt(bss->gtk[keyid], hdr, data, len,
  186. &dlen);
  187. else if (bss->group_cipher == WPA_CIPHER_WEP40)
  188. decrypted = wep_decrypt(wt, hdr, data, len, &dlen);
  189. else
  190. decrypted = ccmp_decrypt(bss->gtk[keyid], hdr, data, len,
  191. &dlen);
  192. if (decrypted) {
  193. rx_data_process(wt, bss->bssid, NULL, dst, src, decrypted,
  194. dlen, 1, NULL);
  195. os_memcpy(bss->rsc[keyid], pn, 6);
  196. write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
  197. decrypted, dlen);
  198. } else
  199. add_note(wt, MSG_DEBUG, "Failed to decrypt frame");
  200. os_free(decrypted);
  201. }
  202. static void rx_data_bss_prot(struct wlantest *wt,
  203. const struct ieee80211_hdr *hdr, const u8 *qos,
  204. const u8 *dst, const u8 *src, const u8 *data,
  205. size_t len)
  206. {
  207. struct wlantest_bss *bss;
  208. struct wlantest_sta *sta, *sta2;
  209. int keyid;
  210. u16 fc = le_to_host16(hdr->frame_control);
  211. u8 *decrypted;
  212. size_t dlen;
  213. int tid;
  214. u8 pn[6], *rsc;
  215. struct wlantest_tdls *tdls = NULL, *found;
  216. const u8 *tk = NULL;
  217. int ptk_iter_done = 0;
  218. int try_ptk_iter = 0;
  219. if (hdr->addr1[0] & 0x01) {
  220. rx_data_bss_prot_group(wt, hdr, qos, dst, src, data, len);
  221. return;
  222. }
  223. if (fc & WLAN_FC_TODS) {
  224. bss = bss_get(wt, hdr->addr1);
  225. if (bss == NULL)
  226. return;
  227. sta = sta_get(bss, hdr->addr2);
  228. if (sta)
  229. sta->counters[WLANTEST_STA_COUNTER_PROT_DATA_TX]++;
  230. } else if (fc & WLAN_FC_FROMDS) {
  231. bss = bss_get(wt, hdr->addr2);
  232. if (bss == NULL)
  233. return;
  234. sta = sta_get(bss, hdr->addr1);
  235. } else {
  236. bss = bss_get(wt, hdr->addr3);
  237. if (bss == NULL)
  238. return;
  239. sta = sta_find(bss, hdr->addr2);
  240. sta2 = sta_find(bss, hdr->addr1);
  241. if (sta == NULL || sta2 == NULL)
  242. return;
  243. found = NULL;
  244. dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list)
  245. {
  246. if ((tdls->init == sta && tdls->resp == sta2) ||
  247. (tdls->init == sta2 && tdls->resp == sta)) {
  248. found = tdls;
  249. if (tdls->link_up)
  250. break;
  251. }
  252. }
  253. if (found) {
  254. if (!found->link_up)
  255. add_note(wt, MSG_DEBUG,
  256. "TDLS: Link not up, but Data "
  257. "frame seen");
  258. tk = found->tpk.tk;
  259. tdls = found;
  260. }
  261. }
  262. if ((sta == NULL ||
  263. (!sta->ptk_set && sta->pairwise_cipher != WPA_CIPHER_WEP40)) &&
  264. tk == NULL) {
  265. add_note(wt, MSG_MSGDUMP, "No PTK known to decrypt the frame");
  266. if (dl_list_empty(&wt->ptk))
  267. return;
  268. try_ptk_iter = 1;
  269. }
  270. if (len < 4) {
  271. add_note(wt, MSG_INFO, "Too short encrypted data frame");
  272. return;
  273. }
  274. if (sta->pairwise_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP) &&
  275. !(data[3] & 0x20)) {
  276. add_note(wt, MSG_INFO, "Expected TKIP/CCMP frame from "
  277. MACSTR " did not have ExtIV bit set to 1",
  278. MAC2STR(src));
  279. return;
  280. }
  281. if (tk == NULL && sta->pairwise_cipher == WPA_CIPHER_TKIP) {
  282. if (data[3] & 0x1f) {
  283. add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
  284. " used non-zero reserved bit",
  285. MAC2STR(hdr->addr2));
  286. }
  287. if (data[1] != ((data[0] | 0x20) & 0x7f)) {
  288. add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
  289. " used incorrect WEPSeed[1] (was 0x%x, "
  290. "expected 0x%x)",
  291. MAC2STR(hdr->addr2), data[1],
  292. (data[0] | 0x20) & 0x7f);
  293. }
  294. } else if (tk || sta->pairwise_cipher == WPA_CIPHER_CCMP) {
  295. if (data[2] != 0 || (data[3] & 0x1f) != 0) {
  296. add_note(wt, MSG_INFO, "CCMP frame from " MACSTR
  297. " used non-zero reserved bit",
  298. MAC2STR(hdr->addr2));
  299. }
  300. }
  301. keyid = data[3] >> 6;
  302. if (keyid != 0) {
  303. add_note(wt, MSG_INFO, "Unexpected non-zero KeyID %d in "
  304. "individually addressed Data frame from " MACSTR,
  305. keyid, MAC2STR(hdr->addr2));
  306. }
  307. if (qos)
  308. tid = qos[0] & 0x0f;
  309. else
  310. tid = 0;
  311. if (tk) {
  312. if (os_memcmp(hdr->addr2, tdls->init->addr, ETH_ALEN) == 0)
  313. rsc = tdls->rsc_init[tid];
  314. else
  315. rsc = tdls->rsc_resp[tid];
  316. } else if (fc & WLAN_FC_TODS)
  317. rsc = sta->rsc_tods[tid];
  318. else
  319. rsc = sta->rsc_fromds[tid];
  320. if (tk == NULL && sta->pairwise_cipher == WPA_CIPHER_TKIP)
  321. tkip_get_pn(pn, data);
  322. else if (sta->pairwise_cipher == WPA_CIPHER_WEP40)
  323. goto skip_replay_det;
  324. else
  325. ccmp_get_pn(pn, data);
  326. if (os_memcmp(pn, rsc, 6) <= 0) {
  327. u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
  328. add_note(wt, MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
  329. " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
  330. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  331. MAC2STR(hdr->addr3),
  332. WLAN_GET_SEQ_SEQ(seq_ctrl),
  333. WLAN_GET_SEQ_FRAG(seq_ctrl));
  334. wpa_hexdump(MSG_INFO, "RX PN", pn, 6);
  335. wpa_hexdump(MSG_INFO, "RSC", rsc, 6);
  336. }
  337. skip_replay_det:
  338. if (tk)
  339. decrypted = ccmp_decrypt(tk, hdr, data, len, &dlen);
  340. else if (sta->pairwise_cipher == WPA_CIPHER_TKIP)
  341. decrypted = tkip_decrypt(sta->ptk.tk1, hdr, data, len, &dlen);
  342. else if (sta->pairwise_cipher == WPA_CIPHER_WEP40)
  343. decrypted = wep_decrypt(wt, hdr, data, len, &dlen);
  344. else if (sta->ptk_set)
  345. decrypted = ccmp_decrypt(sta->ptk.tk1, hdr, data, len, &dlen);
  346. else {
  347. decrypted = try_all_ptk(wt, sta->pairwise_cipher, hdr, data,
  348. len, &dlen);
  349. ptk_iter_done = 1;
  350. }
  351. if (!decrypted && !ptk_iter_done) {
  352. decrypted = try_all_ptk(wt, sta->pairwise_cipher, hdr, data,
  353. len, &dlen);
  354. if (decrypted) {
  355. add_note(wt, MSG_DEBUG, "Current PTK did not work, but found a match from all known PTKs");
  356. }
  357. }
  358. if (decrypted) {
  359. u16 fc = le_to_host16(hdr->frame_control);
  360. const u8 *peer_addr = NULL;
  361. if (!(fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)))
  362. peer_addr = hdr->addr1;
  363. os_memcpy(rsc, pn, 6);
  364. rx_data_process(wt, bss->bssid, sta->addr, dst, src, decrypted,
  365. dlen, 1, peer_addr);
  366. write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
  367. decrypted, dlen);
  368. } else if (!try_ptk_iter)
  369. add_note(wt, MSG_DEBUG, "Failed to decrypt frame");
  370. os_free(decrypted);
  371. }
  372. static void rx_data_bss(struct wlantest *wt, const struct ieee80211_hdr *hdr,
  373. const u8 *qos, const u8 *dst, const u8 *src,
  374. const u8 *data, size_t len)
  375. {
  376. u16 fc = le_to_host16(hdr->frame_control);
  377. int prot = !!(fc & WLAN_FC_ISWEP);
  378. if (qos) {
  379. u8 ack = (qos[0] & 0x60) >> 5;
  380. wpa_printf(MSG_MSGDUMP, "BSS DATA: " MACSTR " -> " MACSTR
  381. " len=%u%s tid=%u%s%s",
  382. MAC2STR(src), MAC2STR(dst), (unsigned int) len,
  383. prot ? " Prot" : "", qos[0] & 0x0f,
  384. (qos[0] & 0x10) ? " EOSP" : "",
  385. ack == 0 ? "" :
  386. (ack == 1 ? " NoAck" :
  387. (ack == 2 ? " NoExpAck" : " BA")));
  388. } else {
  389. wpa_printf(MSG_MSGDUMP, "BSS DATA: " MACSTR " -> " MACSTR
  390. " len=%u%s",
  391. MAC2STR(src), MAC2STR(dst), (unsigned int) len,
  392. prot ? " Prot" : "");
  393. }
  394. if (prot)
  395. rx_data_bss_prot(wt, hdr, qos, dst, src, data, len);
  396. else {
  397. const u8 *bssid, *sta_addr, *peer_addr;
  398. if (fc & WLAN_FC_TODS) {
  399. bssid = hdr->addr1;
  400. sta_addr = hdr->addr2;
  401. peer_addr = NULL;
  402. } else if (fc & WLAN_FC_FROMDS) {
  403. bssid = hdr->addr2;
  404. sta_addr = hdr->addr1;
  405. peer_addr = NULL;
  406. } else {
  407. bssid = hdr->addr3;
  408. sta_addr = hdr->addr2;
  409. peer_addr = hdr->addr1;
  410. }
  411. rx_data_process(wt, bssid, sta_addr, dst, src, data, len, 0,
  412. peer_addr);
  413. }
  414. }
  415. static struct wlantest_tdls * get_tdls(struct wlantest *wt, const u8 *bssid,
  416. const u8 *sta1_addr,
  417. const u8 *sta2_addr)
  418. {
  419. struct wlantest_bss *bss;
  420. struct wlantest_sta *sta1, *sta2;
  421. struct wlantest_tdls *tdls, *found = NULL;
  422. bss = bss_find(wt, bssid);
  423. if (bss == NULL)
  424. return NULL;
  425. sta1 = sta_find(bss, sta1_addr);
  426. if (sta1 == NULL)
  427. return NULL;
  428. sta2 = sta_find(bss, sta2_addr);
  429. if (sta2 == NULL)
  430. return NULL;
  431. dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) {
  432. if ((tdls->init == sta1 && tdls->resp == sta2) ||
  433. (tdls->init == sta2 && tdls->resp == sta1)) {
  434. found = tdls;
  435. if (tdls->link_up)
  436. break;
  437. }
  438. }
  439. return found;
  440. }
  441. static void add_direct_link(struct wlantest *wt, const u8 *bssid,
  442. const u8 *sta1_addr, const u8 *sta2_addr)
  443. {
  444. struct wlantest_tdls *tdls;
  445. tdls = get_tdls(wt, bssid, sta1_addr, sta2_addr);
  446. if (tdls == NULL)
  447. return;
  448. if (tdls->link_up)
  449. tdls->counters[WLANTEST_TDLS_COUNTER_VALID_DIRECT_LINK]++;
  450. else
  451. tdls->counters[WLANTEST_TDLS_COUNTER_INVALID_DIRECT_LINK]++;
  452. }
  453. static void add_ap_path(struct wlantest *wt, const u8 *bssid,
  454. const u8 *sta1_addr, const u8 *sta2_addr)
  455. {
  456. struct wlantest_tdls *tdls;
  457. tdls = get_tdls(wt, bssid, sta1_addr, sta2_addr);
  458. if (tdls == NULL)
  459. return;
  460. if (tdls->link_up)
  461. tdls->counters[WLANTEST_TDLS_COUNTER_INVALID_AP_PATH]++;
  462. else
  463. tdls->counters[WLANTEST_TDLS_COUNTER_VALID_AP_PATH]++;
  464. }
  465. void rx_data(struct wlantest *wt, const u8 *data, size_t len)
  466. {
  467. const struct ieee80211_hdr *hdr;
  468. u16 fc, stype;
  469. size_t hdrlen;
  470. const u8 *qos = NULL;
  471. if (len < 24)
  472. return;
  473. hdr = (const struct ieee80211_hdr *) data;
  474. fc = le_to_host16(hdr->frame_control);
  475. stype = WLAN_FC_GET_STYPE(fc);
  476. hdrlen = 24;
  477. if ((fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) ==
  478. (WLAN_FC_TODS | WLAN_FC_FROMDS))
  479. hdrlen += ETH_ALEN;
  480. if (stype & 0x08) {
  481. qos = data + hdrlen;
  482. hdrlen += 2;
  483. }
  484. if (len < hdrlen)
  485. return;
  486. wt->rx_data++;
  487. switch (fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) {
  488. case 0:
  489. wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s IBSS DA=" MACSTR " SA="
  490. MACSTR " BSSID=" MACSTR,
  491. data_stype(WLAN_FC_GET_STYPE(fc)),
  492. fc & WLAN_FC_PWRMGT ? " PwrMgt" : "",
  493. fc & WLAN_FC_ISWEP ? " Prot" : "",
  494. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  495. MAC2STR(hdr->addr3));
  496. add_direct_link(wt, hdr->addr3, hdr->addr1, hdr->addr2);
  497. rx_data_bss(wt, hdr, qos, hdr->addr1, hdr->addr2,
  498. data + hdrlen, len - hdrlen);
  499. break;
  500. case WLAN_FC_FROMDS:
  501. wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s FromDS DA=" MACSTR
  502. " BSSID=" MACSTR " SA=" MACSTR,
  503. data_stype(WLAN_FC_GET_STYPE(fc)),
  504. fc & WLAN_FC_PWRMGT ? " PwrMgt" : "",
  505. fc & WLAN_FC_ISWEP ? " Prot" : "",
  506. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  507. MAC2STR(hdr->addr3));
  508. add_ap_path(wt, hdr->addr2, hdr->addr1, hdr->addr3);
  509. rx_data_bss(wt, hdr, qos, hdr->addr1, hdr->addr3,
  510. data + hdrlen, len - hdrlen);
  511. break;
  512. case WLAN_FC_TODS:
  513. wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s ToDS BSSID=" MACSTR
  514. " SA=" MACSTR " DA=" MACSTR,
  515. data_stype(WLAN_FC_GET_STYPE(fc)),
  516. fc & WLAN_FC_PWRMGT ? " PwrMgt" : "",
  517. fc & WLAN_FC_ISWEP ? " Prot" : "",
  518. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  519. MAC2STR(hdr->addr3));
  520. add_ap_path(wt, hdr->addr1, hdr->addr3, hdr->addr2);
  521. rx_data_bss(wt, hdr, qos, hdr->addr3, hdr->addr2,
  522. data + hdrlen, len - hdrlen);
  523. break;
  524. case WLAN_FC_TODS | WLAN_FC_FROMDS:
  525. wpa_printf(MSG_EXCESSIVE, "DATA %s%s%s WDS RA=" MACSTR " TA="
  526. MACSTR " DA=" MACSTR " SA=" MACSTR,
  527. data_stype(WLAN_FC_GET_STYPE(fc)),
  528. fc & WLAN_FC_PWRMGT ? " PwrMgt" : "",
  529. fc & WLAN_FC_ISWEP ? " Prot" : "",
  530. MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
  531. MAC2STR(hdr->addr3),
  532. MAC2STR((const u8 *) (hdr + 1)));
  533. break;
  534. }
  535. }