Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:41:36 2011 +0000
Revision:
0:8f5825f330b0
setDataLen hacked to 180bytes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RodColeman 0:8f5825f330b0 1 /*
RodColeman 0:8f5825f330b0 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
RodColeman 0:8f5825f330b0 3 * All rights reserved.
RodColeman 0:8f5825f330b0 4 *
RodColeman 0:8f5825f330b0 5 * Redistribution and use in source and binary forms, with or without modification,
RodColeman 0:8f5825f330b0 6 * are permitted provided that the following conditions are met:
RodColeman 0:8f5825f330b0 7 *
RodColeman 0:8f5825f330b0 8 * 1. Redistributions of source code must retain the above copyright notice,
RodColeman 0:8f5825f330b0 9 * this list of conditions and the following disclaimer.
RodColeman 0:8f5825f330b0 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
RodColeman 0:8f5825f330b0 11 * this list of conditions and the following disclaimer in the documentation
RodColeman 0:8f5825f330b0 12 * and/or other materials provided with the distribution.
RodColeman 0:8f5825f330b0 13 * 3. The name of the author may not be used to endorse or promote products
RodColeman 0:8f5825f330b0 14 * derived from this software without specific prior written permission.
RodColeman 0:8f5825f330b0 15 *
RodColeman 0:8f5825f330b0 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
RodColeman 0:8f5825f330b0 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
RodColeman 0:8f5825f330b0 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
RodColeman 0:8f5825f330b0 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
RodColeman 0:8f5825f330b0 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
RodColeman 0:8f5825f330b0 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
RodColeman 0:8f5825f330b0 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
RodColeman 0:8f5825f330b0 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
RodColeman 0:8f5825f330b0 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
RodColeman 0:8f5825f330b0 25 * OF SUCH DAMAGE.
RodColeman 0:8f5825f330b0 26 *
RodColeman 0:8f5825f330b0 27 * This file is part of the lwIP TCP/IP stack.
RodColeman 0:8f5825f330b0 28 *
RodColeman 0:8f5825f330b0 29 * Author: Adam Dunkels <adam@sics.se>
RodColeman 0:8f5825f330b0 30 *
RodColeman 0:8f5825f330b0 31 */
RodColeman 0:8f5825f330b0 32 #ifndef __LWIP_IP_ADDR_H__
RodColeman 0:8f5825f330b0 33 #define __LWIP_IP_ADDR_H__
RodColeman 0:8f5825f330b0 34
RodColeman 0:8f5825f330b0 35 #include "lwip/opt.h"
RodColeman 0:8f5825f330b0 36 #include "lwip/def.h"
RodColeman 0:8f5825f330b0 37
RodColeman 0:8f5825f330b0 38 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 39 extern "C" {
RodColeman 0:8f5825f330b0 40 #endif
RodColeman 0:8f5825f330b0 41
RodColeman 0:8f5825f330b0 42 /* This is the aligned version of ip_addr_t,
RodColeman 0:8f5825f330b0 43 used as local variable, on the stack, etc. */
RodColeman 0:8f5825f330b0 44 struct ip_addr {
RodColeman 0:8f5825f330b0 45 u32_t addr;
RodColeman 0:8f5825f330b0 46 };
RodColeman 0:8f5825f330b0 47
RodColeman 0:8f5825f330b0 48 /* This is the packed version of ip_addr_t,
RodColeman 0:8f5825f330b0 49 used in network headers that are itself packed */
RodColeman 0:8f5825f330b0 50 #ifdef PACK_STRUCT_USE_INCLUDES
RodColeman 0:8f5825f330b0 51 # include "arch/bpstruct.h"
RodColeman 0:8f5825f330b0 52 #endif
RodColeman 0:8f5825f330b0 53 PACK_STRUCT_BEGIN
RodColeman 0:8f5825f330b0 54 struct ip_addr_packed {
RodColeman 0:8f5825f330b0 55 PACK_STRUCT_FIELD(u32_t addr);
RodColeman 0:8f5825f330b0 56 } PACK_STRUCT_STRUCT;
RodColeman 0:8f5825f330b0 57 PACK_STRUCT_END
RodColeman 0:8f5825f330b0 58 #ifdef PACK_STRUCT_USE_INCLUDES
RodColeman 0:8f5825f330b0 59 # include "arch/epstruct.h"
RodColeman 0:8f5825f330b0 60 #endif
RodColeman 0:8f5825f330b0 61
RodColeman 0:8f5825f330b0 62 /** ip_addr_t uses a struct for convenience only, so that the same defines can
RodColeman 0:8f5825f330b0 63 * operate both on ip_addr_t as well as on ip_addr_p_t. */
RodColeman 0:8f5825f330b0 64 typedef struct ip_addr ip_addr_t;
RodColeman 0:8f5825f330b0 65 typedef struct ip_addr_packed ip_addr_p_t;
RodColeman 0:8f5825f330b0 66
RodColeman 0:8f5825f330b0 67 /*
RodColeman 0:8f5825f330b0 68 * struct ipaddr2 is used in the definition of the ARP packet format in
RodColeman 0:8f5825f330b0 69 * order to support compilers that don't have structure packing.
RodColeman 0:8f5825f330b0 70 */
RodColeman 0:8f5825f330b0 71 #ifdef PACK_STRUCT_USE_INCLUDES
RodColeman 0:8f5825f330b0 72 # include "arch/bpstruct.h"
RodColeman 0:8f5825f330b0 73 #endif
RodColeman 0:8f5825f330b0 74 PACK_STRUCT_BEGIN
RodColeman 0:8f5825f330b0 75 struct ip_addr2 {
RodColeman 0:8f5825f330b0 76 PACK_STRUCT_FIELD(u16_t addrw[2]);
RodColeman 0:8f5825f330b0 77 } PACK_STRUCT_STRUCT;
RodColeman 0:8f5825f330b0 78 PACK_STRUCT_END
RodColeman 0:8f5825f330b0 79 #ifdef PACK_STRUCT_USE_INCLUDES
RodColeman 0:8f5825f330b0 80 # include "arch/epstruct.h"
RodColeman 0:8f5825f330b0 81 #endif
RodColeman 0:8f5825f330b0 82
RodColeman 0:8f5825f330b0 83 /* Forward declaration to not include netif.h */
RodColeman 0:8f5825f330b0 84 struct netif;
RodColeman 0:8f5825f330b0 85
RodColeman 0:8f5825f330b0 86 extern const ip_addr_t ip_addr_any;
RodColeman 0:8f5825f330b0 87 extern const ip_addr_t ip_addr_broadcast;
RodColeman 0:8f5825f330b0 88
RodColeman 0:8f5825f330b0 89 /** IP_ADDR_ can be used as a fixed IP address
RodColeman 0:8f5825f330b0 90 * for the wildcard and the broadcast address
RodColeman 0:8f5825f330b0 91 */
RodColeman 0:8f5825f330b0 92 #define IP_ADDR_ANY ((ip_addr_t *)&ip_addr_any)
RodColeman 0:8f5825f330b0 93 #define IP_ADDR_BROADCAST ((ip_addr_t *)&ip_addr_broadcast)
RodColeman 0:8f5825f330b0 94
RodColeman 0:8f5825f330b0 95 /** 255.255.255.255 */
RodColeman 0:8f5825f330b0 96 #define IPADDR_NONE ((u32_t)0xffffffffUL)
RodColeman 0:8f5825f330b0 97 /** 127.0.0.1 */
RodColeman 0:8f5825f330b0 98 #define IPADDR_LOOPBACK ((u32_t)0x7f000001UL)
RodColeman 0:8f5825f330b0 99 /** 0.0.0.0 */
RodColeman 0:8f5825f330b0 100 #define IPADDR_ANY ((u32_t)0x00000000UL)
RodColeman 0:8f5825f330b0 101 /** 255.255.255.255 */
RodColeman 0:8f5825f330b0 102 #define IPADDR_BROADCAST ((u32_t)0xffffffffUL)
RodColeman 0:8f5825f330b0 103
RodColeman 0:8f5825f330b0 104 /* Definitions of the bits in an Internet address integer.
RodColeman 0:8f5825f330b0 105
RodColeman 0:8f5825f330b0 106 On subnets, host and network parts are found according to
RodColeman 0:8f5825f330b0 107 the subnet mask, not these masks. */
RodColeman 0:8f5825f330b0 108 #define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0)
RodColeman 0:8f5825f330b0 109 #define IP_CLASSA_NET 0xff000000
RodColeman 0:8f5825f330b0 110 #define IP_CLASSA_NSHIFT 24
RodColeman 0:8f5825f330b0 111 #define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET)
RodColeman 0:8f5825f330b0 112 #define IP_CLASSA_MAX 128
RodColeman 0:8f5825f330b0 113
RodColeman 0:8f5825f330b0 114 #define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL)
RodColeman 0:8f5825f330b0 115 #define IP_CLASSB_NET 0xffff0000
RodColeman 0:8f5825f330b0 116 #define IP_CLASSB_NSHIFT 16
RodColeman 0:8f5825f330b0 117 #define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET)
RodColeman 0:8f5825f330b0 118 #define IP_CLASSB_MAX 65536
RodColeman 0:8f5825f330b0 119
RodColeman 0:8f5825f330b0 120 #define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL)
RodColeman 0:8f5825f330b0 121 #define IP_CLASSC_NET 0xffffff00
RodColeman 0:8f5825f330b0 122 #define IP_CLASSC_NSHIFT 8
RodColeman 0:8f5825f330b0 123 #define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET)
RodColeman 0:8f5825f330b0 124
RodColeman 0:8f5825f330b0 125 #define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL)
RodColeman 0:8f5825f330b0 126 #define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */
RodColeman 0:8f5825f330b0 127 #define IP_CLASSD_NSHIFT 28 /* net and host fields, but */
RodColeman 0:8f5825f330b0 128 #define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */
RodColeman 0:8f5825f330b0 129 #define IP_MULTICAST(a) IP_CLASSD(a)
RodColeman 0:8f5825f330b0 130
RodColeman 0:8f5825f330b0 131 #define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
RodColeman 0:8f5825f330b0 132 #define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
RodColeman 0:8f5825f330b0 133
RodColeman 0:8f5825f330b0 134 #define IP_LOOPBACKNET 127 /* official! */
RodColeman 0:8f5825f330b0 135
RodColeman 0:8f5825f330b0 136
RodColeman 0:8f5825f330b0 137 #if BYTE_ORDER == BIG_ENDIAN
RodColeman 0:8f5825f330b0 138 /** Set an IP address given by the four byte-parts */
RodColeman 0:8f5825f330b0 139 #define IP4_ADDR(ipaddr, a,b,c,d) \
RodColeman 0:8f5825f330b0 140 (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \
RodColeman 0:8f5825f330b0 141 ((u32_t)((b) & 0xff) << 16) | \
RodColeman 0:8f5825f330b0 142 ((u32_t)((c) & 0xff) << 8) | \
RodColeman 0:8f5825f330b0 143 (u32_t)((d) & 0xff)
RodColeman 0:8f5825f330b0 144 #else
RodColeman 0:8f5825f330b0 145 /** Set an IP address given by the four byte-parts.
RodColeman 0:8f5825f330b0 146 Little-endian version that prevents the use of htonl. */
RodColeman 0:8f5825f330b0 147 #define IP4_ADDR(ipaddr, a,b,c,d) \
RodColeman 0:8f5825f330b0 148 (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \
RodColeman 0:8f5825f330b0 149 ((u32_t)((c) & 0xff) << 16) | \
RodColeman 0:8f5825f330b0 150 ((u32_t)((b) & 0xff) << 8) | \
RodColeman 0:8f5825f330b0 151 (u32_t)((a) & 0xff)
RodColeman 0:8f5825f330b0 152 #endif
RodColeman 0:8f5825f330b0 153
RodColeman 0:8f5825f330b0 154 /** MEMCPY-like copying of IP addresses where addresses are known to be
RodColeman 0:8f5825f330b0 155 * 16-bit-aligned if the port is correctly configured (so a port could define
RodColeman 0:8f5825f330b0 156 * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */
RodColeman 0:8f5825f330b0 157 #ifndef IPADDR2_COPY
RodColeman 0:8f5825f330b0 158 #define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t))
RodColeman 0:8f5825f330b0 159 #endif
RodColeman 0:8f5825f330b0 160
RodColeman 0:8f5825f330b0 161 /** Copy IP address - faster than ip_addr_set: no NULL check */
RodColeman 0:8f5825f330b0 162 #define ip_addr_copy(dest, src) ((dest).addr = (src).addr)
RodColeman 0:8f5825f330b0 163 /** Safely copy one IP address to another (src may be NULL) */
RodColeman 0:8f5825f330b0 164 #define ip_addr_set(dest, src) ((dest)->addr = \
RodColeman 0:8f5825f330b0 165 ((src) == NULL ? 0 : \
RodColeman 0:8f5825f330b0 166 (src)->addr))
RodColeman 0:8f5825f330b0 167 /** Set complete address to zero */
RodColeman 0:8f5825f330b0 168 #define ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0)
RodColeman 0:8f5825f330b0 169 /** Set address to IPADDR_ANY (no need for htonl()) */
RodColeman 0:8f5825f330b0 170 #define ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY)
RodColeman 0:8f5825f330b0 171 /** Set address to loopback address */
RodColeman 0:8f5825f330b0 172 #define ip_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
RodColeman 0:8f5825f330b0 173 /** Safely copy one IP address to another and change byte order
RodColeman 0:8f5825f330b0 174 * from host- to network-order. */
RodColeman 0:8f5825f330b0 175 #define ip_addr_set_hton(dest, src) ((dest)->addr = \
RodColeman 0:8f5825f330b0 176 ((src) == NULL ? 0:\
RodColeman 0:8f5825f330b0 177 htonl((src)->addr)))
RodColeman 0:8f5825f330b0 178 /** IPv4 only: set the IP address given as an u32_t */
RodColeman 0:8f5825f330b0 179 #define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
RodColeman 0:8f5825f330b0 180 /** IPv4 only: get the IP address as an u32_t */
RodColeman 0:8f5825f330b0 181 #define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
RodColeman 0:8f5825f330b0 182
RodColeman 0:8f5825f330b0 183 /** Get the network address by combining host address with netmask */
RodColeman 0:8f5825f330b0 184 #define ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr))
RodColeman 0:8f5825f330b0 185
RodColeman 0:8f5825f330b0 186 /**
RodColeman 0:8f5825f330b0 187 * Determine if two address are on the same network.
RodColeman 0:8f5825f330b0 188 *
RodColeman 0:8f5825f330b0 189 * @arg addr1 IP address 1
RodColeman 0:8f5825f330b0 190 * @arg addr2 IP address 2
RodColeman 0:8f5825f330b0 191 * @arg mask network identifier mask
RodColeman 0:8f5825f330b0 192 * @return !0 if the network identifiers of both address match
RodColeman 0:8f5825f330b0 193 */
RodColeman 0:8f5825f330b0 194 #define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
RodColeman 0:8f5825f330b0 195 (mask)->addr) == \
RodColeman 0:8f5825f330b0 196 ((addr2)->addr & \
RodColeman 0:8f5825f330b0 197 (mask)->addr))
RodColeman 0:8f5825f330b0 198 #define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
RodColeman 0:8f5825f330b0 199
RodColeman 0:8f5825f330b0 200 #define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
RodColeman 0:8f5825f330b0 201
RodColeman 0:8f5825f330b0 202 #define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif))
RodColeman 0:8f5825f330b0 203 u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif);
RodColeman 0:8f5825f330b0 204
RodColeman 0:8f5825f330b0 205 #define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
RodColeman 0:8f5825f330b0 206 u8_t ip4_addr_netmask_valid(u32_t netmask);
RodColeman 0:8f5825f330b0 207
RodColeman 0:8f5825f330b0 208 #define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
RodColeman 0:8f5825f330b0 209
RodColeman 0:8f5825f330b0 210 #define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
RodColeman 0:8f5825f330b0 211
RodColeman 0:8f5825f330b0 212 #define ip_addr_debug_print(debug, ipaddr) \
RodColeman 0:8f5825f330b0 213 LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
RodColeman 0:8f5825f330b0 214 ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
RodColeman 0:8f5825f330b0 215 ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
RodColeman 0:8f5825f330b0 216 ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
RodColeman 0:8f5825f330b0 217 ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0))
RodColeman 0:8f5825f330b0 218
RodColeman 0:8f5825f330b0 219 /* Get one byte from the 4-byte address */
RodColeman 0:8f5825f330b0 220 #define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
RodColeman 0:8f5825f330b0 221 #define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
RodColeman 0:8f5825f330b0 222 #define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
RodColeman 0:8f5825f330b0 223 #define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
RodColeman 0:8f5825f330b0 224 /* These are cast to u16_t, with the intent that they are often arguments
RodColeman 0:8f5825f330b0 225 * to printf using the U16_F format from cc.h. */
RodColeman 0:8f5825f330b0 226 #define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
RodColeman 0:8f5825f330b0 227 #define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
RodColeman 0:8f5825f330b0 228 #define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
RodColeman 0:8f5825f330b0 229 #define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
RodColeman 0:8f5825f330b0 230
RodColeman 0:8f5825f330b0 231 /** For backwards compatibility */
RodColeman 0:8f5825f330b0 232 #define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr)
RodColeman 0:8f5825f330b0 233
RodColeman 0:8f5825f330b0 234 u32_t ipaddr_addr(const char *cp);
RodColeman 0:8f5825f330b0 235 int ipaddr_aton(const char *cp, ip_addr_t *addr);
RodColeman 0:8f5825f330b0 236 /** returns ptr to static buffer; not reentrant! */
RodColeman 0:8f5825f330b0 237 char *ipaddr_ntoa(const ip_addr_t *addr);
RodColeman 0:8f5825f330b0 238 char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen);
RodColeman 0:8f5825f330b0 239
RodColeman 0:8f5825f330b0 240 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 241 }
RodColeman 0:8f5825f330b0 242 #endif
RodColeman 0:8f5825f330b0 243
RodColeman 0:8f5825f330b0 244 #endif /* __LWIP_IP_ADDR_H__ */