]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add optional "join" argument for p2p_prov_disc command
authorJithu Jance <jithu@broadcom.com>
Tue, 6 Dec 2011 19:28:02 +0000 (21:28 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 6 Dec 2011 19:28:02 +0000 (21:28 +0200)
This can be used to request Provision Discovery Request to be sent
for the purpose of joining a running group, e.g., to request the GO
to display a PIN that we can then use with p2p_connect join command.

Signed-hostap: Jithu Jance <jithu@broadcom.com>

src/drivers/driver.h
wpa_supplicant/README-P2P
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dbus/dbus_new_handlers_p2p.c
wpa_supplicant/driver_i.h
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h
wpa_supplicant/wpa_cli.c

index 388b405b86c87d5d63ff001b20bd7e16b0aad400..c8a71fd7c5cd28c7bd2303afdd4942f5e78db713 100644 (file)
@@ -2194,7 +2194,7 @@ struct wpa_driver_ops {
         * struct wpa_driver_capa.
         */
        int (*p2p_prov_disc_req)(void *priv, const u8 *peer_addr,
-                                u16 config_methods);
+                                u16 config_methods, int join);
 
        /**
         * p2p_sd_request - Schedule a service discovery query
index 4b713984b8bc65b93f01718c303dc4b40b7001d0..db6e4aefad072b700e3428d6756eb461f341ae19 100644 (file)
@@ -101,7 +101,7 @@ Flush P2P peer table and state.
 
 Group Formation
 
-p2p_prov_disc <peer device address> <display|keypad|pbc>
+p2p_prov_disc <peer device address> <display|keypad|pbc> [join]
 
 Send P2P provision discovery request to the specified peer. The
 parameters for this command are the P2P device address of the peer and
@@ -110,6 +110,10 @@ the desired configuration method. For example, "p2p_prov_disc
 us and "p2p_prov_disc 02:01:02:03:04:05 keypad" would request the peer
 to enter a PIN that we display.
 
+The optional "join" parameter can be used to indicate that this command
+is requesting an already running GO to prepare for a new client. This is
+mainly used with "display" to request it to display a PIN.
+
 p2p_connect <peer device address> <pbc|pin|PIN#> [display|keypad]
        [persistent] [join|auth] [go_intent=<0..15>] [freq=<in MHz>]
 
index 443b693dc81a910d730e7f98474ff926f5e4df1c..4092fe076ca79cb1589a52c31f91a85bfbd482ba 100644 (file)
@@ -2551,7 +2551,7 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
        u8 addr[ETH_ALEN];
        char *pos;
 
-       /* <addr> <config method> */
+       /* <addr> <config method> [join] */
 
        if (hwaddr_aton(cmd, addr))
                return -1;
@@ -2561,7 +2561,8 @@ static int p2p_ctrl_prov_disc(struct wpa_supplicant *wpa_s, char *cmd)
                return -1;
        pos++;
 
-       return wpas_p2p_prov_disc(wpa_s, addr, pos);
+       return wpas_p2p_prov_disc(wpa_s, addr, pos,
+                                 os_strstr(pos, "join") != NULL);
 }
 
 
index f2c5a188729f775c6e7a299ac9eadd05e01fb3a1..5b62b947eb4adc1b3861a9709d72e7600ba65f18 100644 (file)
@@ -692,7 +692,7 @@ DBusMessage * wpas_dbus_handler_p2p_prov_disc_req(DBusMessage *message,
            os_strcmp(config_method, "pushbutton"))
                return wpas_dbus_error_invalid_args(message, NULL);
 
-       if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method) < 0)
+       if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method, 0) < 0)
                return wpas_dbus_error_unknown_error(message,
                                "Failed to send provision discovery request");
 
index 8b584db211461dd644b99d69d46d68c13583b30d..d61b3fddbb43945238e866caa121452f8861f3e4 100644 (file)
@@ -569,12 +569,12 @@ static inline int wpa_drv_p2p_set_params(struct wpa_supplicant *wpa_s,
 
 static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
                                            const u8 *peer_addr,
-                                           u16 config_methods)
+                                           u16 config_methods, int join)
 {
        if (!wpa_s->driver->p2p_prov_disc_req)
                return -1;
        return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
-                                               config_methods);
+                                               config_methods, join);
 }
 
 static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,
index 450cec87abe5c9348dbf35c8264071ac4fbe8475..564517f7c2a3be12ddfe1e3f6181b3902e5db403 100644 (file)
@@ -3281,30 +3281,32 @@ void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
 
 
 int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
-                      const char *config_method)
+                      const char *config_method, int join)
 {
        u16 config_methods;
 
-       if (os_strcmp(config_method, "display") == 0)
+       if (os_strncmp(config_method, "display", 7) == 0)
                config_methods = WPS_CONFIG_DISPLAY;
-       else if (os_strcmp(config_method, "keypad") == 0)
+       else if (os_strncmp(config_method, "keypad", 6) == 0)
                config_methods = WPS_CONFIG_KEYPAD;
-       else if (os_strcmp(config_method, "pbc") == 0 ||
-                os_strcmp(config_method, "pushbutton") == 0)
+       else if (os_strncmp(config_method, "pbc", 3) == 0 ||
+                os_strncmp(config_method, "pushbutton", 10) == 0)
                config_methods = WPS_CONFIG_PUSHBUTTON;
-       else
+       else {
+               wpa_printf(MSG_DEBUG, "P2P: Unknown config method");
                return -1;
+       }
 
        if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) {
                return wpa_drv_p2p_prov_disc_req(wpa_s, peer_addr,
-                                                config_methods);
+                                                config_methods, join);
        }
 
        if (wpa_s->global->p2p == NULL || wpa_s->global->p2p_disabled)
                return -1;
 
        return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
-                                config_methods, 0);
+                                config_methods, join);
 }
 
 
index 9a13f9f6c24eaa76a86fc4412bb6d0c77e712c8d..33b22db17eb98bea925c22ea6b238b2e8a6bc49c 100644 (file)
@@ -43,7 +43,7 @@ struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s,
 void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
                          int registrar);
 int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
-                      const char *config_method);
+                      const char *config_method, int join);
 void wpas_send_action_tx_status(struct wpa_supplicant *wpa_s, const u8 *dst,
                                const u8 *data, size_t data_len,
                                enum p2p_send_action_result result);
index e35f04152983380c0beacdf06f2d518cf2d77ad6..42c81cd7eab198b4ee298d160d57e0e731186956 100644 (file)
@@ -2077,15 +2077,19 @@ static int wpa_cli_cmd_p2p_prov_disc(struct wpa_ctrl *ctrl, int argc,
        char cmd[128];
        int res;
 
-       if (argc != 2) {
-               printf("Invalid P2P_PROV_DISC command: needs two arguments "
-                      "(address and config method\n"
-                      "(display, keypad, or pbc)\n");
+       if (argc != 2 && argc != 3) {
+               printf("Invalid P2P_PROV_DISC command: needs at least "
+                      "two arguments, address and config method\n"
+                      "(display, keypad, or pbc) and an optional join\n");
                return -1;
        }
 
-       res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s",
-                         argv[0], argv[1]);
+       if (argc == 3)
+               res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s %s",
+                                 argv[0], argv[1], argv[2]);
+       else
+               res = os_snprintf(cmd, sizeof(cmd), "P2P_PROV_DISC %s %s",
+                                 argv[0], argv[1]);
        if (res < 0 || (size_t) res >= sizeof(cmd))
                return -1;
        cmd[sizeof(cmd) - 1] = '\0';