Q1-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 |
Hostapd |
hostapd 2.10 |
Add vendor IE in Beacons, Probe-Response, Assoc-Response similar to SSID IE
Call flow for add vendor ie in Beacons
main ()
hostapd_setup_interface ()
setup_interface ()
setup_interface2 ()
hostapd_setup_interface_complete ()
hostapd_setup_interface_complete_sync ()
hostapd_setup_bss ()
ieee802_11_set_beacon ()
__ieee802_11_set_beacon ()
ieee802_11_build_ap_params ()
ap_add_vendor_ie ()
Call flow for add vendor ie in Probe-Response
nl80211_global_init ()
wpa_driver_nl80211_init_nl_global ()
process_global_event ()
do_process_drv_event ()
mlme_event ()
mlme_event_mgmt ()
wpa_supplicant_event ()
hostapd_mgmt_rx ()
ieee802_11_mgmt ()
handle_probe_req ()
hostapd_gen_probe_resp ()
ap_add_vendor_ie ()
Call flow for add vendor ie in Assoc-Response
nl80211_global_init ()
wpa_driver_nl80211_init_nl_global ()
process_global_event ()
do_process_drv_event ()
mlme_event ()
mlme_event_mgmt ()
wpa_supplicant_event ()
hostapd_mgmt_rx ()
ieee802_11_mgmt ()
handle_assoc ()
send_assoc_resp ()
ap_add_vendor_ie ()
Download the below patch file
add_vendor_ie_beacons_prob_assoc_res.patch
See the full content of patch file
diff -crB original/hostapd-2.10/src/ap/beacon.c changed/hostapd-2.10/src/ap/beacon.c
*** original/hostapd-2.10/src/ap/beacon.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/beacon.c 2024-07-25 19:20:50.669434548 +0530
***************
*** 499,504 ****
--- 499,505 ----
*pos++ = hapd->conf->ssid.ssid_len;
os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len);
pos += hapd->conf->ssid.ssid_len;
+ pos = ap_add_vendor_ie(pos);
/* Supported rates */
pos = hostapd_eid_supp_rates(hapd, pos);
***************
*** 1515,1520 ****
--- 1516,1522 ----
hapd->conf->ssid.ssid_len);
pos += hapd->conf->ssid.ssid_len;
}
+ pos = ap_add_vendor_ie(pos);
/* Supported rates */
pos = hostapd_eid_supp_rates(hapd, pos);
diff -crB original/hostapd-2.10/src/ap/ieee802_11.c changed/hostapd-2.10/src/ap/ieee802_11.c
*** original/hostapd-2.10/src/ap/ieee802_11.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/ieee802_11.c 2024-07-25 19:21:07.529434287 +0530
***************
*** 5067,5072 ****
--- 5067,5074 ----
BIT(14) | BIT(15));
/* Supported rates */
p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
+ p = ap_add_vendor_ie(p);
+
/* Extended supported rates */
p = hostapd_eid_ext_supp_rates(hapd, p);
diff -crB original/hostapd-2.10/src/ap/ieee802_11.h changed/hostapd-2.10/src/ap/ieee802_11.h
*** original/hostapd-2.10/src/ap/ieee802_11.h 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/ieee802_11.h 2024-07-25 19:21:31.189433919 +0530
***************
*** 115,120 ****
--- 115,121 ----
u8 * hostapd_eid_adv_proto(struct hostapd_data *hapd, u8 *eid);
u8 * hostapd_eid_roaming_consortium(struct hostapd_data *hapd, u8 *eid);
u8 * hostapd_eid_time_adv(struct hostapd_data *hapd, u8 *eid);
+ u8 * ap_add_vendor_ie(u8 *eid);
u8 * hostapd_eid_time_zone(struct hostapd_data *hapd, u8 *eid);
int hostapd_update_time_adv(struct hostapd_data *hapd);
void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr);
diff -crB original/hostapd-2.10/src/ap/ieee802_11_shared.c changed/hostapd-2.10/src/ap/ieee802_11_shared.c
*** original/hostapd-2.10/src/ap/ieee802_11_shared.c 2022-01-17 02:21:29.000000000 +0530
--- changed/hostapd-2.10/src/ap/ieee802_11_shared.c 2024-07-25 19:22:06.989433364 +0530
***************
*** 625,630 ****
--- 625,647 ----
return eid;
}
+ char data_vendor_ie[] = {0x11, 0x22, 0x33, 0x44, 0x55};
+
+ u8 * ap_add_vendor_ie(u8 *eid)
+ {
+ size_t len;
+ len = os_strlen(data_vendor_ie);
+
+ *eid++ = WLAN_EID_VENDOR_SPECIFIC;
+ *eid++ = len + 3;
+ WPA_PUT_BE24(eid, OUI_WFA);
+ eid += 3;
+ os_memcpy(eid, data_vendor_ie, len);
+ eid += len;
+
+ return eid;
+ }
+
u8 * hostapd_eid_time_zone(struct hostapd_data *hapd, u8 *eid)
{
test:~$ pwd
/home/test
Make sure internet is available in laptop to download hostapd package
test:~$ sudo wget http://w1.fi/releases/hostapd-2.10.tar.gz
Create a directory
test:~$ mkdir hostapd
Change directory to hostapd
test:~$ cd hostapd
Note : Your present working directory should be hostapd
test:~$ pwd
/home/test/hostapd/
Extract hostapd
test:~$ sudo tar -xvf ~/hostapd-2.10.tar.gz
Run the below command to apply patch
test:~$ patch -p1 < add_vendor_ie_beacons_prob_assoc_res.patch
patching file hostapd-2.10/src/ap/beacon.c
patching file hostapd-2.10/src/ap/ieee802_11.c
patching file hostapd-2.10/src/ap/ieee802_11.h
patching file hostapd-2.10/src/ap/ieee802_11_shared.c
Change directory to hostapd
test:~$ cd hostapd-2.10/hostapd/
Check the current working directory using pwd command
Make sure your current working directory is hostapd
test:~$ pwd
/home/test/hostapd/hostapd-2.10/hostapd/
Copy the contents of defconfig file to .config file
test:~$ sudo cp defconfig .config
Compile hostapd
test:~$ sudo make
Create run_hostapd.conf
test:~$ sudo vim ./run_hostapd.conf
ctrl_interface=/run/hostapd
interface=wlan0
driver=nl80211
ssid=test_open
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
Run hostapd
test:~$ sudo ./hostapd ./run_hostapd.conf
Download file to check wireshark output
add_vendor_ie_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: Wi-Fi Alliance: Unknown

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

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: Vendor Specific: Wi-Fi Alliance: Unknown

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

Click on IEEE 802.11 Wireless Management
Click on Tagged parameters
Click on Tag: Vendor Specific: Wi-Fi Alliance: Unknown
