aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/rx_data.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2011-01-24 12:50:51 (GMT)
committerJouni Malinen <j@w1.fi>2011-01-24 12:50:51 (GMT)
commit244c9303cb148f96e6e7bbd0c5b24479ce4df3b8 (patch)
tree0874f90b38a681ae9497e0b9fc65fe5b03443488 /wlantest/rx_data.c
parent719e7eb28d5679e9a3c7e44366a80d4403bc5cdc (diff)
downloadhostap-244c9303cb148f96e6e7bbd0c5b24479ce4df3b8.zip
hostap-244c9303cb148f96e6e7bbd0c5b24479ce4df3b8.tar.gz
hostap-244c9303cb148f96e6e7bbd0c5b24479ce4df3b8.tar.bz2
wlantest: Determine ping matches properly for direct link
Check ICMP echo request/response matches for both STAs to get proper counter values for a ping from a one STA to another one using TDLS.
Diffstat (limited to 'wlantest/rx_data.c')
-rw-r--r--wlantest/rx_data.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/wlantest/rx_data.c b/wlantest/rx_data.c
index 95daaf2..9e04321 100644
--- a/wlantest/rx_data.c
+++ b/wlantest/rx_data.c
@@ -61,14 +61,16 @@ static const char * data_stype(u16 stype)
static void rx_data_eth(struct wlantest *wt, const u8 *bssid,
const u8 *sta_addr, const u8 *dst, const u8 *src,
- u16 ethertype, const u8 *data, size_t len, int prot)
+ u16 ethertype, const u8 *data, size_t len, int prot,
+ const u8 *peer_addr)
{
switch (ethertype) {
case ETH_P_PAE:
rx_data_eapol(wt, dst, src, data, len, prot);
break;
case ETH_P_IP:
- rx_data_ip(wt, bssid, sta_addr, dst, src, data, len);
+ rx_data_ip(wt, bssid, sta_addr, dst, src, data, len,
+ peer_addr);
break;
case 0x890d:
rx_data_80211_encap(wt, bssid, sta_addr, dst, src, data, len);
@@ -80,14 +82,16 @@ static void rx_data_eth(struct wlantest *wt, const u8 *bssid,
static void rx_data_process(struct wlantest *wt, const u8 *bssid,
const u8 *sta_addr,
const u8 *dst, const u8 *src,
- const u8 *data, size_t len, int prot)
+ const u8 *data, size_t len, int prot,
+ const u8 *peer_addr)
{
if (len == 0)
return;
if (len >= 8 && os_memcmp(data, "\xaa\xaa\x03\x00\x00\x00", 6) == 0) {
rx_data_eth(wt, bssid, sta_addr, dst, src,
- WPA_GET_BE16(data + 6), data + 8, len - 8, prot);
+ WPA_GET_BE16(data + 6), data + 8, len - 8, prot,
+ peer_addr);
return;
}
@@ -181,7 +185,7 @@ skip_replay_det:
&dlen);
if (decrypted) {
rx_data_process(wt, bss->bssid, NULL, dst, src, decrypted,
- dlen, 1);
+ dlen, 1, NULL);
os_memcpy(bss->rsc[keyid], pn, 6);
write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
decrypted, dlen);
@@ -334,8 +338,12 @@ skip_replay_det:
else
decrypted = ccmp_decrypt(sta->ptk.tk1, hdr, data, len, &dlen);
if (decrypted) {
+ u16 fc = le_to_host16(hdr->frame_control);
+ u8 *peer_addr = NULL;
+ if (!(fc & (WLAN_FC_FROMDS | WLAN_FC_TODS)))
+ peer_addr = hdr->addr1;
rx_data_process(wt, bss->bssid, sta->addr, dst, src, decrypted,
- dlen, 1);
+ dlen, 1, peer_addr);
os_memcpy(rsc, pn, 6);
write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
decrypted, dlen);
@@ -371,15 +379,23 @@ static void rx_data_bss(struct wlantest *wt, const struct ieee80211_hdr *hdr,
if (prot)
rx_data_bss_prot(wt, hdr, qos, dst, src, data, len);
else {
- const u8 *bssid, *sta_addr;
+ const u8 *bssid, *sta_addr, *peer_addr;
+ int direct_link = !(fc & (WLAN_FC_FROMDS | WLAN_FC_TODS));
if (fc & WLAN_FC_TODS) {
bssid = hdr->addr1;
sta_addr = hdr->addr2;
- } else {
+ peer_addr = NULL;
+ } else if (fc & WLAN_FC_FROMDS) {
bssid = hdr->addr2;
sta_addr = hdr->addr1;
+ peer_addr = NULL;
+ } else {
+ bssid = hdr->addr3;
+ sta_addr = hdr->addr2;
+ peer_addr = hdr->addr1;
}
- rx_data_process(wt, bssid, sta_addr, dst, src, data, len, 0);
+ rx_data_process(wt, bssid, sta_addr, dst, src, data, len, 0,
+ peer_addr);
}
}