iw: scan: add extension tag parsing

HE IEs are part of the extension tag (ID 255).

Signed-off-by: Brian Norris <briannorris@chromium.org>
Link: https://lore.kernel.org/r/20201118033936.3667788-2-briannorris@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
diff --git a/scan.c b/scan.c
index 8c23483..58a0998 100644
--- a/scan.c
+++ b/scan.c
@@ -2272,6 +2272,36 @@
 	printf("\n");
 }
 
+static const struct ie_print ext_printers[] = {
+};
+
+static void print_extension(unsigned char len, unsigned char *ie,
+			    bool unknown, enum print_ie_type ptype)
+{
+	unsigned char tag;
+
+	if (len < 1) {
+		printf("\tExtension IE: <empty>\n");
+		return;
+	}
+
+	tag = ie[0];
+	if (tag < ARRAY_SIZE(ext_printers) && ext_printers[tag].name &&
+	    ext_printers[tag].flags & BIT(ptype)) {
+		print_ie(&ext_printers[tag], tag, len - 1, ie + 1, NULL);
+		return;
+	}
+
+	if (unknown) {
+		int i;
+
+		printf("\tUnknown Extension ID (%d):", ie[0]);
+		for (i = 1; i < len; i++)
+			printf(" %.2x", ie[i]);
+		printf("\n");
+	}
+}
+
 void print_ies(unsigned char *ie, int ielen, bool unknown,
 	       enum print_ie_type ptype)
 {
@@ -2290,6 +2320,8 @@
 				 ie[0], ie[1], ie + 2, &ie_buffer);
 		} else if (ie[0] == 221 /* vendor */) {
 			print_vendor(ie[1], ie + 2, unknown, ptype);
+		} else if (ie[0] == 255 /* extension */) {
+			print_extension(ie[1], ie + 2, unknown, ptype);
 		} else if (unknown) {
 			int i;