P2P: Add command for pre-authorizing an invitation to an active group

This is mainly designed for testing and allows p2p_connect join auth
to be used to accept a specific invitation to an active group that
may be received in the future.
This commit is contained in:
Jouni Malinen 2010-06-27 00:11:42 -07:00 committed by Jouni Malinen
parent 3c5126a41f
commit 108def931e
3 changed files with 24 additions and 1 deletions

View file

@ -1850,7 +1850,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
int freq = 0; int freq = 0;
/* <addr> <"pbc" | "pin" | PIN> [label|display|keypad] [persistent] /* <addr> <"pbc" | "pin" | PIN> [label|display|keypad] [persistent]
* [join|auth] [go_intent=<0..15>] [freq=<in MHz>] */ * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] */
if (hwaddr_aton(cmd, addr)) if (hwaddr_aton(cmd, addr))
return -1; return -1;
@ -2451,6 +2451,7 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
"disabled" : "enabled"); "disabled" : "enabled");
if (wpa_s->global->p2p_disabled) { if (wpa_s->global->p2p_disabled) {
wpas_p2p_stop_find(wpa_s); wpas_p2p_stop_find(wpa_s);
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
p2p_flush(wpa_s->global->p2p); p2p_flush(wpa_s->global->p2p);
} }
return 0; return 0;
@ -2716,6 +2717,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
if (p2p_ctrl_set(wpa_s, buf + 8) < 0) if (p2p_ctrl_set(wpa_s, buf + 8) < 0)
reply_len = -1; reply_len = -1;
} else if (os_strcmp(buf, "P2P_FLUSH") == 0) { } else if (os_strcmp(buf, "P2P_FLUSH") == 0) {
os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
p2p_flush(wpa_s->global->p2p); p2p_flush(wpa_s->global->p2p);
} else if (os_strncmp(buf, "P2P_PRESENCE_REQ ", 17) == 0) { } else if (os_strncmp(buf, "P2P_PRESENCE_REQ ", 17) == 0) {
if (p2p_ctrl_presence_req(wpa_s, buf + 17) < 0) if (p2p_ctrl_presence_req(wpa_s, buf + 17) < 0)

View file

@ -41,6 +41,8 @@ wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
int go); int go);
static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s); static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s);
static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx); static void wpas_p2p_join_scan(void *eloop_ctx, void *timeout_ctx);
static int wpas_p2p_join(struct wpa_supplicant *wpa_s, const u8 *iface_addr,
const u8 *dev_addr, enum p2p_wps_method wps_method);
static int wpas_p2p_create_iface(struct wpa_supplicant *wpa_s); static int wpas_p2p_create_iface(struct wpa_supplicant *wpa_s);
@ -1685,6 +1687,13 @@ static u8 wpas_invitation_process(void *ctx, const u8 *sa, const u8 *bssid,
if (!persistent_group) { if (!persistent_group) {
wpa_printf(MSG_DEBUG, "P2P: Invitation from " MACSTR wpa_printf(MSG_DEBUG, "P2P: Invitation from " MACSTR
" to join an active group", MAC2STR(sa)); " to join an active group", MAC2STR(sa));
if (!is_zero_ether_addr(wpa_s->p2p_auth_invite) &&
os_memcmp(go_dev_addr, wpa_s->p2p_auth_invite, ETH_ALEN) ==
0) {
wpa_printf(MSG_DEBUG, "P2P: Accept previously "
"authorized invitation");
goto accept_inv;
}
/* /*
* Do not accept the invitation automatically; notify user and * Do not accept the invitation automatically; notify user and
* request approval. * request approval.
@ -1731,6 +1740,7 @@ static u8 wpas_invitation_process(void *ctx, const u8 *sa, const u8 *bssid,
ETH_ALEN); ETH_ALEN);
} }
accept_inv:
if (wpa_s->current_ssid && wpa_drv_get_bssid(wpa_s, cur_bssid) == 0 && if (wpa_s->current_ssid && wpa_drv_get_bssid(wpa_s, cur_bssid) == 0 &&
wpa_s->assoc_freq) { wpa_s->assoc_freq) {
wpa_printf(MSG_DEBUG, "P2P: Trying to force channel to match " wpa_printf(MSG_DEBUG, "P2P: Trying to force channel to match "
@ -1772,6 +1782,9 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid,
if (s) { if (s) {
wpas_p2p_group_add_persistent( wpas_p2p_group_add_persistent(
wpa_s, s, s->mode == WPAS_MODE_P2P_GO, 0); wpa_s, s, s->mode == WPAS_MODE_P2P_GO, 0);
} else {
wpas_p2p_join(wpa_s, bssid, go_dev_addr,
wpa_s->p2p_wps_method);
} }
return; return;
} }
@ -2453,6 +2466,13 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
if (join) { if (join) {
u8 iface_addr[ETH_ALEN]; u8 iface_addr[ETH_ALEN];
if (auth) {
wpa_printf(MSG_DEBUG, "P2P: Authorize invitation to "
"connect a running group from " MACSTR,
MAC2STR(peer_addr));
os_memcpy(wpa_s->p2p_auth_invite, peer_addr, ETH_ALEN);
return ret;
}
if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr, if (p2p_get_interface_addr(wpa_s->global->p2p, peer_addr,
iface_addr) < 0) iface_addr) < 0)
os_memcpy(iface_addr, peer_addr, ETH_ALEN); os_memcpy(iface_addr, peer_addr, ETH_ALEN);

View file

@ -474,6 +474,7 @@ struct wpa_supplicant {
int p2p_long_listen; int p2p_long_listen;
char p2p_pin[10]; char p2p_pin[10];
int p2p_wps_method; int p2p_wps_method;
u8 p2p_auth_invite[ETH_ALEN];
int p2p_sd_over_ctrl_iface; int p2p_sd_over_ctrl_iface;
int p2p_in_provisioning; int p2p_in_provisioning;
int pending_invite_ssid_id; int pending_invite_ssid_id;