2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Fundamental constants relating to ethernet.
35 #ifndef _NET_ETHERNET_H_
36 #define _NET_ETHERNET_H_
37 #include <sys/appleapiopts.h>
40 * The number of bytes in an ethernet (MAC) address.
42 #define ETHER_ADDR_LEN 6
45 * The number of bytes in the type field.
47 #define ETHER_TYPE_LEN 2
50 * The number of bytes in the trailing CRC field.
52 #define ETHER_CRC_LEN 4
55 * The length of the combined header.
57 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
60 * The minimum packet length.
62 #define ETHER_MIN_LEN 64
65 * The maximum packet length.
67 #define ETHER_MAX_LEN 1518
70 * A macro to validate a length with
72 #define ETHER_IS_VALID_LEN(foo) \
73 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
76 * Structure of a 10Mb/s Ethernet header.
79 u_char ether_dhost
[ETHER_ADDR_LEN
];
80 u_char ether_shost
[ETHER_ADDR_LEN
];
85 * Structure of a 48-bit Ethernet address.
88 u_char octet
[ETHER_ADDR_LEN
];
91 #define ether_addr_octet octet
93 #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
94 #define ETHERTYPE_IP 0x0800 /* IP protocol */
95 #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
96 #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
97 #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
98 #define ETHERTYPE_IPV6 0x86dd /* IPv6 */
99 #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
100 /* XXX - add more useful types here */
103 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
104 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
105 * by an ETHER type (as given above) and then the (variable-length) header.
107 #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
108 #define ETHERTYPE_NTRAILER 16
110 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
111 #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
113 #ifdef KERNEL_PRIVATE
115 * The following are used by ethernet interfaces.
118 struct ether_addr
*ether_aton(const char *);
120 #ifdef BSD_KERNEL_PRIVATE
121 extern u_char etherbroadcastaddr
[ETHER_ADDR_LEN
];
123 #endif /* KERNEL_PRIVATE */
126 #include <sys/cdefs.h>
129 * Ethernet address conversion/parsing routines.
133 int ether_hostton(const char *, struct ether_addr
*);
134 int ether_line(const char *, struct ether_addr
*, char *);
135 char *ether_ntoa(const struct ether_addr
*);
136 struct ether_addr
*ether_aton(const char *);
137 int ether_ntohost(char *, const struct ether_addr
*);
141 #endif /* !_NET_ETHERNET_H_ */