Q7-Add vendor IE
Topics in this section,
In this section, you are going to learn
How to add vendor ie in beacons, probe-response, assoc-response similar to ssid ie
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.2 |
Supplicant |
wpa_supplicant 2.10 |
Hostapd |
hostapd 2.10 |
Add vendor IE in Beacons, Probe-Response, Assoc-Response similar to SSID IE
Callflow for add vendor ie in beacons
ieee80211_beacon_get_tim
__ieee80211_beacon_get
ieee80211_beacon_get_ap
drv_add_vendor_ie
Callflow for add vendor ie in probe-response, assoc-response
ieee80211_mgmt_tx
ieee80211_tx_skb_tid
__ieee80211_tx_skb_tid_band
ieee80211_xmit
ieee80211_tx
drv_add_vendor_ie
Download the below patch file
add_vendor_ie_in_beacons_prob_assoc_res.patch
See the full content of patch file
Binary files original/net/mac80211/agg-rx.o and changed/net/mac80211/agg-rx.o differ
Binary files original/net/mac80211/agg-tx.o and changed/net/mac80211/agg-tx.o differ
Binary files original/net/mac80211/airtime.o and changed/net/mac80211/airtime.o differ
Binary files original/net/mac80211/cfg.o and changed/net/mac80211/cfg.o differ
Binary files original/net/mac80211/chan.o and changed/net/mac80211/chan.o differ
Binary files original/net/mac80211/debugfs_key.o and changed/net/mac80211/debugfs_key.o differ
Binary files original/net/mac80211/debugfs_netdev.o and changed/net/mac80211/debugfs_netdev.o differ
Binary files original/net/mac80211/debugfs.o and changed/net/mac80211/debugfs.o differ
Binary files original/net/mac80211/debugfs_sta.o and changed/net/mac80211/debugfs_sta.o differ
Binary files original/net/mac80211/driver-ops.o and changed/net/mac80211/driver-ops.o differ
Binary files original/net/mac80211/eht.o and changed/net/mac80211/eht.o differ
Binary files original/net/mac80211/ethtool.o and changed/net/mac80211/ethtool.o differ
Binary files original/net/mac80211/fils_aead.o and changed/net/mac80211/fils_aead.o differ
Binary files original/net/mac80211/he.o and changed/net/mac80211/he.o differ
Binary files original/net/mac80211/ht.o and changed/net/mac80211/ht.o differ
Binary files original/net/mac80211/ibss.o and changed/net/mac80211/ibss.o differ
diff -crB original/net/mac80211/ieee80211_i.h changed/net/mac80211/ieee80211_i.h
*** original/net/mac80211/ieee80211_i.h 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/ieee80211_i.h 2024-08-02 12:31:17.691283737 +0530
***************
*** 599,604 ****
--- 599,605 ----
/* dialog token enumerator for neg TTLM request */
u8 dialog_token_alloc;
struct wiphy_delayed_work neg_ttlm_timeout_work;
+ int drv_sta_data ;
};
struct ieee80211_if_ibss {
Binary files original/net/mac80211/iface.o and changed/net/mac80211/iface.o differ
Binary files original/net/mac80211/key.o and changed/net/mac80211/key.o differ
Binary files original/net/mac80211/led.o and changed/net/mac80211/led.o differ
diff -crB original/net/mac80211/link.c changed/net/mac80211/link.c
*** original/net/mac80211/link.c 2024-07-11 19:39:07.644259000 +0530
--- changed/net/mac80211/link.c 2024-08-02 12:31:17.531363740 +0530
***************
*** 250,258 ****
ieee80211_link_setup(&link->data);
}
! if (new_links == 0)
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
ret = ieee80211_check_dup_link_addrs(sdata);
if (!ret) {
--- 249,258 ----
ieee80211_link_setup(&link->data);
}
! if (new_links == 0) {
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
+ }
ret = ieee80211_check_dup_link_addrs(sdata);
if (!ret) {
***************
*** 291,299 ****
links[link_id] = NULL;
}
deinit:
! if (use_deflink)
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
return ret;
}
--- 291,300 ----
links[link_id] = NULL;
}
deinit:
! if (use_deflink) {
ieee80211_link_init(sdata, -1, &sdata->deflink,
&sdata->vif.bss_conf);
+ }
return ret;
}
Binary files original/net/mac80211/link.o and changed/net/mac80211/link.o differ
Binary files original/net/mac80211/mac80211.ko and changed/net/mac80211/mac80211.ko differ
diff -crB original/net/mac80211/mac80211.mod.c changed/net/mac80211/mac80211.mod.c
*** original/net/mac80211/mac80211.mod.c 2024-07-11 19:39:07.824257000 +0530
--- changed/net/mac80211/mac80211.mod.c 2024-08-02 12:31:17.687285738 +0530
***************
*** 716,719 ****
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "BB095EE77446E94801FEB4A");
--- 716,719 ----
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "DA78421F5B708BD38AD24C8");
Binary files original/net/mac80211/mac80211.mod.o and changed/net/mac80211/mac80211.mod.o differ
Binary files original/net/mac80211/mac80211.o and changed/net/mac80211/mac80211.o differ
Binary files original/net/mac80211/main.o and changed/net/mac80211/main.o differ
Binary files original/net/mac80211/mesh_hwmp.o and changed/net/mac80211/mesh_hwmp.o differ
Binary files original/net/mac80211/mesh.o and changed/net/mac80211/mesh.o differ
Binary files original/net/mac80211/mesh_pathtbl.o and changed/net/mac80211/mesh_pathtbl.o differ
Binary files original/net/mac80211/mesh_plink.o and changed/net/mac80211/mesh_plink.o differ
Binary files original/net/mac80211/mesh_ps.o and changed/net/mac80211/mesh_ps.o differ
Binary files original/net/mac80211/mesh_sync.o and changed/net/mac80211/mesh_sync.o differ
diff -crB original/net/mac80211/mlme.c changed/net/mac80211/mlme.c
*** original/net/mac80211/mlme.c 2024-07-11 19:39:07.648259000 +0530
--- changed/net/mac80211/mlme.c 2024-08-02 12:31:17.531363740 +0530
***************
*** 1545,1550 ****
--- 1545,1552 ----
ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT);
}
+ extern int drv_add_vendor_ie(struct sk_buff *skb);
+
static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
Binary files original/net/mac80211/mlme.o and changed/net/mac80211/mlme.o differ
Binary files original/net/mac80211/ocb.o and changed/net/mac80211/ocb.o differ
Binary files original/net/mac80211/offchannel.o and changed/net/mac80211/offchannel.o differ
Binary files original/net/mac80211/parse.o and changed/net/mac80211/parse.o differ
Binary files original/net/mac80211/pm.o and changed/net/mac80211/pm.o differ
Binary files original/net/mac80211/rate.o and changed/net/mac80211/rate.o differ
Binary files original/net/mac80211/rc80211_minstrel_ht.o and changed/net/mac80211/rc80211_minstrel_ht.o differ
diff -crB original/net/mac80211/rx.c changed/net/mac80211/rx.c
*** original/net/mac80211/rx.c 2024-07-11 19:39:07.648259000 +0530
--- changed/net/mac80211/rx.c 2024-08-02 12:31:17.539359740 +0530
***************
*** 3991,3996 ****
--- 3991,3998 ----
return RX_QUEUED;
}
+ extern int drv_add_vendor_ie(struct sk_buff *skb);
+
static ieee80211_rx_result debug_noinline
ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
{
Binary files original/net/mac80211/rx.o and changed/net/mac80211/rx.o differ
Binary files original/net/mac80211/s1g.o and changed/net/mac80211/s1g.o differ
Binary files original/net/mac80211/scan.o and changed/net/mac80211/scan.o differ
Binary files original/net/mac80211/spectmgmt.o and changed/net/mac80211/spectmgmt.o differ
Binary files original/net/mac80211/sta_info.o and changed/net/mac80211/sta_info.o differ
Binary files original/net/mac80211/status.o and changed/net/mac80211/status.o differ
Binary files original/net/mac80211/tdls.o and changed/net/mac80211/tdls.o differ
Binary files original/net/mac80211/tkip.o and changed/net/mac80211/tkip.o differ
Binary files original/net/mac80211/trace.o and changed/net/mac80211/trace.o differ
diff -crB original/net/mac80211/tx.c changed/net/mac80211/tx.c
*** original/net/mac80211/tx.c 2024-07-11 19:39:07.652259000 +0530
--- changed/net/mac80211/tx.c 2024-08-02 12:31:17.531363740 +0530
***************
*** 1926,1931 ****
--- 1926,1933 ----
}
EXPORT_SYMBOL(ieee80211_tx_prepare_skb);
+ extern int drv_add_vendor_ie(struct sk_buff *skb);
+
/*
* Returns false if the frame couldn't be transmitted but was queued instead.
*/
***************
*** 1943,1949 ****
dev_kfree_skb(skb);
return true;
}
!
/* initialises tx */
res_prepare = ieee80211_tx_prepare(sdata, &tx, sta, skb);
--- 1945,1957 ----
dev_kfree_skb(skb);
return true;
}
! struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
! if(ieee80211_is_assoc_resp(hdr->frame_control) || ieee80211_is_probe_resp(hdr->frame_control) )
! {
! int ret = drv_add_vendor_ie(skb);
! if (ret)
! return ret;
! }
/* initialises tx */
res_prepare = ieee80211_tx_prepare(sdata, &tx, sta, skb);
***************
*** 5345,5357 ****
/* for AP the csa offsets are from tail */
csa_off_base = skb->len;
}
-
if (beacon->tail)
skb_put_data(skb, beacon->tail, beacon->tail_len);
if (ieee80211_beacon_protect(skb, local, sdata, link) < 0)
return NULL;
ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb,
chanctx_conf, csa_off_base);
return skb;
--- 5353,5370 ----
/* for AP the csa offsets are from tail */
csa_off_base = skb->len;
}
if (beacon->tail)
skb_put_data(skb, beacon->tail, beacon->tail_len);
if (ieee80211_beacon_protect(skb, local, sdata, link) < 0)
return NULL;
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+
+ if(ieee80211_is_beacon(hdr->frame_control))
+ {
+ drv_add_vendor_ie(skb);
+ }
ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb,
chanctx_conf, csa_off_base);
return skb;
Binary files original/net/mac80211/tx.o and changed/net/mac80211/tx.o differ
diff -crB original/net/mac80211/util.c changed/net/mac80211/util.c
*** original/net/mac80211/util.c 2024-07-11 19:39:07.652259000 +0530
--- changed/net/mac80211/util.c 2024-08-02 12:31:17.547355740 +0530
***************
*** 1188,1193 ****
--- 1188,1211 ----
return 0;
}
+ int drv_add_vendor_ie(struct sk_buff *skb);
+
+ static const u8 data_vendor_ie[] = {
+ 0x00, 0x5, 0x0f2, /*OUI_MICROSOFT: Microsoft (also used in Wi-Fi specs) 00:50:F2 */
+ 0x11, 0x22, 0x33, 0x44, 0x55 /* CUSTOM DATA */
+ };
+
+ int drv_add_vendor_ie(struct sk_buff *skb)
+ {
+
+ if (skb_tailroom(skb) < (2+sizeof(data_vendor_ie)))
+ return -ENOBUFS;
+ skb_put_u8(skb, WLAN_EID_VENDOR_SPECIFIC);
+ skb_put_u8(skb, ARRAY_SIZE(data_vendor_ie));
+ skb_put_data(skb, data_vendor_ie, ARRAY_SIZE(data_vendor_ie));
+ return 0;
+ }
+
static int ieee80211_put_preq_ies_band(struct sk_buff *skb,
struct ieee80211_sub_if_data *sdata,
const u8 *ie, size_t ie_len,
***************
*** 1234,1240 ****
*offset);
if (skb_tailroom(skb) < noffset - *offset)
return -ENOBUFS;
! skb_put_data(skb, ie + *offset, noffset - *offset);
*offset = noffset;
}
--- 1251,1257 ----
*offset);
if (skb_tailroom(skb) < noffset - *offset)
return -ENOBUFS;
!
*offset = noffset;
}
Binary files original/net/mac80211/util.o and changed/net/mac80211/util.o differ
Binary files original/net/mac80211/vht.o and changed/net/mac80211/vht.o differ
Binary files original/net/mac80211/wbrf.o and changed/net/mac80211/wbrf.o differ
Binary files original/net/mac80211/wep.o and changed/net/mac80211/wep.o differ
Binary files original/net/mac80211/wme.o and changed/net/mac80211/wme.o differ
Binary files original/net/mac80211/wpa.o and changed/net/mac80211/wpa.o differ
test:~$ pwd
/home/test/
Compile Linux
Change directory to linux-6.9.2
test:~$ cd linux-6.9.2/
Note : Your present working directory should be linux-6.9.2
test:~$ pwd
/home/test/linux-6.9.2/
Remove mac80211 module
test:~$ sudo systemctl stop NetworkManager.service
test:~$ sudo rmmod mac80211
Run the below command to apply patch
test:~$ sudo patch -p1 < add_vendor_ie_in_beacons_prob_assoc_res.patch
patching file net/mac80211/ieee80211_i.h
patching file net/mac80211/link.c
patching file net/mac80211/mac80211.mod.c
patching file net/mac80211/mlme.c
patching file net/mac80211/rx.c
patching file net/mac80211/tx.c
patching file net/mac80211/util.c
Compile mac80211 folder
test:~$ sudo make -C . M=net/mac80211/
Insert mac80211 module
test:~$ sudo insmod ./net/mac80211/mac80211.ko
Download file to check wireshark output
add_vendor_ie_in_beacons_prob_assoc_res.pcapng
Check for beacon packet
Click on packet No.2 as shown in the image below

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: Vendor Specific: Power R, Inc.

Check for probe-response packet
Click on packet No.72 as shown in the image below

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: Vendor Specific: Power R, Inc.

Check for association response packet
Click on packet No.150 as shown in the image below

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: Vendor Specific: Power R, Inc.
