Q2-Add SSID IE
Topics in this section,
In this section, you are going to learn
How to add multiple SSID IE elements in Probe-Request, Association-Request
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.2 |
Supplicant |
wpa_supplicant 2.10 |
Hostapd |
hostapd 2.10 |
Add multiple SSID IE elements in Probe-Request, Association-Request
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_multiple_ssid_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_multiple_ssid_ie ()
Download the below patch file
add_multiple_ssid_ie_prob_assoc_req.patch
See the full content of patch file
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:55:34.976053128 +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) {
--- 250,259 ----
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;
}
--- 292,301 ----
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:55:34.980051128 +0530
***************
*** 716,719 ****
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "BB095EE77446E94801FEB4A");
--- 716,719 ----
MODULE_INFO(depends, "cfg80211,libarc4");
! MODULE_INFO(srcversion, "0C0176A335CFAFC904C98FC");
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
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:55:35.171955126 +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_multiple_ssid_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_multiple_ssid_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
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:55:35.167957126 +0530
***************
*** 1188,1193 ****
--- 1188,1216 ----
return 0;
}
+ int drv_add_multiple_ssid_ie(struct sk_buff *skb);
+
+ char data_ssid1_ie[] = "test_open_ssid1";
+ char data_ssid2_ie[] = "test_open_ssid2";
+
+ int drv_add_multiple_ssid_ie(struct sk_buff *skb)
+ {
+ if (skb_tailroom(skb) < (2 + sizeof(data_ssid1_ie)))
+ return -ENOBUFS;
+ skb_put_u8(skb, WLAN_EID_SSID);
+ skb_put_u8(skb, sizeof(data_ssid1_ie));
+ skb_put_data(skb, data_ssid1_ie, sizeof(data_ssid1_ie));
+
+
+ if (skb_tailroom(skb) < (2 + sizeof(data_ssid1_ie)))
+ return -ENOBUFS;
+ skb_put_u8(skb, WLAN_EID_SSID);
+ skb_put_u8(skb, sizeof(data_ssid1_ie));
+ skb_put_data(skb, data_ssid2_ie, sizeof(data_ssid1_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[] = {
--- 1243,1251 ----
~rate_mask, WLAN_EID_SUPP_RATES);
if (err)
return err;
! err = drv_add_multiple_ssid_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;
}
--- 1259,1265 ----
*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
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_multiple_ssid_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_multiple_ssid_ie_prob_assoc_req.pcapng
Check for probe request packet
Click on packet No.70 as shown in the image below

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: SSID parameter set : Undecoded

Check for association request packet
Click on packet No.149 as shown in the image below

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: SSID parameter set : Undecoded
