Add assocresp_elements parameter for hostapd
authorBala Krishna Bhamidipati <c_bbhami@qti.qualcomm.com>
Wed, 20 Apr 2016 04:04:17 +0000 (09:34 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 20 Apr 2016 10:12:50 +0000 (13:12 +0300)
This new parameter allows hostapd to add Vendor Specific elements into
(Re)Association Response frames similarly to the way vendor_elements
parameter can be used for Beacon and Probe Response frames.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.c
src/ap/ap_config.h
src/ap/ap_drv_ops.c
src/ap/ieee802_11.c

index bb7f3ea..93f25b2 100644 (file)
@@ -3379,6 +3379,36 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 
                wpabuf_free(bss->vendor_elements);
                bss->vendor_elements = elems;
+       } else if (os_strcmp(buf, "assocresp_elements") == 0) {
+               struct wpabuf *elems;
+               size_t len = os_strlen(pos);
+               if (len & 0x01) {
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: Invalid assocresp_elements '%s'",
+                                  line, pos);
+                       return 1;
+               }
+               len /= 2;
+               if (len == 0) {
+                       wpabuf_free(bss->assocresp_elements);
+                       bss->assocresp_elements = NULL;
+                       return 0;
+               }
+
+               elems = wpabuf_alloc(len);
+               if (elems == NULL)
+                       return 1;
+
+               if (hexstr2bin(pos, wpabuf_put(elems, len), len)) {
+                       wpabuf_free(elems);
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: Invalid assocresp_elements '%s'",
+                                  line, pos);
+                       return 1;
+               }
+
+               wpabuf_free(bss->assocresp_elements);
+               bss->assocresp_elements = elems;
        } else if (os_strcmp(buf, "sae_anti_clogging_threshold") == 0) {
                bss->sae_anti_clogging_threshold = atoi(pos);
        } else if (os_strcmp(buf, "sae_groups") == 0) {
index 9cecfc7..c62fc7e 100644 (file)
@@ -283,6 +283,13 @@ ignore_broadcast_ssid=0
 # one or more elements)
 #vendor_elements=dd0411223301
 
+# Additional vendor specific elements for (Re)Association Response frames
+# This parameter can be used to add additional vendor specific element(s) into
+# the end of the (Re)Association Response frames. The format for these
+# element(s) is a hexdump of the raw information elements (id+len+payload for
+# one or more elements)
+#assocresp_elements=dd0411223301
+
 # TX queue parameters (EDCF / bursting)
 # tx_queue_<queue name>_<param>
 # queues: data0, data1, data2, data3, after_beacon, beacon
index e7d7bb9..2345dd9 100644 (file)
@@ -567,6 +567,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 #endif /* CONFIG_HS20 */
 
        wpabuf_free(conf->vendor_elements);
+       wpabuf_free(conf->assocresp_elements);
 
        os_free(conf->sae_groups);
 
index 4c4659a..b263eb0 100644 (file)
@@ -557,6 +557,7 @@ struct hostapd_bss_config {
 #endif /* CONFIG_RADIUS_TEST */
 
        struct wpabuf *vendor_elements;
+       struct wpabuf *assocresp_elements;
 
        unsigned int sae_anti_clogging_threshold;
        int *sae_groups;
index a3f4dd9..dca6b8b 100644 (file)
@@ -179,6 +179,7 @@ int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
 
        add_buf(&beacon, hapd->conf->vendor_elements);
        add_buf(&proberesp, hapd->conf->vendor_elements);
+       add_buf(&assocresp, hapd->conf->assocresp_elements);
 
        *beacon_ret = beacon;
        *proberesp_ret = proberesp;
index c108faa..781afa2 100644 (file)
@@ -1960,6 +1960,14 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
 
        p = hostapd_eid_mbo(hapd, p, buf + sizeof(buf) - p);
 
+       if (hapd->conf->assocresp_elements &&
+           (size_t) (buf + sizeof(buf) - p) >=
+           wpabuf_len(hapd->conf->assocresp_elements)) {
+               os_memcpy(p, wpabuf_head(hapd->conf->assocresp_elements),
+                         wpabuf_len(hapd->conf->assocresp_elements));
+               p += wpabuf_len(hapd->conf->assocresp_elements);
+       }
+
        send_len += p - reply->u.assoc_resp.variable;
 
        if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0) {