]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add group ifname to P2P-PROV-DISC-* events
authorJouni Malinen <j@w1.fi>
Tue, 6 Dec 2011 19:57:17 +0000 (21:57 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 6 Dec 2011 19:57:17 +0000 (21:57 +0200)
If Provision Discovery Request is sent for GO role (i.e., P2P Group ID
attribute is included), add the group interface name to the control
interface event on the GO. This makes it easier to figure out which
ctrl_iface needs to be used for wps_pbc/wps_pin command to authorize
the joining P2P client.

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

src/drivers/driver_test.c
src/p2p/p2p.h
src/p2p/p2p_pd.c
wpa_supplicant/events.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 3faa85d879d17e3d7fbe4a9f3c6c98d66dea6345..f8e314b172e9ba25f1cf3f7488ac5e8dd0993810 100644 (file)
@@ -3196,7 +3196,8 @@ static void test_sd_response(void *ctx, const u8 *sa, u16 update_indic,
 static void test_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
                               const u8 *dev_addr, const u8 *pri_dev_type,
                               const char *dev_name, u16 supp_config_methods,
-                              u8 dev_capab, u8 group_capab)
+                              u8 dev_capab, u8 group_capab,
+                              const u8 *group_id, size_t group_id_len)
 {
        wpa_printf(MSG_DEBUG, "%s(peer=" MACSTR " config_methods=0x%x)",
                   __func__, MAC2STR(peer), config_methods);
index 4735acee698a5b5ce907dcd7dcb2bac615adb6be..1159121caeaaee748b3a178a0f25a5268af07b2b 100644 (file)
@@ -594,6 +594,8 @@ struct p2p_config {
         * @supp_config_methods: Supported configuration Methods
         * @dev_capab: Device Capabilities
         * @group_capab: Group Capabilities
+        * @group_id: P2P Group ID (or %NULL if not included)
+        * @group_id_len: Length of P2P Group ID
         *
         * This callback is used to indicate reception of a Provision Discovery
         * Request frame that the P2P module accepted.
@@ -601,7 +603,8 @@ struct p2p_config {
        void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods,
                              const u8 *dev_addr, const u8 *pri_dev_type,
                              const char *dev_name, u16 supp_config_methods,
-                             u8 dev_capab, u8 group_capab);
+                             u8 dev_capab, u8 group_capab,
+                             const u8 *group_id, size_t group_id_len);
 
        /**
         * prov_disc_resp - Callback on Provisiong Discovery Response
index ac086b9bd08d587c55abc8e604b2e7b899138558..903c9ee56390352819523a7a94f53bba3e397ce0 100644 (file)
@@ -191,8 +191,8 @@ out:
                                        msg.device_name, msg.config_methods,
                                        msg.capability ? msg.capability[0] : 0,
                                        msg.capability ? msg.capability[1] :
-                                       0);
-
+                                       0,
+                                       msg.group_id, msg.group_id_len);
        }
        p2p_parse_free(&msg);
 }
index 9823501ba9829c10b75f5e3bbdddae81e657a361..c38991715f03275d9c19a999c2787aaddb0e2383 100644 (file)
@@ -2375,7 +2375,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                   data->p2p_prov_disc_req.dev_name,
                                   data->p2p_prov_disc_req.supp_config_methods,
                                   data->p2p_prov_disc_req.dev_capab,
-                                  data->p2p_prov_disc_req.group_capab);
+                                  data->p2p_prov_disc_req.group_capab,
+                                  NULL, 0);
                break;
        case EVENT_P2P_PROV_DISC_RESPONSE:
                wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer,
index e76656b4b7fbde3536000c51fbb27ea807add3d7..4ce04321aaf3451474fad19b677fbe23b5aeae3e 100644 (file)
@@ -1688,13 +1688,28 @@ static void wpas_prov_disc_local_keypad(struct wpa_supplicant *wpa_s,
 void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
                        const u8 *dev_addr, const u8 *pri_dev_type,
                        const char *dev_name, u16 supp_config_methods,
-                       u8 dev_capab, u8 group_capab)
+                       u8 dev_capab, u8 group_capab, const u8 *group_id,
+                       size_t group_id_len)
 {
        struct wpa_supplicant *wpa_s = ctx;
        char devtype[WPS_DEV_TYPE_BUFSIZE];
-       char params[200];
+       char params[300];
        u8 empty_dev_type[8];
        unsigned int generated_pin = 0;
+       struct wpa_supplicant *group = NULL;
+
+       if (group_id) {
+               for (group = wpa_s->global->ifaces; group; group = group->next)
+               {
+                       struct wpa_ssid *s = group->current_ssid;
+                       if (s != NULL &&
+                           s->mode == WPAS_MODE_P2P_GO &&
+                           group_id_len - ETH_ALEN == s->ssid_len &&
+                           os_memcmp(group_id + ETH_ALEN, s->ssid,
+                                     s->ssid_len) == 0)
+                               break;
+               }
+       }
 
        if (pri_dev_type == NULL) {
                os_memset(empty_dev_type, 0, sizeof(empty_dev_type));
@@ -1702,11 +1717,13 @@ void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
        }
        os_snprintf(params, sizeof(params), " p2p_dev_addr=" MACSTR
                    " pri_dev_type=%s name='%s' config_methods=0x%x "
-                   "dev_capab=0x%x group_capab=0x%x",
+                   "dev_capab=0x%x group_capab=0x%x%s%s",
                    MAC2STR(dev_addr),
                    wps_dev_type_bin2str(pri_dev_type, devtype,
                                         sizeof(devtype)),
-                   dev_name, supp_config_methods, dev_capab, group_capab);
+                   dev_name, supp_config_methods, dev_capab, group_capab,
+                   group ? " group=" : "",
+                   group ? group->ifname : "");
        params[sizeof(params) - 1] = '\0';
 
        if (config_methods & WPS_CONFIG_DISPLAY) {
index 33b22db17eb98bea925c22ea6b238b2e8a6bc49c..6afc4bb060d4b38ff900233213cdbf953810ad51 100644 (file)
@@ -73,7 +73,8 @@ void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id);
 void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
                        const u8 *dev_addr, const u8 *pri_dev_type,
                        const char *dev_name, u16 supp_config_methods,
-                       u8 dev_capab, u8 group_capab);
+                       u8 dev_capab, u8 group_capab, const u8 *group_id,
+                       size_t group_id_len);
 void wpas_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods);
 void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
                     u16 update_indic, const u8 *tlvs, size_t tlvs_len);