Q1-Add vendor IE
Topics in this section,
In this section, you are going to learn
How to add vendor IE in Probe-Request, Association-Request 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 Probe-Request, Association-Request similar to SSID IE
Call flow for add vendor ie in Probe-request
ieee80211_scan ()
ieee80211_request_scan ()
__ieee80211_start_scan ()
ieee80211_prep_hw_scan ()
ieee80211_build_preq_ies ()
ieee80211_put_preq_ies ()
ieee80211_put_preq_ies_band ()
drv_add_vendor_ie ()
Call flow for add vendor ie in Association-Request
ieee80211_add_iface ()
ieee80211_if_add ()
ieee80211_setup_sdata ()
ieee80211_iface_work ()
ieee80211_sta_work ()
ieee80211_do_assoc ()
ieee80211_send_assoc ()
drv_add_vendor_ie ()
Download the below patch file
add_vendor_ie_prob_assoc_req.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/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_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/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/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
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
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-01 22:02:39.356695722 +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-01 22:02:39.548599719 +0530
***************
*** 716,719 ****
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "BB095EE77446E94801FEB4A");
--- 716,719 ----
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "835924CB0693AC10A97FD9F");
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
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-01 22:02:39.552597719 +0530
***************
*** 1544,1550 ****
ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT);
}
!
static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
--- 1544,1550 ----
ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT);
}
! 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;
***************
*** 1701,1706 ****
--- 1701,1709 ----
*pos++ = WLAN_EID_SSID;
*pos++ = assoc_data->ssid_len;
memcpy(pos, assoc_data->ssid, assoc_data->ssid_len);
+ ret = drv_add_vendor_ie(skb);
+ if (ret)
+ return ret;
/*
* This bit is technically reserved, so it shouldn't matter for either
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
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/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-01 22:02:39.552597719 +0530
***************
*** 1188,1193 ****
--- 1188,1213 ----
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,
***************
*** 1220,1226 ****
~rate_mask, WLAN_EID_SUPP_RATES);
if (err)
return err;
!
/* insert "request information" if in custom IEs */
if (ie && ie_len) {
static const u8 before_extrates[] = {
--- 1240,1248 ----
~rate_mask, WLAN_EID_SUPP_RATES);
if (err)
return err;
! err = drv_add_vendor_ie(skb);
! if (err)
! return err;
/* insert "request information" if in custom IEs */
if (ie && ie_len) {
static const u8 before_extrates[] = {
***************
*** 1234,1240 ****
*offset);
if (skb_tailroom(skb) < noffset - *offset)
return -ENOBUFS;
! skb_put_data(skb, ie + *offset, noffset - *offset);
*offset = noffset;
}
--- 1256,1262 ----
*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/wme.o and changed/net/mac80211/wme.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_prob_assoc_req.patch
patching file net/mac80211/link.c
patching file net/mac80211/mac80211.mod.c
patching file net/mac80211/mlme.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_prob_assoc_req.pcapng
Check for probe request packet
Click on packet No.34 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 request packet
Click on packet No.113 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.
