]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Add application extension data to WPS IE
authorBilal Hatipoglu <bilal.hatipoglu@airties.com>
Fri, 3 Jan 2020 08:58:26 +0000 (11:58 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 4 Jan 2020 21:39:30 +0000 (23:39 +0200)
Application Extension attribute is defined in WSC tech spec v2.07 page
104. Allow hostapd to be configured to add this extension into WPS IE in
Beacon and Probe Response frames. The implementation is very similar to
vendor extension.

A new optional entry called "wps_application_ext" is added to hostapd
config file to configure this. It enodes the payload of the Application
Extension attribute in hexdump format.

Signed-off-by: Veli Demirel <veli.demirel@airties.com>
Signed-off-by: Bilal Hatipoglu <bilal.hatipoglu@airties.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.c
src/ap/ap_config.h
src/ap/wps_hostapd.c
src/wps/wps.h
src/wps/wps_dev_attr.c
src/wps/wps_dev_attr.h
src/wps/wps_registrar.c

index 53a8687a9b9be7184937230848431f5d00ddf5dc..89e02a59a105043e89bf052d34a606dae93aaa08 100644 (file)
@@ -3762,6 +3762,9 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "server_id") == 0) {
                os_free(bss->server_id);
                bss->server_id = os_strdup(pos);
+       } else if (os_strcmp(buf, "wps_application_ext") == 0) {
+               wpabuf_free(bss->wps_application_ext);
+               bss->wps_application_ext = wpabuf_parse_bin(pos);
 #ifdef CONFIG_WPS_NFC
        } else if (os_strcmp(buf, "wps_nfc_dev_pw_id") == 0) {
                bss->wps_nfc_dev_pw_id = atoi(pos);
index 263a04e8f01ad23634491ee5adf6f3f9209b72b5..10a6291ff09d8a9c06fc576f1866dd74d26f0acc 100644 (file)
@@ -2205,6 +2205,13 @@ own_ip_addr=127.0.0.1
 #wps_nfc_dh_privkey: Hexdump of DH Private Key
 #wps_nfc_dev_pw: Hexdump of Device Password
 
+# Application Extension attribute for Beacon and Probe Response frames
+# This parameter can be used to add application extension into WPS IE. The
+# contents of this parameter starts with 16-octet (32 hexdump characters) of
+# UUID to identify the specific application and that is followed by the actual
+# application specific data.
+#wps_application_ext=<hexdump>
+
 ##### Wi-Fi Direct (P2P) ######################################################
 
 # Enable P2P Device management
index 945f05285b639d0df0e87aabbd0ec1c5490b7ef1..cc041441c53e261e4597d92a2e13c06a7b919ee7 100644 (file)
@@ -813,6 +813,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
        os_free(conf->upc);
        for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
                wpabuf_free(conf->wps_vendor_ext[i]);
+       wpabuf_free(conf->wps_application_ext);
        wpabuf_free(conf->wps_nfc_dh_pubkey);
        wpabuf_free(conf->wps_nfc_dh_privkey);
        wpabuf_free(conf->wps_nfc_dev_pw);
index a74eac0835f4ba573a5381284dfa565af9c0a771..1efdc2b4320b7332b7f15feb20e5bb7f5fe3c05b 100644 (file)
@@ -498,6 +498,7 @@ struct hostapd_bss_config {
        char *model_url;
        char *upc;
        struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
+       struct wpabuf *wps_application_ext;
        int wps_nfc_pw_from_config;
        int wps_nfc_dev_pw_id;
        struct wpabuf *wps_nfc_dh_pubkey;
index 175b9fc09d2b05f47edb25dad1c4904b3beb13dd..3ea2228a90f7ae093d1d70c340c6c1403d1b4d28 100644 (file)
@@ -985,6 +985,21 @@ static int hostapd_wps_set_vendor_ext(struct hostapd_data *hapd,
 }
 
 
+static int hostapd_wps_set_application_ext(struct hostapd_data *hapd,
+                                          struct wps_context *wps)
+{
+       wpabuf_free(wps->dev.application_ext);
+
+       if (!hapd->conf->wps_application_ext) {
+               wps->dev.application_ext = NULL;
+               return 0;
+       }
+
+       wps->dev.application_ext = wpabuf_dup(hapd->conf->wps_application_ext);
+       return wps->dev.application_ext ? 0 : -1;
+}
+
+
 static void hostapd_free_wps(struct wps_context *wps)
 {
        int i;
@@ -1074,7 +1089,8 @@ int hostapd_init_wps(struct hostapd_data *hapd,
        os_memcpy(wps->dev.pri_dev_type, hapd->conf->device_type,
                  WPS_DEV_TYPE_LEN);
 
-       if (hostapd_wps_set_vendor_ext(hapd, wps) < 0)
+       if (hostapd_wps_set_vendor_ext(hapd, wps) < 0 ||
+           hostapd_wps_set_application_ext(hapd, wps) < 0)
                goto fail;
 
        wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version);
@@ -1311,6 +1327,7 @@ void hostapd_update_wps(struct hostapd_data *hapd)
 #endif /* CONFIG_WPS_UPNP */
 
        hostapd_wps_set_vendor_ext(hapd, hapd->wps);
+       hostapd_wps_set_application_ext(hapd, hapd->wps);
 
        if (hapd->conf->wps_state)
                wps_registrar_update_ie(hapd->wps->registrar);
index 9963c46875518791a501b74a0642c7f4c2f6f9db..f42045e9387dae8e120918c1189375bd04677931 100644 (file)
@@ -98,6 +98,7 @@ struct wps_device_data {
        u16 config_methods;
        struct wpabuf *vendor_ext_m1;
        struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
+       struct wpabuf *application_ext;
 
        int p2p;
        u8 multi_ap_ext;
index b209fea8a4f2045de68814bcdb6176475ecc4a16..c2e949cb6f21db5ee4a8a264817516c5e194e92b 100644 (file)
@@ -242,6 +242,21 @@ int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg)
 }
 
 
+int wps_build_application_ext(struct wps_device_data *dev, struct wpabuf *msg)
+{
+       if (!dev->application_ext)
+               return 0;
+
+       wpa_hexdump_buf(MSG_DEBUG, "WPS:  * Application Extension",
+                       dev->application_ext);
+       wpabuf_put_be16(msg, ATTR_APPLICATION_EXT);
+       wpabuf_put_be16(msg, wpabuf_len(dev->application_ext));
+       wpabuf_put_buf(msg, dev->application_ext);
+
+       return 0;
+}
+
+
 static int wps_process_manufacturer(struct wps_device_data *dev, const u8 *str,
                                    size_t str_len)
 {
@@ -424,4 +439,6 @@ void wps_device_data_free(struct wps_device_data *dev)
        dev->model_number = NULL;
        os_free(dev->serial_number);
        dev->serial_number = NULL;
+       wpabuf_free(dev->application_ext);
+       dev->application_ext = NULL;
 }
index a4b4173cdbaf4aa8c4aa76402a23d9167a0d99bd..81fdd5f4e95812afc3086cdb237e2226819b023b 100644 (file)
@@ -33,6 +33,7 @@ void wps_process_vendor_ext_m1(struct wps_device_data *dev, const u8 ext);
 int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands);
 void wps_device_data_free(struct wps_device_data *dev);
 int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg);
