]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 1997-2021 Free Software Foundation, Inc. |
1fb05e3d UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
1fb05e3d UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
1fb05e3d | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
1fb05e3d UD |
17 | |
18 | /* Based on the FreeBSD version of this file. Curiously, that file | |
19 | lacks a copyright in the header. */ | |
20 | ||
21 | #ifndef __NET_ETHERNET_H | |
22 | #define __NET_ETHERNET_H 1 | |
23 | ||
1fb05e3d | 24 | #include <sys/types.h> |
11160cb7 ZW |
25 | #include <stdint.h> |
26 | ||
1fb05e3d UD |
27 | #include <linux/if_ether.h> /* IEEE 802.3 Ethernet constants */ |
28 | ||
29 | __BEGIN_DECLS | |
30 | ||
31 | /* This is a name for the 48 bit ethernet address available on many | |
32 | systems. */ | |
33 | struct ether_addr | |
34 | { | |
11160cb7 | 35 | uint8_t ether_addr_octet[ETH_ALEN]; |
1331528f | 36 | } __attribute__ ((__packed__)); |
1fb05e3d UD |
37 | |
38 | /* 10Mb/s ethernet header */ | |
39 | struct ether_header | |
40 | { | |
11160cb7 ZW |
41 | uint8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ |
42 | uint8_t ether_shost[ETH_ALEN]; /* source ether addr */ | |
43 | uint16_t ether_type; /* packet type ID field */ | |
1331528f | 44 | } __attribute__ ((__packed__)); |
1fb05e3d UD |
45 | |
46 | /* Ethernet protocol ID's */ | |
47 | #define ETHERTYPE_PUP 0x0200 /* Xerox PUP */ | |
d03eba12 | 48 | #define ETHERTYPE_SPRITE 0x0500 /* Sprite */ |
1fb05e3d UD |
49 | #define ETHERTYPE_IP 0x0800 /* IP */ |
50 | #define ETHERTYPE_ARP 0x0806 /* Address resolution */ | |
51 | #define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ | |
d03eba12 UD |
52 | #define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ |
53 | #define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ | |
54 | #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ | |
55 | #define ETHERTYPE_IPX 0x8137 /* IPX */ | |
56 | #define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */ | |
57 | #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ | |
58 | ||
1fb05e3d UD |
59 | #define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */ |
60 | #define ETHER_TYPE_LEN 2 /* bytes in type field */ | |
61 | #define ETHER_CRC_LEN 4 /* bytes in CRC field */ | |
62 | #define ETHER_HDR_LEN ETH_HLEN /* total octets in header */ | |
4707d46c UD |
63 | #define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */ |
64 | #define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */ | |
1fb05e3d | 65 | |
2ea6af74 | 66 | /* make sure ethernet length is valid */ |
1fb05e3d UD |
67 | #define ETHER_IS_VALID_LEN(foo) \ |
68 | ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) | |
69 | ||
70 | /* | |
71 | * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have | |
72 | * (type-ETHERTYPE_TRAIL)*512 bytes of data followed | |
73 | * by an ETHER type (as given above) and then the (variable-length) header. | |
74 | */ | |
75 | #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ | |
76 | #define ETHERTYPE_NTRAILER 16 | |
77 | ||
78 | #define ETHERMTU ETH_DATA_LEN | |
4707d46c | 79 | #define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) |
1fb05e3d UD |
80 | |
81 | __END_DECLS | |
82 | ||
4707d46c | 83 | #endif /* net/ethernet.h */ |