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/LPC1768/lwip/include/ipv4/lwip/ip.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_IP_H__ |
shintamainjp | 0:521ba375aa0f | 33 | #define __LWIP_IP_H__ |
shintamainjp | 0:521ba375aa0f | 34 | |
shintamainjp | 0:521ba375aa0f | 35 | #include "lwip/opt.h" |
shintamainjp | 0:521ba375aa0f | 36 | |
shintamainjp | 0:521ba375aa0f | 37 | #include "lwip/def.h" |
shintamainjp | 0:521ba375aa0f | 38 | #include "lwip/pbuf.h" |
shintamainjp | 0:521ba375aa0f | 39 | #include "lwip/ip_addr.h" |
shintamainjp | 0:521ba375aa0f | 40 | #include "lwip/err.h" |
shintamainjp | 0:521ba375aa0f | 41 | #include "lwip/netif.h" |
shintamainjp | 0:521ba375aa0f | 42 | |
shintamainjp | 0:521ba375aa0f | 43 | #ifdef __cplusplus |
shintamainjp | 0:521ba375aa0f | 44 | extern "C" { |
shintamainjp | 0:521ba375aa0f | 45 | #endif |
shintamainjp | 0:521ba375aa0f | 46 | |
shintamainjp | 0:521ba375aa0f | 47 | /** Currently, the function ip_output_if_opt() is only used with IGMP */ |
shintamainjp | 0:521ba375aa0f | 48 | #define IP_OPTIONS_SEND LWIP_IGMP |
shintamainjp | 0:521ba375aa0f | 49 | |
shintamainjp | 0:521ba375aa0f | 50 | #define IP_HLEN 20 |
shintamainjp | 0:521ba375aa0f | 51 | |
shintamainjp | 0:521ba375aa0f | 52 | #define IP_PROTO_ICMP 1 |
shintamainjp | 0:521ba375aa0f | 53 | #define IP_PROTO_IGMP 2 |
shintamainjp | 0:521ba375aa0f | 54 | #define IP_PROTO_UDP 17 |
shintamainjp | 0:521ba375aa0f | 55 | #define IP_PROTO_UDPLITE 136 |
shintamainjp | 0:521ba375aa0f | 56 | #define IP_PROTO_TCP 6 |
shintamainjp | 0:521ba375aa0f | 57 | |
shintamainjp | 0:521ba375aa0f | 58 | /* This is passed as the destination address to ip_output_if (not |
shintamainjp | 0:521ba375aa0f | 59 | to ip_output), meaning that an IP header already is constructed |
shintamainjp | 0:521ba375aa0f | 60 | in the pbuf. This is used when TCP retransmits. */ |
shintamainjp | 0:521ba375aa0f | 61 | #ifdef IP_HDRINCL |
shintamainjp | 0:521ba375aa0f | 62 | #undef IP_HDRINCL |
shintamainjp | 0:521ba375aa0f | 63 | #endif /* IP_HDRINCL */ |
shintamainjp | 0:521ba375aa0f | 64 | #define IP_HDRINCL NULL |
shintamainjp | 0:521ba375aa0f | 65 | |
shintamainjp | 0:521ba375aa0f | 66 | #if LWIP_NETIF_HWADDRHINT |
shintamainjp | 0:521ba375aa0f | 67 | #define IP_PCB_ADDRHINT ;u8_t addr_hint |
shintamainjp | 0:521ba375aa0f | 68 | #else |
shintamainjp | 0:521ba375aa0f | 69 | #define IP_PCB_ADDRHINT |
shintamainjp | 0:521ba375aa0f | 70 | #endif /* LWIP_NETIF_HWADDRHINT */ |
shintamainjp | 0:521ba375aa0f | 71 | |
shintamainjp | 0:521ba375aa0f | 72 | /* This is the common part of all PCB types. It needs to be at the |
shintamainjp | 0:521ba375aa0f | 73 | beginning of a PCB type definition. It is located here so that |
shintamainjp | 0:521ba375aa0f | 74 | changes to this common part are made in one location instead of |
shintamainjp | 0:521ba375aa0f | 75 | having to change all PCB structs. */ |
shintamainjp | 0:521ba375aa0f | 76 | #define IP_PCB \ |
shintamainjp | 0:521ba375aa0f | 77 | /* ip addresses in network byte order */ \ |
shintamainjp | 0:521ba375aa0f | 78 | ip_addr_t local_ip; \ |
shintamainjp | 0:521ba375aa0f | 79 | ip_addr_t remote_ip; \ |
shintamainjp | 0:521ba375aa0f | 80 | /* Socket options */ \ |
shintamainjp | 0:521ba375aa0f | 81 | u8_t so_options; \ |
shintamainjp | 0:521ba375aa0f | 82 | /* Type Of Service */ \ |
shintamainjp | 0:521ba375aa0f | 83 | u8_t tos; \ |
shintamainjp | 0:521ba375aa0f | 84 | /* Time To Live */ \ |
shintamainjp | 0:521ba375aa0f | 85 | u8_t ttl \ |
shintamainjp | 0:521ba375aa0f | 86 | /* link layer address resolution hint */ \ |
shintamainjp | 0:521ba375aa0f | 87 | IP_PCB_ADDRHINT |
shintamainjp | 0:521ba375aa0f | 88 | |
shintamainjp | 0:521ba375aa0f | 89 | struct ip_pcb { |
shintamainjp | 0:521ba375aa0f | 90 | /* Common members of all PCB types */ |
shintamainjp | 0:521ba375aa0f | 91 | IP_PCB; |
shintamainjp | 0:521ba375aa0f | 92 | }; |
shintamainjp | 0:521ba375aa0f | 93 | |
shintamainjp | 0:521ba375aa0f | 94 | /* |
shintamainjp | 0:521ba375aa0f | 95 | * Option flags per-socket. These are the same like SO_XXX. |
shintamainjp | 0:521ba375aa0f | 96 | */ |
shintamainjp | 0:521ba375aa0f | 97 | /*#define SOF_DEBUG (u8_t)0x01U Unimplemented: turn on debugging info recording */ |
shintamainjp | 0:521ba375aa0f | 98 | #define SOF_ACCEPTCONN (u8_t)0x02U /* socket has had listen() */ |
shintamainjp | 0:521ba375aa0f | 99 | #define SOF_REUSEADDR (u8_t)0x04U /* allow local address reuse */ |
shintamainjp | 0:521ba375aa0f | 100 | #define SOF_KEEPALIVE (u8_t)0x08U /* keep connections alive */ |
shintamainjp | 0:521ba375aa0f | 101 | /*#define SOF_DONTROUTE (u8_t)0x10U Unimplemented: just use interface addresses */ |
shintamainjp | 0:521ba375aa0f | 102 | #define SOF_BROADCAST (u8_t)0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ |
shintamainjp | 0:521ba375aa0f | 103 | /*#define SOF_USELOOPBACK (u8_t)0x40U Unimplemented: bypass hardware when possible */ |
shintamainjp | 0:521ba375aa0f | 104 | #define SOF_LINGER (u8_t)0x80U /* linger on close if data present */ |
shintamainjp | 0:521ba375aa0f | 105 | /*#define SOF_OOBINLINE (u16_t)0x0100U Unimplemented: leave received OOB data in line */ |
shintamainjp | 0:521ba375aa0f | 106 | /*#define SOF_REUSEPORT (u16_t)0x0200U Unimplemented: allow local address & port reuse */ |
shintamainjp | 0:521ba375aa0f | 107 | |
shintamainjp | 0:521ba375aa0f | 108 | /* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */ |
shintamainjp | 0:521ba375aa0f | 109 | #define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) |
shintamainjp | 0:521ba375aa0f | 110 | |
shintamainjp | 0:521ba375aa0f | 111 | |
shintamainjp | 0:521ba375aa0f | 112 | #ifdef PACK_STRUCT_USE_INCLUDES |
shintamainjp | 0:521ba375aa0f | 113 | # include "arch/bpstruct.h" |
shintamainjp | 0:521ba375aa0f | 114 | #endif |
shintamainjp | 0:521ba375aa0f | 115 | PACK_STRUCT_BEGIN |
shintamainjp | 0:521ba375aa0f | 116 | struct ip_hdr { |
shintamainjp | 0:521ba375aa0f | 117 | /* version / header length / type of service */ |
shintamainjp | 0:521ba375aa0f | 118 | PACK_STRUCT_FIELD(u16_t _v_hl_tos); |
shintamainjp | 0:521ba375aa0f | 119 | /* total length */ |
shintamainjp | 0:521ba375aa0f | 120 | PACK_STRUCT_FIELD(u16_t _len); |
shintamainjp | 0:521ba375aa0f | 121 | /* identification */ |
shintamainjp | 0:521ba375aa0f | 122 | PACK_STRUCT_FIELD(u16_t _id); |
shintamainjp | 0:521ba375aa0f | 123 | /* fragment offset field */ |
shintamainjp | 0:521ba375aa0f | 124 | PACK_STRUCT_FIELD(u16_t _offset); |
shintamainjp | 0:521ba375aa0f | 125 | #define IP_RF 0x8000 /* reserved fragment flag */ |
shintamainjp | 0:521ba375aa0f | 126 | #define IP_DF 0x4000 /* dont fragment flag */ |
shintamainjp | 0:521ba375aa0f | 127 | #define IP_MF 0x2000 /* more fragments flag */ |
shintamainjp | 0:521ba375aa0f | 128 | #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ |
shintamainjp | 0:521ba375aa0f | 129 | /* time to live */ |
shintamainjp | 0:521ba375aa0f | 130 | PACK_STRUCT_FIELD(u8_t _ttl); |
shintamainjp | 0:521ba375aa0f | 131 | /* protocol*/ |
shintamainjp | 0:521ba375aa0f | 132 | PACK_STRUCT_FIELD(u8_t _proto); |
shintamainjp | 0:521ba375aa0f | 133 | /* checksum */ |
shintamainjp | 0:521ba375aa0f | 134 | PACK_STRUCT_FIELD(u16_t _chksum); |
shintamainjp | 0:521ba375aa0f | 135 | /* source and destination IP addresses */ |
shintamainjp | 0:521ba375aa0f | 136 | PACK_STRUCT_FIELD(ip_addr_p_t src); |
shintamainjp | 0:521ba375aa0f | 137 | PACK_STRUCT_FIELD(ip_addr_p_t dest); |
shintamainjp | 0:521ba375aa0f | 138 | } PACK_STRUCT_STRUCT; |
shintamainjp | 0:521ba375aa0f | 139 | PACK_STRUCT_END |
shintamainjp | 0:521ba375aa0f | 140 | #ifdef PACK_STRUCT_USE_INCLUDES |
shintamainjp | 0:521ba375aa0f | 141 | # include "arch/epstruct.h" |
shintamainjp | 0:521ba375aa0f | 142 | #endif |
shintamainjp | 0:521ba375aa0f | 143 | |
shintamainjp | 0:521ba375aa0f | 144 | #define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12) |
shintamainjp | 0:521ba375aa0f | 145 | #define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f) |
shintamainjp | 0:521ba375aa0f | 146 | #define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff) |
shintamainjp | 0:521ba375aa0f | 147 | #define IPH_LEN(hdr) ((hdr)->_len) |
shintamainjp | 0:521ba375aa0f | 148 | #define IPH_ID(hdr) ((hdr)->_id) |
shintamainjp | 0:521ba375aa0f | 149 | #define IPH_OFFSET(hdr) ((hdr)->_offset) |
shintamainjp | 0:521ba375aa0f | 150 | #define IPH_TTL(hdr) ((hdr)->_ttl) |
shintamainjp | 0:521ba375aa0f | 151 | #define IPH_PROTO(hdr) ((hdr)->_proto) |
shintamainjp | 0:521ba375aa0f | 152 | #define IPH_CHKSUM(hdr) ((hdr)->_chksum) |
shintamainjp | 0:521ba375aa0f | 153 | |
shintamainjp | 0:521ba375aa0f | 154 | #define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos))) |
shintamainjp | 0:521ba375aa0f | 155 | #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) |
shintamainjp | 0:521ba375aa0f | 156 | #define IPH_ID_SET(hdr, id) (hdr)->_id = (id) |
shintamainjp | 0:521ba375aa0f | 157 | #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) |
shintamainjp | 0:521ba375aa0f | 158 | #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) |
shintamainjp | 0:521ba375aa0f | 159 | #define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) |
shintamainjp | 0:521ba375aa0f | 160 | #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) |
shintamainjp | 0:521ba375aa0f | 161 | |
shintamainjp | 0:521ba375aa0f | 162 | /** The interface that provided the packet for the current callback invocation. */ |
shintamainjp | 0:521ba375aa0f | 163 | extern struct netif *current_netif; |
shintamainjp | 0:521ba375aa0f | 164 | /** Header of the input packet currently being processed. */ |
shintamainjp | 0:521ba375aa0f | 165 | extern const struct ip_hdr *current_header; |
shintamainjp | 0:521ba375aa0f | 166 | /** Source IP address of current_header */ |
shintamainjp | 0:521ba375aa0f | 167 | extern ip_addr_t current_iphdr_src; |
shintamainjp | 0:521ba375aa0f | 168 | /** Destination IP address of current_header */ |
shintamainjp | 0:521ba375aa0f | 169 | extern ip_addr_t current_iphdr_dest; |
shintamainjp | 0:521ba375aa0f | 170 | |
shintamainjp | 0:521ba375aa0f | 171 | #define ip_init() /* Compatibility define, not init needed. */ |
shintamainjp | 0:521ba375aa0f | 172 | struct netif *ip_route(ip_addr_t *dest); |
shintamainjp | 0:521ba375aa0f | 173 | err_t ip_input(struct pbuf *p, struct netif *inp); |
shintamainjp | 0:521ba375aa0f | 174 | err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, |
shintamainjp | 0:521ba375aa0f | 175 | u8_t ttl, u8_t tos, u8_t proto); |
shintamainjp | 0:521ba375aa0f | 176 | err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, |
shintamainjp | 0:521ba375aa0f | 177 | u8_t ttl, u8_t tos, u8_t proto, |
shintamainjp | 0:521ba375aa0f | 178 | struct netif *netif); |
shintamainjp | 0:521ba375aa0f | 179 | #if LWIP_NETIF_HWADDRHINT |
shintamainjp | 0:521ba375aa0f | 180 | err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, |
shintamainjp | 0:521ba375aa0f | 181 | u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint); |
shintamainjp | 0:521ba375aa0f | 182 | #endif /* LWIP_NETIF_HWADDRHINT */ |
shintamainjp | 0:521ba375aa0f | 183 | #if IP_OPTIONS_SEND |
shintamainjp | 0:521ba375aa0f | 184 | err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, |
shintamainjp | 0:521ba375aa0f | 185 | u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, |
shintamainjp | 0:521ba375aa0f | 186 | u16_t optlen); |
shintamainjp | 0:521ba375aa0f | 187 | #endif /* IP_OPTIONS_SEND */ |
shintamainjp | 0:521ba375aa0f | 188 | /** Get the interface that received the current packet. |
shintamainjp | 0:521ba375aa0f | 189 | * This function must only be called from a receive callback (udp_recv, |
shintamainjp | 0:521ba375aa0f | 190 | * raw_recv, tcp_accept). It will return NULL otherwise. */ |
shintamainjp | 0:521ba375aa0f | 191 | #define ip_current_netif() (current_netif) |
shintamainjp | 0:521ba375aa0f | 192 | /** Get the IP header of the current packet. |
shintamainjp | 0:521ba375aa0f | 193 | * This function must only be called from a receive callback (udp_recv, |
shintamainjp | 0:521ba375aa0f | 194 | * raw_recv, tcp_accept). It will return NULL otherwise. */ |
shintamainjp | 0:521ba375aa0f | 195 | #define ip_current_header() (current_header) |
shintamainjp | 0:521ba375aa0f | 196 | /** Source IP address of current_header */ |
shintamainjp | 0:521ba375aa0f | 197 | #define ip_current_src_addr() (¤t_iphdr_src) |
shintamainjp | 0:521ba375aa0f | 198 | /** Destination IP address of current_header */ |
shintamainjp | 0:521ba375aa0f | 199 | #define ip_current_dest_addr() (¤t_iphdr_dest) |
shintamainjp | 0:521ba375aa0f | 200 | |
shintamainjp | 0:521ba375aa0f | 201 | #if IP_DEBUG |
shintamainjp | 0:521ba375aa0f | 202 | void ip_debug_print(struct pbuf *p); |
shintamainjp | 0:521ba375aa0f | 203 | #else |
shintamainjp | 0:521ba375aa0f | 204 | #define ip_debug_print(p) |
shintamainjp | 0:521ba375aa0f | 205 | #endif /* IP_DEBUG */ |
shintamainjp | 0:521ba375aa0f | 206 | |
shintamainjp | 0:521ba375aa0f | 207 | #ifdef __cplusplus |
shintamainjp | 0:521ba375aa0f | 208 | } |
shintamainjp | 0:521ba375aa0f | 209 | #endif |
shintamainjp | 0:521ba375aa0f | 210 | |
shintamainjp | 0:521ba375aa0f | 211 | #endif /* __LWIP_IP_H__ */ |
shintamainjp | 0:521ba375aa0f | 212 | |
shintamainjp | 0:521ba375aa0f | 213 |