mbeduino + Weatherduino Weather Stations post test

Dependencies:   mbed

Committer:
okini3939
Date:
Tue Oct 26 17:19:28 2010 +0000
Revision:
0:10bcaa7c2253

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:10bcaa7c2253 1 /*
okini3939 0:10bcaa7c2253 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
okini3939 0:10bcaa7c2253 3 * All rights reserved.
okini3939 0:10bcaa7c2253 4 *
okini3939 0:10bcaa7c2253 5 * Redistribution and use in source and binary forms, with or without modification,
okini3939 0:10bcaa7c2253 6 * are permitted provided that the following conditions are met:
okini3939 0:10bcaa7c2253 7 *
okini3939 0:10bcaa7c2253 8 * 1. Redistributions of source code must retain the above copyright notice,
okini3939 0:10bcaa7c2253 9 * this list of conditions and the following disclaimer.
okini3939 0:10bcaa7c2253 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
okini3939 0:10bcaa7c2253 11 * this list of conditions and the following disclaimer in the documentation
okini3939 0:10bcaa7c2253 12 * and/or other materials provided with the distribution.
okini3939 0:10bcaa7c2253 13 * 3. The name of the author may not be used to endorse or promote products
okini3939 0:10bcaa7c2253 14 * derived from this software without specific prior written permission.
okini3939 0:10bcaa7c2253 15 *
okini3939 0:10bcaa7c2253 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
okini3939 0:10bcaa7c2253 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
okini3939 0:10bcaa7c2253 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
okini3939 0:10bcaa7c2253 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
okini3939 0:10bcaa7c2253 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
okini3939 0:10bcaa7c2253 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
okini3939 0:10bcaa7c2253 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
okini3939 0:10bcaa7c2253 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
okini3939 0:10bcaa7c2253 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
okini3939 0:10bcaa7c2253 25 * OF SUCH DAMAGE.
okini3939 0:10bcaa7c2253 26 *
okini3939 0:10bcaa7c2253 27 * This file is part of the lwIP TCP/IP stack.
okini3939 0:10bcaa7c2253 28 *
okini3939 0:10bcaa7c2253 29 * Author: Adam Dunkels <adam@sics.se>
okini3939 0:10bcaa7c2253 30 *
okini3939 0:10bcaa7c2253 31 */
okini3939 0:10bcaa7c2253 32 #ifndef __LWIP_IP_H__
okini3939 0:10bcaa7c2253 33 #define __LWIP_IP_H__
okini3939 0:10bcaa7c2253 34
okini3939 0:10bcaa7c2253 35 #include "lwip/opt.h"
okini3939 0:10bcaa7c2253 36
okini3939 0:10bcaa7c2253 37 #include "lwip/def.h"
okini3939 0:10bcaa7c2253 38 #include "lwip/pbuf.h"
okini3939 0:10bcaa7c2253 39 #include "lwip/ip_addr.h"
okini3939 0:10bcaa7c2253 40 #include "lwip/err.h"
okini3939 0:10bcaa7c2253 41 #include "lwip/netif.h"
okini3939 0:10bcaa7c2253 42
okini3939 0:10bcaa7c2253 43 #ifdef __cplusplus
okini3939 0:10bcaa7c2253 44 extern "C" {
okini3939 0:10bcaa7c2253 45 #endif
okini3939 0:10bcaa7c2253 46
okini3939 0:10bcaa7c2253 47 /** Currently, the function ip_output_if_opt() is only used with IGMP */
okini3939 0:10bcaa7c2253 48 #define IP_OPTIONS_SEND LWIP_IGMP
okini3939 0:10bcaa7c2253 49
okini3939 0:10bcaa7c2253 50 #define IP_HLEN 20
okini3939 0:10bcaa7c2253 51
okini3939 0:10bcaa7c2253 52 #define IP_PROTO_ICMP 1
okini3939 0:10bcaa7c2253 53 #define IP_PROTO_IGMP 2
okini3939 0:10bcaa7c2253 54 #define IP_PROTO_UDP 17
okini3939 0:10bcaa7c2253 55 #define IP_PROTO_UDPLITE 136
okini3939 0:10bcaa7c2253 56 #define IP_PROTO_TCP 6
okini3939 0:10bcaa7c2253 57
okini3939 0:10bcaa7c2253 58 /* This is passed as the destination address to ip_output_if (not
okini3939 0:10bcaa7c2253 59 to ip_output), meaning that an IP header already is constructed
okini3939 0:10bcaa7c2253 60 in the pbuf. This is used when TCP retransmits. */
okini3939 0:10bcaa7c2253 61 #ifdef IP_HDRINCL
okini3939 0:10bcaa7c2253 62 #undef IP_HDRINCL
okini3939 0:10bcaa7c2253 63 #endif /* IP_HDRINCL */
okini3939 0:10bcaa7c2253 64 #define IP_HDRINCL NULL
okini3939 0:10bcaa7c2253 65
okini3939 0:10bcaa7c2253 66 #if LWIP_NETIF_HWADDRHINT
okini3939 0:10bcaa7c2253 67 #define IP_PCB_ADDRHINT ;u8_t addr_hint
okini3939 0:10bcaa7c2253 68 #else
okini3939 0:10bcaa7c2253 69 #define IP_PCB_ADDRHINT
okini3939 0:10bcaa7c2253 70 #endif /* LWIP_NETIF_HWADDRHINT */
okini3939 0:10bcaa7c2253 71
okini3939 0:10bcaa7c2253 72 /* This is the common part of all PCB types. It needs to be at the
okini3939 0:10bcaa7c2253 73 beginning of a PCB type definition. It is located here so that
okini3939 0:10bcaa7c2253 74 changes to this common part are made in one location instead of
okini3939 0:10bcaa7c2253 75 having to change all PCB structs. */
okini3939 0:10bcaa7c2253 76 #define IP_PCB \
okini3939 0:10bcaa7c2253 77 /* ip addresses in network byte order */ \
okini3939 0:10bcaa7c2253 78 ip_addr_t local_ip; \
okini3939 0:10bcaa7c2253 79 ip_addr_t remote_ip; \
okini3939 0:10bcaa7c2253 80 /* Socket options */ \
okini3939 0:10bcaa7c2253 81 u8_t so_options; \
okini3939 0:10bcaa7c2253 82 /* Type Of Service */ \
okini3939 0:10bcaa7c2253 83 u8_t tos; \
okini3939 0:10bcaa7c2253 84 /* Time To Live */ \
okini3939 0:10bcaa7c2253 85 u8_t ttl \
okini3939 0:10bcaa7c2253 86 /* link layer address resolution hint */ \
okini3939 0:10bcaa7c2253 87 IP_PCB_ADDRHINT
okini3939 0:10bcaa7c2253 88
okini3939 0:10bcaa7c2253 89 struct ip_pcb {
okini3939 0:10bcaa7c2253 90 /* Common members of all PCB types */
okini3939 0:10bcaa7c2253 91 IP_PCB;
okini3939 0:10bcaa7c2253 92 };
okini3939 0:10bcaa7c2253 93
okini3939 0:10bcaa7c2253 94 /*
okini3939 0:10bcaa7c2253 95 * Option flags per-socket. These are the same like SO_XXX.
okini3939 0:10bcaa7c2253 96 */
okini3939 0:10bcaa7c2253 97 /*#define SOF_DEBUG (u8_t)0x01U Unimplemented: turn on debugging info recording */
okini3939 0:10bcaa7c2253 98 #define SOF_ACCEPTCONN (u8_t)0x02U /* socket has had listen() */
okini3939 0:10bcaa7c2253 99 #define SOF_REUSEADDR (u8_t)0x04U /* allow local address reuse */
okini3939 0:10bcaa7c2253 100 #define SOF_KEEPALIVE (u8_t)0x08U /* keep connections alive */
okini3939 0:10bcaa7c2253 101 /*#define SOF_DONTROUTE (u8_t)0x10U Unimplemented: just use interface addresses */
okini3939 0:10bcaa7c2253 102 #define SOF_BROADCAST (u8_t)0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
okini3939 0:10bcaa7c2253 103 /*#define SOF_USELOOPBACK (u8_t)0x40U Unimplemented: bypass hardware when possible */
okini3939 0:10bcaa7c2253 104 #define SOF_LINGER (u8_t)0x80U /* linger on close if data present */
okini3939 0:10bcaa7c2253 105 /*#define SOF_OOBINLINE (u16_t)0x0100U Unimplemented: leave received OOB data in line */
okini3939 0:10bcaa7c2253 106 /*#define SOF_REUSEPORT (u16_t)0x0200U Unimplemented: allow local address & port reuse */
okini3939 0:10bcaa7c2253 107
okini3939 0:10bcaa7c2253 108 /* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
okini3939 0:10bcaa7c2253 109 #define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/)
okini3939 0:10bcaa7c2253 110
okini3939 0:10bcaa7c2253 111
okini3939 0:10bcaa7c2253 112 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 0:10bcaa7c2253 113 # include "arch/bpstruct.h"
okini3939 0:10bcaa7c2253 114 #endif
okini3939 0:10bcaa7c2253 115 PACK_STRUCT_BEGIN
okini3939 0:10bcaa7c2253 116 struct ip_hdr {
okini3939 0:10bcaa7c2253 117 /* version / header length / type of service */
okini3939 0:10bcaa7c2253 118 PACK_STRUCT_FIELD(u16_t _v_hl_tos);
okini3939 0:10bcaa7c2253 119 /* total length */
okini3939 0:10bcaa7c2253 120 PACK_STRUCT_FIELD(u16_t _len);
okini3939 0:10bcaa7c2253 121 /* identification */
okini3939 0:10bcaa7c2253 122 PACK_STRUCT_FIELD(u16_t _id);
okini3939 0:10bcaa7c2253 123 /* fragment offset field */
okini3939 0:10bcaa7c2253 124 PACK_STRUCT_FIELD(u16_t _offset);
okini3939 0:10bcaa7c2253 125 #define IP_RF 0x8000 /* reserved fragment flag */
okini3939 0:10bcaa7c2253 126 #define IP_DF 0x4000 /* dont fragment flag */
okini3939 0:10bcaa7c2253 127 #define IP_MF 0x2000 /* more fragments flag */
okini3939 0:10bcaa7c2253 128 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
okini3939 0:10bcaa7c2253 129 /* time to live */
okini3939 0:10bcaa7c2253 130 PACK_STRUCT_FIELD(u8_t _ttl);
okini3939 0:10bcaa7c2253 131 /* protocol*/
okini3939 0:10bcaa7c2253 132 PACK_STRUCT_FIELD(u8_t _proto);
okini3939 0:10bcaa7c2253 133 /* checksum */
okini3939 0:10bcaa7c2253 134 PACK_STRUCT_FIELD(u16_t _chksum);
okini3939 0:10bcaa7c2253 135 /* source and destination IP addresses */
okini3939 0:10bcaa7c2253 136 PACK_STRUCT_FIELD(ip_addr_p_t src);
okini3939 0:10bcaa7c2253 137 PACK_STRUCT_FIELD(ip_addr_p_t dest);
okini3939 0:10bcaa7c2253 138 } PACK_STRUCT_STRUCT;
okini3939 0:10bcaa7c2253 139 PACK_STRUCT_END
okini3939 0:10bcaa7c2253 140 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 0:10bcaa7c2253 141 # include "arch/epstruct.h"
okini3939 0:10bcaa7c2253 142 #endif
okini3939 0:10bcaa7c2253 143
okini3939 0:10bcaa7c2253 144 #define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
okini3939 0:10bcaa7c2253 145 #define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
okini3939 0:10bcaa7c2253 146 #define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
okini3939 0:10bcaa7c2253 147 #define IPH_LEN(hdr) ((hdr)->_len)
okini3939 0:10bcaa7c2253 148 #define IPH_ID(hdr) ((hdr)->_id)
okini3939 0:10bcaa7c2253 149 #define IPH_OFFSET(hdr) ((hdr)->_offset)
okini3939 0:10bcaa7c2253 150 #define IPH_TTL(hdr) ((hdr)->_ttl)
okini3939 0:10bcaa7c2253 151 #define IPH_PROTO(hdr) ((hdr)->_proto)
okini3939 0:10bcaa7c2253 152 #define IPH_CHKSUM(hdr) ((hdr)->_chksum)
okini3939 0:10bcaa7c2253 153
okini3939 0:10bcaa7c2253 154 #define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
okini3939 0:10bcaa7c2253 155 #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
okini3939 0:10bcaa7c2253 156 #define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
okini3939 0:10bcaa7c2253 157 #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
okini3939 0:10bcaa7c2253 158 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
okini3939 0:10bcaa7c2253 159 #define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto)
okini3939 0:10bcaa7c2253 160 #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
okini3939 0:10bcaa7c2253 161
okini3939 0:10bcaa7c2253 162 /** The interface that provided the packet for the current callback invocation. */
okini3939 0:10bcaa7c2253 163 extern struct netif *current_netif;
okini3939 0:10bcaa7c2253 164 /** Header of the input packet currently being processed. */
okini3939 0:10bcaa7c2253 165 extern const struct ip_hdr *current_header;
okini3939 0:10bcaa7c2253 166 /** Source IP address of current_header */
okini3939 0:10bcaa7c2253 167 extern ip_addr_t current_iphdr_src;
okini3939 0:10bcaa7c2253 168 /** Destination IP address of current_header */
okini3939 0:10bcaa7c2253 169 extern ip_addr_t current_iphdr_dest;
okini3939 0:10bcaa7c2253 170
okini3939 0:10bcaa7c2253 171 #define ip_init() /* Compatibility define, not init needed. */
okini3939 0:10bcaa7c2253 172 struct netif *ip_route(ip_addr_t *dest);
okini3939 0:10bcaa7c2253 173 err_t ip_input(struct pbuf *p, struct netif *inp);
okini3939 0:10bcaa7c2253 174 err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
okini3939 0:10bcaa7c2253 175 u8_t ttl, u8_t tos, u8_t proto);
okini3939 0:10bcaa7c2253 176 err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
okini3939 0:10bcaa7c2253 177 u8_t ttl, u8_t tos, u8_t proto,
okini3939 0:10bcaa7c2253 178 struct netif *netif);
okini3939 0:10bcaa7c2253 179 #if LWIP_NETIF_HWADDRHINT
okini3939 0:10bcaa7c2253 180 err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
okini3939 0:10bcaa7c2253 181 u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
okini3939 0:10bcaa7c2253 182 #endif /* LWIP_NETIF_HWADDRHINT */
okini3939 0:10bcaa7c2253 183 #if IP_OPTIONS_SEND
okini3939 0:10bcaa7c2253 184 err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
okini3939 0:10bcaa7c2253 185 u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
okini3939 0:10bcaa7c2253 186 u16_t optlen);
okini3939 0:10bcaa7c2253 187 #endif /* IP_OPTIONS_SEND */
okini3939 0:10bcaa7c2253 188 /** Get the interface that received the current packet.
okini3939 0:10bcaa7c2253 189 * This function must only be called from a receive callback (udp_recv,
okini3939 0:10bcaa7c2253 190 * raw_recv, tcp_accept). It will return NULL otherwise. */
okini3939 0:10bcaa7c2253 191 #define ip_current_netif() (current_netif)
okini3939 0:10bcaa7c2253 192 /** Get the IP header of the current packet.
okini3939 0:10bcaa7c2253 193 * This function must only be called from a receive callback (udp_recv,
okini3939 0:10bcaa7c2253 194 * raw_recv, tcp_accept). It will return NULL otherwise. */
okini3939 0:10bcaa7c2253 195 #define ip_current_header() (current_header)
okini3939 0:10bcaa7c2253 196 /** Source IP address of current_header */
okini3939 0:10bcaa7c2253 197 #define ip_current_src_addr() (&current_iphdr_src)
okini3939 0:10bcaa7c2253 198 /** Destination IP address of current_header */
okini3939 0:10bcaa7c2253 199 #define ip_current_dest_addr() (&current_iphdr_dest)
okini3939 0:10bcaa7c2253 200
okini3939 0:10bcaa7c2253 201 #if IP_DEBUG
okini3939 0:10bcaa7c2253 202 void ip_debug_print(struct pbuf *p);
okini3939 0:10bcaa7c2253 203 #else
okini3939 0:10bcaa7c2253 204 #define ip_debug_print(p)
okini3939 0:10bcaa7c2253 205 #endif /* IP_DEBUG */
okini3939 0:10bcaa7c2253 206
okini3939 0:10bcaa7c2253 207 #ifdef __cplusplus
okini3939 0:10bcaa7c2253 208 }
okini3939 0:10bcaa7c2253 209 #endif
okini3939 0:10bcaa7c2253 210
okini3939 0:10bcaa7c2253 211 #endif /* __LWIP_IP_H__ */
okini3939 0:10bcaa7c2253 212
okini3939 0:10bcaa7c2253 213