These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

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