]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/ethernet.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Fundamental constants relating to ethernet.
30 #ifndef _NET_ETHERNET_H_
31 #define _NET_ETHERNET_H_
32 #include <sys/appleapiopts.h>
35 * The number of bytes in an ethernet (MAC) address.
37 #define ETHER_ADDR_LEN 6
40 * The number of bytes in the type field.
42 #define ETHER_TYPE_LEN 2
45 * The number of bytes in the trailing CRC field.
47 #define ETHER_CRC_LEN 4
50 * The length of the combined header.
52 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
55 * The minimum packet length.
57 #define ETHER_MIN_LEN 64
60 * The maximum packet length.
62 #define ETHER_MAX_LEN 1518
65 * A macro to validate a length with
67 #define ETHER_IS_VALID_LEN(foo) \
68 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
71 * Structure of a 10Mb/s Ethernet header.
74 u_char ether_dhost
[ETHER_ADDR_LEN
];
75 u_char ether_shost
[ETHER_ADDR_LEN
];
80 * Structure of a 48-bit Ethernet address.
83 u_char octet
[ETHER_ADDR_LEN
];
86 #define ether_addr_octet octet
88 #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
89 #define ETHERTYPE_IP 0x0800 /* IP protocol */
90 #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
91 #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
92 #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
93 #define ETHERTYPE_IPV6 0x86dd /* IPv6 */
94 #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
95 /* XXX - add more useful types here */
98 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
99 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
100 * by an ETHER type (as given above) and then the (variable-length) header.
102 #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
103 #define ETHERTYPE_NTRAILER 16
105 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
106 #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
109 #ifdef __APPLE_API_PRIVATE
110 struct ether_addr
*ether_aton
__P((char *));
111 #endif /* __APPLE_API_PRIVATE */
115 #include <sys/cdefs.h>
118 * Ethernet address conversion/parsing routines.
122 int ether_hostton
__P((char *, struct ether_addr
*));
123 int ether_line
__P((char *, struct ether_addr
*, char *));
124 char *ether_ntoa
__P((const struct ether_addr
*));
125 int ether_ntohost
__P((char *, struct ether_addr
*));
129 #endif /* !_NET_ETHERNET_H_ */