]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P NFC: Add OOB GO Negotiation Channel attribute
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:55 +0000 (21:10 +0200)
Add definition and helper functions for the new OOB GO Negotiation
Channel attribute.

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

src/common/ieee802_11_defs.h
src/p2p/p2p_build.c
src/p2p/p2p_i.h
src/p2p/p2p_parse.c

index 592ae54e77560ac66bbb79a6ed66c72a1182d4a7..67ce9ac24fd12ad95da39f0093eb5bb28be82cd8 100644 (file)
@@ -926,6 +926,7 @@ enum p2p_attr_id {
        P2P_ATTR_INTERFACE = 16,
        P2P_ATTR_OPERATING_CHANNEL = 17,
        P2P_ATTR_INVITATION_FLAGS = 18,
+       P2P_ATTR_OOB_GO_NEG_CHANNEL = 19,
        P2P_ATTR_VENDOR_SPECIFIC = 221
 };
 
@@ -971,6 +972,12 @@ enum p2p_status_code {
        P2P_SC_FAIL_REJECTED_BY_USER = 11,
 };
 
+enum p2p_role_indication {
+       P2P_DEVICE_NOT_IN_GROUP = 0x00,
+       P2P_CLIENT_IN_A_GROUP = 0x01,
+       P2P_GO_IN_A_GROUP = 0x02,
+};
+
 #define P2P_WILDCARD_SSID "DIRECT-"
 #define P2P_WILDCARD_SSID_LEN 7
 
index 42c023266673959459e236b22155f89e74a8f84c..664fadec2a860cf48667adcafe2d8992218d7e4f 100644 (file)
@@ -328,6 +328,23 @@ void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p)
 }
 
 
+void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
+                                   u8 oper_class, u8 channel,
+                                   enum p2p_role_indication role)
+{
+       /* OOB Group Owner Negotiation Channel */
+       wpabuf_put_u8(buf, P2P_ATTR_OOB_GO_NEG_CHANNEL);
+       wpabuf_put_le16(buf, 6);
+       wpabuf_put_data(buf, country, 3);
+       wpabuf_put_u8(buf, oper_class); /* Operating Class */
+       wpabuf_put_u8(buf, channel); /* Channel Number */
+       wpabuf_put_u8(buf, (u8) role); /* Role indication */
+       wpa_printf(MSG_DEBUG, "P2P: * OOB GO Negotiation Channel: Operating "
+                  "Class %u Channel %u Role %d",
+                  oper_class, channel, role);
+}
+
+
 static int p2p_add_wps_string(struct wpabuf *buf, enum wps_attribute attr,
                              const char *val)
 {
index fe4e3b3c455c8b2048badf25d2b2a00b80b52e8c..7e584ed2c3506a3e8b2ad76bc2c6b7c87997b485 100644 (file)
@@ -12,6 +12,8 @@
 #include "utils/list.h"
 #include "p2p.h"
 
+enum p2p_role_indication;
+
 enum p2p_go_state {
        UNKNOWN_GO,
        LOCAL_GO,
@@ -503,6 +505,8 @@ struct p2p_message {
 
        const u8 *minor_reason_code;
 
+       const u8 *oob_go_neg_channel;
+
        /* P2P Device Info */
        const u8 *p2p_device_info;
        size_t p2p_device_info_len;
@@ -636,6 +640,9 @@ void p2p_buf_add_noa(struct wpabuf *buf, u8 noa_index, u8 opp_ps, u8 ctwindow,
 void p2p_buf_add_ext_listen_timing(struct wpabuf *buf, u16 period,
                                   u16 interval);
 void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
+void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
+                                   u8 oper_class, u8 channel,
+                                   enum p2p_role_indication role);
 int p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
                     int all_attr);
 
index 097a31de19d34e3cb3bb3fc5fe2472b59949047b..1281c72337cdb132ea0f7a343695163919bae922 100644 (file)
@@ -268,6 +268,19 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
                wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u",
                           *msg->minor_reason_code);
                break;
+       case P2P_ATTR_OOB_GO_NEG_CHANNEL:
+               if (len < 6) {
+                       wpa_printf(MSG_DEBUG, "P2P: Too short OOB GO Neg "
+                                  "Channel attribute (length %d)", len);
+                       return -1;
+               }
+               msg->oob_go_neg_channel = data;
+               wpa_printf(MSG_DEBUG, "P2P: * OOB GO Neg Channel: "
+                          "Country %c%c(0x%02x) Operating Class %d "
+                          "Channel Number %d Role %d",
+                          data[0], data[1], data[2], data[3], data[4],
+                          data[5]);
+               break;
        default:
                wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d "
                           "(length %d)", id, len);