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