]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Add multi_ap_subelem to wps_build_wfa_ext()
authorArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tue, 12 Feb 2019 14:35:24 +0000 (15:35 +0100)
committerJouni Malinen <j@w1.fi>
Mon, 18 Feb 2019 18:30:26 +0000 (20:30 +0200)
The Multi-AP specification adds a new subelement to the WFA extension
element in the WPS exchange. Add an additional parameter to
wps_build_wfa_ext() to add this subelement. The subelement is only added
if the parameter is nonzero. Note that we don't reuse the existing
MULTI_AP_SUB_ELEM_TYPE definition here, but rather define a new
WFA_ELEM_MULTI_AP, to make sure the enum of WFA subelement types for WPS
vendor extension remains complete.

For now, all callers set the multi_ap_subelem parameter to 0.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
src/p2p/p2p_build.c
src/wps/wps.c
src/wps/wps_attr_build.c
src/wps/wps_common.c
src/wps/wps_defs.h
src/wps/wps_enrollee.c
src/wps/wps_er.c
src/wps/wps_i.h
src/wps/wps_registrar.c
src/wps/wps_upnp.c

index 2882c6ad02e7eb85fff43224b8c2013d05fc95a1..63eb2e84c3762cb2327770b881fb04ed0c20b60c 100644 (file)
@@ -802,7 +802,7 @@ int p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
                wpabuf_put_be16(buf, p2p->cfg->config_methods);
        }
 
-       if (wps_build_wfa_ext(buf, 0, NULL, 0) < 0)
+       if (wps_build_wfa_ext(buf, 0, NULL, 0, 0) < 0)
                return -1;
 
        if (all_attr && p2p->cfg->num_sec_dev_types) {
index 8d228270ff10c2f1e92d366da2330c97de9d11e8..c162e793d567b56a75738602d89dba0df16156cf 100644 (file)
@@ -430,7 +430,7 @@ struct wpabuf * wps_build_assoc_req_ie(enum wps_request_type req_type)
 
        if (wps_build_version(ie) ||
            wps_build_req_type(ie, req_type) ||
-           wps_build_wfa_ext(ie, 0, NULL, 0)) {
+           wps_build_wfa_ext(ie, 0, NULL, 0, 0)) {
                wpabuf_free(ie);
                return NULL;
        }
@@ -464,7 +464,7 @@ struct wpabuf * wps_build_assoc_resp_ie(void)
 
        if (wps_build_version(ie) ||
            wps_build_resp_type(ie, WPS_RESP_AP) ||
-           wps_build_wfa_ext(ie, 0, NULL, 0)) {
+           wps_build_wfa_ext(ie, 0, NULL, 0, 0)) {
                wpabuf_free(ie);
                return NULL;
        }
@@ -516,7 +516,7 @@ struct wpabuf * wps_build_probe_req_ie(u16 pw_id, struct wps_device_data *dev,
            wps_build_model_name(dev, ie) ||
            wps_build_model_number(dev, ie) ||
            wps_build_dev_name(dev, ie) ||
-           wps_build_wfa_ext(ie, req_type == WPS_REQ_ENROLLEE, NULL, 0) ||
+           wps_build_wfa_ext(ie, req_type == WPS_REQ_ENROLLEE, NULL, 0, 0) ||
            wps_build_req_dev_type(dev, ie, num_req_dev_types, req_dev_types)
            ||
            wps_build_secondary_dev_type(dev, ie)
index 7dfa95b799002ea31c351654a5545875ea4cce16..4e872f37295c1f6312a1c1f8886f2501ea8b4f15 100644 (file)
@@ -204,7 +204,8 @@ int wps_build_version(struct wpabuf *msg)
 
 
 int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll,
-                     const u8 *auth_macs, size_t auth_macs_count)
+                     const u8 *auth_macs, size_t auth_macs_count,
+                     u8 multi_ap_subelem)
 {
        u8 *len;
 
@@ -245,6 +246,14 @@ int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll,
                                   MAC2STR(&auth_macs[i * ETH_ALEN]));
        }
 
