The Pedigree Project 0.1
lwip/prot/ethernet.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
25/*
26 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without modification,
30 * are permitted provided that the following conditions are met:
31 *
32 * 1. Redistributions of source code must retain the above copyright notice,
33 * this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright notice,
35 * this list of conditions and the following disclaimer in the documentation
36 * and/or other materials provided with the distribution.
37 * 3. The name of the author may not be used to endorse or promote products
38 * derived from this software without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
41 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
43 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
45 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
48 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 * OF SUCH DAMAGE.
50 *
51 * This file is part of the lwIP TCP/IP stack.
52 *
53 * Author: Adam Dunkels <adam@sics.se>
54 *
55 */
56#ifndef LWIP_HDR_PROT_ETHERNET_H
57#define LWIP_HDR_PROT_ETHERNET_H
58
59#include "lwip/arch.h"
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65#ifndef ETH_HWADDR_LEN
66#ifdef ETHARP_HWADDR_LEN
67#define ETH_HWADDR_LEN ETHARP_HWADDR_LEN /* compatibility mode */
68#else
69#define ETH_HWADDR_LEN 6
70#endif
71#endif
72
73#ifdef PACK_STRUCT_USE_INCLUDES
74# include "arch/bpstruct.h"
75#endif
77struct eth_addr {
78 PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]);
79} PACK_STRUCT_STRUCT;
81#ifdef PACK_STRUCT_USE_INCLUDES
82# include "arch/epstruct.h"
83#endif
84
85#ifdef PACK_STRUCT_USE_INCLUDES
86# include "arch/bpstruct.h"
87#endif
90struct eth_hdr {
91#if ETH_PAD_SIZE
92 PACK_STRUCT_FLD_8(u8_t padding[ETH_PAD_SIZE]);
93#endif
94 PACK_STRUCT_FLD_S(struct eth_addr dest);
95 PACK_STRUCT_FLD_S(struct eth_addr src);
96 PACK_STRUCT_FIELD(u16_t type);
97} PACK_STRUCT_STRUCT;
99#ifdef PACK_STRUCT_USE_INCLUDES
100# include "arch/epstruct.h"
101#endif
102
103#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
104
105#ifdef PACK_STRUCT_USE_INCLUDES
106# include "arch/bpstruct.h"
107#endif
113 PACK_STRUCT_FIELD(u16_t prio_vid);
114 PACK_STRUCT_FIELD(u16_t tpid);
115} PACK_STRUCT_STRUCT;
117#ifdef PACK_STRUCT_USE_INCLUDES
118# include "arch/epstruct.h"
119#endif
120
121#define SIZEOF_VLAN_HDR 4
122#define VLAN_ID(vlan_hdr) (lwip_htons((vlan_hdr)->prio_vid) & 0xFFF)
123
129 ETHTYPE_IP = 0x0800U,
131 ETHTYPE_ARP = 0x0806U,
133 ETHTYPE_WOL = 0x0842U,
135 ETHTYPE_RARP = 0x8035U,
137 ETHTYPE_VLAN = 0x8100U,
139 ETHTYPE_IPV6 = 0x86DDU,
143 ETHTYPE_PPPOE = 0x8864U,
145 ETHTYPE_JUMBO = 0x8870U,
151 ETHTYPE_LLDP = 0x88CCU,
153 ETHTYPE_SERCOS = 0x88CDU,
155 ETHTYPE_MRP = 0x88E3U,
157 ETHTYPE_PTP = 0x88F7U,
159 ETHTYPE_QINQ = 0x9100U
161
163#define LL_IP4_MULTICAST_ADDR_0 0x01
164#define LL_IP4_MULTICAST_ADDR_1 0x00
165#define LL_IP4_MULTICAST_ADDR_2 0x5e
166
168#define LL_IP6_MULTICAST_ADDR_0 0x33
169#define LL_IP6_MULTICAST_ADDR_1 0x33
170
173#ifndef ETHADDR32_COPY
174#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
175#endif
176
179#ifndef ETHADDR16_COPY
180#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
181#endif
182
183#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0)
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif /* LWIP_HDR_PROT_ETHERNET_H */
#define PACK_STRUCT_END
Definition arch.h:270
#define PACK_STRUCT_BEGIN
Definition arch.h:261
#define PACK_STRUCT_FLD_8(x)
Definition arch.h:301
#define PACK_STRUCT_FIELD(x)
Definition arch.h:292
#define PACK_STRUCT_FLD_S(x)
Definition arch.h:310
@ ETHTYPE_LLDP
@ ETHTYPE_RARP
@ ETHTYPE_JUMBO
@ ETHTYPE_QINQ
@ ETHTYPE_ARP
@ ETHTYPE_ETHERCAT
@ ETHTYPE_WOL
@ ETHTYPE_PPPOEDISC
@ ETHTYPE_PROFINET
@ ETHTYPE_PPPOE
@ ETHTYPE_PTP
@ ETHTYPE_IPV6
@ ETHTYPE_SERCOS
@ ETHTYPE_IP
@ ETHTYPE_MRP
@ ETHTYPE_VLAN
#define ETH_PAD_SIZE
Definition opt.h:624