2 * Fundamental constants relating to ethernet.
4 * $Id: ethernet.h,v 1.8 1997/02/22 09:40:58 peter Exp $
8 #ifndef _NET_ETHERNET_H_
9 #define _NET_ETHERNET_H_
12 * The number of bytes in an ethernet (MAC) address.
14 #define ETHER_ADDR_LEN 6
17 * The number of bytes in the type field.
19 #define ETHER_TYPE_LEN 2
22 * The number of bytes in the trailing CRC field.
24 #define ETHER_CRC_LEN 4
27 * The length of the combined header.
29 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
32 * The minimum packet length.
34 #define ETHER_MIN_LEN 64
37 * The maximum packet length.
39 #define ETHER_MAX_LEN 1518
42 * A macro to validate a length with
44 #define ETHER_IS_VALID_LEN(foo) \
45 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
48 * Structure of a 10Mb/s Ethernet header.
51 u_char ether_dhost[ETHER_ADDR_LEN];
52 u_char ether_shost[ETHER_ADDR_LEN];
57 * Structure of a 48-bit Ethernet address.
60 u_char octet[ETHER_ADDR_LEN];
63 #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
64 #define ETHERTYPE_IP 0x0800 /* IP protocol */
65 #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
66 #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
67 #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
68 #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
69 /* XXX - add more useful types here */
72 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
73 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
74 * by an ETHER type (as given above) and then the (variable-length) header.
76 #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
77 #define ETHERTYPE_NTRAILER 16
79 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
80 #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
83 #include <sys/cdefs.h>
86 * Ethernet address conversion/parsing routines.
89 struct ether_addr *ether_aton __P((char *));
90 int ether_hostton __P((char *, struct ether_addr *));
91 int ether_line __P((char *, struct ether_addr *, char *));
92 char *ether_ntoa __P((struct ether_addr *));
93 int ether_ntohost __P((char *, struct ether_addr *));
97 #endif /* !_NET_ETHERNET_H_ */