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