xref: /linux-6.15/include/linux/if_ether.h (revision 6d6c1ba7)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * INET		An implementation of the TCP/IP protocol suite for the LINUX
41da177e4SLinus Torvalds  *		operating system.  INET is implemented using the  BSD Socket
51da177e4SLinus Torvalds  *		interface as the means of communication with the user level.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *		Global definitions for the Ethernet IEEE 802.3 interface.
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * Version:	@(#)if_ether.h	1.0.1a	02/08/94
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  * Author:	Fred N. van Kempen, <[email protected]>
121da177e4SLinus Torvalds  *		Donald Becker, <[email protected]>
13113aa838SAlan Cox  *		Alan Cox, <[email protected]>
141da177e4SLinus Torvalds  *		Steve Whitehouse, <[email protected]>
151da177e4SLinus Torvalds  */
161da177e4SLinus Torvalds #ifndef _LINUX_IF_ETHER_H
171da177e4SLinus Torvalds #define _LINUX_IF_ETHER_H
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #include <linux/skbuff.h>
20607ca46eSDavid Howells #include <uapi/linux/if_ether.h>
211da177e4SLinus Torvalds 
22*6d6c1ba7SUday Shankar /* XX:XX:XX:XX:XX:XX */
23*6d6c1ba7SUday Shankar #define MAC_ADDR_STR_LEN (3 * ETH_ALEN - 1)
24*6d6c1ba7SUday Shankar 
eth_hdr(const struct sk_buff * skb)251da177e4SLinus Torvalds static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
261da177e4SLinus Torvalds {
2798e399f8SArnaldo Carvalho de Melo 	return (struct ethhdr *)skb_mac_header(skb);
281da177e4SLinus Torvalds }
2920380731SArnaldo Carvalho de Melo 
3096cc4b69SEric Dumazet /* Prefer this version in TX path, instead of
3196cc4b69SEric Dumazet  * skb_reset_mac_header() + eth_hdr()
3296cc4b69SEric Dumazet  */
skb_eth_hdr(const struct sk_buff * skb)3396cc4b69SEric Dumazet static inline struct ethhdr *skb_eth_hdr(const struct sk_buff *skb)
3496cc4b69SEric Dumazet {
3596cc4b69SEric Dumazet 	return (struct ethhdr *)skb->data;
3696cc4b69SEric Dumazet }
3796cc4b69SEric Dumazet 
inner_eth_hdr(const struct sk_buff * skb)38af67eb9eSAlexander Duyck static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb)
39af67eb9eSAlexander Duyck {
40af67eb9eSAlexander Duyck 	return (struct ethhdr *)skb_inner_mac_header(skb);
41af67eb9eSAlexander Duyck }
42af67eb9eSAlexander Duyck 
433b04dddeSStephen Hemminger int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
443b04dddeSStephen Hemminger 
457ffc49a6SMichael Chan extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
467ffc49a6SMichael Chan 
471da177e4SLinus Torvalds #endif	/* _LINUX_IF_ETHER_H */
48