]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 A |
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 License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Fundamental constants relating to ethernet. | |
30 | * | |
31 | */ | |
32 | ||
33 | #ifndef _NET_ETHERNET_H_ | |
34 | #define _NET_ETHERNET_H_ | |
9bccf70c | 35 | #include <sys/appleapiopts.h> |
1c79356b A |
36 | |
37 | /* | |
38 | * The number of bytes in an ethernet (MAC) address. | |
39 | */ | |
40 | #define ETHER_ADDR_LEN 6 | |
41 | ||
42 | /* | |
43 | * The number of bytes in the type field. | |
44 | */ | |
45 | #define ETHER_TYPE_LEN 2 | |
46 | ||
47 | /* | |
48 | * The number of bytes in the trailing CRC field. | |
49 | */ | |
50 | #define ETHER_CRC_LEN 4 | |
51 | ||
52 | /* | |
53 | * The length of the combined header. | |
54 | */ | |
55 | #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) | |
56 | ||
57 | /* | |
58 | * The minimum packet length. | |
59 | */ | |
60 | #define ETHER_MIN_LEN 64 | |
61 | ||
62 | /* | |
63 | * The maximum packet length. | |
64 | */ | |
65 | #define ETHER_MAX_LEN 1518 | |
66 | ||
67 | /* | |
68 | * A macro to validate a length with | |
69 | */ | |
70 | #define ETHER_IS_VALID_LEN(foo) \ | |
71 | ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) | |
72 | ||
73 | /* | |
74 | * Structure of a 10Mb/s Ethernet header. | |
75 | */ | |
76 | struct ether_header { | |
77 | u_char ether_dhost[ETHER_ADDR_LEN]; | |
78 | u_char ether_shost[ETHER_ADDR_LEN]; | |
79 | u_short ether_type; | |
80 | }; | |
81 | ||
82 | /* | |
83 | * Structure of a 48-bit Ethernet address. | |
84 | */ | |
85 | struct ether_addr { | |
86 | u_char octet[ETHER_ADDR_LEN]; | |
87 | }; | |
88 | ||
89 | #define ether_addr_octet octet | |
90 | ||
91 | #define ETHERTYPE_PUP 0x0200 /* PUP protocol */ | |
92 | #define ETHERTYPE_IP 0x0800 /* IP protocol */ | |
93 | #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ | |
94 | #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */ | |
95 | #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ | |
96 | #define ETHERTYPE_IPV6 0x86dd /* IPv6 */ | |
97 | #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ | |
98 | /* XXX - add more useful types here */ | |
99 | ||
100 | /* | |
101 | * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have | |
102 | * (type-ETHERTYPE_TRAIL)*512 bytes of data followed | |
103 | * by an ETHER type (as given above) and then the (variable-length) header. | |
104 | */ | |
105 | #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ | |
106 | #define ETHERTYPE_NTRAILER 16 | |
107 | ||
108 | #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) | |
109 | #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) | |
110 | ||
91447636 A |
111 | #ifdef KERNEL_PRIVATE |
112 | /* | |
113 | * The following are used by ethernet interfaces. | |
114 | */ | |
115 | ||
116 | struct ether_addr *ether_aton(const char *); | |
117 | ||
118 | #ifdef BSD_KERNEL_PRIVATE | |
119 | extern u_char etherbroadcastaddr[ETHER_ADDR_LEN]; | |
1c79356b | 120 | #endif |
91447636 | 121 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 122 | |
9bccf70c | 123 | #ifndef KERNEL |
1c79356b A |
124 | #include <sys/cdefs.h> |
125 | ||
126 | /* | |
127 | * Ethernet address conversion/parsing routines. | |
128 | */ | |
129 | __BEGIN_DECLS | |
130 | ||
91447636 A |
131 | int ether_hostton(const char *, struct ether_addr *); |
132 | int ether_line(const char *, struct ether_addr *, char *); | |
133 | char *ether_ntoa(const struct ether_addr *); | |
134 | struct ether_addr *ether_aton(const char *); | |
135 | int ether_ntohost(char *, const struct ether_addr *); | |
1c79356b A |
136 | __END_DECLS |
137 | #endif /* !KERNEL */ | |
138 | ||
139 | #endif /* !_NET_ETHERNET_H_ */ |