Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * INET     An implementation of the TCP/IP protocol suite for the LINUX
0004  *      operating system.  INET is implemented using the  BSD Socket
0005  *      interface as the means of communication with the user level.
0006  *
0007  *      Global definitions for the ARP (RFC 826) protocol.
0008  *
0009  * Version: @(#)if_arp.h    1.0.1   04/16/93
0010  *
0011  * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
0012  *      Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
0013  *      Ross Biro
0014  *      Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
0015  *      Florian La Roche,
0016  *      Jonathan Layes <layes@loran.com>
0017  *      Arnaldo Carvalho de Melo <acme@conectiva.com.br> ARPHRD_HWX25
0018  */
0019 #ifndef _LINUX_IF_ARP_H
0020 #define _LINUX_IF_ARP_H
0021 
0022 #include <linux/skbuff.h>
0023 #include <uapi/linux/if_arp.h>
0024 
0025 static inline struct arphdr *arp_hdr(const struct sk_buff *skb)
0026 {
0027     return (struct arphdr *)skb_network_header(skb);
0028 }
0029 
0030 static inline unsigned int arp_hdr_len(const struct net_device *dev)
0031 {
0032     switch (dev->type) {
0033 #if IS_ENABLED(CONFIG_FIREWIRE_NET)
0034     case ARPHRD_IEEE1394:
0035         /* ARP header, device address and 2 IP addresses */
0036         return sizeof(struct arphdr) + dev->addr_len + sizeof(u32) * 2;
0037 #endif
0038     default:
0039         /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
0040         return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2;
0041     }
0042 }
0043 
0044 static inline bool dev_is_mac_header_xmit(const struct net_device *dev)
0045 {
0046     switch (dev->type) {
0047     case ARPHRD_TUNNEL:
0048     case ARPHRD_TUNNEL6:
0049     case ARPHRD_SIT:
0050     case ARPHRD_IPGRE:
0051     case ARPHRD_IP6GRE:
0052     case ARPHRD_VOID:
0053     case ARPHRD_NONE:
0054     case ARPHRD_RAWIP:
0055     case ARPHRD_PIMREG:
0056         return false;
0057     default:
0058         return true;
0059     }
0060 }
0061 
0062 #endif  /* _LINUX_IF_ARP_H */