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 and Association-Request
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.2 |
Supplicant |
wpa_supplicant 2.10 |
Add multiple SSID IE elements in Probe-Request, Association-Request
Call flow for add multiple SSID IE elements in Probe-Request
main ()
wpa_supplicant_add_iface ()
wpa_supplicant_init_iface ()
wpa_supplicant_driver_init ()
wpa_supplicant_req_scan ()
wpa_supplicant_scan ()
wpa_supplicant_extra_ies ()
sta_build_multiple_ssid_ie ()
Call flow for add multiple SSID IE elements in Association-Request
nl80211_global_init ()
wpa_driver_nl80211_init_nl_global ()
process_global_event ()
do_process_drv_event ()
send_scan_event ()
process_global_event ()
do_process_drv_event ()
mlme_event ()
mlme_event_auth ()
wpa_supplicant_event ()
sme_event_auth ()
sme_associate ()
construct_vendor_ie ()
sta_construct_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/wpa_supplicant-2.10/wpa_supplicant/scan.c changed/wpa_supplicant-2.10/wpa_supplicant/scan.c
*** original/wpa_supplicant-2.10/wpa_supplicant/scan.c 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/wpa_supplicant/scan.c 2024-07-29 16:40:23.276221122 +0530
***************
*** 589,594 ****
--- 589,621 ----
}
+ unsigned char name_ie_1[]= { 0x74,0x65,0x73,0x74,0x5F,0x6F,0x70,0x65,0x6E,0x5F,0x73,0x73,0x69,0x64,0x31
+ };
+ unsigned char name_ie_2[]= { 0x74,0x65,0x73,0x74,0x5F,0x6F,0x70,0x65,0x6E,0x5F,0x73,0x73,0x69,0x64,0x31
+ };
+
+ void sta_build_multiple_ssid_ie(struct wpa_supplicant *wpa_s, struct wpabuf **extra_ie)
+ {
+ size_t buf_len;
+ buf_len = 1 + /* Element ID */
+ 1 + /* Length */
+ sizeof(name_ie_1);
+ if (wpabuf_resize(extra_ie, buf_len) == 0) {
+ wpabuf_put_u8(*extra_ie, WLAN_EID_SSID);
+ wpabuf_put_u8(*extra_ie, buf_len-2);
+ wpabuf_put_data(*extra_ie, name_ie_1, sizeof(name_ie_1));
+ }
+ buf_len = 1 + /* Element ID */
+ 1 + /* Length */
+ sizeof(name_ie_2);
+ if (wpabuf_resize(extra_ie, buf_len) == 0) {
+ wpabuf_put_u8(*extra_ie, WLAN_EID_SSID);
+ wpabuf_put_u8(*extra_ie, buf_len-2);
+ wpabuf_put_data(*extra_ie, name_ie_2, sizeof(name_ie_2));
+ }
+
+ }
+
static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
{
struct wpabuf *extra_ie = NULL;
***************
*** 674,681 ****
if (wpabuf_resize(&extra_ie, wpabuf_len(buf)) == 0)
wpabuf_put_buf(extra_ie, buf);
! }
!
return extra_ie;
}
--- 701,708 ----
if (wpabuf_resize(&extra_ie, wpabuf_len(buf)) == 0)
wpabuf_put_buf(extra_ie, buf);
! }
! sta_build_multiple_ssid_ie(wpa_s, &extra_ie);
return extra_ie;
}
diff -crB original/wpa_supplicant-2.10/wpa_supplicant/sme.c changed/wpa_supplicant-2.10/wpa_supplicant/sme.c
*** original/wpa_supplicant-2.10/wpa_supplicant/sme.c 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/wpa_supplicant/sme.c 2024-07-29 16:29:42.428231067 +0530
***************
*** 1721,1726 ****
--- 1721,1740 ----
}
#endif /* CONFIG_IEEE80211R */
+ unsigned char name_ie_assoc_1[]= {
+ 0x00,0x0F,0x74,0x65,0x73,0x74,0x5F,0x6F,0x70,0x65,0x6E,0x5F,0x73,0x73,0x69,0x64,0x31
+ };
+ unsigned char name_ie_assoc_2[]= {
+ 0x00,0x0F,0x74,0x65,0x73,0x74,0x5F,0x6F,0x70,0x65,0x6E,0x5F,0x73,0x73,0x69,0x64,0x32
+ };
+
+ void sta_construct_multiple_ssid_ie(struct wpa_supplicant *wpa_s)
+ {
+ os_memcpy(wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,name_ie_assoc_2,sizeof(name_ie_assoc_2));
+ wpa_s->sme.assoc_req_ie_len += sizeof(name_ie_assoc_2);
+ os_memcpy(wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,name_ie_assoc_1,sizeof(name_ie_assoc_1));
+ wpa_s->sme.assoc_req_ie_len += sizeof(name_ie_assoc_1);
+ }
void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
const u8 *bssid, u16 auth_type)
***************
*** 1957,1963 ****
}
wpa_s->sme.assoc_req_ie_len += multi_ap_ie_len;
}
!
params.bssid = bssid;
params.ssid = wpa_s->sme.ssid;
params.ssid_len = wpa_s->sme.ssid_len;
--- 1971,1977 ----
}
wpa_s->sme.assoc_req_ie_len += multi_ap_ie_len;
}
! sta_construct_multiple_ssid_ie(wpa_s);
params.bssid = bssid;
params.ssid = wpa_s->sme.ssid;
params.ssid_len = wpa_s->sme.ssid_len;
test:~$ pwd
/home/test
Make sure internet is available in laptop to download supplicant package
test:~$ sudo wget https://w1.fi/releases/wpa_supplicant-2.10.tar.gz
Create a directory
test:~$ mkdir supplicant
Change directory to supplicant
test:~$ cd supplicant
Note : Your present working directory should be supplicant
test:~$ pwd
/home/test/supplicant/
Extract wpa_supplicant
test:~$ sudo tar -xvf ~/wpa_supplicant-2.10.tar.gz
Run the below command to apply patch
test:~$ patch -p1 < add_multiple_ssid_ie_prob_assoc_req.patch
patching file wpa_supplicant-2.10/wpa_supplicant/scan.c
patching file wpa_supplicant-2.10/wpa_supplicant/sme.c
Change directory to wpa_supplicant
test:~$ cd wpa_supplicant-2.10/wpa_supplicant/
Check the current working directory using pwd command
Make sure your current working directory is wpa_supplicant
test:~$ pwd
/home/test/supplicant/wpa_supplicant-2.10/wpa_supplicant
Copy the contents of defconfig file to .config file
test:~$ sudo cp defconfig .config
Compile wpa_supplicant
test:~$ sudo make
Create run_supplicant.conf
test:~$ sudo vim ./run_supplicant.conf
ctrl_interface=/run/wpa_supplicant
update_config=1
network={
ssid="test_open"
key_mgmt=NONE
}
Run wpa_supplicant
test:~$ sudo ./wpa_supplicant -Dnl80211 -i wlan1 -c ./run_supplicant.conf
Download file to check wireshark output
add_multiple_ssid_ie_prob_assoc_req.pcapng
Check for probe request packet
Click on packet No.25 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.62 as shown in the image below

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