2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
\r
3 * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
\r
4 * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
\r
5 * All rights reserved.
\r
7 * Redistribution and use in source and binary forms, with or without modification,
\r
8 * are permitted provided that the following conditions are met:
\r
10 * 1. Redistributions of source code must retain the above copyright notice,
\r
11 * this list of conditions and the following disclaimer.
\r
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
13 * this list of conditions and the following disclaimer in the documentation
\r
14 * and/or other materials provided with the distribution.
\r
15 * 3. The name of the author may not be used to endorse or promote products
\r
16 * derived from this software without specific prior written permission.
\r
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
\r
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
\r
21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
\r
23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\r
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
\r
29 * This file is part of the lwIP TCP/IP stack.
\r
31 * Author: Adam Dunkels <adam@sics.se>
\r
35 #ifndef __NETIF_ETHARP_H__
\r
36 #define __NETIF_ETHARP_H__
\r
38 #include "lwip/opt.h"
\r
40 #if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
\r
42 #include "lwip/pbuf.h"
\r
43 #include "lwip/ip_addr.h"
\r
44 #include "lwip/netif.h"
\r
45 #include "lwip/ip.h"
\r
51 #ifndef ETH_PAD_SIZE
\r
52 #define ETH_PAD_SIZE 0
\r
55 #ifndef ETHARP_HWADDR_LEN
\r
56 #define ETHARP_HWADDR_LEN 6
\r
59 #ifdef PACK_STRUCT_USE_INCLUDES
\r
60 # include "arch/bpstruct.h"
\r
64 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
\r
65 } PACK_STRUCT_STRUCT;
\r
67 #ifdef PACK_STRUCT_USE_INCLUDES
\r
68 # include "arch/epstruct.h"
\r
71 #ifdef PACK_STRUCT_USE_INCLUDES
\r
72 # include "arch/bpstruct.h"
\r
77 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
\r
79 PACK_STRUCT_FIELD(struct eth_addr dest);
\r
80 PACK_STRUCT_FIELD(struct eth_addr src);
\r
81 PACK_STRUCT_FIELD(u16_t type);
\r
82 } PACK_STRUCT_STRUCT;
\r
84 #ifdef PACK_STRUCT_USE_INCLUDES
\r
85 # include "arch/epstruct.h"
\r
88 #ifdef PACK_STRUCT_USE_INCLUDES
\r
89 # include "arch/bpstruct.h"
\r
92 /** the ARP message */
\r
94 PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
\r
95 PACK_STRUCT_FIELD(u16_t hwtype);
\r
96 PACK_STRUCT_FIELD(u16_t proto);
\r
97 PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
\r
98 PACK_STRUCT_FIELD(u16_t opcode);
\r
99 PACK_STRUCT_FIELD(struct eth_addr shwaddr);
\r
100 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
\r
101 PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
\r
102 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
\r
103 } PACK_STRUCT_STRUCT;
\r
105 #ifdef PACK_STRUCT_USE_INCLUDES
\r
106 # include "arch/epstruct.h"
\r
109 #ifdef PACK_STRUCT_USE_INCLUDES
\r
110 # include "arch/bpstruct.h"
\r
114 PACK_STRUCT_FIELD(struct eth_hdr eth);
\r
115 PACK_STRUCT_FIELD(struct ip_hdr ip);
\r
116 } PACK_STRUCT_STRUCT;
\r
118 #ifdef PACK_STRUCT_USE_INCLUDES
\r
119 # include "arch/epstruct.h"
\r
122 /** 5 seconds period */
\r
123 #define ARP_TMR_INTERVAL 5000
\r
125 #define ETHTYPE_ARP 0x0806
\r
126 #define ETHTYPE_IP 0x0800
\r
127 #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
\r
128 #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */
\r
130 /** ARP message types (opcodes) */
\r
131 #define ARP_REQUEST 1
\r
132 #define ARP_REPLY 2
\r
135 /** struct for queueing outgoing packets for unknown address
\r
136 * defined here to be accessed by memp.h
\r
138 struct etharp_q_entry {
\r
139 struct etharp_q_entry *next;
\r
142 #endif /* ARP_QUEUEING */
\r
144 #define etharp_init() /* Compatibility define, not init needed. */
\r
145 void etharp_tmr(void);
\r
146 s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
\r
147 struct eth_addr **eth_ret, struct ip_addr **ip_ret);
\r
148 void etharp_ip_input(struct netif *netif, struct pbuf *p);
\r
149 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
\r
151 err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
\r
152 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
\r
153 err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
\r
155 err_t ethernet_input(struct pbuf *p, struct netif *netif);
\r
158 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
\r
159 const struct eth_addr *ethdst_addr,
\r
160 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
\r
161 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
\r
162 const u16_t opcode);
\r
163 #endif /* LWIP_AUTOIP */
\r
165 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
\r
167 extern const struct eth_addr ethbroadcast, ethzero;
\r
173 #endif /* LWIP_ARP */
\r
175 #endif /* __NETIF_ARP_H__ */
\r