f1e168ccdd1e01feba59114b0c2448b0731ef6cf
[dragonfly.git] / sys / net / ethernet.h
1 /*
2  * Fundamental constants relating to ethernet.
3  *
4  * $FreeBSD: src/sys/net/ethernet.h,v 1.12.2.8 2002/12/01 14:03:09 sobomax Exp $
5  * $DragonFly: src/sys/net/ethernet.h,v 1.21 2008/09/17 07:51:59 sephe Exp $
6  *
7  */
8
9 #ifndef _NET_ETHERNET_H_
10 #define _NET_ETHERNET_H_
11
12 #ifndef _SYS_TYPES_H_
13 #include <sys/types.h>
14 #endif
15
16 /*
17  * The number of bytes in an ethernet (MAC) address.
18  */
19 #define ETHER_ADDR_LEN          6
20
21 /*
22  * The number of bytes in the type field.
23  */
24 #define ETHER_TYPE_LEN          2
25
26 /*
27  * The number of bytes in the trailing CRC field.
28  */
29 #define ETHER_CRC_LEN           4
30
31 /*
32  * Mbuf adjust factor to force 32-bit alignment of IP header.
33  * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a
34  * receive so the upper layers get the IP header properly aligned
35  * past the 14-byte Ethernet header.
36  */
37 #define ETHER_ALIGN             2
38
39 /*
40  * The length of the combined header.
41  */
42 #define ETHER_HDR_LEN           (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
43
44 /*
45  * The minimum packet length.
46  */
47 #define ETHER_MIN_LEN           64
48
49 /*
50  * The maximum packet length.
51  */
52 #define ETHER_MAX_LEN           1518
53 #define ETHER_MAX_LEN_JUMBO     9018    /* max jumbo frame len, including CRC */
54
55 #define ETHER_VLAN_ENCAP_LEN    4       /* len of 802.1Q VLAN encapsulation */
56
57 /*
58  * Ethernet CRC32 polynomials (big- and little-endian verions).
59  */
60 #define ETHER_CRC_POLY_LE       0xedb88320
61 #define ETHER_CRC_POLY_BE       0x04c11db6
62
63 /*
64  * Structure of a 10Mb/s Ethernet header.
65  */
66 struct  ether_header {
67         u_char  ether_dhost[ETHER_ADDR_LEN];
68         u_char  ether_shost[ETHER_ADDR_LEN];
69         u_short ether_type;
70 };
71
72 /*
73  * Structure of a 48-bit Ethernet address.
74  */
75 struct  ether_addr {
76         u_char octet[ETHER_ADDR_LEN];
77 };
78
79 extern const uint8_t    etherbroadcastaddr[ETHER_ADDR_LEN];
80
81 #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
82
83 /*
84  *  NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
85  *  However, there are some conflicts.
86  */
87
88 #define ETHERTYPE_8023          0x0004  /* IEEE 802.3 packet */
89                    /* 0x0101 .. 0x1FF      Experimental */
90 #define ETHERTYPE_PUP           0x0200  /* Xerox PUP protocol - see 0A00 */
91 #define ETHERTYPE_PUPAT         0x0200  /* PUP Address Translation - see 0A01 */
92 #define ETHERTYPE_SPRITE        0x0500  /* ??? */
93                              /* 0x0400     Nixdorf */
94 #define ETHERTYPE_NS            0x0600  /* XNS */
95 #define ETHERTYPE_NSAT          0x0601  /* XNS Address Translation (3Mb only) */
96 #define ETHERTYPE_DLOG1         0x0660  /* DLOG (?) */
97 #define ETHERTYPE_DLOG2         0x0661  /* DLOG (?) */
98 #define ETHERTYPE_IP            0x0800  /* IP protocol */
99 #define ETHERTYPE_X75           0x0801  /* X.75 Internet */
100 #define ETHERTYPE_NBS           0x0802  /* NBS Internet */
101 #define ETHERTYPE_ECMA          0x0803  /* ECMA Internet */
102 #define ETHERTYPE_CHAOS         0x0804  /* CHAOSnet */
103 #define ETHERTYPE_X25           0x0805  /* X.25 Level 3 */
104 #define ETHERTYPE_ARP           0x0806  /* Address resolution protocol */
105 #define ETHERTYPE_NSCOMPAT      0x0807  /* XNS Compatibility */
106 #define ETHERTYPE_FRARP         0x0808  /* Frame Relay ARP (RFC1701) */
107                              /* 0x081C     Symbolics Private */
108                     /* 0x0888 - 0x088A     Xyplex */
109 #define ETHERTYPE_UBDEBUG       0x0900  /* Ungermann-Bass network debugger */
110 #define ETHERTYPE_IEEEPUP       0x0A00  /* Xerox IEEE802.3 PUP */
111 #define ETHERTYPE_IEEEPUPAT     0x0A01  /* Xerox IEEE802.3 PUP Address Translation */
112 #define ETHERTYPE_VINES         0x0BAD  /* Banyan VINES */
113 #define ETHERTYPE_VINESLOOP     0x0BAE  /* Banyan VINES Loopback */
114 #define ETHERTYPE_VINESECHO     0x0BAF  /* Banyan VINES Echo */
115
116 /*                     0x1000 - 0x100F     Berkeley Trailer */
117 /*
118  * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
119  * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
120  * by an ETHER type (as given above) and then the (variable-length) header.
121  */
122 #define ETHERTYPE_TRAIL         0x1000  /* Trailer packet */
123 #define ETHERTYPE_NTRAILER      16
124
125 #define ETHERTYPE_DCA           0x1234  /* DCA - Multicast */
126 #define ETHERTYPE_VALID         0x1600  /* VALID system protocol */
127 #define ETHERTYPE_DOGFIGHT      0x1989  /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */
128 #define ETHERTYPE_RCL           0x1995  /* Datapoint Corporation (RCL lan protocol) */
129
130                                         /* The following 3C0x types
131                                            are unregistered: */
132 #define ETHERTYPE_NBPVCD        0x3C00  /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */
133 #define ETHERTYPE_NBPSCD        0x3C01  /* 3Com NBP System control datagram not registered */
134 #define ETHERTYPE_NBPCREQ       0x3C02  /* 3Com NBP Connect request (virtual cct) not registered */
135 #define ETHERTYPE_NBPCRSP       0x3C03  /* 3Com NBP Connect repsonse not registered */
136 #define ETHERTYPE_NBPCC         0x3C04  /* 3Com NBP Connect complete not registered */
137 #define ETHERTYPE_NBPCLREQ      0x3C05  /* 3Com NBP Close request (virtual cct) not registered */
138 #define ETHERTYPE_NBPCLRSP      0x3C06  /* 3Com NBP Close response not registered */
139 #define ETHERTYPE_NBPDG         0x3C07  /* 3Com NBP Datagram (like XNS IDP) not registered */
140 #define ETHERTYPE_NBPDGB        0x3C08  /* 3Com NBP Datagram broadcast not registered */
141 #define ETHERTYPE_NBPCLAIM      0x3C09  /* 3Com NBP Claim NetBIOS name not registered */
142 #define ETHERTYPE_NBPDLTE       0x3C0A  /* 3Com NBP Delete Netbios name not registered */
143 #define ETHERTYPE_NBPRAS        0x3C0B  /* 3Com NBP Remote adaptor status request not registered */
144 #define ETHERTYPE_NBPRAR        0x3C0C  /* 3Com NBP Remote adaptor response not registered */
145 #define ETHERTYPE_NBPRST        0x3C0D  /* 3Com NBP Reset not registered */
146
147 #define ETHERTYPE_PCS           0x4242  /* PCS Basic Block Protocol */
148 #define ETHERTYPE_IMLBLDIAG     0x424C  /* Information Modes Little Big LAN diagnostic */
149 #define ETHERTYPE_DIDDLE        0x4321  /* THD - Diddle */
150 #define ETHERTYPE_IMLBL         0x4C42  /* Information Modes Little Big LAN */
151 #define ETHERTYPE_SIMNET        0x5208  /* BBN Simnet Private */
152 #define ETHERTYPE_DECEXPER      0x6000  /* DEC Unassigned, experimental */
153 #define ETHERTYPE_MOPDL         0x6001  /* DEC MOP dump/load */
154 #define ETHERTYPE_MOPRC         0x6002  /* DEC MOP remote console */
155 #define ETHERTYPE_DECnet        0x6003  /* DEC DECNET Phase IV route */
156 #define ETHERTYPE_DN            ETHERTYPE_DECnet        /* libpcap, tcpdump */
157 #define ETHERTYPE_LAT           0x6004  /* DEC LAT */
158 #define ETHERTYPE_DECDIAG       0x6005  /* DEC diagnostic protocol (at interface initialization?) */
159 #define ETHERTYPE_DECCUST       0x6006  /* DEC customer protocol */
160 #define ETHERTYPE_SCA           0x6007  /* DEC LAVC, SCA */
161 #define ETHERTYPE_AMBER         0x6008  /* DEC AMBER */
162 #define ETHERTYPE_DECMUMPS      0x6009  /* DEC MUMPS */
163                     /* 0x6010 - 0x6014     3Com Corporation */
164 #define ETHERTYPE_TRANSETHER    0x6558  /* Trans Ether Bridging (RFC1701)*/
165 #define ETHERTYPE_RAWFR         0x6559  /* Raw Frame Relay (RFC1701) */
166 #define ETHERTYPE_UBDL          0x7000  /* Ungermann-Bass download */
167 #define ETHERTYPE_UBNIU         0x7001  /* Ungermann-Bass NIUs */
168 #define ETHERTYPE_UBDIAGLOOP    0x7002  /* Ungermann-Bass diagnostic/loopback */
169 #define ETHERTYPE_UBNMC         0x7003  /* Ungermann-Bass ??? (NMC to/from UB Bridge) */
170 #define ETHERTYPE_UBBST         0x7005  /* Ungermann-Bass Bridge Spanning Tree */
171 #define ETHERTYPE_OS9           0x7007  /* OS/9 Microware */
172 #define ETHERTYPE_OS9NET        0x7009  /* OS/9 Net? */
173                     /* 0x7020 - 0x7029     LRT (England) (now Sintrom) */
174 #define ETHERTYPE_RACAL         0x7030  /* Racal-Interlan */
175 #define ETHERTYPE_PRIMENTS      0x7031  /* Prime NTS (Network Terminal Service) */
176 #define ETHERTYPE_CABLETRON     0x7034  /* Cabletron */
177 #define ETHERTYPE_CRONUSVLN     0x8003  /* Cronus VLN */
178 #define ETHERTYPE_CRONUS        0x8004  /* Cronus Direct */
179 #define ETHERTYPE_HP            0x8005  /* HP Probe */
180 #define ETHERTYPE_NESTAR        0x8006  /* Nestar */
181 #define ETHERTYPE_ATTSTANFORD   0x8008  /* AT&T/Stanford (local use) */
182 #define ETHERTYPE_EXCELAN       0x8010  /* Excelan */
183 #define ETHERTYPE_SG_DIAG       0x8013  /* SGI diagnostic type */
184 #define ETHERTYPE_SG_NETGAMES   0x8014  /* SGI network games */
185 #define ETHERTYPE_SG_RESV       0x8015  /* SGI reserved type */
186 #define ETHERTYPE_SG_BOUNCE     0x8016  /* SGI bounce server */
187 #define ETHERTYPE_APOLLODOMAIN  0x8019  /* Apollo DOMAIN */
188 #define ETHERTYPE_TYMSHARE      0x802E  /* Tymeshare */
189 #define ETHERTYPE_TIGAN         0x802F  /* Tigan, Inc. */
190 #define ETHERTYPE_REVARP        0x8035  /* Reverse addr resolution protocol */
191 #define ETHERTYPE_AEONIC        0x8036  /* Aeonic Systems */
192 #define ETHERTYPE_IPXNEW        0x8037  /* IPX (Novell Netware?) */
193 #define ETHERTYPE_LANBRIDGE     0x8038  /* DEC LANBridge */
194 #define ETHERTYPE_DSMD  0x8039  /* DEC DSM/DDP */
195 #define ETHERTYPE_ARGONAUT      0x803A  /* DEC Argonaut Console */
196 #define ETHERTYPE_VAXELN        0x803B  /* DEC VAXELN */
197 #define ETHERTYPE_DECDNS        0x803C  /* DEC DNS Naming Service */
198 #define ETHERTYPE_ENCRYPT       0x803D  /* DEC Ethernet Encryption */
199 #define ETHERTYPE_DECDTS        0x803E  /* DEC Distributed Time Service */
200 #define ETHERTYPE_DECLTM        0x803F  /* DEC LAN Traffic Monitor */
201 #define ETHERTYPE_DECNETBIOS    0x8040  /* DEC PATHWORKS DECnet NETBIOS Emulation */
202 #define ETHERTYPE_DECLAST       0x8041  /* DEC Local Area System Transport */
203                              /* 0x8042     DEC Unassigned */
204 #define ETHERTYPE_PLANNING      0x8044  /* Planning Research Corp. */
205                     /* 0x8046 - 0x8047     AT&T */
206 #define ETHERTYPE_DECAM         0x8048  /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */
207 #define ETHERTYPE_EXPERDATA     0x8049  /* ExperData */
208 #define ETHERTYPE_VEXP          0x805B  /* Stanford V Kernel exp. */
209 #define ETHERTYPE_VPROD         0x805C  /* Stanford V Kernel prod. */
210 #define ETHERTYPE_ES            0x805D  /* Evans & Sutherland */
211 #define ETHERTYPE_LITTLE        0x8060  /* Little Machines */
212 #define ETHERTYPE_COUNTERPOINT  0x8062  /* Counterpoint Computers */
213                     /* 0x8065 - 0x8066     Univ. of Mass @ Amherst */
214 #define ETHERTYPE_VEECO         0x8067  /* Veeco Integrated Auto. */
215 #define ETHERTYPE_GENDYN        0x8068  /* General Dynamics */
216 #define ETHERTYPE_ATT           0x8069  /* AT&T */
217 #define ETHERTYPE_AUTOPHON      0x806A  /* Autophon */
218 #define ETHERTYPE_COMDESIGN     0x806C  /* ComDesign */
219 #define ETHERTYPE_COMPUGRAPHIC  0x806D  /* Compugraphic Corporation */
220                     /* 0x806E - 0x8077     Landmark Graphics Corp. */
221 #define ETHERTYPE_MATRA         0x807A  /* Matra */
222 #define ETHERTYPE_DDE           0x807B  /* Dansk Data Elektronik */
223 #define ETHERTYPE_MERIT         0x807C  /* Merit Internodal (or Univ of Michigan?) */
224                     /* 0x807D - 0x807F     Vitalink Communications */
225 #define ETHERTYPE_VLTLMAN       0x8080  /* Vitalink TransLAN III Management */
226                     /* 0x8081 - 0x8083     Counterpoint Computers */
227                     /* 0x8088 - 0x808A     Xyplex */
228 #define ETHERTYPE_ATALK         0x809B  /* AppleTalk */
229 #define ETHERTYPE_AT            ETHERTYPE_ATALK         /* old NetBSD */
230 #define ETHERTYPE_APPLETALK     ETHERTYPE_ATALK         /* HP-UX */
231                     /* 0x809C - 0x809E     Datability */
232 #define ETHERTYPE_SPIDER        0x809F  /* Spider Systems Ltd. */
233                              /* 0x80A3     Nixdorf */
234                     /* 0x80A4 - 0x80B3     Siemens Gammasonics Inc. */
235                     /* 0x80C0 - 0x80C3     DCA (Digital Comm. Assoc.) Data Exchange Cluster */
236                     /* 0x80C4 - 0x80C5     Banyan Systems */
237 #define ETHERTYPE_PACER         0x80C6  /* Pacer Software */
238 #define ETHERTYPE_APPLITEK      0x80C7  /* Applitek Corporation */
239                     /* 0x80C8 - 0x80CC     Intergraph Corporation */
240                     /* 0x80CD - 0x80CE     Harris Corporation */
241                     /* 0x80CF - 0x80D2     Taylor Instrument */
242                     /* 0x80D3 - 0x80D4     Rosemount Corporation */
243 #define ETHERTYPE_SNA           0x80D5  /* IBM SNA Services over Ethernet */
244 #define ETHERTYPE_VARIAN        0x80DD  /* Varian Associates */
245                     /* 0x80DE - 0x80DF     TRFS (Integrated Solutions Transparent Remote File System) */
246                     /* 0x80E0 - 0x80E3     Allen-Bradley */
247                     /* 0x80E4 - 0x80F0     Datability */
248 #define ETHERTYPE_RETIX         0x80F2  /* Retix */
249 #define ETHERTYPE_AARP          0x80F3  /* AppleTalk AARP */
250                     /* 0x80F4 - 0x80F5     Kinetics */
251 #define ETHERTYPE_APOLLO        0x80F7  /* Apollo Computer */
252 #define ETHERTYPE_VLAN          0x8100  /* IEEE 802.1Q VLAN tagging (XXX conflicts) */
253                     /* 0x80FF - 0x8101     Wellfleet Communications (XXX conflicts) */
254 #define ETHERTYPE_BOFL          0x8102  /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */
255 #define ETHERTYPE_WELLFLEET     0x8103  /* Wellfleet Communications */
256                     /* 0x8107 - 0x8109     Symbolics Private */
257 #define ETHERTYPE_TALARIS       0x812B  /* Talaris */
258 #define ETHERTYPE_WATERLOO      0x8130  /* Waterloo Microsystems Inc. (XXX which?) */
259 #define ETHERTYPE_HAYES         0x8130  /* Hayes Microcomputers (XXX which?) */
260 #define ETHERTYPE_VGLAB         0x8131  /* VG Laboratory Systems */
261                     /* 0x8132 - 0x8137     Bridge Communications */
262 #define ETHERTYPE_IPX           0x8137  /* Novell (old) NetWare IPX (ECONFIG E option) */
263 #define ETHERTYPE_NOVELL        0x8138  /* Novell, Inc. */
264                     /* 0x8139 - 0x813D     KTI */
265 #define ETHERTYPE_MUMPS         0x813F  /* M/MUMPS data sharing */
266 #define ETHERTYPE_AMOEBA        0x8145  /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */
267 #define ETHERTYPE_FLIP          0x8146  /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */
268 #define ETHERTYPE_VURESERVED    0x8147  /* Vrije Universiteit (NL) [reserved] */
269 #define ETHERTYPE_LOGICRAFT     0x8148  /* Logicraft */
270 #define ETHERTYPE_NCD           0x8149  /* Network Computing Devices */
271 #define ETHERTYPE_ALPHA         0x814A  /* Alpha Micro */
272 #define ETHERTYPE_SNMP          0x814C  /* SNMP over Ethernet (see RFC1089) */
273                     /* 0x814D - 0x814E     BIIN */
274 #define ETHERTYPE_TEC   0x814F  /* Technically Elite Concepts */
275 #define ETHERTYPE_RATIONAL      0x8150  /* Rational Corp */
276                     /* 0x8151 - 0x8153     Qualcomm */
277                     /* 0x815C - 0x815E     Computer Protocol Pty Ltd */
278                     /* 0x8164 - 0x8166     Charles River Data Systems */
279 #define ETHERTYPE_XTP           0x817D  /* Protocol Engines XTP */
280 #define ETHERTYPE_SGITW         0x817E  /* SGI/Time Warner prop. */
281 #define ETHERTYPE_HIPPI_FP      0x8180  /* HIPPI-FP encapsulation */
282 #define ETHERTYPE_STP           0x8181  /* Scheduled Transfer STP, HIPPI-ST */
283                     /* 0x8182 - 0x8183     Reserved for HIPPI-6400 */
284                     /* 0x8184 - 0x818C     SGI prop. */
285 #define ETHERTYPE_MOTOROLA      0x818D  /* Motorola */
286 #define ETHERTYPE_NETBEUI       0x8191  /* PowerLAN NetBIOS/NetBEUI (PC) */
287                     /* 0x819A - 0x81A3     RAD Network Devices */
288                     /* 0x81B7 - 0x81B9     Xyplex */
289                     /* 0x81CC - 0x81D5     Apricot Computers */
290                     /* 0x81D6 - 0x81DD     Artisoft Lantastic */
291                     /* 0x81E6 - 0x81EF     Polygon */
292                     /* 0x81F0 - 0x81F2     Comsat Labs */
293                     /* 0x81F3 - 0x81F5     SAIC */
294                     /* 0x81F6 - 0x81F8     VG Analytical */
295                     /* 0x8203 - 0x8205     QNX Software Systems Ltd. */
296                     /* 0x8221 - 0x8222     Ascom Banking Systems */
297                     /* 0x823E - 0x8240     Advanced Encryption Systems */
298                     /* 0x8263 - 0x826A     Charles River Data Systems */
299                     /* 0x827F - 0x8282     Athena Programming */
300                     /* 0x829A - 0x829B     Inst Ind Info Tech */
301                     /* 0x829C - 0x82AB     Taurus Controls */
302                     /* 0x82AC - 0x8693     Walker Richer & Quinn */
303 #define ETHERTYPE_ACCTON        0x8390  /* Accton Technologies (unregistered) */
304 #define ETHERTYPE_TALARISMC     0x852B  /* Talaris multicast */
305 #define ETHERTYPE_KALPANA       0x8582  /* Kalpana */
306                     /* 0x8694 - 0x869D     Idea Courier */
307                     /* 0x869E - 0x86A1     Computer Network Tech */
308                     /* 0x86A3 - 0x86AC     Gateway Communications */
309 #define ETHERTYPE_SECTRA        0x86DB  /* SECTRA */
310 #define ETHERTYPE_IPV6          0x86DD  /* IP protocol version 6 */
311 #define ETHERTYPE_DELTACON      0x86DE  /* Delta Controls */
312 #define ETHERTYPE_ATOMIC        0x86DF  /* ATOMIC */
313                     /* 0x86E0 - 0x86EF     Landis & Gyr Powers */
314                     /* 0x8700 - 0x8710     Motorola */
315 #define ETHERTYPE_RDP           0x8739  /* Control Technology Inc. RDP Without IP */
316 #define ETHERTYPE_MICP          0x873A  /* Control Technology Inc. Mcast Industrial Ctrl Proto. */
317                     /* 0x873B - 0x873C     Control Technology Inc. Proprietary */
318 #define ETHERTYPE_TCPCOMP       0x876B  /* TCP/IP Compression (RFC1701) */
319 #define ETHERTYPE_IPAS          0x876C  /* IP Autonomous Systems (RFC1701) */
320 #define ETHERTYPE_SECUREDATA    0x876D  /* Secure Data (RFC1701) */
321 #define ETHERTYPE_FLOWCONTROL   0x8808  /* 802.3x flow control packet */
322 #define ETHERTYPE_PPP           0x880B  /* PPP (obsolete by PPPOE) */
323 #define ETHERTYPE_HITACHI       0x8820  /* Hitachi Cable (Optoelectronic Systems Laboratory) */
324 #define ETHERTYPE_MPLS          0x8847  /* MPLS Unicast */
325 #define ETHERTYPE_MPLS_MCAST    0x8848  /* MPLS Multicast */
326 #define ETHERTYPE_AXIS          0x8856  /* Axis Communications AB proprietary bootstrap/config */
327 #define ETHERTYPE_PPPOEDISC     0x8863  /* PPP Over Ethernet Discovery Stage */
328 #define ETHERTYPE_PPPOE         0x8864  /* PPP Over Ethernet Session Stage */
329 #define ETHERTYPE_LANPROBE      0x8888  /* HP LanProbe test? */
330 #define ETHERTYPE_PAE           0x888e  /* EAPOL PAE/802.1x */
331 #define ETHERTYPE_LOOPBACK      0x9000  /* Loopback: used to test interfaces */
332 #define ETHERTYPE_LBACK         ETHERTYPE_LOOPBACK      /* DEC MOP loopback */
333 #define ETHERTYPE_XNSSM         0x9001  /* 3Com (Formerly Bridge Communications), XNS Systems Management */
334 #define ETHERTYPE_TCPSM         0x9002  /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */
335 #define ETHERTYPE_BCLOOP        0x9003  /* 3Com (Formerly Bridge Communications), loopback detection */
336 #define ETHERTYPE_DEBNI         0xAAAA  /* DECNET? Used by VAX 6220 DEBNI */
337 #define ETHERTYPE_SONIX         0xFAF5  /* Sonix Arpeggio */
338 #define ETHERTYPE_VITAL         0xFF00  /* BBN VITAL-LanBridge cache wakeups */
339                     /* 0xFF00 - 0xFFOF     ISC Bunker Ramo */
340
341 #define ETHERTYPE_MAX           0xFFFF  /* Maximum valid ethernet type, reserved */
342
343 /*
344  * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
345  * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
346  * by an ETHER type (as given above) and then the (variable-length) header.
347  */
348 #define ETHERTYPE_TRAIL         0x1000          /* Trailer packet */
349 #define ETHERTYPE_NTRAILER      16
350
351 #define ETHERMTU        (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
352 #define ETHERMIN        (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
353 #define ETHERMTU_JUMBO  (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
354
355 #ifdef _KERNEL
356
357 #define M_ETHER_BRIDGED         M_PROTO1
358 #define M_ETHER_VLANCHECKED     M_PROTO2
359 #define M_ETHER_BRIDGED_FROM_US M_PROTO3
360
361 #define M_ETHER_FLAGS           (M_ETHER_BRIDGED | M_ETHER_VLANCHECKED | \
362                                  M_ETHER_BRIDGED_FROM_US)
363
364 struct ifnet;
365 struct mbuf;
366 struct mbuf_chain;
367
368 extern  void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp);
369 extern  void (*ng_ether_input_orphan_p)(struct ifnet *ifp,
370                 struct mbuf *m, const struct ether_header *eh);
371 extern  int  (*ng_ether_output_p)(struct ifnet *ifp, struct mbuf **mp);
372 extern  void (*ng_ether_attach_p)(struct ifnet *ifp);
373 extern  void (*ng_ether_detach_p)(struct ifnet *ifp);
374
375 extern  void (*vlan_input_p)(struct mbuf *m);
376
377 /*
378  * The ETHER_BPF_MTAP macro should be used by drivers which support hardware
379  * offload for VLAN tag processing.  It will check the mbuf to see if it has
380  * M_VLANTAG set, and if it does, will pass the packet along to
381  * vlan_ether_ptap.  This function will re-insert VLAN tags for the duration
382  * of the tap, so they show up properly for network analyzers.
383  */
384 #define ETHER_BPF_MTAP(_ifp, _m) do {                                   \
385         if ((_ifp)->if_bpf) {                                           \
386                 M_ASSERTPKTHDR((_m));                                   \
387                 if ((_m)->m_flags & M_VLANTAG) {                        \
388                         vlan_ether_ptap((_ifp)->if_bpf, (_m),           \
389                                         (_m)->m_pkthdr.ether_vlantag);  \
390                 } else {                                                \
391                         bpf_mtap((_ifp)->if_bpf, (_m));                 \
392                 }                                                       \
393         }                                                               \
394 } while (0)
395
396 struct altq_pktattr;
397 struct ifaltq;
398
399 void    altq_etherclassify(struct ifaltq *, struct mbuf *, struct altq_pktattr *);
400
401 #else /* _KERNEL */
402
403 #include <sys/cdefs.h>
404
405 /*
406  * Ethernet address conversion/parsing routines.
407  */
408 __BEGIN_DECLS
409 struct  ether_addr *ether_aton (const char *);
410 struct ether_addr       *ether_aton_r(const char *, struct ether_addr *);
411 int     ether_hostton (const char *, struct ether_addr *);
412 int     ether_line (const char *, struct ether_addr *, char *);
413 char    *ether_ntoa (const struct ether_addr *);
414 char    *ether_ntoa_r(const struct ether_addr *, char *);
415 int     ether_ntohost (char *, const struct ether_addr *);
416 __END_DECLS
417
418 #endif /* !_KERNEL */
419
420 #endif /* !_NET_ETHERNET_H_ */