xref: /linux/include/linux/if_ether.h (revision 1a9239bb4253f9076b5b4b2a1a4e8d7defd77a95)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * INET		An implementation of the TCP/IP protocol suite for the LINUX
4  *		operating system.  INET is implemented using the  BSD Socket
5  *		interface as the means of communication with the user level.
6  *
7  *		Global definitions for the Ethernet IEEE 802.3 interface.
8  *
9  * Version:	@(#)if_ether.h	1.0.1a	02/08/94
10  *
11  * Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12  *		Donald Becker, <becker@super.org>
13  *		Alan Cox, <alan@lxorguk.ukuu.org.uk>
14  *		Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
15  */
16 #ifndef _LINUX_IF_ETHER_H
17 #define _LINUX_IF_ETHER_H
18 
19 #include <linux/skbuff.h>
20 #include <uapi/linux/if_ether.h>
21 
22 /* XX:XX:XX:XX:XX:XX */
23 #define MAC_ADDR_STR_LEN (3 * ETH_ALEN - 1)
24 
eth_hdr(const struct sk_buff * skb)25 static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
26 {
27 	return (struct ethhdr *)skb_mac_header(skb);
28 }
29 
30 /* Prefer this version in TX path, instead of
31  * skb_reset_mac_header() + eth_hdr()
32  */
skb_eth_hdr(const struct sk_buff * skb)33 static inline struct ethhdr *skb_eth_hdr(const struct sk_buff *skb)
34 {
35 	return (struct ethhdr *)skb->data;
36 }
37 
inner_eth_hdr(const struct sk_buff * skb)38 static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb)
39 {
40 	return (struct ethhdr *)skb_inner_mac_header(skb);
41 }
42 
43 int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
44 
45 extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
46 
47 #endif	/* _LINUX_IF_ETHER_H */
48