aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/if_arp.h
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-03-03 12:20:57 -0800
committerDavid S. Miller <davem@davemloft.net>2008-03-03 12:20:57 -0800
commit988b705077d8f922408913f4f521ae073256d4a1 (patch)
tree9b57725b954e1e96a80043ed43d83f8e032b47b6 /include/linux/if_arp.h
parentipv6: fix inet6_init/icmpv6_cleanup sections mismatch (diff)
downloadwireguard-linux-988b705077d8f922408913f4f521ae073256d4a1.tar.xz
wireguard-linux-988b705077d8f922408913f4f521ae073256d4a1.zip
[ARP]: Introduce the arp_hdr_len helper.
There are some place, that calculate the ARP header length. These calculations are correct, but a) some operate with "magic" constants, b) enlarge the code length (sometimes at the cost of coding style), c) are not informative from the first glance. The proposal is to introduce a helper, that includes all the good sides of these calculations. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_arp.h')
-rw-r--r--include/linux/if_arp.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 296e8e86e91d..4d3401812e6c 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -156,6 +156,12 @@ static inline struct arphdr *arp_hdr(const struct sk_buff *skb)
{
return (struct arphdr *)skb_network_header(skb);
}
+
+static inline int arp_hdr_len(struct net_device *dev)
+{
+ /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
+ return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2;
+}
#endif
#endif /* _LINUX_IF_ARP_H */