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