* Received frame processing
* Copyright (c) 2010, Jouni Malinen <j@w1.fi>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
*/
#include "utils/includes.h"
#include "utils/radiotap.h"
#include "utils/radiotap_iter.h"
#include "common/ieee802_11_defs.h"
+#include "common/qca-vendor.h"
#include "wlantest.h"
if (!to_ap) {
if (sta->pwrmgt && !sta->pspoll) {
u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
- wpa_printf(MSG_DEBUG, "AP " MACSTR " sent a frame "
- "(%u:%u) to a sleeping STA " MACSTR
- " (seq=%u)",
- MAC2STR(sta->bss->bssid),
- type, stype, MAC2STR(sta->addr),
- WLAN_GET_SEQ_SEQ(seq_ctrl));
+ add_note(wt, MSG_DEBUG, "AP " MACSTR " sent a frame "
+ "(%u:%u) to a sleeping STA " MACSTR
+ " (seq=%u)",
+ MAC2STR(sta->bss->bssid),
+ type, stype, MAC2STR(sta->addr),
+ WLAN_GET_SEQ_SEQ(seq_ctrl));
} else
sta->pspoll = 0;
return;
* maintain state through the frame exchange.
*/
if (sta->pwrmgt && !(fc & WLAN_FC_PWRMGT)) {
- wpa_printf(MSG_DEBUG, "STA " MACSTR " woke up from "
- "sleep", MAC2STR(sta->addr));
+ add_note(wt, MSG_DEBUG, "STA " MACSTR " woke up from "
+ "sleep", MAC2STR(sta->addr));
sta->pwrmgt = 0;
} else if (!sta->pwrmgt && (fc & WLAN_FC_PWRMGT)) {
- wpa_printf(MSG_DEBUG, "STA " MACSTR " went to sleep",
- MAC2STR(sta->addr));
+ add_note(wt, MSG_DEBUG, "STA " MACSTR " went to sleep",
+ MAC2STR(sta->addr));
sta->pwrmgt = 1;
}
}
if ((fc & WLAN_FC_RETRY) && hdr->seq_ctrl == *seq_ctrl) {
u16 s = le_to_host16(hdr->seq_ctrl);
- wpa_printf(MSG_MSGDUMP, "Ignore duplicated frame (seq=%u "
- "frag=%u A1=" MACSTR " A2=" MACSTR ")",
- WLAN_GET_SEQ_SEQ(s), WLAN_GET_SEQ_FRAG(s),
- MAC2STR(hdr->addr1), MAC2STR(hdr->addr2));
+ add_note(wt, MSG_MSGDUMP, "Ignore duplicated frame (seq=%u "
+ "frag=%u A1=" MACSTR " A2=" MACSTR ")",
+ WLAN_GET_SEQ_SEQ(s), WLAN_GET_SEQ_FRAG(s),
+ MAC2STR(hdr->addr1), MAC2STR(hdr->addr2));
return 1;
}
if (wt->last_len < 24 || (last->addr1[0] & 0x01) ||
os_memcmp(hdr->addr1, last->addr2, ETH_ALEN) != 0) {
- wpa_printf(MSG_MSGDUMP, "Unknown Ack frame (previous frame "
- "not seen)");
+ add_note(wt, MSG_MSGDUMP, "Unknown Ack frame (previous frame "
+ "not seen)");
return;
}
wpa_hexdump(MSG_EXCESSIVE, "Process data", data, len);
- if (ieee80211_radiotap_iterator_init(&iter, (void *) data, len)) {
- wpa_printf(MSG_INFO, "Invalid radiotap frame");
+ if (ieee80211_radiotap_iterator_init(&iter, (void *) data, len, NULL)) {
+ add_note(wt, MSG_INFO, "Invalid radiotap frame");
return;
}
if (ret == -ENOENT)
break;
if (ret) {
- wpa_printf(MSG_INFO, "Invalid radiotap header: %d",
- ret);
+ add_note(wt, MSG_INFO, "Invalid radiotap header: %d",
+ ret);
return;
}
switch (iter.this_arg_index) {
failed = le_to_host16((*(u16 *) iter.this_arg)) &
IEEE80211_RADIOTAP_F_TX_FAIL;
break;
-
+ case IEEE80211_RADIOTAP_VENDOR_NAMESPACE:
+ if (WPA_GET_BE24(iter.this_arg) == OUI_QCA &&
+ iter.this_arg[3] == QCA_RADIOTAP_VID_WLANTEST) {
+ add_note(wt, MSG_DEBUG,
+ "Skip frame inserted by wlantest");
+ return;
+ }
}
}
- if (iter.max_length == 8) {
- wpa_printf(MSG_DEBUG, "Skip frame inserted by wlantest");
- return;
- }
- frame = data + iter.max_length;
- frame_len = len - iter.max_length;
+ frame = data + iter._max_length;
+ frame_len = len - iter._max_length;
if (fcs && frame_len >= 4) {
frame_len -= 4;
fcspos = frame + frame_len;
if (check_fcs(frame, frame_len, fcspos) < 0) {
- wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
- "FCS");
+ add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+ "invalid FCS");
wt->fcs_error++;
return;
}
return;
if (!txflags)
rx_frame(wt, frame, frame_len);
- else
+ else {
+ add_note(wt, MSG_EXCESSIVE, "TX status - process as RX of "
+ "local frame");
tx_status(wt, frame, frame_len, !failed);
+ /* Process as RX frame to support local monitor interface */
+ rx_frame(wt, frame, frame_len);
+ }
}
frame_len -= 4;
fcspos = frame + frame_len;
if (check_fcs(frame, frame_len, fcspos) < 0) {
- wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
- "FCS");
+ add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+ "invalid FCS");
wt->fcs_error++;
return;
}
void wlantest_process_80211(struct wlantest *wt, const u8 *data, size_t len)
{
wpa_hexdump(MSG_EXCESSIVE, "Process data", data, len);
+
+ if (wt->assume_fcs && len >= 4) {
+ const u8 *fcspos;
+
+ len -= 4;
+ fcspos = data + len;
+ if (check_fcs(data, len, fcspos) < 0) {
+ add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+ "invalid FCS");
+ wt->fcs_error++;
+ return;
+ }
+ }
+
rx_frame(wt, data, len);
}