]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Fundamental constants relating to ethernet. | |
27 | * | |
28 | */ | |
29 | ||
30 | #ifndef _NET_ETHERNET_H_ | |
31 | #define _NET_ETHERNET_H_ | |
9bccf70c | 32 | #include <sys/appleapiopts.h> |
1c79356b A |
33 | |
34 | /* | |
35 | * The number of bytes in an ethernet (MAC) address. | |
36 | */ | |
37 | #define ETHER_ADDR_LEN 6 | |
38 | ||
39 | /* | |
40 | * The number of bytes in the type field. | |
41 | */ | |
42 | #define ETHER_TYPE_LEN 2 | |
43 | ||
44 | /* | |
45 | * The number of bytes in the trailing CRC field. | |
46 | */ | |
47 | #define ETHER_CRC_LEN 4 | |
48 | ||
49 | /* | |
50 | * The length of the combined header. | |
51 | */ | |
52 | #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) | |
53 | ||
54 | /* | |
55 | * The minimum packet length. | |
56 | */ | |
57 | #define ETHER_MIN_LEN 64 | |
58 | ||
59 | /* | |
60 | * The maximum packet length. | |
61 | */ | |
62 | #define ETHER_MAX_LEN 1518 | |
63 | ||
64 | /* | |
65 | * A macro to validate a length with | |
66 | */ | |
67 | #define ETHER_IS_VALID_LEN(foo) \ | |
68 | ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) | |
69 | ||
70 | /* | |
71 | * Structure of a 10Mb/s Ethernet header. | |
72 | */ | |
73 | struct ether_header { | |
74 | u_char ether_dhost[ETHER_ADDR_LEN]; | |
75 | u_char ether_shost[ETHER_ADDR_LEN]; | |
76 | u_short ether_type; | |
77 | }; | |
78 | ||
79 | /* | |
80 | * Structure of a 48-bit Ethernet address. | |
81 | */ | |
82 | struct ether_addr { | |
83 | u_char octet[ETHER_ADDR_LEN]; | |
84 | }; | |
85 | ||
86 | #define ether_addr_octet octet | |
87 | ||
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 */ | |
96 | ||
97 | /* | |
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. | |
101 | */ | |
102 | #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ | |
103 | #define ETHERTYPE_NTRAILER 16 | |
104 | ||
105 | #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) | |
106 | #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) | |
107 | ||
9bccf70c A |
108 | #ifdef KERNEL |
109 | #ifdef __APPLE_API_PRIVATE | |
1c79356b | 110 | struct ether_addr *ether_aton __P((char *)); |
9bccf70c | 111 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
112 | #endif |
113 | ||
9bccf70c | 114 | #ifndef KERNEL |
1c79356b A |
115 | #include <sys/cdefs.h> |
116 | ||
117 | /* | |
118 | * Ethernet address conversion/parsing routines. | |
119 | */ | |
120 | __BEGIN_DECLS | |
121 | ||
122 | int ether_hostton __P((char *, struct ether_addr *)); | |
123 | int ether_line __P((char *, struct ether_addr *, char *)); | |
55e303ae | 124 | char *ether_ntoa __P((const struct ether_addr *)); |
1c79356b A |
125 | int ether_ntohost __P((char *, struct ether_addr *)); |
126 | __END_DECLS | |
127 | #endif /* !KERNEL */ | |
128 | ||
129 | #endif /* !_NET_ETHERNET_H_ */ |