aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/vis.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-11-20 09:47:38 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-16 13:50:19 -0500
commit76543d14aec6ce5cb3fc7be9b39c50fcebd2043b (patch)
tree4f739cfadaee8ec9a06d7855956f3accc1dcc2be /net/batman-adv/vis.c
parent17071578888c7c18709e48e74fae228c04581b9a (diff)
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>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r--net/batman-adv/vis.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index cc3b9f2f3b5..ac7e6610059 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
617 packet->vis_type = atomic_read(&bat_priv->vis_mode); 617 packet->vis_type = atomic_read(&bat_priv->vis_mode);
618 618
619 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); 619 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN);
620 packet->ttl = TTL; 620 packet->header.ttl = TTL;
621 packet->seqno = htonl(ntohl(packet->seqno) + 1); 621 packet->seqno = htonl(ntohl(packet->seqno) + 1);
622 packet->entries = 0; 622 packet->entries = 0;
623 skb_trim(info->skb_packet, sizeof(*packet)); 623 skb_trim(info->skb_packet, sizeof(*packet));
@@ -818,19 +818,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
818 goto out; 818 goto out;
819 819
820 packet = (struct vis_packet *)info->skb_packet->data; 820 packet = (struct vis_packet *)info->skb_packet->data;
821 if (packet->ttl < 2) { 821 if (packet->header.ttl < 2) {
822 pr_debug("Error - can't send vis packet: ttl exceeded\n"); 822 pr_debug("Error - can't send vis packet: ttl exceeded\n");
823 goto out; 823 goto out;
824 } 824 }
825 825
826 memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN); 826 memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
827 packet->ttl--; 827 packet->header.ttl--;
828 828
829 if (is_broadcast_ether_addr(packet->target_orig)) 829 if (is_broadcast_ether_addr(packet->target_orig))
830 broadcast_vis_packet(bat_priv, info); 830 broadcast_vis_packet(bat_priv, info);
831 else 831 else
832 unicast_vis_packet(bat_priv, info); 832 unicast_vis_packet(bat_priv, info);
833 packet->ttl++; /* restore TTL */ 833 packet->header.ttl++; /* restore TTL */
834 834
835out: 835out:
836 if (primary_if) 836 if (primary_if)
@@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv)
910 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); 910 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
911 kref_init(&bat_priv->my_vis_info->refcount); 911 kref_init(&bat_priv->my_vis_info->refcount);
912 bat_priv->my_vis_info->bat_priv = bat_priv; 912 bat_priv->my_vis_info->bat_priv = bat_priv;
913 packet->version = COMPAT_VERSION; 913 packet->header.version = COMPAT_VERSION;
914 packet->packet_type = BAT_VIS; 914 packet->header.packet_type = BAT_VIS;
915 packet->ttl = TTL; 915 packet->header.ttl = TTL;
916 packet->seqno = 0; 916 packet->seqno = 0;
917 packet->entries = 0; 917 packet->entries = 0;
918 918