+       if (multi_ap_subelem) {
+               wpa_printf(MSG_DEBUG, "WPS:  * Multi-AP (0x%x)",
+                          multi_ap_subelem);
+               wpabuf_put_u8(msg, WFA_ELEM_MULTI_AP);
+               wpabuf_put_u8(msg, 1); /* length */
+               wpabuf_put_u8(msg, multi_ap_subelem);
+       }
+
        WPA_PUT_BE16(len, (u8 *) wpabuf_put(msg, 0) - len - 2);
 
 #ifdef CONFIG_WPS_TESTING
index bcae1ba5887b67faf437b249ffb5302d57ad64fc..747dc4710b20ba38ac6b450355275bf1d8310d8c 100644 (file)
@@ -374,7 +374,7 @@ struct wpabuf * wps_get_oob_cred(struct wps_context *wps, int rf_band,
            (rf_band && wps_build_rf_bands_attr(plain, rf_band)) ||
            (channel && wps_build_ap_channel(plain, channel)) ||
            wps_build_mac_addr(plain, wps->dev.mac_addr) ||
-           wps_build_wfa_ext(plain, 0, NULL, 0)) {
+           wps_build_wfa_ext(plain, 0, NULL, 0, 0)) {
                os_free(data.new_psk);
                wpabuf_clear_free(plain);
                return NULL;
@@ -421,7 +421,7 @@ struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id,
 
        if (wps_build_oob_dev_pw(data, dev_pw_id, pubkey,
                                 wpabuf_head(dev_pw), wpabuf_len(dev_pw)) ||
-           wps_build_wfa_ext(data, 0, NULL, 0)) {
+           wps_build_wfa_ext(data, 0, NULL, 0, 0)) {
                wpa_printf(MSG_ERROR, "WPS: Failed to build NFC password "
                           "token");
                wpabuf_clear_free(data);
@@ -586,7 +586,7 @@ struct wpabuf * wps_build_wsc_ack(struct wps_data *wps)
            wps_build_msg_type(msg, WPS_WSC_ACK) ||
            wps_build_enrollee_nonce(wps, msg) ||
            wps_build_registrar_nonce(wps, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -610,7 +610,7 @@ struct wpabuf * wps_build_wsc_nack(struct wps_data *wps)
            wps_build_enrollee_nonce(wps, msg) ||
            wps_build_registrar_nonce(wps, msg) ||
            wps_build_config_error(msg, wps->config_error) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -726,7 +726,7 @@ struct wpabuf * wps_build_nfc_handover_req(struct wps_context *ctx,
        if (wps_build_oob_dev_pw(msg, DEV_PW_NFC_CONNECTION_HANDOVER,
                                 nfc_dh_pubkey, NULL, 0) ||
            wps_build_uuid_e(msg, ctx->uuid) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -809,7 +809,7 @@ struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
            wps_build_ssid(msg, ctx) ||
            wps_build_ap_freq(msg, freq) ||
            (bssid && wps_build_mac_addr(msg, bssid)) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -848,7 +848,7 @@ struct wpabuf * wps_build_nfc_handover_req_p2p(struct wps_context *ctx,
            wps_build_rf_bands(&ctx->dev, msg, 0) ||
            wps_build_serial_number(&ctx->dev, msg) ||
            wps_build_uuid_e(msg, ctx->uuid) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -900,7 +900,7 @@ struct wpabuf * wps_build_nfc_handover_sel_p2p(struct wps_context *ctx,
            wps_build_rf_bands(&ctx->dev, msg, 0) ||
            wps_build_serial_number(&ctx->dev, msg) ||
            wps_build_uuid_e(msg, ctx->uuid) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
index 301864da433d028a743b5f03abddb55d0a26722e..9fccb4eeb5c102f68fd544233f82b9b838f8e4b4 100644 (file)
@@ -152,7 +152,8 @@ enum {
        WFA_ELEM_NETWORK_KEY_SHAREABLE = 0x02,
        WFA_ELEM_REQUEST_TO_ENROLL = 0x03,
        WFA_ELEM_SETTINGS_DELAY_TIME = 0x04,
-       WFA_ELEM_REGISTRAR_CONFIGURATION_METHODS = 0x05
+       WFA_ELEM_REGISTRAR_CONFIGURATION_METHODS = 0x05,
+       WFA_ELEM_MULTI_AP = 0x06
 };
 
 /* Device Password ID */
index 417507740d7aa7010afb7ae7ee7397d653198920..4786582af4d57e39b53b7a466c933932f13bc857 100644 (file)
@@ -152,7 +152,7 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
            wps_build_dev_password_id(msg, wps->dev_pw_id) ||
            wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
            wps_build_os_version(&wps->wps->dev, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_vendor_ext_m1(&wps->wps->dev, msg)) {
                wpabuf_free(msg);
                return NULL;
@@ -190,7 +190,7 @@ static struct wpabuf * wps_build_m3(struct wps_data *wps)
            wps_build_msg_type(msg, WPS_M3) ||
            wps_build_registrar_nonce(wps, msg) ||
            wps_build_e_hash(wps, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_free(msg);
                return NULL;
@@ -223,7 +223,7 @@ static struct wpabuf * wps_build_m5(struct wps_data *wps)
            wps_build_e_snonce1(wps, plain) ||
            wps_build_key_wrap_auth(wps, plain) ||
            wps_build_encr_settings(wps, msg, plain) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_clear_free(plain);
                wpabuf_free(msg);
@@ -393,7 +393,7 @@ static struct wpabuf * wps_build_m7(struct wps_data *wps)
            (wps->wps->ap && wps_build_ap_settings(wps, plain)) ||
            wps_build_key_wrap_auth(wps, plain) ||
            wps_build_encr_settings(wps, msg, plain) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_clear_free(plain);
                wpabuf_free(msg);
@@ -430,7 +430,7 @@ static struct wpabuf * wps_build_wsc_done(struct wps_data *wps)
            wps_build_msg_type(msg, WPS_WSC_DONE) ||
            wps_build_enrollee_nonce(wps, msg) ||
            wps_build_registrar_nonce(wps, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
index affd6a4af38a376708a9a3cc31fcf4145bbb4a33..06a8fdaf3459ccfd138940c93bba309056ec72f2 100644 (file)
@@ -1530,7 +1530,7 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
            wps_er_build_selected_registrar(msg, sel_reg) ||
            wps_er_build_dev_password_id(msg, dev_passwd_id) ||
            wps_er_build_sel_reg_config_methods(msg, sel_reg_config_methods) ||
-           wps_build_wfa_ext(msg, 0, auth_macs, count) ||
+           wps_build_wfa_ext(msg, 0, auth_macs, count, 0) ||
            wps_er_build_uuid_r(msg, er->wps->uuid)) {
                wpabuf_free(msg);
                return;
@@ -2048,7 +2048,7 @@ struct wpabuf * wps_er_config_token_from_cred(struct wps_context *wps,
        data.wps = wps;
        data.use_cred = cred;
        if (wps_build_cred(&data, ret) ||
-           wps_build_wfa_ext(ret, 0, NULL, 0)) {
+           wps_build_wfa_ext(ret, 0, NULL, 0, 0)) {
                wpabuf_free(ret);
                return NULL;
        }
index fe0c60bd120bf340a3807373159588d1041b7f8e..7972fc2258e6540802bcbcebf1047ce7e4ff5fe8 100644 (file)
@@ -163,7 +163,8 @@ int wps_build_encr_settings(struct wps_data *wps, struct wpabuf *msg,
                            struct wpabuf *plain);
 int wps_build_version(struct wpabuf *msg);
 int wps_build_wfa_ext(struct wpabuf *msg, int req_to_enroll,
-                     const u8 *auth_macs, size_t auth_macs_count);
+                     const u8 *auth_macs, size_t auth_macs_count,
+                     u8 multi_ap_subelem);
 int wps_build_msg_type(struct wpabuf *msg, enum wps_msg_type msg_type);
 int wps_build_enrollee_nonce(struct wps_data *wps, struct wpabuf *msg);
 int wps_build_registrar_nonce(struct wps_data *wps, struct wpabuf *msg);
index 379925e3f0a9e249fb297fc19a784fe6537e5872..b5ac29bea621651b95f3ab034f61479fa6668b57 100644 (file)
@@ -1281,7 +1281,7 @@ static int wps_set_ie(struct wps_registrar *reg)
            wps_build_sel_reg_config_methods(reg, beacon) ||
            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) ||
+           wps_build_wfa_ext(beacon, 0, auth_macs, count, 0) ||
            wps_build_vendor_ext(&reg->wps->dev, beacon)) {
                wpabuf_free(beacon);
                wpabuf_free(probe);
@@ -1311,7 +1311,7 @@ static int wps_set_ie(struct wps_registrar *reg)
            wps_build_device_attrs(&reg->wps->dev, probe) ||
            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) ||
+           wps_build_wfa_ext(probe, 0, auth_macs, count, 0) ||
            wps_build_vendor_ext(&reg->wps->dev, probe)) {
                wpabuf_free(beacon);
                wpabuf_free(probe);
@@ -1845,7 +1845,7 @@ static struct wpabuf * wps_build_m2(struct wps_data *wps)
            wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
            wps_build_dev_password_id(msg, wps->dev_pw_id) ||
            wps_build_os_version(&wps->wps->dev, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -1913,7 +1913,7 @@ static struct wpabuf * wps_build_m2d(struct wps_data *wps)
            wps_build_assoc_state(wps, msg) ||
            wps_build_config_error(msg, err) ||
            wps_build_os_version(&wps->wps->dev, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }
@@ -1949,7 +1949,7 @@ static struct wpabuf * wps_build_m4(struct wps_data *wps)
            wps_build_r_snonce1(wps, plain) ||
            wps_build_key_wrap_auth(wps, plain) ||
            wps_build_encr_settings(wps, msg, plain) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_clear_free(plain);
                wpabuf_free(msg);
@@ -1984,7 +1984,7 @@ static struct wpabuf * wps_build_m6(struct wps_data *wps)
            wps_build_r_snonce2(wps, plain) ||
            wps_build_key_wrap_auth(wps, plain) ||
            wps_build_encr_settings(wps, msg, plain) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_clear_free(plain);
                wpabuf_free(msg);
@@ -2021,7 +2021,7 @@ static struct wpabuf * wps_build_m8(struct wps_data *wps)
            (!wps->wps->ap && !wps->er && wps_build_ap_settings(wps, plain)) ||
            wps_build_key_wrap_auth(wps, plain) ||
            wps_build_encr_settings(wps, msg, plain) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0, 0) ||
            wps_build_authenticator(wps, msg)) {
                wpabuf_clear_free(plain);
                wpabuf_clear_free(msg);
index 0c458c6adef9de4fd25b35ee660ba6ef8c6ca7df..ca893a43c64b4dc437f058e9e5ab47a43455556d 100644 (file)
@@ -599,7 +599,7 @@ static struct wpabuf * build_fake_wsc_ack(void)
        wpabuf_put_be16(msg, ATTR_REGISTRAR_NONCE);
        wpabuf_put_be16(msg, WPS_NONCE_LEN);
        wpabuf_put(msg, WPS_NONCE_LEN);
-       if (wps_build_wfa_ext(msg, 0, NULL, 0)) {
+       if (wps_build_wfa_ext(msg, 0, NULL, 0, 0)) {
                wpabuf_free(msg);
                return NULL;
        }