]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Add support for NFC handover select generation with wpa_supplicant
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 15 Feb 2013 10:34:55 +0000 (12:34 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 15 Feb 2013 10:34:55 +0000 (12:34 +0200)
When wpa_supplicant is controlling an AP mode interface, it can generate
the alternative carrier record for NFC connection handover select
message similarly to the way this is done in hostapd.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/ap.c
wpa_supplicant/ap.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wps_supplicant.c
wpa_supplicant/wps_supplicant.h

index df0bba07b62a624dee6e4d533602b06b620c89c5..23c7025e327a3f74ac6483903d18876054b0ae3f 100644 (file)
@@ -860,6 +860,18 @@ struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
        return hostapd_wps_nfc_config_token(hapd, ndef);
 }
 
+
+struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
+                                            int ndef)
+{
+       struct hostapd_data *hapd;
+
+       if (wpa_s->ap_iface == NULL)
+               return NULL;
+       hapd = wpa_s->ap_iface->bss[0];
+       return hostapd_wps_nfc_hs_cr(hapd, ndef);
+}
+
 #endif /* CONFIG_WPS */
 
 
index a997937eef1ca2a9b37fc0c2b32c4439bf0bd5d3..fd4c25abb5c03a52144b7762d07bb6ed6747ce58 100644 (file)
@@ -54,5 +54,7 @@ void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
                       int offset);
 struct wpabuf * wpas_ap_wps_nfc_config_token(struct wpa_supplicant *wpa_s,
                                             int ndef);
+struct wpabuf * wpas_ap_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
+                                            int ndef);
 
 #endif /* AP_H */
index 1163c2453818257883363dc8549091100f383d04..f36fef759ebbf5fd49073a4467624f0be2b29e68 100644 (file)
@@ -909,12 +909,13 @@ static int wpas_ctrl_nfc_get_handover_req(struct wpa_supplicant *wpa_s,
 
 
 static int wpas_ctrl_nfc_get_handover_sel_wps(struct wpa_supplicant *wpa_s,
-                                             char *reply, size_t max_len)
+                                             char *reply, size_t max_len,
+                                             int ndef, int cr)
 {
        struct wpabuf *buf;
        int res;
 
-       buf = wpas_wps_nfc_handover_sel(wpa_s);
+       buf = wpas_wps_nfc_handover_sel(wpa_s, ndef, cr);
        if (buf == NULL)
                return -1;
 
@@ -934,18 +935,24 @@ static int wpas_ctrl_nfc_get_handover_sel(struct wpa_supplicant *wpa_s,
                                          size_t max_len)
 {
        char *pos;
+       int ndef;
 
        pos = os_strchr(cmd, ' ');
        if (pos == NULL)
                return -1;
        *pos++ = '\0';
 
-       if (os_strcmp(cmd, "NDEF") != 0)
+       if (os_strcmp(cmd, "WPS") == 0)
+               ndef = 0;
+       else if (os_strcmp(cmd, "NDEF") == 0)
+               ndef = 1;
+       else
                return -1;
 
-       if (os_strcmp(pos, "WPS") == 0) {
-               return wpas_ctrl_nfc_get_handover_sel_wps(wpa_s, reply,
-                                                         max_len);
+       if (os_strcmp(pos, "WPS") == 0 || os_strcmp(pos, "WPS-CR") == 0) {
+               return wpas_ctrl_nfc_get_handover_sel_wps(
+                       wpa_s, reply, max_len, ndef,
+                       os_strcmp(pos, "WPS-CR") == 0);
        }
 
        return -1;
index a38972b5cef54cd6ebfb395375d924b71390883c..c89479f7d4f71d264c4ee184dfd3b53c82a9128f 100644 (file)
@@ -2003,9 +2003,12 @@ struct wpabuf * wpas_wps_nfc_handover_req(struct wpa_supplicant *wpa_s, int cr)
 }
 
 
-struct wpabuf * wpas_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s)
+struct wpabuf * wpas_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
+                                         int ndef, int cr)
 {
-       return NULL;
+       if (!cr)
+               return NULL;
+       return wpas_ap_wps_nfc_handover_sel(wpa_s, ndef);
 }
 
 
index c3816f4571ef595a5bfef05712f169905fd16dad..5bc5ffa5d7c76645feb931caedd7f17ff2c4da96 100644 (file)
@@ -69,7 +69,8 @@ int wpas_wps_start_nfc(struct wpa_supplicant *wpa_s, const u8 *bssid);
 int wpas_wps_nfc_tag_read(struct wpa_supplicant *wpa_s,
                          const struct wpabuf *data);
 struct wpabuf * wpas_wps_nfc_handover_req(struct wpa_supplicant *wpa_s, int cr);
-struct wpabuf * wpas_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s);
+struct wpabuf * wpas_wps_nfc_handover_sel(struct wpa_supplicant *wpa_s,
+                                         int ndef, int cr);
 int wpas_wps_nfc_rx_handover_req(struct wpa_supplicant *wpa_s,
                                 const struct wpabuf *data);
 int wpas_wps_nfc_rx_handover_sel(struct wpa_supplicant *wpa_s,