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