]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Store P2P Device Address in per-device PSK records
authorJouni Malinen <j@w1.fi>
Sun, 1 Sep 2013 07:47:34 +0000 (10:47 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 1 Sep 2013 07:47:34 +0000 (10:47 +0300)
This makes the P2P Device Address of the Enrollee available with the PSK
records to allow P2P Device Address instead of P2P Interface Address to
be used for finding the correct PSK.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/ap_config.h
src/ap/wps_hostapd.c
src/wps/wps.h
src/wps/wps_registrar.c
wpa_supplicant/wps_supplicant.c

index e2836456e8e566e2417640dc7b653a970c8da01e..1fd41afd6bceebef191e2ce2da147f5138b02191 100644 (file)
@@ -105,6 +105,7 @@ struct hostapd_wpa_psk {
        int group;
        u8 psk[PMK_LEN];
        u8 addr[ETH_ALEN];
+       u8 p2p_dev_addr[ETH_ALEN];
 };
 
 struct hostapd_eap_user {
index 4f627c894781cef9fded57923a3a9e8c2282ea7e..85eae35a211b9a93bf7bc347808805f5918568c7 100644 (file)
@@ -91,15 +91,24 @@ static int hostapd_wps_for_each(struct hostapd_data *hapd,
 }
 
 
-static int hostapd_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
+static int hostapd_wps_new_psk_cb(void *ctx, const u8 *mac_addr,
+                                 const u8 *p2p_dev_addr, const u8 *psk,
                                  size_t psk_len)
 {
        struct hostapd_data *hapd = ctx;
        struct hostapd_wpa_psk *p;
        struct hostapd_ssid *ssid = &hapd->conf->ssid;
 
-       wpa_printf(MSG_DEBUG, "Received new WPA/WPA2-PSK from WPS for STA "
-                  MACSTR, MAC2STR(mac_addr));
+       if (is_zero_ether_addr(p2p_dev_addr)) {
+               wpa_printf(MSG_DEBUG,
+                          "Received new WPA/WPA2-PSK from WPS for STA " MACSTR,
+                          MAC2STR(mac_addr));
+       } else {
+               wpa_printf(MSG_DEBUG,
+                          "Received new WPA/WPA2-PSK from WPS for STA " MACSTR
+                          " P2P Device Addr " MACSTR,
+                          MAC2STR(mac_addr), MAC2STR(p2p_dev_addr));
+       }
        wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len);
 
        if (psk_len != PMK_LEN) {
@@ -113,6 +122,7 @@ static int hostapd_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
        if (p == NULL)
                return -1;
        os_memcpy(p->addr, mac_addr, ETH_ALEN);
+       os_memcpy(p->p2p_dev_addr, p2p_dev_addr, ETH_ALEN);
        os_memcpy(p->psk, psk, PMK_LEN);
 
        p->next = ssid->wpa_psk;
index 2e6719f4033d650f9891bd0e773bd34612c436db..15137a8a8452225b9f92882dcc2453f615c57ff2 100644 (file)
@@ -246,14 +246,15 @@ struct wps_registrar_config {
         * new_psk_cb - Callback for new PSK
         * @ctx: Higher layer context data (cb_ctx)
         * @mac_addr: MAC address of the Enrollee
+        * @p2p_dev_addr: P2P Device Address of the Enrollee or all zeros if not
         * @psk: The new PSK
         * @psk_len: The length of psk in octets
         * Returns: 0 on success, -1 on failure
         *
         * This callback is called when a new per-device PSK is provisioned.
         */
-       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk,
-                         size_t psk_len);
+       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
+                         const u8 *psk, size_t psk_len);
 
        /**
         * set_ie_cb - Callback for WPS IE changes
index 20a8b7f62f919dd683cc3da204b3152b7ed6c19b..e8ebfab15fce8bde7756dd72a17837f8935f7a27 100644 (file)
@@ -142,8 +142,8 @@ struct wps_registrar {
        int pbc;
        int selected_registrar;
 
-       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk,
-                         size_t psk_len);
+       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
+                         const u8 *psk, size_t psk_len);
        int (*set_ie_cb)(void *ctx, struct wpabuf *beacon_ie,
                         struct wpabuf *probe_resp_ie);
        void (*pin_needed_cb)(void *ctx, const u8 *uuid_e,
@@ -1164,12 +1164,13 @@ void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr,
 
 
 static int wps_cb_new_psk(struct wps_registrar *reg, const u8 *mac_addr,
-                         const u8 *psk, size_t psk_len)
+                         const u8 *p2p_dev_addr, const u8 *psk, size_t psk_len)
 {
        if (reg->new_psk_cb == NULL)
                return 0;
 
-       return reg->new_psk_cb(reg->cb_ctx, mac_addr, psk, psk_len);
+       return reg->new_psk_cb(reg->cb_ctx, mac_addr, p2p_dev_addr, psk,
+                              psk_len);
 }
 
 
@@ -3168,7 +3169,8 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
 
        if (wps->new_psk) {
                if (wps_cb_new_psk(wps->wps->registrar, wps->mac_addr_e,
-                                  wps->new_psk, wps->new_psk_len)) {
+                                  wps->p2p_dev_addr, wps->new_psk,
+                                  wps->new_psk_len)) {
                        wpa_printf(MSG_DEBUG, "WPS: Failed to configure the "
                                   "new PSK");
                }
index b855dbd0035ec2cf20d33dcfee552dff2110d2d6..f6c2fcb5c788545b459ee9e611669295717b3828 100644 (file)
@@ -1205,11 +1205,20 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
 }
 
 
-static int wpas_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
+static int wpas_wps_new_psk_cb(void *ctx, const u8 *mac_addr,
+                              const u8 *p2p_dev_addr, const u8 *psk,
                               size_t psk_len)
 {
-       wpa_printf(MSG_DEBUG, "WPS: Received new WPA/WPA2-PSK from WPS for "
-                  "STA " MACSTR, MAC2STR(mac_addr));
+       if (is_zero_ether_addr(p2p_dev_addr)) {
+               wpa_printf(MSG_DEBUG,
+                          "Received new WPA/WPA2-PSK from WPS for STA " MACSTR,
+                          MAC2STR(mac_addr));
+       } else {
+               wpa_printf(MSG_DEBUG,
+                          "Received new WPA/WPA2-PSK from WPS for STA " MACSTR
+                          " P2P Device Addr " MACSTR,
+                          MAC2STR(mac_addr), MAC2STR(p2p_dev_addr));
+       }
        wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len);
 
        /* TODO */