Currently, in ieee80211_monitor.c:ieee80211_monitor_input(), the skb->pkt_type field for "tx" (outgoing) packets is not always set to PACKET_OUTGOING. If the outgoing packet is addressed to a broadcast or multicast address then the packet type will be PACKET_BROADCAST or PACKET_MULTICAST, respectively.
According to manpage "packet(7)", PACKET_OUTGOING should be used "for a packet originated from the local host that is looped back to a packet socket". I believe this should apply to all outgoing packets regardless of their destination address. Without doing so, applications using packet sockets will not be able to discern between broadcast/multicast packets actually received and those that are looped back outgoing packets. However, if changed so that all outgoing packets have PACKET_OUTGOING, applications can always check the destination address field to determine whether it was broadcast/multicast/otherhost/host/etc.
The following patch is extremely simple, which changes the logic to first do "if outgoing packet, then set packet type to outgoing, else if multicast...". This way all outgoing packets will have packet type PACKET_OUTGOING.
Patch:
Index: net80211/ieee80211_monitor.c
===================================================================
--- net80211/ieee80211_monitor.c (revision 1970)
+++ net80211/ieee80211_monitor.c (working copy)
@@ -346,13 +346,15 @@
* The frame passed it's CRC, so we can rely
* on the contents of the frame to set pkttype.
*/
- if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+ if (tx)
+ pkttype = PACKET_OUTGOING;
+ else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
if (IEEE80211_ADDR_EQ(wh->i_addr1, dev->broadcast))
pkttype = PACKET_BROADCAST;
else
pkttype = PACKET_MULTICAST;
} else
- pkttype = (tx) ? PACKET_OUTGOING : PACKET_HOST;
+ pkttype = PACKET_HOST;
}
if (vap->iv_opmode != IEEE80211_M_MONITOR ||
As requested by the patch submission guidelines, here is the svn info output:
URL: http://svn.madwifi.org/trunk
Repository Root: http://svn.madwifi.org
Repository UUID: 0192ed92-7a03-0410-a25b-9323aeb14dbd
Revision: 1970
Node Kind: directory
Schedule: normal
Last Changed Author: scottr
Last Changed Rev: 1970
Last Changed Date: 2007-01-15 19:34:22 -0800 (Mon, 15 Jan 2007)
Properties Last Updated: 2007-01-16 08:29:34 -0800 (Tue, 16 Jan 2007)