Hi. This is the feed program for Cosm. (The previous name of the services is Pachube.)
Dependencies: mbed ThermistorPack Pachube ConfigFile EthernetNetIf TextLCD HTTPClient_ToBeRemoved FatFileSystem SDFileSystem
extlib/EthernetNetIf/LPC2368/lwip/include/lwip/udp.h@0:521ba375aa0f, 2012-08-06 (annotated)
- Committer:
- shintamainjp
- Date:
- Mon Aug 06 12:37:59 2012 +0000
- Revision:
- 0:521ba375aa0f
Pachube renamed to Cosm.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:521ba375aa0f | 1 | /* |
shintamainjp | 0:521ba375aa0f | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
shintamainjp | 0:521ba375aa0f | 3 | * All rights reserved. |
shintamainjp | 0:521ba375aa0f | 4 | * |
shintamainjp | 0:521ba375aa0f | 5 | * Redistribution and use in source and binary forms, with or without modification, |
shintamainjp | 0:521ba375aa0f | 6 | * are permitted provided that the following conditions are met: |
shintamainjp | 0:521ba375aa0f | 7 | * |
shintamainjp | 0:521ba375aa0f | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
shintamainjp | 0:521ba375aa0f | 9 | * this list of conditions and the following disclaimer. |
shintamainjp | 0:521ba375aa0f | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
shintamainjp | 0:521ba375aa0f | 11 | * this list of conditions and the following disclaimer in the documentation |
shintamainjp | 0:521ba375aa0f | 12 | * and/or other materials provided with the distribution. |
shintamainjp | 0:521ba375aa0f | 13 | * 3. The name of the author may not be used to endorse or promote products |
shintamainjp | 0:521ba375aa0f | 14 | * derived from this software without specific prior written permission. |
shintamainjp | 0:521ba375aa0f | 15 | * |
shintamainjp | 0:521ba375aa0f | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
shintamainjp | 0:521ba375aa0f | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
shintamainjp | 0:521ba375aa0f | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
shintamainjp | 0:521ba375aa0f | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
shintamainjp | 0:521ba375aa0f | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
shintamainjp | 0:521ba375aa0f | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
shintamainjp | 0:521ba375aa0f | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
shintamainjp | 0:521ba375aa0f | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
shintamainjp | 0:521ba375aa0f | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
shintamainjp | 0:521ba375aa0f | 25 | * OF SUCH DAMAGE. |
shintamainjp | 0:521ba375aa0f | 26 | * |
shintamainjp | 0:521ba375aa0f | 27 | * This file is part of the lwIP TCP/IP stack. |
shintamainjp | 0:521ba375aa0f | 28 | * |
shintamainjp | 0:521ba375aa0f | 29 | * Author: Adam Dunkels <adam@sics.se> |
shintamainjp | 0:521ba375aa0f | 30 | * |
shintamainjp | 0:521ba375aa0f | 31 | */ |
shintamainjp | 0:521ba375aa0f | 32 | #ifndef __LWIP_UDP_H__ |
shintamainjp | 0:521ba375aa0f | 33 | #define __LWIP_UDP_H__ |
shintamainjp | 0:521ba375aa0f | 34 | |
shintamainjp | 0:521ba375aa0f | 35 | #include "lwip/opt.h" |
shintamainjp | 0:521ba375aa0f | 36 | |
shintamainjp | 0:521ba375aa0f | 37 | #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ |
shintamainjp | 0:521ba375aa0f | 38 | |
shintamainjp | 0:521ba375aa0f | 39 | #include "lwip/pbuf.h" |
shintamainjp | 0:521ba375aa0f | 40 | #include "lwip/netif.h" |
shintamainjp | 0:521ba375aa0f | 41 | #include "lwip/ip_addr.h" |
shintamainjp | 0:521ba375aa0f | 42 | #include "lwip/ip.h" |
shintamainjp | 0:521ba375aa0f | 43 | |
shintamainjp | 0:521ba375aa0f | 44 | #ifdef __cplusplus |
shintamainjp | 0:521ba375aa0f | 45 | extern "C" { |
shintamainjp | 0:521ba375aa0f | 46 | #endif |
shintamainjp | 0:521ba375aa0f | 47 | |
shintamainjp | 0:521ba375aa0f | 48 | #define UDP_HLEN 8 |
shintamainjp | 0:521ba375aa0f | 49 | |
shintamainjp | 0:521ba375aa0f | 50 | /* Fields are (of course) in network byte order. */ |
shintamainjp | 0:521ba375aa0f | 51 | #ifdef PACK_STRUCT_USE_INCLUDES |
shintamainjp | 0:521ba375aa0f | 52 | # include "arch/bpstruct.h" |
shintamainjp | 0:521ba375aa0f | 53 | #endif |
shintamainjp | 0:521ba375aa0f | 54 | PACK_STRUCT_BEGIN |
shintamainjp | 0:521ba375aa0f | 55 | struct udp_hdr { |
shintamainjp | 0:521ba375aa0f | 56 | PACK_STRUCT_FIELD(u16_t src); |
shintamainjp | 0:521ba375aa0f | 57 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ |
shintamainjp | 0:521ba375aa0f | 58 | PACK_STRUCT_FIELD(u16_t len); |
shintamainjp | 0:521ba375aa0f | 59 | PACK_STRUCT_FIELD(u16_t chksum); |
shintamainjp | 0:521ba375aa0f | 60 | } PACK_STRUCT_STRUCT; |
shintamainjp | 0:521ba375aa0f | 61 | PACK_STRUCT_END |
shintamainjp | 0:521ba375aa0f | 62 | #ifdef PACK_STRUCT_USE_INCLUDES |
shintamainjp | 0:521ba375aa0f | 63 | # include "arch/epstruct.h" |
shintamainjp | 0:521ba375aa0f | 64 | #endif |
shintamainjp | 0:521ba375aa0f | 65 | |
shintamainjp | 0:521ba375aa0f | 66 | #define UDP_FLAGS_NOCHKSUM 0x01U |
shintamainjp | 0:521ba375aa0f | 67 | #define UDP_FLAGS_UDPLITE 0x02U |
shintamainjp | 0:521ba375aa0f | 68 | #define UDP_FLAGS_CONNECTED 0x04U |
shintamainjp | 0:521ba375aa0f | 69 | #define UDP_FLAGS_MULTICAST_LOOP 0x08U |
shintamainjp | 0:521ba375aa0f | 70 | |
shintamainjp | 0:521ba375aa0f | 71 | struct udp_pcb; |
shintamainjp | 0:521ba375aa0f | 72 | |
shintamainjp | 0:521ba375aa0f | 73 | /** Function prototype for udp pcb receive callback functions |
shintamainjp | 0:521ba375aa0f | 74 | * addr and port are in same byte order as in the pcb |
shintamainjp | 0:521ba375aa0f | 75 | * The callback is responsible for freeing the pbuf |
shintamainjp | 0:521ba375aa0f | 76 | * if it's not used any more. |
shintamainjp | 0:521ba375aa0f | 77 | * |
shintamainjp | 0:521ba375aa0f | 78 | * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf |
shintamainjp | 0:521ba375aa0f | 79 | * makes 'addr' invalid, too. |
shintamainjp | 0:521ba375aa0f | 80 | * |
shintamainjp | 0:521ba375aa0f | 81 | * @param arg user supplied argument (udp_pcb.recv_arg) |
shintamainjp | 0:521ba375aa0f | 82 | * @param pcb the udp_pcb which received data |
shintamainjp | 0:521ba375aa0f | 83 | * @param p the packet buffer that was received |
shintamainjp | 0:521ba375aa0f | 84 | * @param addr the remote IP address from which the packet was received |
shintamainjp | 0:521ba375aa0f | 85 | * @param port the remote port from which the packet was received |
shintamainjp | 0:521ba375aa0f | 86 | */ |
shintamainjp | 0:521ba375aa0f | 87 | typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 88 | ip_addr_t *addr, u16_t port); |
shintamainjp | 0:521ba375aa0f | 89 | |
shintamainjp | 0:521ba375aa0f | 90 | |
shintamainjp | 0:521ba375aa0f | 91 | struct udp_pcb { |
shintamainjp | 0:521ba375aa0f | 92 | /* Common members of all PCB types */ |
shintamainjp | 0:521ba375aa0f | 93 | IP_PCB; |
shintamainjp | 0:521ba375aa0f | 94 | |
shintamainjp | 0:521ba375aa0f | 95 | /* Protocol specific PCB members */ |
shintamainjp | 0:521ba375aa0f | 96 | |
shintamainjp | 0:521ba375aa0f | 97 | struct udp_pcb *next; |
shintamainjp | 0:521ba375aa0f | 98 | |
shintamainjp | 0:521ba375aa0f | 99 | u8_t flags; |
shintamainjp | 0:521ba375aa0f | 100 | /** ports are in host byte order */ |
shintamainjp | 0:521ba375aa0f | 101 | u16_t local_port, remote_port; |
shintamainjp | 0:521ba375aa0f | 102 | |
shintamainjp | 0:521ba375aa0f | 103 | #if LWIP_IGMP |
shintamainjp | 0:521ba375aa0f | 104 | /** outgoing network interface for multicast packets */ |
shintamainjp | 0:521ba375aa0f | 105 | ip_addr_t multicast_ip; |
shintamainjp | 0:521ba375aa0f | 106 | #endif /* LWIP_IGMP */ |
shintamainjp | 0:521ba375aa0f | 107 | |
shintamainjp | 0:521ba375aa0f | 108 | #if LWIP_UDPLITE |
shintamainjp | 0:521ba375aa0f | 109 | /** used for UDP_LITE only */ |
shintamainjp | 0:521ba375aa0f | 110 | u16_t chksum_len_rx, chksum_len_tx; |
shintamainjp | 0:521ba375aa0f | 111 | #endif /* LWIP_UDPLITE */ |
shintamainjp | 0:521ba375aa0f | 112 | |
shintamainjp | 0:521ba375aa0f | 113 | /** receive callback function */ |
shintamainjp | 0:521ba375aa0f | 114 | udp_recv_fn recv; |
shintamainjp | 0:521ba375aa0f | 115 | /** user-supplied argument for the recv callback */ |
shintamainjp | 0:521ba375aa0f | 116 | void *recv_arg; |
shintamainjp | 0:521ba375aa0f | 117 | }; |
shintamainjp | 0:521ba375aa0f | 118 | /* udp_pcbs export for exernal reference (e.g. SNMP agent) */ |
shintamainjp | 0:521ba375aa0f | 119 | extern struct udp_pcb *udp_pcbs; |
shintamainjp | 0:521ba375aa0f | 120 | |
shintamainjp | 0:521ba375aa0f | 121 | /* The following functions is the application layer interface to the |
shintamainjp | 0:521ba375aa0f | 122 | UDP code. */ |
shintamainjp | 0:521ba375aa0f | 123 | struct udp_pcb * udp_new (void); |
shintamainjp | 0:521ba375aa0f | 124 | void udp_remove (struct udp_pcb *pcb); |
shintamainjp | 0:521ba375aa0f | 125 | err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr, |
shintamainjp | 0:521ba375aa0f | 126 | u16_t port); |
shintamainjp | 0:521ba375aa0f | 127 | err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr, |
shintamainjp | 0:521ba375aa0f | 128 | u16_t port); |
shintamainjp | 0:521ba375aa0f | 129 | void udp_disconnect (struct udp_pcb *pcb); |
shintamainjp | 0:521ba375aa0f | 130 | void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, |
shintamainjp | 0:521ba375aa0f | 131 | void *recv_arg); |
shintamainjp | 0:521ba375aa0f | 132 | err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 133 | ip_addr_t *dst_ip, u16_t dst_port, |
shintamainjp | 0:521ba375aa0f | 134 | struct netif *netif); |
shintamainjp | 0:521ba375aa0f | 135 | err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 136 | ip_addr_t *dst_ip, u16_t dst_port); |
shintamainjp | 0:521ba375aa0f | 137 | err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); |
shintamainjp | 0:521ba375aa0f | 138 | |
shintamainjp | 0:521ba375aa0f | 139 | #if LWIP_CHECKSUM_ON_COPY |
shintamainjp | 0:521ba375aa0f | 140 | err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 141 | ip_addr_t *dst_ip, u16_t dst_port, |
shintamainjp | 0:521ba375aa0f | 142 | struct netif *netif, u8_t have_chksum, |
shintamainjp | 0:521ba375aa0f | 143 | u16_t chksum); |
shintamainjp | 0:521ba375aa0f | 144 | err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 145 | ip_addr_t *dst_ip, u16_t dst_port, |
shintamainjp | 0:521ba375aa0f | 146 | u8_t have_chksum, u16_t chksum); |
shintamainjp | 0:521ba375aa0f | 147 | err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, |
shintamainjp | 0:521ba375aa0f | 148 | u8_t have_chksum, u16_t chksum); |
shintamainjp | 0:521ba375aa0f | 149 | #endif /* LWIP_CHECKSUM_ON_COPY */ |
shintamainjp | 0:521ba375aa0f | 150 | |
shintamainjp | 0:521ba375aa0f | 151 | #define udp_flags(pcb) ((pcb)->flags) |
shintamainjp | 0:521ba375aa0f | 152 | #define udp_setflags(pcb, f) ((pcb)->flags = (f)) |
shintamainjp | 0:521ba375aa0f | 153 | |
shintamainjp | 0:521ba375aa0f | 154 | /* The following functions are the lower layer interface to UDP. */ |
shintamainjp | 0:521ba375aa0f | 155 | void udp_input (struct pbuf *p, struct netif *inp); |
shintamainjp | 0:521ba375aa0f | 156 | |
shintamainjp | 0:521ba375aa0f | 157 | #define udp_init() /* Compatibility define, not init needed. */ |
shintamainjp | 0:521ba375aa0f | 158 | |
shintamainjp | 0:521ba375aa0f | 159 | #if UDP_DEBUG |
shintamainjp | 0:521ba375aa0f | 160 | void udp_debug_print(struct udp_hdr *udphdr); |
shintamainjp | 0:521ba375aa0f | 161 | #else |
shintamainjp | 0:521ba375aa0f | 162 | #define udp_debug_print(udphdr) |
shintamainjp | 0:521ba375aa0f | 163 | #endif |
shintamainjp | 0:521ba375aa0f | 164 | |
shintamainjp | 0:521ba375aa0f | 165 | #ifdef __cplusplus |
shintamainjp | 0:521ba375aa0f | 166 | } |
shintamainjp | 0:521ba375aa0f | 167 | #endif |
shintamainjp | 0:521ba375aa0f | 168 | |
shintamainjp | 0:521ba375aa0f | 169 | #endif /* LWIP_UDP */ |
shintamainjp | 0:521ba375aa0f | 170 | |
shintamainjp | 0:521ba375aa0f | 171 | #endif /* __LWIP_UDP_H__ */ |