P2P NFC: Define WPS_NFC config method
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 15 Feb 2013 15:07:28 +0000 (17:07 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 27 Jan 2014 19:10:56 +0000 (21:10 +0200)
This will be used to track NFC as config method in P2P operations.

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

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_go_neg.c

index 9b49e74..0fb2bd4 100644 (file)
@@ -3387,6 +3387,8 @@ const char * p2p_wps_method_text(enum p2p_wps_method method)
                return "Keypad";
        case WPS_PBC:
                return "PBC";
+       case WPS_NFC:
+               return "NFC";
        }
 
        return "??";
index 6b2d39e..247491e 100644 (file)
@@ -50,7 +50,7 @@ struct p2p_channels {
 };
 
 enum p2p_wps_method {
-       WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC
+       WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC, WPS_NFC
 };
 
 /**
index a887a5e..f23cff6 100644 (file)
@@ -103,6 +103,8 @@ u16 p2p_wps_method_pw_id(enum p2p_wps_method wps_method)
                return DEV_PW_USER_SPECIFIED;
        case WPS_PBC:
                return DEV_PW_PUSHBUTTON;
+       case WPS_NFC:
+               return DEV_PW_NFC_CONNECTION_HANDOVER;
        default:
                return DEV_PW_DEFAULT;
        }
@@ -118,6 +120,8 @@ static const char * p2p_wps_method_str(enum p2p_wps_method wps_method)
                return "Keypad";
        case WPS_PBC:
                return "PBC";
+       case WPS_NFC:
+               return "NFC";
        default:
                return "??";
        }
@@ -131,6 +135,7 @@ static struct wpabuf * p2p_build_go_neg_req(struct p2p_data *p2p,
        u8 *len;
        u8 group_capab;
        size_t extra = 0;
+       u16 pw_id;
 
 #ifdef CONFIG_WIFI_DISPLAY
        if (p2p->wfd_ie_go_neg)
@@ -172,8 +177,10 @@ static struct wpabuf * p2p_build_go_neg_req(struct p2p_data *p2p,
        p2p_buf_update_ie_hdr(buf, len);
 
        /* WPS IE with Device Password ID attribute */
-       if (p2p_build_wps_ie(p2p, buf, p2p_wps_method_pw_id(peer->wps_method),
-                            0) < 0) {
+       pw_id = p2p_wps_method_pw_id(peer->wps_method);
+       if (peer->oob_pw_id)
+               pw_id = peer->oob_pw_id;
+       if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
                p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Request");
                wpabuf_free(buf);
                return NULL;
@@ -250,6 +257,7 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
        u8 *len;
        u8 group_capab;
        size_t extra = 0;
+       u16 pw_id;
 
        p2p_dbg(p2p, "Building GO Negotiation Response");
 
@@ -312,9 +320,10 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
        p2p_buf_update_ie_hdr(buf, len);
 
        /* WPS IE with Device Password ID attribute */
-       if (p2p_build_wps_ie(p2p, buf,
-                            p2p_wps_method_pw_id(peer ? peer->wps_method :
-                                                 WPS_NOT_READY), 0) < 0) {
+       pw_id = p2p_wps_method_pw_id(peer ? peer->wps_method : WPS_NOT_READY);
+       if (peer && peer->oob_pw_id)
+               pw_id = peer->oob_pw_id;
+       if (p2p_build_wps_ie(p2p, buf, pw_id, 0) < 0) {
                p2p_dbg(p2p, "Failed to build WPS IE for GO Negotiation Response");
                wpabuf_free(buf);
                return NULL;