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_UDP_H__
okini3939 0:10bcaa7c2253 33 #define __LWIP_UDP_H__
okini3939 0:10bcaa7c2253 34
okini3939 0:10bcaa7c2253 35 #include "lwip/opt.h"
okini3939 0:10bcaa7c2253 36
okini3939 0:10bcaa7c2253 37 #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
okini3939 0:10bcaa7c2253 38
okini3939 0:10bcaa7c2253 39 #include "lwip/pbuf.h"
okini3939 0:10bcaa7c2253 40 #include "lwip/netif.h"
okini3939 0:10bcaa7c2253 41 #include "lwip/ip_addr.h"
okini3939 0:10bcaa7c2253 42 #include "lwip/ip.h"
okini3939 0:10bcaa7c2253 43
okini3939 0:10bcaa7c2253 44 #ifdef __cplusplus
okini3939 0:10bcaa7c2253 45 extern "C" {
okini3939 0:10bcaa7c2253 46 #endif
okini3939 0:10bcaa7c2253 47
okini3939 0:10bcaa7c2253 48 #define UDP_HLEN 8
okini3939 0:10bcaa7c2253 49
okini3939 0:10bcaa7c2253 50 /* Fields are (of course) in network byte order. */
okini3939 0:10bcaa7c2253 51 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 0:10bcaa7c2253 52 # include "arch/bpstruct.h"
okini3939 0:10bcaa7c2253 53 #endif
okini3939 0:10bcaa7c2253 54 PACK_STRUCT_BEGIN
okini3939 0:10bcaa7c2253 55 struct udp_hdr {
okini3939 0:10bcaa7c2253 56 PACK_STRUCT_FIELD(u16_t src);
okini3939 0:10bcaa7c2253 57 PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
okini3939 0:10bcaa7c2253 58 PACK_STRUCT_FIELD(u16_t len);
okini3939 0:10bcaa7c2253 59 PACK_STRUCT_FIELD(u16_t chksum);
okini3939 0:10bcaa7c2253 60 } PACK_STRUCT_STRUCT;
okini3939 0:10bcaa7c2253 61 PACK_STRUCT_END
okini3939 0:10bcaa7c2253 62 #ifdef PACK_STRUCT_USE_INCLUDES
okini3939 0:10bcaa7c2253 63 # include "arch/epstruct.h"
okini3939 0:10bcaa7c2253 64 #endif
okini3939 0:10bcaa7c2253 65
okini3939 0:10bcaa7c2253 66 #define UDP_FLAGS_NOCHKSUM 0x01U
okini3939 0:10bcaa7c2253 67 #define UDP_FLAGS_UDPLITE 0x02U
okini3939 0:10bcaa7c2253 68 #define UDP_FLAGS_CONNECTED 0x04U
okini3939 0:10bcaa7c2253 69 #define UDP_FLAGS_MULTICAST_LOOP 0x08U
okini3939 0:10bcaa7c2253 70
okini3939 0:10bcaa7c2253 71 struct udp_pcb;
okini3939 0:10bcaa7c2253 72
okini3939 0:10bcaa7c2253 73 /** Function prototype for udp pcb receive callback functions
okini3939 0:10bcaa7c2253 74 * addr and port are in same byte order as in the pcb
okini3939 0:10bcaa7c2253 75 * The callback is responsible for freeing the pbuf
okini3939 0:10bcaa7c2253 76 * if it's not used any more.
okini3939 0:10bcaa7c2253 77 *
okini3939 0:10bcaa7c2253 78 * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf
okini3939 0:10bcaa7c2253 79 * makes 'addr' invalid, too.
okini3939 0:10bcaa7c2253 80 *
okini3939 0:10bcaa7c2253 81 * @param arg user supplied argument (udp_pcb.recv_arg)
okini3939 0:10bcaa7c2253 82 * @param pcb the udp_pcb which received data
okini3939 0:10bcaa7c2253 83 * @param p the packet buffer that was received
okini3939 0:10bcaa7c2253 84 * @param addr the remote IP address from which the packet was received
okini3939 0:10bcaa7c2253 85 * @param port the remote port from which the packet was received
okini3939 0:10bcaa7c2253 86 */
okini3939 0:10bcaa7c2253 87 typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 88 ip_addr_t *addr, u16_t port);
okini3939 0:10bcaa7c2253 89
okini3939 0:10bcaa7c2253 90
okini3939 0:10bcaa7c2253 91 struct udp_pcb {
okini3939 0:10bcaa7c2253 92 /* Common members of all PCB types */
okini3939 0:10bcaa7c2253 93 IP_PCB;
okini3939 0:10bcaa7c2253 94
okini3939 0:10bcaa7c2253 95 /* Protocol specific PCB members */
okini3939 0:10bcaa7c2253 96
okini3939 0:10bcaa7c2253 97 struct udp_pcb *next;
okini3939 0:10bcaa7c2253 98
okini3939 0:10bcaa7c2253 99 u8_t flags;
okini3939 0:10bcaa7c2253 100 /** ports are in host byte order */
okini3939 0:10bcaa7c2253 101 u16_t local_port, remote_port;
okini3939 0:10bcaa7c2253 102
okini3939 0:10bcaa7c2253 103 #if LWIP_IGMP
okini3939 0:10bcaa7c2253 104 /** outgoing network interface for multicast packets */
okini3939 0:10bcaa7c2253 105 ip_addr_t multicast_ip;
okini3939 0:10bcaa7c2253 106 #endif /* LWIP_IGMP */
okini3939 0:10bcaa7c2253 107
okini3939 0:10bcaa7c2253 108 #if LWIP_UDPLITE
okini3939 0:10bcaa7c2253 109 /** used for UDP_LITE only */
okini3939 0:10bcaa7c2253 110 u16_t chksum_len_rx, chksum_len_tx;
okini3939 0:10bcaa7c2253 111 #endif /* LWIP_UDPLITE */
okini3939 0:10bcaa7c2253 112
okini3939 0:10bcaa7c2253 113 /** receive callback function */
okini3939 0:10bcaa7c2253 114 udp_recv_fn recv;
okini3939 0:10bcaa7c2253 115 /** user-supplied argument for the recv callback */
okini3939 0:10bcaa7c2253 116 void *recv_arg;
okini3939 0:10bcaa7c2253 117 };
okini3939 0:10bcaa7c2253 118 /* udp_pcbs export for exernal reference (e.g. SNMP agent) */
okini3939 0:10bcaa7c2253 119 extern struct udp_pcb *udp_pcbs;
okini3939 0:10bcaa7c2253 120
okini3939 0:10bcaa7c2253 121 /* The following functions is the application layer interface to the
okini3939 0:10bcaa7c2253 122 UDP code. */
okini3939 0:10bcaa7c2253 123 struct udp_pcb * udp_new (void);
okini3939 0:10bcaa7c2253 124 void udp_remove (struct udp_pcb *pcb);
okini3939 0:10bcaa7c2253 125 err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr,
okini3939 0:10bcaa7c2253 126 u16_t port);
okini3939 0:10bcaa7c2253 127 err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr,
okini3939 0:10bcaa7c2253 128 u16_t port);
okini3939 0:10bcaa7c2253 129 void udp_disconnect (struct udp_pcb *pcb);
okini3939 0:10bcaa7c2253 130 void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv,
okini3939 0:10bcaa7c2253 131 void *recv_arg);
okini3939 0:10bcaa7c2253 132 err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 133 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 0:10bcaa7c2253 134 struct netif *netif);
okini3939 0:10bcaa7c2253 135 err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 136 ip_addr_t *dst_ip, u16_t dst_port);
okini3939 0:10bcaa7c2253 137 err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
okini3939 0:10bcaa7c2253 138
okini3939 0:10bcaa7c2253 139 #if LWIP_CHECKSUM_ON_COPY
okini3939 0:10bcaa7c2253 140 err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 141 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 0:10bcaa7c2253 142 struct netif *netif, u8_t have_chksum,
okini3939 0:10bcaa7c2253 143 u16_t chksum);
okini3939 0:10bcaa7c2253 144 err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 145 ip_addr_t *dst_ip, u16_t dst_port,
okini3939 0:10bcaa7c2253 146 u8_t have_chksum, u16_t chksum);
okini3939 0:10bcaa7c2253 147 err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
okini3939 0:10bcaa7c2253 148 u8_t have_chksum, u16_t chksum);
okini3939 0:10bcaa7c2253 149 #endif /* LWIP_CHECKSUM_ON_COPY */
okini3939 0:10bcaa7c2253 150
okini3939 0:10bcaa7c2253 151 #define udp_flags(pcb) ((pcb)->flags)
okini3939 0:10bcaa7c2253 152 #define udp_setflags(pcb, f) ((pcb)->flags = (f))
okini3939 0:10bcaa7c2253 153
okini3939 0:10bcaa7c2253 154 /* The following functions are the lower layer interface to UDP. */
okini3939 0:10bcaa7c2253 155 void udp_input (struct pbuf *p, struct netif *inp);
okini3939 0:10bcaa7c2253 156
okini3939 0:10bcaa7c2253 157 #define udp_init() /* Compatibility define, not init needed. */
okini3939 0:10bcaa7c2253 158
okini3939 0:10bcaa7c2253 159 #if UDP_DEBUG
okini3939 0:10bcaa7c2253 160 void udp_debug_print(struct udp_hdr *udphdr);
okini3939 0:10bcaa7c2253 161 #else
okini3939 0:10bcaa7c2253 162 #define udp_debug_print(udphdr)
okini3939 0:10bcaa7c2253 163 #endif
okini3939 0:10bcaa7c2253 164
okini3939 0:10bcaa7c2253 165 #ifdef __cplusplus
okini3939 0:10bcaa7c2253 166 }
okini3939 0:10bcaa7c2253 167 #endif
okini3939 0:10bcaa7c2253 168
okini3939 0:10bcaa7c2253 169 #endif /* LWIP_UDP */
okini3939 0:10bcaa7c2253 170
okini3939 0:10bcaa7c2253 171 #endif /* __LWIP_UDP_H__ */