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

Committer:
RodColeman
Date:
Thu Sep 08 10:48:09 2011 +0000
Revision:
0:850eacf3e945
revised fixed length to 178 bytes

Who changed what in which revision?

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