aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2013-09-08 00:51:04 (GMT)
committerJouni Malinen <j@w1.fi>2014-01-27 19:44:30 (GMT)
commitabe44e3ca20245ed991f105399b0e868b2e3b691 (patch)
tree273e0e20fdc9843eda358b621f3ec0ec54d42677
parent23318bea947a28c3d147ca4db98aba6aadd22afa (diff)
downloadhostap-abe44e3ca20245ed991f105399b0e868b2e3b691.zip
hostap-abe44e3ca20245ed991f105399b0e868b2e3b691.tar.gz
hostap-abe44e3ca20245ed991f105399b0e868b2e3b691.tar.bz2
P2P NFC: Add GO info into handover message when in client role
P2P Group ID can optionally be included in the connection handover messages when acting as a P2P Client in a group. Add this information and show it in the P2P-NFC-PEER-CLIENT event message. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--src/p2p/p2p.c30
-rw-r--r--src/p2p/p2p.h8
-rw-r--r--wpa_supplicant/p2p_supplicant.c46
3 files changed, 69 insertions, 15 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 64dc8bd..c553e23 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4380,7 +4380,9 @@ void p2p_err(struct p2p_data *p2p, const char *fmt, ...)
#ifdef CONFIG_WPS_NFC
static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p,
- int client_freq)
+ int client_freq,
+ const u8 *go_dev_addr,
+ const u8 *ssid, size_t ssid_len)
{
struct wpabuf *buf;
u8 op_class, channel;
@@ -4413,6 +4415,14 @@ static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p,
/* Limit number of clients to avoid very long message */
p2p_buf_add_group_info(p2p->groups[0], buf, 5);
p2p_group_buf_add_id(p2p->groups[0], buf);
+ } else if (client_freq > 0 &&
+ go_dev_addr && !is_zero_ether_addr(go_dev_addr) &&
+ ssid && ssid_len > 0) {
+ /*
+ * Add the optional P2P Group ID to indicate in which group this
+ * device is a P2P Client.
+ */
+ p2p_buf_add_group_id(buf, go_dev_addr, ssid, ssid_len);
}
return buf;
@@ -4420,16 +4430,22 @@ static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p,
struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p,
- int client_freq)
+ int client_freq,
+ const u8 *go_dev_addr,
+ const u8 *ssid, size_t ssid_len)
{
- return p2p_build_nfc_handover(p2p, client_freq);
+ return p2p_build_nfc_handover(p2p, client_freq, go_dev_addr, ssid,
+ ssid_len);
}
struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p,
- int client_freq)
+ int client_freq,
+ const u8 *go_dev_addr,
+ const u8 *ssid, size_t ssid_len)
{
- return p2p_build_nfc_handover(p2p, client_freq);
+ return p2p_build_nfc_handover(p2p, client_freq, go_dev_addr, ssid,
+ ssid_len);
}
@@ -4499,6 +4515,10 @@ int p2p_process_nfc_connection_handover(struct p2p_data *p2p,
if (role == P2P_GO_IN_A_GROUP) {
p2p_dbg(p2p, "Peer OOB GO operating channel: %u MHz", freq);
params->go_freq = freq;
+ } else if (role == P2P_CLIENT_IN_A_GROUP) {
+ p2p_dbg(p2p, "Peer (client) OOB GO operating channel: %u MHz",
+ freq);
+ params->go_freq = freq;
} else
p2p_dbg(p2p, "Peer OOB GO Neg channel: %u MHz", freq);
dev->oob_go_neg_freq = freq;
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 3831b1c..3d8ee1f 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1900,9 +1900,13 @@ int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int,
const char * p2p_get_state_txt(struct p2p_data *p2p);
struct wpabuf * p2p_build_nfc_handover_req(struct p2p_data *p2p,
- int client_freq);
+ int client_freq,
+ const u8 *go_dev_addr,
+ const u8 *ssid, size_t ssid_len);
struct wpabuf * p2p_build_nfc_handover_sel(struct p2p_data *p2p,
- int client_freq);
+ int client_freq,
+ const u8 *go_dev_addr,
+ const u8 *ssid, size_t ssid_len);
struct p2p_nfc_params {
int sel;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 9c815ae..312efc9 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -7041,16 +7041,25 @@ static struct wpabuf * wpas_p2p_nfc_handover(int ndef, struct wpabuf *wsc,
}
-static int wpas_p2p_cli_freq(struct wpa_supplicant *wpa_s)
+static int wpas_p2p_cli_freq(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid **ssid, u8 *go_dev_addr)
{
struct wpa_supplicant *iface;
+ if (go_dev_addr)
+ os_memset(go_dev_addr, 0, ETH_ALEN);
+ if (ssid)
+ *ssid = NULL;
for (iface = wpa_s->global->ifaces; iface; iface = iface->next) {
if (iface->wpa_state < WPA_ASSOCIATING ||
iface->current_ssid == NULL || iface->assoc_freq == 0 ||
!iface->current_ssid->p2p_group ||
iface->current_ssid->mode != WPAS_MODE_INFRA)
continue;
+ if (ssid)
+ *ssid = iface->current_ssid;
+ if (go_dev_addr)
+ os_memcpy(go_dev_addr, iface->go_dev_addr, ETH_ALEN);
return iface->assoc_freq;
}
return 0;
@@ -7061,7 +7070,9 @@ struct wpabuf * wpas_p2p_nfc_handover_req(struct wpa_supplicant *wpa_s,
int ndef)
{
struct wpabuf *wsc, *p2p;
- int cli_freq = wpas_p2p_cli_freq(wpa_s);
+ struct wpa_ssid *ssid;
+ u8 go_dev_addr[ETH_ALEN];
+ int cli_freq = wpas_p2p_cli_freq(wpa_s, &ssid, go_dev_addr);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) {
wpa_printf(MSG_DEBUG, "P2P: P2P disabled - cannot build handover request");
@@ -7080,7 +7091,9 @@ struct wpabuf * wpas_p2p_nfc_handover_req(struct wpa_supplicant *wpa_s,
wpa_s->parent->wps, wpa_s->conf->wps_nfc_dh_pubkey);
} else
wsc = NULL;
- p2p = p2p_build_nfc_handover_req(wpa_s->global->p2p, cli_freq);
+ p2p = p2p_build_nfc_handover_req(wpa_s->global->p2p, cli_freq,
+ go_dev_addr, ssid ? ssid->ssid : NULL,
+ ssid ? ssid->ssid_len : 0);
return wpas_p2p_nfc_handover(ndef, wsc, p2p);
}
@@ -7090,7 +7103,9 @@ struct wpabuf * wpas_p2p_nfc_handover_sel(struct wpa_supplicant *wpa_s,
int ndef, int tag)
{
struct wpabuf *wsc, *p2p;
- int cli_freq = wpas_p2p_cli_freq(wpa_s);
+ struct wpa_ssid *ssid;
+ u8 go_dev_addr[ETH_ALEN];
+ int cli_freq = wpas_p2p_cli_freq(wpa_s, &ssid, go_dev_addr);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return NULL;
@@ -7109,7 +7124,9 @@ struct wpabuf * wpas_p2p_nfc_handover_sel(struct wpa_supplicant *wpa_s,
tag ? wpa_s->conf->wps_nfc_dev_pw : NULL);
} else
wsc = NULL;
- p2p = p2p_build_nfc_handover_sel(wpa_s->global->p2p, cli_freq);
+ p2p = p2p_build_nfc_handover_sel(wpa_s->global->p2p, cli_freq,
+ go_dev_addr, ssid ? ssid->ssid : NULL,
+ ssid ? ssid->ssid_len : 0);
return wpas_p2p_nfc_handover(ndef, wsc, p2p);
}
@@ -7280,12 +7297,25 @@ static int wpas_p2p_nfc_connection_handover(struct wpa_supplicant *wpa_s,
}
if (params.next_step == PEER_CLIENT) {
- wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_NFC_PEER_CLIENT "peer="
- MACSTR, MAC2STR(params.peer->p2p_device_addr));
+ if (!is_zero_ether_addr(params.go_dev_addr)) {
+ wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_NFC_PEER_CLIENT
+ "peer=" MACSTR " freq=%d go_dev_addr=" MACSTR
+ " ssid=\"%s\"",
+ MAC2STR(params.peer->p2p_device_addr),
+ params.go_freq,
+ MAC2STR(params.go_dev_addr),
+ wpa_ssid_txt(params.go_ssid,
+ params.go_ssid_len));
+ } else {
+ wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_NFC_PEER_CLIENT
+ "peer=" MACSTR " freq=%d",
+ MAC2STR(params.peer->p2p_device_addr),
+ params.go_freq);
+ }
return 0;
}
- if (wpas_p2p_cli_freq(wpa_s)) {
+ if (wpas_p2p_cli_freq(wpa_s, NULL, NULL)) {
wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_NFC_WHILE_CLIENT "peer="
MACSTR, MAC2STR(params.peer->p2p_device_addr));
return 0;