]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/ethernet/uIP/uip-1.0/uip/uip-fw.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / Common / ethernet / uIP / uip-1.0 / uip / uip-fw.h
1 /**\r
2  * \addtogroup uipfw\r
3  * @{\r
4  */\r
5 \r
6 /**\r
7  * \file\r
8  * uIP packet forwarding header file.\r
9  * \author Adam Dunkels <adam@sics.se>\r
10  */\r
11 \r
12 /*\r
13  * Copyright (c) 2004, Swedish Institute of Computer Science.\r
14  * All rights reserved.\r
15  *\r
16  * Redistribution and use in source and binary forms, with or without\r
17  * modification, are permitted provided that the following conditions\r
18  * are met:\r
19  * 1. Redistributions of source code must retain the above copyright\r
20  *    notice, this list of conditions and the following disclaimer.\r
21  * 2. Redistributions in binary form must reproduce the above copyright\r
22  *    notice, this list of conditions and the following disclaimer in the\r
23  *    documentation and/or other materials provided with the distribution.\r
24  * 3. Neither the name of the Institute nor the names of its contributors\r
25  *    may be used to endorse or promote products derived from this software\r
26  *    without specific prior written permission.\r
27  *\r
28  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND\r
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE\r
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
38  * SUCH DAMAGE.\r
39  *\r
40  * This file is part of the uIP TCP/IP stack\r
41  *\r
42  * Author: Adam Dunkels <adam@sics.se>\r
43  *\r
44  * $Id: uip-fw.h,v 1.2 2006/06/12 08:00:30 adam Exp $\r
45  */\r
46 #ifndef __UIP_FW_H__\r
47 #define __UIP_FW_H__\r
48 \r
49 #include "uip.h"\r
50 \r
51 /**\r
52  * Representation of a uIP network interface.\r
53  */\r
54 struct uip_fw_netif {\r
55   struct uip_fw_netif *next;  /**< Pointer to the next interface when\r
56                                  linked in a list. */\r
57   u16_t ipaddr[2];            /**< The IP address of this interface. */\r
58   u16_t netmask[2];           /**< The netmask of the interface. */\r
59   u8_t (* output)(void);\r
60                               /**< A pointer to the function that\r
61                                  sends a packet. */\r
62 };\r
63 \r
64 /**\r
65  * Intantiating macro for a uIP network interface.\r
66  *\r
67  * Example:\r
68  \code\r
69  struct uip_fw_netif slipnetif =\r
70    {UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};\r
71  \endcode\r
72  * \param ip1,ip2,ip3,ip4 The IP address of the network interface.\r
73  *\r
74  * \param nm1,nm2,nm3,nm4 The netmask of the network interface.\r
75  *\r
76  * \param outputfunc A pointer to the output function of the network interface.\r
77  *\r
78  * \hideinitializer\r
79  */\r
80 #define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \\r
81         NULL, \\r
82         {HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \\r
83         {HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \\r
84         outputfunc\r
85 \r
86 /**\r
87  * Set the IP address of a network interface.\r
88  *\r
89  * \param netif A pointer to the uip_fw_netif structure for the network interface.\r
90  *\r
91  * \param addr A pointer to an IP address.\r
92  *\r
93  * \hideinitializer\r
94  */\r
95 #define uip_fw_setipaddr(netif, addr) \\r
96         do { (netif)->ipaddr[0] = ((u16_t *)(addr))[0]; \\r
97              (netif)->ipaddr[1] = ((u16_t *)(addr))[1]; } while(0)\r
98 /**\r
99  * Set the netmask of a network interface.\r
100  *\r
101  * \param netif A pointer to the uip_fw_netif structure for the network interface.\r
102  *\r
103  * \param addr A pointer to an IP address representing the netmask.\r
104  *\r
105  * \hideinitializer\r
106  */\r
107 #define uip_fw_setnetmask(netif, addr) \\r
108         do { (netif)->netmask[0] = ((u16_t *)(addr))[0]; \\r
109              (netif)->netmask[1] = ((u16_t *)(addr))[1]; } while(0)\r
110 \r
111 void uip_fw_init(void);\r
112 u8_t uip_fw_forward(void);\r
113 u8_t uip_fw_output(void);\r
114 void uip_fw_register(struct uip_fw_netif *netif);\r
115 void uip_fw_default(struct uip_fw_netif *netif);\r
116 void uip_fw_periodic(void);\r
117 \r
118 \r
119 /**\r
120  * A non-error message that indicates that a packet should be\r
121  * processed locally.\r
122  *\r
123  * \hideinitializer\r
124  */\r
125 #define UIP_FW_LOCAL     0\r
126 \r
127 /**\r
128  * A non-error message that indicates that something went OK.\r
129  *\r
130  * \hideinitializer\r
131  */\r
132 #define UIP_FW_OK        0\r
133 \r
134 /**\r
135  * A non-error message that indicates that a packet was forwarded.\r
136  *\r
137  * \hideinitializer\r
138  */\r
139 #define UIP_FW_FORWARDED 1\r
140 \r
141 /**\r
142  * A non-error message that indicates that a zero-length packet\r
143  * transmission was attempted, and that no packet was sent.\r
144  *\r
145  * \hideinitializer\r
146  */\r
147 #define UIP_FW_ZEROLEN   2\r
148 \r
149 /**\r
150  * An error message that indicates that a packet that was too large\r
151  * for the outbound network interface was detected.\r
152  *\r
153  * \hideinitializer\r
154  */\r
155 #define UIP_FW_TOOLARGE  3\r
156 \r
157 /**\r
158  * An error message that indicates that no suitable interface could be\r
159  * found for an outbound packet.\r
160  *\r
161  * \hideinitializer\r
162  */\r
163 #define UIP_FW_NOROUTE   4\r
164 \r
165 /**\r
166  * An error message that indicates that a packet that should be\r
167  * forwarded or output was dropped.\r
168  *\r
169  * \hideinitializer\r
170  */\r
171 #define UIP_FW_DROPPED   5\r
172 \r
173 \r
174 #endif /* __UIP_FW_H__ */\r
175 \r
176 /** @} */\r