]> git.sur5r.net Git - freertos/blob - Demo/Common/ethernet/lwIP/include/netif/etharp.h
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@82 1d2547de-c912-0410-9cb9...
[freertos] / Demo / Common / ethernet / lwIP / include / netif / etharp.h
1 /*\r
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
6  * \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
9  *\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
17  *\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
27  * OF SUCH DAMAGE.\r
28  *\r
29  * This file is part of the lwIP TCP/IP stack.\r
30  * \r
31  * Author: Adam Dunkels <adam@sics.se>\r
32  *\r
33  */\r
34 \r
35 #ifndef __NETIF_ETHARP_H__\r
36 #define __NETIF_ETHARP_H__\r
37 \r
38 #ifndef ETH_PAD_SIZE\r
39 #define ETH_PAD_SIZE 0\r
40 #endif\r
41 \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
46 \r
47 #ifdef PACK_STRUCT_USE_INCLUDES\r
48 #  include "arch/bpstruct.h"\r
49 #endif\r
50 PACK_STRUCT_BEGIN\r
51 struct eth_addr {\r
52   PACK_STRUCT_FIELD(u8_t addr[6]);\r
53 } PACK_STRUCT_STRUCT;\r
54 PACK_STRUCT_END\r
55 #ifdef PACK_STRUCT_USE_INCLUDES\r
56 #  include "arch/epstruct.h"\r
57 #endif\r
58 \r
59 #ifdef PACK_STRUCT_USE_INCLUDES\r
60 #  include "arch/bpstruct.h"\r
61 #endif\r
62 PACK_STRUCT_BEGIN\r
63 struct eth_hdr {\r
64 #if ETH_PAD_SIZE\r
65   PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);\r
66 #endif\r
67   PACK_STRUCT_FIELD(struct eth_addr dest);\r
68   PACK_STRUCT_FIELD(struct eth_addr src);\r
69   PACK_STRUCT_FIELD(u16_t type);\r
70 } PACK_STRUCT_STRUCT;\r
71 PACK_STRUCT_END\r
72 #ifdef PACK_STRUCT_USE_INCLUDES\r
73 #  include "arch/epstruct.h"\r
74 #endif\r
75 \r
76 #ifdef PACK_STRUCT_USE_INCLUDES\r
77 #  include "arch/bpstruct.h"\r
78 #endif\r
79 PACK_STRUCT_BEGIN\r
80 /** the ARP message */\r
81 struct etharp_hdr {\r
82   PACK_STRUCT_FIELD(struct eth_hdr ethhdr);\r
83   PACK_STRUCT_FIELD(u16_t hwtype);\r
84   PACK_STRUCT_FIELD(u16_t proto);\r
85   PACK_STRUCT_FIELD(u16_t _hwlen_protolen);\r
86   PACK_STRUCT_FIELD(u16_t opcode);\r
87   PACK_STRUCT_FIELD(struct eth_addr shwaddr);\r
88   PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);\r
89   PACK_STRUCT_FIELD(struct eth_addr dhwaddr);\r
90   PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);\r
91 } PACK_STRUCT_STRUCT;\r
92 PACK_STRUCT_END\r
93 #ifdef PACK_STRUCT_USE_INCLUDES\r
94 #  include "arch/epstruct.h"\r
95 #endif\r
96 \r
97 #ifdef PACK_STRUCT_USE_INCLUDES\r
98 #  include "arch/bpstruct.h"\r
99 #endif\r
100 PACK_STRUCT_BEGIN\r
101 struct ethip_hdr {\r
102   PACK_STRUCT_FIELD(struct eth_hdr eth);\r
103   PACK_STRUCT_FIELD(struct ip_hdr ip);\r
104 } PACK_STRUCT_STRUCT;\r
105 PACK_STRUCT_END\r
106 #ifdef PACK_STRUCT_USE_INCLUDES\r
107 #  include "arch/epstruct.h"\r
108 #endif\r
109 \r
110 /** 5 seconds period */\r
111 #define ARP_TMR_INTERVAL 5000\r
112 \r
113 #define ETHTYPE_ARP 0x0806\r
114 #define ETHTYPE_IP  0x0800\r
115 \r
116 \r
117 void etharp_init(void);\r
118 void etharp_tmr(void);\r
119 s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,\r
120          struct eth_addr **eth_ret, struct ip_addr **ip_ret);\r
121 void etharp_ip_input(struct netif *netif, struct pbuf *p);\r
122 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,\r
123          struct pbuf *p);\r
124 err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr,\r
125          struct pbuf *q);\r
126 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);\r
127 err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);\r
128 \r
129 #endif /* __NETIF_ARP_H__ */\r