Skip to content

Commit 05e54ea

Browse files
Kalle Valolinvjw
authored andcommitted
mac80211: create Probe Request template
Certain type of hardware, for example wl1251 and wl1271, need a template for the Probe Request. Create a function ieee80211_probereq_get() which creates the template and drivers send it to hardware. Signed-off-by: Kalle Valo <kalle.valo@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent f7f7057 commit 05e54ea

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

include/net/mac80211.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,23 @@ struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
19041904
struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
19051905
struct ieee80211_vif *vif);
19061906

1907+
/**
1908+
* ieee80211_probereq_get - retrieve a Probe Request template
1909+
* @hw: pointer obtained from ieee80211_alloc_hw().
1910+
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
1911+
* @ssid: SSID buffer
1912+
* @ssid_len: length of SSID
1913+
* @ie: buffer containing all IEs except SSID for the template
1914+
* @ie_len: length of the IE buffer
1915+
*
1916+
* Creates a Probe Request template which can, for example, be uploaded to
1917+
* hardware.
1918+
*/
1919+
struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
1920+
struct ieee80211_vif *vif,
1921+
const u8 *ssid, size_t ssid_len,
1922+
const u8 *ie, size_t ie_len);
1923+
19071924
/**
19081925
* ieee80211_rts_get - RTS frame generation function
19091926
* @hw: pointer obtained from ieee80211_alloc_hw().

net/mac80211/tx.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,56 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
22782278
}
22792279
EXPORT_SYMBOL(ieee80211_nullfunc_get);
22802280

2281+
struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
2282+
struct ieee80211_vif *vif,
2283+
const u8 *ssid, size_t ssid_len,
2284+
const u8 *ie, size_t ie_len)
2285+
{
2286+
struct ieee80211_sub_if_data *sdata;
2287+
struct ieee80211_local *local;
2288+
struct ieee80211_hdr_3addr *hdr;
2289+
struct sk_buff *skb;
2290+
size_t ie_ssid_len;
2291+
u8 *pos;
2292+
2293+
sdata = vif_to_sdata(vif);
2294+
local = sdata->local;
2295+
ie_ssid_len = 2 + ssid_len;
2296+
2297+
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) +
2298+
ie_ssid_len + ie_len);
2299+
if (!skb) {
2300+
printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
2301+
"request template\n", sdata->name);
2302+
return NULL;
2303+
}
2304+
2305+
skb_reserve(skb, local->hw.extra_tx_headroom);
2306+
2307+
hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr));
2308+
memset(hdr, 0, sizeof(*hdr));
2309+
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2310+
IEEE80211_STYPE_PROBE_REQ);
2311+
memset(hdr->addr1, 0xff, ETH_ALEN);
2312+
memcpy(hdr->addr2, vif->addr, ETH_ALEN);
2313+
memset(hdr->addr3, 0xff, ETH_ALEN);
2314+
2315+
pos = skb_put(skb, ie_ssid_len);
2316+
*pos++ = WLAN_EID_SSID;
2317+
*pos++ = ssid_len;
2318+
if (ssid)
2319+
memcpy(pos, ssid, ssid_len);
2320+
pos += ssid_len;
2321+
2322+
if (ie) {
2323+
pos = skb_put(skb, ie_len);
2324+
memcpy(pos, ie, ie_len);
2325+
}
2326+
2327+
return skb;
2328+
}
2329+
EXPORT_SYMBOL(ieee80211_probereq_get);
2330+
22812331
void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
22822332
const void *frame, size_t frame_len,
22832333
const struct ieee80211_tx_info *frame_txctl,

0 commit comments

Comments
 (0)