+int wps_build_application_ext(struct wps_device_data *dev, struct wpabuf *msg);
 int wps_build_req_dev_type(struct wps_device_data *dev, struct wpabuf *msg,
                           unsigned int num_req_dev_types,
                           const u8 *req_dev_types);
index 671f5fed76b4d8c7deb6f559afa9695dd5f67ba2..da81d1adc4da43d88efc2fb9cb98e6fb42101b2e 100644 (file)
@@ -1331,7 +1331,8 @@ static int wps_set_ie(struct wps_registrar *reg)
            wps_build_sel_pbc_reg_uuid_e(reg, beacon) ||
            (reg->dualband && wps_build_rf_bands(&reg->wps->dev, beacon, 0)) ||
            wps_build_wfa_ext(beacon, 0, auth_macs, count, 0) ||
-           wps_build_vendor_ext(&reg->wps->dev, beacon)) {
+           wps_build_vendor_ext(&reg->wps->dev, beacon) ||
+           wps_build_application_ext(&reg->wps->dev, beacon)) {
                wpabuf_free(beacon);
                wpabuf_free(probe);
                return -1;
@@ -1361,7 +1362,8 @@ static int wps_set_ie(struct wps_registrar *reg)
            wps_build_probe_config_methods(reg, probe) ||
            (reg->dualband && wps_build_rf_bands(&reg->wps->dev, probe, 0)) ||
            wps_build_wfa_ext(probe, 0, auth_macs, count, 0) ||
-           wps_build_vendor_ext(&reg->wps->dev, probe)) {
+           wps_build_vendor_ext(&reg->wps->dev, probe) ||
+           wps_build_application_ext(&reg->wps->dev, probe)) {
                wpabuf_free(beacon);
                wpabuf_free(probe);
                return -1;