source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifiHD/src/SOFTWARE_FRAMEWORK/SERVICES/LWIP/lwip-1.3.2/src/include/netif/etharp.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 6.1 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*
4 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
5 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
6 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
23 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
25 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
29 * OF SUCH DAMAGE.
30 *
31 * This file is part of the lwIP TCP/IP stack.
32 *
33 * Author: Adam Dunkels <adam@sics.se>
34 *
35 */
36
37#ifndef __NETIF_ETHARP_H__
38#define __NETIF_ETHARP_H__
39
40#include "lwip/opt.h"
41
42#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
43
44#include "lwip/pbuf.h"
45#include "lwip/ip_addr.h"
46#include "lwip/netif.h"
47#include "lwip/ip.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53#ifndef ETH_PAD_SIZE
54#define ETH_PAD_SIZE          0
55#endif
56
57#ifndef ETHARP_HWADDR_LEN
58#define ETHARP_HWADDR_LEN     6
59#endif
60
61#ifdef PACK_STRUCT_USE_INCLUDES
62#  include "arch/bpstruct.h"
63#endif
64PACK_STRUCT_BEGIN
65struct eth_addr {
66  PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
67} PACK_STRUCT_STRUCT;
68PACK_STRUCT_END
69#ifdef PACK_STRUCT_USE_INCLUDES
70#  include "arch/epstruct.h"
71#endif
72
73#ifdef PACK_STRUCT_USE_INCLUDES
74#  include "arch/bpstruct.h"
75#endif
76PACK_STRUCT_BEGIN
77struct eth_hdr {
78#if ETH_PAD_SIZE
79  PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
80#endif
81  PACK_STRUCT_FIELD(struct eth_addr dest);
82  PACK_STRUCT_FIELD(struct eth_addr src);
83  PACK_STRUCT_FIELD(u16_t type);
84} PACK_STRUCT_STRUCT;
85PACK_STRUCT_END
86#ifdef PACK_STRUCT_USE_INCLUDES
87#  include "arch/epstruct.h"
88#endif
89
90#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
91
92#if ETHARP_SUPPORT_VLAN
93
94#ifdef PACK_STRUCT_USE_INCLUDES
95#  include "arch/bpstruct.h"
96#endif
97PACK_STRUCT_BEGIN
98struct eth_vlan_hdr {
99  PACK_STRUCT_FIELD(u16_t tpid);
100  PACK_STRUCT_FIELD(u16_t prio_vid);
101} PACK_STRUCT_STRUCT;
102PACK_STRUCT_END
103#ifdef PACK_STRUCT_USE_INCLUDES
104#  include "arch/epstruct.h"
105#endif
106
107#define SIZEOF_VLAN_HDR 4
108#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
109
110#endif /* ETHARP_SUPPORT_VLAN */
111
112#ifdef PACK_STRUCT_USE_INCLUDES
113#  include "arch/bpstruct.h"
114#endif
115PACK_STRUCT_BEGIN
116/** the ARP message */
117struct etharp_hdr {
118  PACK_STRUCT_FIELD(u16_t hwtype);
119  PACK_STRUCT_FIELD(u16_t proto);
120  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
121  PACK_STRUCT_FIELD(u16_t opcode);
122  PACK_STRUCT_FIELD(struct eth_addr shwaddr);
123  PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
124  PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
125  PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
126} PACK_STRUCT_STRUCT;
127PACK_STRUCT_END
128#ifdef PACK_STRUCT_USE_INCLUDES
129#  include "arch/epstruct.h"
130#endif
131
132#define SIZEOF_ETHARP_HDR 28
133#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
134
135/** 5 seconds period */
136#define ARP_TMR_INTERVAL 5000
137
138#define ETHTYPE_ARP       0x0806
139#define ETHTYPE_IP        0x0800
140#define ETHTYPE_VLAN      0x8100
141#define ETHTYPE_PPPOEDISC 0x8863  /* PPP Over Ethernet Discovery Stage */
142#define ETHTYPE_PPPOE     0x8864  /* PPP Over Ethernet Session Stage */
143
144/** ARP message types (opcodes) */
145#define ARP_REQUEST 1
146#define ARP_REPLY   2
147
148#if ARP_QUEUEING
149/** struct for queueing outgoing packets for unknown address
150  * defined here to be accessed by memp.h
151  */
152struct etharp_q_entry {
153  struct etharp_q_entry *next;
154  struct pbuf *p;
155};
156#endif /* ARP_QUEUEING */
157
158#define etharp_init() /* Compatibility define, not init needed. */
159void etharp_tmr(void);
160s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
161         struct eth_addr **eth_ret, struct ip_addr **ip_ret);
162void etharp_ip_input(struct netif *netif, struct pbuf *p);
163void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
164         struct pbuf *p);
165err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
166err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
167err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
168/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
169 *  this is an ARP packet sent by a node in order to spontaneously cause other
170 *  nodes to update an entry in their ARP cache.
171 *  From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
172#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
173
174err_t ethernet_input(struct pbuf *p, struct netif *netif);
175
176#if LWIP_AUTOIP
177err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
178                 const struct eth_addr *ethdst_addr,
179                 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
180                 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
181                 const u16_t opcode);
182#endif /* LWIP_AUTOIP */
183
184#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
185
186extern const struct eth_addr ethbroadcast, ethzero;
187
188#ifdef __cplusplus
189}
190#endif
191
192#endif /* LWIP_ARP */
193
194#endif /* __NETIF_ARP_H__ */
Note: See TracBrowser for help on using the repository browser.