Skip to content

Commit 732b539

Browse files
jmalinenjmberg-intel
authored andcommitted
mac80211_hwsim: Update timestamp in Probe Response frames
Previously, this was done only for Beacon frames, but similar timestamp update is needed for Probe Response frames to make these more accurately match the real IEEE 802.11 behavior. Previously, all zeros timestamp was sent in Probe Response frames. Signed-off-by: Jouni Malinen <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent c39b336 commit 732b539

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
12501250
{
12511251
struct mac80211_hwsim_data *data = hw->priv;
12521252
struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb);
1253+
struct ieee80211_hdr *hdr = (void *)skb->data;
12531254
struct ieee80211_chanctx_conf *chanctx_conf;
12541255
struct ieee80211_channel *channel;
12551256
bool ack;
@@ -1295,6 +1296,22 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
12951296
ARRAY_SIZE(txi->control.rates));
12961297

12971298
txi->rate_driver_data[0] = channel;
1299+
1300+
if (skb->len >= 24 + 8 &&
1301+
ieee80211_is_probe_resp(hdr->frame_control)) {
1302+
/* fake header transmission time */
1303+
struct ieee80211_mgmt *mgmt;
1304+
struct ieee80211_rate *txrate;
1305+
u64 ts;
1306+
1307+
mgmt = (struct ieee80211_mgmt *)skb->data;
1308+
txrate = ieee80211_get_tx_rate(hw, txi);
1309+
ts = mac80211_hwsim_get_tsf_raw();
1310+
mgmt->u.probe_resp.timestamp =
1311+
cpu_to_le64(ts + data->tsf_offset +
1312+
24 * 8 * 10 / txrate->bitrate);
1313+
}
1314+
12981315
mac80211_hwsim_monitor_rx(hw, skb, channel);
12991316

13001317
/* wmediumd mode check */

0 commit comments

Comments
 (0)