diff mbox

supplicant: Use ap_vendor_elements in probe and assoc requests.

Message ID 1459556709-14720-1-git-send-email-greearb@candelatech.com
State Changes Requested
Headers show

Commit Message

Ben Greear April 2, 2016, 12:25 a.m. UTC
From: Ben Greear <greearb@candelatech.com>

This lets user specify additional IEs for probe requests and
association requests.  This patch re-uses much of the existing
ap_vendor_elements support in wpa_supplicant.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 wpa_supplicant/scan.c           |  8 ++++++++
 wpa_supplicant/sme.c            | 14 ++++++++++++++
 wpa_supplicant/wpa_supplicant.c | 13 +++++++++++++
 3 files changed, 35 insertions(+)

Comments

Jouni Malinen April 2, 2016, 10:25 a.m. UTC | #1
On Fri, Apr 01, 2016 at 08:25:09PM -0400, greearb@candelatech.com wrote:
> This lets user specify additional IEs for probe requests and
> association requests.  This patch re-uses much of the existing
> ap_vendor_elements support in wpa_supplicant.

I could understand adding configuration option for additional IEs in
Probe Request and Association Request frames, but I don't understand why
this would reuse ap_vendor_elements which is both named and documented
as applying to AP and P2P GO mode. That's just asking for problems since
the existing parameter is already in use and the set of IEs in various
management frames is different. Even the Probe Request and Association
Request frame cases are so different, that it would likely make more
sense to have separate parameters for each of those.
Ben Greear April 2, 2016, 3:23 p.m. UTC | #2
On 04/02/2016 03:25 AM, Jouni Malinen wrote:
> On Fri, Apr 01, 2016 at 08:25:09PM -0400, greearb@candelatech.com wrote:
>> This lets user specify additional IEs for probe requests and
>> association requests.  This patch re-uses much of the existing
>> ap_vendor_elements support in wpa_supplicant.
>
> I could understand adding configuration option for additional IEs in
> Probe Request and Association Request frames, but I don't understand why
> this would reuse ap_vendor_elements which is both named and documented
> as applying to AP and P2P GO mode. That's just asking for problems since
> the existing parameter is already in use and the set of IEs in various
> management frames is different. Even the Probe Request and Association
> Request frame cases are so different, that it would likely make more
> sense to have separate parameters for each of those.

Ok, I'll make new config entries.  How does 'probe_ie' and 'assoc_ie'
sound for a names?

Thanks,
Ben
Jouni Malinen April 2, 2016, 4:39 p.m. UTC | #3
On Sat, Apr 02, 2016 at 08:23:37AM -0700, Ben Greear wrote:
> On 04/02/2016 03:25 AM, Jouni Malinen wrote:
> >management frames is different. Even the Probe Request and Association
> >Request frame cases are so different, that it would likely make more
> >sense to have separate parameters for each of those.
> 
> Ok, I'll make new config entries.  How does 'probe_ie' and 'assoc_ie'
> sound for a names?

It would be a bit clearer if those were to include "req" in then to make
it more obvious that these do not apply from the AP mode response frame.
In other words, probe_req_ie and assoc_req_ie.
diff mbox

Patch

diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 619654b..2f68a90 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -512,6 +512,14 @@  static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
 		wpas_mbo_scan_ie(wpa_s, extra_ie);
 #endif /* CONFIG_MBO */
 
+	/* Add user-specified IE */
+	if (wpa_s->conf->ap_vendor_elements) {
+		int ln = wpabuf_len(wpa_s->conf->ap_vendor_elements);
+		if (wpabuf_resize(&extra_ie, ln) == 0) {
+			wpabuf_put_buf(extra_ie, wpa_s->conf->ap_vendor_elements);
+		}
+	}
+
 	return extra_ie;
 }
 
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index a6ace1a..35cadcc 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -464,6 +464,20 @@  static void sme_send_authentication(struct wpa_supplicant *wpa_s,
 		os_memcpy(pos, ext_capab, ext_capab_len);
 	}
 
+	/* Add user-specified IE */
+	if (wpa_s->conf->ap_vendor_elements) {
+		int v_ies_len = wpabuf_len(wpa_s->conf->ap_vendor_elements);
+
+		if (wpa_s->sme.assoc_req_ie_len + v_ies_len <= sizeof(wpa_s->sme.assoc_req_ie)) {
+			os_memcpy(wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
+				  wpabuf_head(wpa_s->conf->ap_vendor_elements), v_ies_len);
+			wpa_s->sme.assoc_req_ie_len += v_ies_len;
+			wpa_msg(wpa_s, MSG_INFO, "SME: added user-specified vendor elements, len: %d",
+				v_ies_len);
+		}
+	}
+
+
 #ifdef CONFIG_HS20
 	if (is_hs20_network(wpa_s, ssid, bss)) {
 		struct wpabuf *hs20;
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 3df1b7d..d3644d4 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2434,6 +2434,19 @@  static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
 	}
 #endif /* CONFIG_MBO */
 
+	/* Add user-specified IE */
+	if (wpa_s->conf->ap_vendor_elements) {
+		int v_ies_len = wpabuf_len(wpa_s->conf->ap_vendor_elements);
+
+		if (wpa_ie_len + v_ies_len <= sizeof(wpa_ie)) {
+			os_memcpy(wpa_ie + wpa_ie_len,
+				  wpabuf_head(wpa_s->conf->ap_vendor_elements), v_ies_len);
+			wpa_ie_len += v_ies_len;
+			wpa_msg(wpa_s, MSG_INFO, "start-assoc-cb, added user-specified vendor elements, len: %d",
+				v_ies_len);
+		}
+	}
+
 	wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
 	use_crypt = 1;
 	cipher_pairwise = wpa_s->pairwise_cipher;