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