3 * Copyright (c) 2009-2010, Atheros Communications
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "common/ieee802_11_defs.h"
13 #include "common/ieee802_11_common.h"
14 #include "wps/wps_i.h"
18 static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
19 struct p2p_message *msg)
24 char devtype[WPS_DEV_TYPE_BUFSIZE];
27 case P2P_ATTR_CAPABILITY:
29 wpa_printf(MSG_DEBUG, "P2P: Too short Capability "
30 "attribute (length %d)", len);
33 msg->capability = data;
34 wpa_printf(MSG_DEBUG, "P2P: * Device Capability %02x "
35 "Group Capability %02x",
38 case P2P_ATTR_DEVICE_ID:
40 wpa_printf(MSG_DEBUG, "P2P: Too short Device ID "
41 "attribute (length %d)", len);
44 msg->device_id = data;
45 wpa_printf(MSG_DEBUG, "P2P: * Device ID " MACSTR,
46 MAC2STR(msg->device_id));
48 case P2P_ATTR_GROUP_OWNER_INTENT:
50 wpa_printf(MSG_DEBUG, "P2P: Too short GO Intent "
51 "attribute (length %d)", len);
54 msg->go_intent = data;
55 wpa_printf(MSG_DEBUG, "P2P: * GO Intent: Intent %u "
56 "Tie breaker %u", data[0] >> 1, data[0] & 0x01);
60 wpa_printf(MSG_DEBUG, "P2P: Too short Status "
61 "attribute (length %d)", len);
65 wpa_printf(MSG_DEBUG, "P2P: * Status: %d", data[0]);
67 case P2P_ATTR_LISTEN_CHANNEL:
69 wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: Ignore "
74 wpa_printf(MSG_DEBUG, "P2P: Too short Listen Channel "
75 "attribute (length %d)", len);
78 msg->listen_channel = data;
79 wpa_printf(MSG_DEBUG, "P2P: * Listen Channel: "
80 "Country %c%c(0x%02x) Regulatory "
81 "Class %d Channel Number %d", data[0], data[1],
82 data[2], data[3], data[4]);
84 case P2P_ATTR_OPERATING_CHANNEL:
86 wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
87 "Ignore null channel");
91 wpa_printf(MSG_DEBUG, "P2P: Too short Operating "
92 "Channel attribute (length %d)", len);
95 msg->operating_channel = data;
96 wpa_printf(MSG_DEBUG, "P2P: * Operating Channel: "
97 "Country %c%c(0x%02x) Regulatory "
98 "Class %d Channel Number %d", data[0], data[1],
99 data[2], data[3], data[4]);
101 case P2P_ATTR_CHANNEL_LIST:
103 wpa_printf(MSG_DEBUG, "P2P: Too short Channel List "
104 "attribute (length %d)", len);
107 msg->channel_list = data;
108 msg->channel_list_len = len;
109 wpa_printf(MSG_DEBUG, "P2P: * Channel List: Country String "
110 "'%c%c(0x%02x)'", data[0], data[1], data[2]);
111 wpa_hexdump(MSG_MSGDUMP, "P2P: Channel List",
112 msg->channel_list, msg->channel_list_len);
114 case P2P_ATTR_GROUP_INFO:
115 msg->group_info = data;
116 msg->group_info_len = len;
117 wpa_printf(MSG_DEBUG, "P2P: * Group Info");
119 case P2P_ATTR_DEVICE_INFO:
120 if (len < ETH_ALEN + 2 + 8 + 1) {
121 wpa_printf(MSG_DEBUG, "P2P: Too short Device Info "
122 "attribute (length %d)", len);
125 msg->p2p_device_info = data;
126 msg->p2p_device_info_len = len;
128 msg->p2p_device_addr = pos;
130 msg->config_methods = WPA_GET_BE16(pos);
132 msg->pri_dev_type = pos;
134 msg->num_sec_dev_types = *pos++;
135 if (msg->num_sec_dev_types * 8 > data + len - pos) {
136 wpa_printf(MSG_DEBUG, "P2P: Device Info underflow");
139 pos += msg->num_sec_dev_types * 8;
140 if (data + len - pos < 4) {
141 wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
142 "length %d", (int) (data + len - pos));
145 if (WPA_GET_BE16(pos) != ATTR_DEV_NAME) {
146 wpa_hexdump(MSG_DEBUG, "P2P: Unexpected Device Name "
151 nlen = WPA_GET_BE16(pos);
153 if (nlen > data + len - pos || nlen > WPS_DEV_NAME_MAX_LEN) {
154 wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
155 "length %u (buf len %d)", nlen,
156 (int) (data + len - pos));
159 os_memcpy(msg->device_name, pos, nlen);
160 msg->device_name[nlen] = '\0';
161 for (i = 0; i < nlen; i++) {
162 if (msg->device_name[i] == '\0')
164 if (is_ctrl_char(msg->device_name[i]))
165 msg->device_name[i] = '_';
167 wpa_printf(MSG_DEBUG, "P2P: * Device Info: addr " MACSTR
168 " primary device type %s device name '%s' "
169 "config methods 0x%x",
170 MAC2STR(msg->p2p_device_addr),
171 wps_dev_type_bin2str(msg->pri_dev_type, devtype,
173 msg->device_name, msg->config_methods);
175 case P2P_ATTR_CONFIGURATION_TIMEOUT:
177 wpa_printf(MSG_DEBUG, "P2P: Too short Configuration "
178 "Timeout attribute (length %d)", len);
181 msg->config_timeout = data;
182 wpa_printf(MSG_DEBUG, "P2P: * Configuration Timeout");
184 case P2P_ATTR_INTENDED_INTERFACE_ADDR:
185 if (len < ETH_ALEN) {
186 wpa_printf(MSG_DEBUG, "P2P: Too short Intended P2P "
187 "Interface Address attribute (length %d)",
191 msg->intended_addr = data;
192 wpa_printf(MSG_DEBUG, "P2P: * Intended P2P Interface Address: "
193 MACSTR, MAC2STR(msg->intended_addr));
195 case P2P_ATTR_GROUP_BSSID:
196 if (len < ETH_ALEN) {
197 wpa_printf(MSG_DEBUG, "P2P: Too short P2P Group BSSID "
198 "attribute (length %d)", len);
201 msg->group_bssid = data;
202 wpa_printf(MSG_DEBUG, "P2P: * P2P Group BSSID: " MACSTR,
203 MAC2STR(msg->group_bssid));
205 case P2P_ATTR_GROUP_ID:
206 if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
207 wpa_printf(MSG_DEBUG, "P2P: Invalid P2P Group ID "
208 "attribute length %d", len);
211 msg->group_id = data;
212 msg->group_id_len = len;
213 wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID: Device Address "
214 MACSTR, MAC2STR(msg->group_id));
215 wpa_hexdump_ascii(MSG_DEBUG, "P2P: * P2P Group ID: SSID",
216 msg->group_id + ETH_ALEN,
217 msg->group_id_len - ETH_ALEN);
219 case P2P_ATTR_INVITATION_FLAGS:
221 wpa_printf(MSG_DEBUG, "P2P: Too short Invitation "
222 "Flag attribute (length %d)", len);
225 msg->invitation_flags = data;
226 wpa_printf(MSG_DEBUG, "P2P: * Invitation Flags: bitmap 0x%x",
229 case P2P_ATTR_MANAGEABILITY:
231 wpa_printf(MSG_DEBUG, "P2P: Too short Manageability "
232 "attribute (length %d)", len);
235 msg->manageability = data;
236 wpa_printf(MSG_DEBUG, "P2P: * Manageability: bitmap 0x%x",
239 case P2P_ATTR_NOTICE_OF_ABSENCE:
241 wpa_printf(MSG_DEBUG, "P2P: Too short Notice of "
242 "Absence attribute (length %d)", len);
247 wpa_printf(MSG_DEBUG, "P2P: * Notice of Absence");
249 case P2P_ATTR_EXT_LISTEN_TIMING:
251 wpa_printf(MSG_DEBUG, "P2P: Too short Extended Listen "
252 "Timing attribute (length %d)", len);
255 msg->ext_listen_timing = data;
256 wpa_printf(MSG_DEBUG, "P2P: * Extended Listen Timing "
257 "(period %u msec interval %u msec)",
258 WPA_GET_LE16(msg->ext_listen_timing),
259 WPA_GET_LE16(msg->ext_listen_timing + 2));
261 case P2P_ATTR_MINOR_REASON_CODE:
263 wpa_printf(MSG_DEBUG, "P2P: Too short Minor Reason "
264 "Code attribute (length %d)", len);
267 msg->minor_reason_code = data;
268 wpa_printf(MSG_DEBUG, "P2P: * Minor Reason Code: %u",
269 *msg->minor_reason_code);
271 case P2P_ATTR_OOB_GO_NEG_CHANNEL:
273 wpa_printf(MSG_DEBUG, "P2P: Too short OOB GO Neg "
274 "Channel attribute (length %d)", len);
277 msg->oob_go_neg_channel = data;
278 wpa_printf(MSG_DEBUG, "P2P: * OOB GO Neg Channel: "
279 "Country %c%c(0x%02x) Operating Class %d "
280 "Channel Number %d Role %d",
281 data[0], data[1], data[2], data[3], data[4],
284 case P2P_ATTR_SERVICE_HASH:
285 if (len < P2PS_HASH_LEN) {
286 wpa_printf(MSG_DEBUG,
287 "P2P: Too short Service Hash (length %u)",
291 msg->service_hash_count = len / P2PS_HASH_LEN;
292 msg->service_hash = data;
293 wpa_hexdump(MSG_DEBUG, "P2P: * Service Hash(s)", data, len);
295 case P2P_ATTR_SESSION_INFORMATION_DATA:
296 msg->session_info = data;
297 msg->session_info_len = len;
298 wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %u bytes - %p",
301 case P2P_ATTR_CONNECTION_CAPABILITY:
303 wpa_printf(MSG_DEBUG,
304 "P2P: Too short Connection Capability (length %u)",
308 msg->conn_cap = data;
309 wpa_printf(MSG_DEBUG, "P2P: * Connection Capability: 0x%x",
312 case P2P_ATTR_ADVERTISEMENT_ID:
314 wpa_printf(MSG_DEBUG,
315 "P2P: Too short Advertisement ID (length %u)",
320 msg->adv_mac = &data[sizeof(u32)];
321 wpa_printf(MSG_DEBUG, "P2P: * Advertisement ID %x",
324 case P2P_ATTR_ADVERTISED_SERVICE:
326 wpa_printf(MSG_DEBUG,
327 "P2P: Too short Service Instance (length %u)",
331 msg->adv_service_instance = data;
332 msg->adv_service_instance_len = len;
333 if (len <= 255 + 8) {
338 if (namelen > len - 7)
340 os_memcpy(str, &data[7], namelen);
342 wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %x-%s",
343 WPA_GET_LE32(data), str);
345 wpa_printf(MSG_DEBUG, "P2P: * Service Instance: %p",
349 case P2P_ATTR_SESSION_ID:
350 if (len < sizeof(u32) + ETH_ALEN) {
351 wpa_printf(MSG_DEBUG,
352 "P2P: Too short Session ID Info (length %u)",
356 msg->session_id = data;
357 msg->session_mac = &data[sizeof(u32)];
358 wpa_printf(MSG_DEBUG, "P2P: * Session ID: %x " MACSTR,
359 WPA_GET_LE32(data), MAC2STR(msg->session_mac));
361 case P2P_ATTR_FEATURE_CAPABILITY:
363 wpa_printf(MSG_DEBUG,
364 "P2P: Too short Feature Capability (length %u)",
368 msg->feature_cap = data;
369 msg->feature_cap_len = len;
370 wpa_printf(MSG_DEBUG, "P2P: * Feature Cap (length=%u)", len);
372 case P2P_ATTR_PERSISTENT_GROUP:
374 if (len < ETH_ALEN || len > ETH_ALEN + SSID_MAX_LEN) {
375 wpa_printf(MSG_DEBUG,
376 "P2P: Invalid Persistent Group Info (length %u)",
381 msg->persistent_dev = data;
382 msg->persistent_ssid_len = len - ETH_ALEN;
383 msg->persistent_ssid = &data[ETH_ALEN];
384 wpa_printf(MSG_DEBUG, "P2P: * Persistent Group: " MACSTR " %s",
385 MAC2STR(msg->persistent_dev),
386 wpa_ssid_txt(msg->persistent_ssid,
387 msg->persistent_ssid_len));
391 wpa_printf(MSG_DEBUG, "P2P: Skipped unknown attribute %d "
392 "(length %d)", id, len);
401 * p2p_parse_p2p_ie - Parse P2P IE
402 * @buf: Concatenated P2P IE(s) payload
403 * @msg: Buffer for returning parsed attributes
404 * Returns: 0 on success, -1 on failure
406 * Note: Caller is responsible for clearing the msg data structure before
407 * calling this function.
409 int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg)
411 const u8 *pos = wpabuf_head_u8(buf);
412 const u8 *end = pos + wpabuf_len(buf);
414 wpa_printf(MSG_DEBUG, "P2P: Parsing P2P IE");
421 wpa_printf(MSG_DEBUG, "P2P: Invalid P2P attribute");
425 attr_len = WPA_GET_LE16(pos);
427 wpa_printf(MSG_DEBUG, "P2P: Attribute %d length %u",
429 if (attr_len > end - pos) {
430 wpa_printf(MSG_DEBUG, "P2P: Attribute underflow "
432 attr_len, (int) (end - pos));
433 wpa_hexdump(MSG_MSGDUMP, "P2P: Data", pos, end - pos);
436 if (p2p_parse_attribute(id, pos, attr_len, msg))
445 static int p2p_parse_wps_ie(const struct wpabuf *buf, struct p2p_message *msg)
447 struct wps_parse_attr attr;
450 wpa_printf(MSG_DEBUG, "P2P: Parsing WPS IE");
451 if (wps_parse_msg(buf, &attr))
453 if (attr.dev_name && attr.dev_name_len < sizeof(msg->device_name) &&
454 !msg->device_name[0])
455 os_memcpy(msg->device_name, attr.dev_name, attr.dev_name_len);
456 if (attr.config_methods) {
457 msg->wps_config_methods =
458 WPA_GET_BE16(attr.config_methods);
459 wpa_printf(MSG_DEBUG, "P2P: Config Methods (WPS): 0x%x",
460 msg->wps_config_methods);
462 if (attr.dev_password_id) {
463 msg->dev_password_id = WPA_GET_BE16(attr.dev_password_id);
464 wpa_printf(MSG_DEBUG, "P2P: Device Password ID: %d",
465 msg->dev_password_id);
466 msg->dev_password_id_present = 1;
468 if (attr.primary_dev_type) {
469 char devtype[WPS_DEV_TYPE_BUFSIZE];
470 msg->wps_pri_dev_type = attr.primary_dev_type;
471 wpa_printf(MSG_DEBUG, "P2P: Primary Device Type (WPS): %s",
472 wps_dev_type_bin2str(msg->wps_pri_dev_type, devtype,
475 if (attr.sec_dev_type_list) {
476 msg->wps_sec_dev_type_list = attr.sec_dev_type_list;
477 msg->wps_sec_dev_type_list_len = attr.sec_dev_type_list_len;
480 for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
481 msg->wps_vendor_ext[i] = attr.vendor_ext[i];
482 msg->wps_vendor_ext_len[i] = attr.vendor_ext_len[i];
485 msg->manufacturer = attr.manufacturer;
486 msg->manufacturer_len = attr.manufacturer_len;
487 msg->model_name = attr.model_name;
488 msg->model_name_len = attr.model_name_len;
489 msg->model_number = attr.model_number;
490 msg->model_number_len = attr.model_number_len;
491 msg->serial_number = attr.serial_number;
492 msg->serial_number_len = attr.serial_number_len;
494 msg->oob_dev_password = attr.oob_dev_password;
495 msg->oob_dev_password_len = attr.oob_dev_password_len;
502 * p2p_parse_ies - Parse P2P message IEs (both WPS and P2P IE)
503 * @data: IEs from the message
504 * @len: Length of data buffer in octets
505 * @msg: Buffer for returning parsed attributes
506 * Returns: 0 on success, -1 on failure
508 * Note: Caller is responsible for clearing the msg data structure before
509 * calling this function.
511 * Note: Caller must free temporary memory allocations by calling
512 * p2p_parse_free() when the parsed data is not needed anymore.
514 int p2p_parse_ies(const u8 *data, size_t len, struct p2p_message *msg)
516 struct ieee802_11_elems elems;
518 ieee802_11_parse_elems(data, len, &elems, 0);
520 msg->ds_params = elems.ds_params;
522 msg->ssid = elems.ssid - 2;
524 msg->wps_attributes = ieee802_11_vendor_ie_concat(data, len,
526 if (msg->wps_attributes &&
527 p2p_parse_wps_ie(msg->wps_attributes, msg)) {
532 msg->p2p_attributes = ieee802_11_vendor_ie_concat(data, len,
534 if (msg->p2p_attributes &&
535 p2p_parse_p2p_ie(msg->p2p_attributes, msg)) {
536 wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P IE data");
537 if (msg->p2p_attributes)
538 wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P IE data",
539 msg->p2p_attributes);
544 #ifdef CONFIG_WIFI_DISPLAY
546 msg->wfd_subelems = ieee802_11_vendor_ie_concat(
547 data, len, WFD_IE_VENDOR_TYPE);
549 #endif /* CONFIG_WIFI_DISPLAY */
551 msg->pref_freq_list = elems.pref_freq_list;
552 msg->pref_freq_list_len = elems.pref_freq_list_len;
559 * p2p_parse - Parse a P2P Action frame contents
560 * @data: Action frame payload after Category and Code fields
561 * @len: Length of data buffer in octets
562 * @msg: Buffer for returning parsed attributes
563 * Returns: 0 on success, -1 on failure
565 * Note: Caller must free temporary memory allocations by calling
566 * p2p_parse_free() when the parsed data is not needed anymore.
568 int p2p_parse(const u8 *data, size_t len, struct p2p_message *msg)
570 os_memset(msg, 0, sizeof(*msg));
571 wpa_printf(MSG_DEBUG, "P2P: Parsing the received message");
573 wpa_printf(MSG_DEBUG, "P2P: No Dialog Token in the message");
576 msg->dialog_token = data[0];
577 wpa_printf(MSG_DEBUG, "P2P: * Dialog Token: %d", msg->dialog_token);
579 return p2p_parse_ies(data + 1, len - 1, msg);
583 int p2p_parse_ies_separate(const u8 *wsc, size_t wsc_len, const u8 *p2p,
584 size_t p2p_len, struct p2p_message *msg)
586 os_memset(msg, 0, sizeof(*msg));
588 msg->wps_attributes = wpabuf_alloc_copy(wsc, wsc_len);
589 if (msg->wps_attributes &&
590 p2p_parse_wps_ie(msg->wps_attributes, msg)) {
595 msg->p2p_attributes = wpabuf_alloc_copy(p2p, p2p_len);
596 if (msg->p2p_attributes &&
597 p2p_parse_p2p_ie(msg->p2p_attributes, msg)) {
598 wpa_printf(MSG_DEBUG, "P2P: Failed to parse P2P IE data");
599 if (msg->p2p_attributes)
600 wpa_hexdump_buf(MSG_MSGDUMP, "P2P: P2P IE data",
601 msg->p2p_attributes);
611 * p2p_parse_free - Free temporary data from P2P parsing
612 * @msg: Parsed attributes
614 void p2p_parse_free(struct p2p_message *msg)
616 wpabuf_free(msg->p2p_attributes);
617 msg->p2p_attributes = NULL;
618 wpabuf_free(msg->wps_attributes);
619 msg->wps_attributes = NULL;
620 #ifdef CONFIG_WIFI_DISPLAY
621 wpabuf_free(msg->wfd_subelems);
622 msg->wfd_subelems = NULL;
623 #endif /* CONFIG_WIFI_DISPLAY */
627 int p2p_group_info_parse(const u8 *gi, size_t gi_len,
628 struct p2p_group_info *info)
632 os_memset(info, 0, sizeof(*info));
639 struct p2p_client_info *cli;
644 cli = &info->client[info->num_clients];
646 if (len > gend - g || len < 2 * ETH_ALEN + 1 + 2 + 8 + 1)
647 return -1; /* invalid data */
649 /* g at start of P2P Client Info Descriptor */
650 cli->p2p_device_addr = g;
652 cli->p2p_interface_addr = g;
654 cli->dev_capab = *g++;
656 cli->config_methods = WPA_GET_BE16(g);
658 cli->pri_dev_type = g;
661 /* g at Number of Secondary Device Types */
663 if (8 * len > cend - g)
664 return -1; /* invalid data */
665 cli->num_sec_dev_types = len;
666 cli->sec_dev_types = g;
669 /* g at Device Name in WPS TLV format */
670 if (cend - g < 2 + 2)
671 return -1; /* invalid data */
672 if (WPA_GET_BE16(g) != ATTR_DEV_NAME)
673 return -1; /* invalid Device Name TLV */
675 count = WPA_GET_BE16(g);
677 if (count > cend - g)
678 return -1; /* invalid Device Name TLV */
679 if (count >= WPS_DEV_NAME_MAX_LEN)
680 count = WPS_DEV_NAME_MAX_LEN;
681 cli->dev_name = (const char *) g;
682 cli->dev_name_len = count;
687 if (info->num_clients == P2P_MAX_GROUP_ENTRIES)
695 static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
700 struct p2p_group_info info;
703 if (p2p_group_info_parse(gi, gi_len, &info) < 0)
706 for (i = 0; i < info.num_clients; i++) {
707 struct p2p_client_info *cli;
708 char name[WPS_DEV_NAME_MAX_LEN + 1];
709 char devtype[WPS_DEV_TYPE_BUFSIZE];
713 cli = &info.client[i];
714 ret = os_snprintf(pos, end - pos, "p2p_group_client: "
715 "dev=" MACSTR " iface=" MACSTR,
716 MAC2STR(cli->p2p_device_addr),
717 MAC2STR(cli->p2p_interface_addr));
718 if (os_snprintf_error(end - pos, ret))
722 ret = os_snprintf(pos, end - pos,
723 " dev_capab=0x%x config_methods=0x%x "
725 cli->dev_capab, cli->config_methods,
726 wps_dev_type_bin2str(cli->pri_dev_type,
729 if (os_snprintf_error(end - pos, ret))
733 for (s = 0; s < cli->num_sec_dev_types; s++) {
734 ret = os_snprintf(pos, end - pos, " dev_type=%s",
735 wps_dev_type_bin2str(
736 &cli->sec_dev_types[s * 8],
737 devtype, sizeof(devtype)));
738 if (os_snprintf_error(end - pos, ret))
743 os_memcpy(name, cli->dev_name, cli->dev_name_len);
744 name[cli->dev_name_len] = '\0';
745 count = (int) cli->dev_name_len - 1;
747 if (is_ctrl_char(name[count]))
752 ret = os_snprintf(pos, end - pos, " dev_name='%s'\n", name);
753 if (os_snprintf_error(end - pos, ret))
763 * p2p_attr_text - Build text format description of P2P IE attributes
764 * @data: P2P IE contents
765 * @buf: Buffer for returning text
766 * @end: Pointer to the end of the buf area
767 * Returns: Number of octets written to the buffer or -1 on faikure
769 * This function can be used to parse P2P IE contents into text format
772 int p2p_attr_text(struct wpabuf *data, char *buf, char *end)
774 struct p2p_message msg;
778 os_memset(&msg, 0, sizeof(msg));
779 if (p2p_parse_p2p_ie(data, &msg))
782 if (msg.capability) {
783 ret = os_snprintf(pos, end - pos,
784 "p2p_dev_capab=0x%x\n"
785 "p2p_group_capab=0x%x\n",
786 msg.capability[0], msg.capability[1]);
787 if (os_snprintf_error(end - pos, ret))
792 if (msg.pri_dev_type) {
793 char devtype[WPS_DEV_TYPE_BUFSIZE];
794 ret = os_snprintf(pos, end - pos,
795 "p2p_primary_device_type=%s\n",
796 wps_dev_type_bin2str(msg.pri_dev_type,
799 if (os_snprintf_error(end - pos, ret))
804 ret = os_snprintf(pos, end - pos, "p2p_device_name=%s\n",
806 if (os_snprintf_error(end - pos, ret))
810 if (msg.p2p_device_addr) {
811 ret = os_snprintf(pos, end - pos, "p2p_device_addr=" MACSTR
813 MAC2STR(msg.p2p_device_addr));
814 if (os_snprintf_error(end - pos, ret))
819 ret = os_snprintf(pos, end - pos, "p2p_config_methods=0x%x\n",
821 if (os_snprintf_error(end - pos, ret))
825 ret = p2p_group_info_text(msg.group_info, msg.group_info_len,
835 int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie)
837 struct p2p_message msg;
839 os_memset(&msg, 0, sizeof(msg));
840 if (p2p_parse_p2p_ie(p2p_ie, &msg))
843 if (!msg.manageability)
846 return !(msg.manageability[0] & P2P_MAN_CROSS_CONNECTION_PERMITTED);
850 u8 p2p_get_group_capab(const struct wpabuf *p2p_ie)
852 struct p2p_message msg;
854 os_memset(&msg, 0, sizeof(msg));
855 if (p2p_parse_p2p_ie(p2p_ie, &msg))
861 return msg.capability[1];
865 const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie)
867 struct p2p_message msg;
869 os_memset(&msg, 0, sizeof(msg));
870 if (p2p_parse_p2p_ie(p2p_ie, &msg))
873 if (msg.p2p_device_addr)
874 return msg.p2p_device_addr;
876 return msg.device_id;