Skip to contentSkip to conversation

monitor: print contents of beacon head/tail, and probe attributes

PATCH In review James Prestwood 2 participants 3 messages Feb 23, 2023 – Feb 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 monitor: print contents of beacon head/tail, and probe attributes

---
 monitor/nlmon.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
monitor/nlmon.c +19 -4
index 25a15154..a7ce2412 100644
@@ -5068,6 +5068,16 @@ static void print_probe_response(unsigned int level,
 			(const uint8_t *) mmpdu + len - resp->ies);
 }
 
+static void print_beacon(unsigned int level,
+				const struct mmpdu_header *mmpdu, size_t len)
+{
+	const struct mmpdu_beacon *beacon = mmpdu_body(mmpdu);
+
+	print_attr(level, "Subtype: Beacon");
+	print_ie(level + 1, "Beacon IEs", beacon->ies,
+			(const uint8_t *) mmpdu + len - beacon->ies);
+}
+
 static void print_frame_type(unsigned int level, const char *label,
 					const void *data, uint16_t size)
 {
@@ -5122,7 +5132,10 @@ static void print_frame_type(unsigned int level, const char *label,
 		str = "Timing Advertisement";
 		break;
 	case 0x08:
-		str = "Beacon";
+		if (mpdu)
+			print_beacon(level + 1, mpdu, size);
+		else
+			str = "Beacon";
 		break;
 	case 0x09:
 		str = "ATIM";
@@ -6240,9 +6253,10 @@ static const struct attr_entry attr_table[] = {
 	{ NL80211_ATTR_DTIM_PERIOD,
 			"DTIM Period", ATTR_U32 },
 	{ NL80211_ATTR_BEACON_HEAD,
-			"Beacon Head", ATTR_BINARY },
+			"Beacon Head",  ATTR_CUSTOM, { .function = print_frame } },
 	{ NL80211_ATTR_BEACON_TAIL,
-			"Beacon Tail", ATTR_BINARY },
+			"Beacon Tail", ATTR_CUSTOM,
+				{ .function = print_management_ies } },
 	{ NL80211_ATTR_STA_AID,
 			"Station AID", ATTR_U16 },
 	{ NL80211_ATTR_STA_FLAGS,
@@ -6520,7 +6534,8 @@ static const struct attr_entry attr_table[] = {
 	{ NL80211_ATTR_PROBE_RESP_OFFLOAD,
 			"Probe Response Offload" },
 	{ NL80211_ATTR_PROBE_RESP,
-			"Probe Response" },
+			"Probe Response", ATTR_CUSTOM,
+					{ .function = print_frame} },
 	{ NL80211_ATTR_DFS_REGION,
 			"DFS Region", ATTR_U8 },
 	{ NL80211_ATTR_DISABLE_HT,
Signature · 1 line
2.34.3
#1 lore raw

PATCH 2/2 netdev: check iftype in channel switch event

Some drivers send this event when starting AP mode which means the handshake object is NULL, causing a crash.

---
 src/netdev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/netdev.c +6 -2
index 035dbd00..dbfdff1a 100644
@@ -5145,8 +5145,12 @@ static void netdev_send_sa_query_delay(struct l_timeout *timeout,
 static void netdev_channel_switch_event(struct l_genl_msg *msg,
 					struct netdev *netdev)
 {
-	_auto_(l_free) struct band_chandef *chandef =
-						l_new(struct band_chandef, 1);
+	_auto_(l_free) struct band_chandef *chandef = NULL;
+
+	if (netdev->type != NL80211_IFTYPE_STATION)
+		return;
+
+	chandef = l_new(struct band_chandef, 1);
 
 	if (nl80211_parse_chandef(msg, chandef) < 0) {
 		l_debug("Couldn't parse operating channel info.");
Signature · 1 line
2.34.3
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 3 lines · James Prestwood
---
  monitor/nlmon.c | 23 +++++++++++++++++++----
  1 file changed, 19 insertions(+), 4 deletions(-)

Both applied, thanks.

Regards,
-Denis