[PATCH 9/9] batctl: tcpdump: fix source address selection for 802.11 data frames

Sven Eckelmann <[email protected]> Sun, 05 Jul 2026 19:30:12 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
For non-AMSDU data frame, we need to select as source host:

* neither from/to DS: addr2
* from DS: addr3
* to DS: addr2
* from+to DS: addr4

But the code is actually selecting:

* neither from/to DS: addr2
* from DS: addr3
* to DS: addr4
* from+to DS: addr3

Instead of checking single bits, the special cases "from+to DS" and "from
DS" have to be checked separately.

Fixes: 5143e351a77b ("batctl: add raw wifi packet decapsulation support")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 tcpdump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tcpdump.c b/tcpdump.c
index 48744ea..764b484 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1369,10 +1369,10 @@ static void parse_wifi_hdr(unsigned char *packet_buff, ssize_t buff_len,
 		return;
 
 	shost = wifi_hdr->addr2;
-	if (fc & IEEE80211_FCTL_FROMDS)
-		shost = wifi_hdr->addr3;
-	else if (fc & IEEE80211_FCTL_TODS)
+	if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
 		shost = wifi_hdr->addr4;
+	else if (fc & IEEE80211_FCTL_FROMDS)
+		shost = wifi_hdr->addr3;
 
 	dhost = wifi_hdr->addr1;
 	if (fc & IEEE80211_FCTL_TODS)

-- 
2.47.3