P2PS: Add Application Service Info to device found events
[mech_eap.git] / wpa_supplicant / p2p_supplicant.c
index 4325a12..bdc2873 100644 (file)
@@ -1849,6 +1849,52 @@ static void wpas_dev_found(void *ctx, const u8 *addr,
                                                    WFD_SUBELEM_DEVICE_INFO);
 #endif /* CONFIG_WIFI_DISPLAY */
 
+       if (info->p2ps_instance) {
+               char str[256];
+               const u8 *buf = wpabuf_head(info->p2ps_instance);
+               size_t len = wpabuf_len(info->p2ps_instance);
+
+               while (len) {
+                       u32 id;
+                       u16 methods;
+                       u8 str_len;
+
+                       if (len < 4 + 2 + 1)
+                               break;
+                       id = WPA_GET_LE32(buf);
+                       buf += sizeof(u32);
+                       methods = WPA_GET_BE16(buf);
+                       buf += sizeof(u16);
+                       str_len = *buf++;
+                       if (str_len > len - 4 - 2 - 1)
+                               break;
+                       os_memcpy(str, buf, str_len);
+                       str[str_len] = '\0';
+                       buf += str_len;
+                       len -= str_len + sizeof(u32) + sizeof(u16) + sizeof(u8);
+
+                       wpa_msg_global(wpa_s, MSG_INFO,
+                                      P2P_EVENT_DEVICE_FOUND MACSTR
+                                      " p2p_dev_addr=" MACSTR
+                                      " pri_dev_type=%s name='%s'"
+                                      " config_methods=0x%x"
+                                      " dev_capab=0x%x"
+                                      " group_capab=0x%x"
+                                      " adv_id=%x asp_svc=%s%s",
+                                      MAC2STR(addr),
+                                      MAC2STR(info->p2p_device_addr),
+                                      wps_dev_type_bin2str(
+                                              info->pri_dev_type,
+                                              devtype, sizeof(devtype)),
+                                      info->device_name, methods,
+                                      info->dev_capab, info->group_capab,
+                                      id, str,
+                                      info->vendor_elems ?
+                                      " vendor_elems=1" : "");
+               }
+               goto done;
+       }
+
        wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_DEVICE_FOUND MACSTR
                       " p2p_dev_addr=" MACSTR
                       " pri_dev_type=%s name='%s' config_methods=0x%x "
@@ -1863,6 +1909,7 @@ static void wpas_dev_found(void *ctx, const u8 *addr,
                       info->vendor_elems ? " vendor_elems=1" : "",
                       new_device);
 
+done:
        os_free(wfd_dev_info_hex);
 #endif /* CONFIG_NO_STDOUT_DEBUG */