From dd37a93884aa70f51efa7636d8ab1ac84514448b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 27 Apr 2013 18:38:41 +0300 Subject: [PATCH] P2P NFC: Report handover select from tag for static handover WPS_NFC_TAG_READ can be used to report static connection handover where the connection handover select message was read from an NFC tag. Signed-hostap: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 10 ++++++++++ wpa_supplicant/p2p_supplicant.h | 2 ++ wpa_supplicant/wps_supplicant.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4e9dcc342..fe50b001a 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -7265,6 +7265,16 @@ static int wpas_p2p_nfc_connection_handover(struct wpa_supplicant *wpa_s, } +int wpas_p2p_nfc_tag_process(struct wpa_supplicant *wpa_s, + const struct wpabuf *data) +{ + if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) + return -1; + + return wpas_p2p_nfc_connection_handover(wpa_s, data, 1, 1); +} + + int wpas_p2p_nfc_report_handover(struct wpa_supplicant *wpa_s, int init, const struct wpabuf *req, const struct wpabuf *sel) diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 0f09d17ee..46c91cd20 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -152,6 +152,8 @@ struct wpabuf * wpas_p2p_nfc_handover_req(struct wpa_supplicant *wpa_s, int ndef); struct wpabuf * wpas_p2p_nfc_handover_sel(struct wpa_supplicant *wpa_s, int ndef, int tag); +int wpas_p2p_nfc_tag_process(struct wpa_supplicant *wpa_s, + const struct wpabuf *data); int wpas_p2p_nfc_report_handover(struct wpa_supplicant *wpa_s, int init, const struct wpabuf *req, const struct wpabuf *sel); diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index b485db9c8..02e33382f 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -2281,6 +2281,14 @@ int wpas_wps_nfc_tag_read(struct wpa_supplicant *wpa_s, /* Assume this contains full NDEF record */ tmp = ndef_parse_wifi(data); if (tmp == NULL) { +#ifdef CONFIG_P2P + tmp = ndef_parse_p2p(data); + if (tmp) { + ret = wpas_p2p_nfc_tag_process(wpa_s, tmp); + wpabuf_free(tmp); + return ret; + } +#endif /* CONFIG_P2P */ wpa_printf(MSG_DEBUG, "WPS: Could not parse NDEF"); return -1; }