From 76543d14aec6ce5cb3fc7be9b39c50fcebd2043b Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 20 Nov 2011 15:47:38 +0100 Subject: 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 Signed-off-by: Marek Lindner --- net/batman-adv/vis.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'net/batman-adv/vis.c') diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index cc3b9f2..ac7e661 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) packet->vis_type = atomic_read(&bat_priv->vis_mode); memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); - packet->ttl = TTL; + packet->header.ttl = TTL; packet->seqno = htonl(ntohl(packet->seqno) + 1); packet->entries = 0; 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) goto out; packet = (struct vis_packet *)info->skb_packet->data; - if (packet->ttl < 2) { + if (packet->header.ttl < 2) { pr_debug("Error - can't send vis packet: ttl exceeded\n"); goto out; } memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN); - packet->ttl--; + packet->header.ttl--; if (is_broadcast_ether_addr(packet->target_orig)) broadcast_vis_packet(bat_priv, info); else unicast_vis_packet(bat_priv, info); - packet->ttl++; /* restore TTL */ + packet->header.ttl++; /* restore TTL */ out: if (primary_if) @@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv) INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); kref_init(&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; - packet->version = COMPAT_VERSION; - packet->packet_type = BAT_VIS; - packet->ttl = TTL; + packet->header.version = COMPAT_VERSION; + packet->header.packet_type = BAT_VIS; + packet->header.ttl = TTL; packet->seqno = 0; packet->entries = 0; -- cgit v1.1