+static inline void print_p2p(const uint8_t type, uint8_t len, const uint8_t *data)
+{
+ bool first = true;
+ __u8 subtype;
+ __u16 sublen;
+
+ while (len >= 3) {
+ subtype = data[0];
+ sublen = (data[2] << 8) + data[1];
+
+ if (sublen > len - 3)
+ break;
+
+ switch (subtype) {
+ case 0x02: /* capability */
+ tab_on_first(&first);
+ if (sublen < 2) {
+ printf("\t * malformed capability\n");
+ break;
+ }
+ printf("\t * Group capa: 0x%.2x, Device capa: 0x%.2x\n",
+ data[3], data[4]);
+ break;
+ case 0x0d: /* device info */
+ if (sublen < 6 + 2 + 8 + 1) {
+ printf("\t * malformed device info\n");
+ break;
+ }
+ /* fall through for now */
+ case 0x00: /* status */
+ case 0x01: /* minor reason */
+ case 0x03: /* device ID */
+ case 0x04: /* GO intent */
+ case 0x05: /* configuration timeout */
+ case 0x06: /* listen channel */
+ case 0x07: /* group BSSID */
+ case 0x08: /* ext listen timing */
+ case 0x09: /* intended interface address */
+ case 0x0a: /* manageability */
+ case 0x0b: /* channel list */
+ case 0x0c: /* NoA */
+ case 0x0e: /* group info */
+ case 0x0f: /* group ID */
+ case 0x10: /* interface */
+ case 0x11: /* operating channel */
+ case 0x12: /* invitation flags */
+ case 0xdd: /* vendor specific */
+ default: {
+ const __u8 *subdata = data + 4;
+ __u16 tmplen = sublen;
+
+ tab_on_first(&first);
+ printf("\t * Unknown TLV (%#.2x, %d bytes):",
+ subtype, tmplen);
+ while (tmplen) {
+ printf(" %.2x", *subdata);
+ subdata++;
+ tmplen--;
+ }
+ printf("\n");
+ break;
+ }
+ }
+
+ data += sublen + 3;
+ len -= sublen + 3;
+ }
+
+ if (len != 0) {
+ tab_on_first(&first);
+ printf("\t * bogus tail data (%d):", len);
+ while (len) {
+ printf(" %.2x", *data);
+ data++;
+ len--;
+ }
+ printf("\n");
+ }
+}
+
+static const struct ie_print wfa_printers[] = {
+ [9] = { "P2P", print_p2p, 2, 255, BIT(PRINT_SCAN), },
+};
+