batman-adv: Explicitly mark the common header structure
All batman-adv packets have a common 3 byte header. It can be used to share some code between different code paths, but it was never explicit stated that this header has to be always the same for all packets. Therefore, new code changes always have the problem that they may accidently introduce regressions by moving some elements around. A new structure is introduced that contains the common header and makes it easier visible that these 3 bytes have to be the same for all on-wire packets. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
This commit is contained in:

committed by
Marek Lindner

parent
1707157888
commit
76543d14ae
@@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
|
||||
batman_ogm_packet = (struct batman_ogm_packet *)
|
||||
(skb->data + ETH_HLEN);
|
||||
|
||||
if (batman_ogm_packet->version != COMPAT_VERSION)
|
||||
if (batman_ogm_packet->header.version != COMPAT_VERSION)
|
||||
goto out;
|
||||
|
||||
if (batman_ogm_packet->packet_type != BAT_OGM)
|
||||
if (batman_ogm_packet->header.packet_type != BAT_OGM)
|
||||
goto out;
|
||||
|
||||
if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
|
||||
@@ -632,11 +632,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
|
||||
goto dropped;
|
||||
|
||||
bcast_packet = (struct bcast_packet *)skb->data;
|
||||
bcast_packet->version = COMPAT_VERSION;
|
||||
bcast_packet->ttl = TTL;
|
||||
bcast_packet->header.version = COMPAT_VERSION;
|
||||
bcast_packet->header.ttl = TTL;
|
||||
|
||||
/* batman packet type: broadcast */
|
||||
bcast_packet->packet_type = BAT_BCAST;
|
||||
bcast_packet->header.packet_type = BAT_BCAST;
|
||||
|
||||
/* hw address of first interface is the orig mac because only
|
||||
* this mac is known throughout the mesh */
|
||||
@@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface,
|
||||
skb_push(skb, hdr_size);
|
||||
unicast_packet = (struct unicast_packet *)skb->data;
|
||||
|
||||
if ((unicast_packet->packet_type != BAT_UNICAST) &&
|
||||
(unicast_packet->packet_type != BAT_UNICAST_FRAG))
|
||||
if ((unicast_packet->header.packet_type != BAT_UNICAST) &&
|
||||
(unicast_packet->header.packet_type != BAT_UNICAST_FRAG))
|
||||
goto dropped;
|
||||
|
||||
skb_reset_mac_header(skb);
|
||||
|
Reference in New Issue
Block a user