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_API_MSG_H__
RodColeman 0:8f5825f330b0 33 #define __LWIP_API_MSG_H__
RodColeman 0:8f5825f330b0 34
RodColeman 0:8f5825f330b0 35 #include "lwip/opt.h"
RodColeman 0:8f5825f330b0 36
RodColeman 0:8f5825f330b0 37 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
RodColeman 0:8f5825f330b0 38
RodColeman 0:8f5825f330b0 39 #include <stddef.h> /* for size_t */
RodColeman 0:8f5825f330b0 40
RodColeman 0:8f5825f330b0 41 #include "lwip/ip_addr.h"
RodColeman 0:8f5825f330b0 42 #include "lwip/err.h"
RodColeman 0:8f5825f330b0 43 #include "lwip/sys.h"
RodColeman 0:8f5825f330b0 44 #include "lwip/igmp.h"
RodColeman 0:8f5825f330b0 45 #include "lwip/api.h"
RodColeman 0:8f5825f330b0 46
RodColeman 0:8f5825f330b0 47 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 48 extern "C" {
RodColeman 0:8f5825f330b0 49 #endif
RodColeman 0:8f5825f330b0 50
RodColeman 0:8f5825f330b0 51 #define NETCONN_SHUT_RD 1
RodColeman 0:8f5825f330b0 52 #define NETCONN_SHUT_WR 2
RodColeman 0:8f5825f330b0 53 #define NETCONN_SHUT_RDWR 3
RodColeman 0:8f5825f330b0 54
RodColeman 0:8f5825f330b0 55 /* IP addresses and port numbers are expected to be in
RodColeman 0:8f5825f330b0 56 * the same byte order as in the corresponding pcb.
RodColeman 0:8f5825f330b0 57 */
RodColeman 0:8f5825f330b0 58 /** This struct includes everything that is necessary to execute a function
RodColeman 0:8f5825f330b0 59 for a netconn in another thread context (mainly used to process netconns
RodColeman 0:8f5825f330b0 60 in the tcpip_thread context to be thread safe). */
RodColeman 0:8f5825f330b0 61 struct api_msg_msg {
RodColeman 0:8f5825f330b0 62 /** The netconn which to process - always needed: it includes the semaphore
RodColeman 0:8f5825f330b0 63 which is used to block the application thread until the function finished. */
RodColeman 0:8f5825f330b0 64 struct netconn *conn;
RodColeman 0:8f5825f330b0 65 /** The return value of the function executed in tcpip_thread. */
RodColeman 0:8f5825f330b0 66 err_t err;
RodColeman 0:8f5825f330b0 67 /** Depending on the executed function, one of these union members is used */
RodColeman 0:8f5825f330b0 68 union {
RodColeman 0:8f5825f330b0 69 /** used for do_send */
RodColeman 0:8f5825f330b0 70 struct netbuf *b;
RodColeman 0:8f5825f330b0 71 /** used for do_newconn */
RodColeman 0:8f5825f330b0 72 struct {
RodColeman 0:8f5825f330b0 73 u8_t proto;
RodColeman 0:8f5825f330b0 74 } n;
RodColeman 0:8f5825f330b0 75 /** used for do_bind and do_connect */
RodColeman 0:8f5825f330b0 76 struct {
RodColeman 0:8f5825f330b0 77 ip_addr_t *ipaddr;
RodColeman 0:8f5825f330b0 78 u16_t port;
RodColeman 0:8f5825f330b0 79 } bc;
RodColeman 0:8f5825f330b0 80 /** used for do_getaddr */
RodColeman 0:8f5825f330b0 81 struct {
RodColeman 0:8f5825f330b0 82 ip_addr_t *ipaddr;
RodColeman 0:8f5825f330b0 83 u16_t *port;
RodColeman 0:8f5825f330b0 84 u8_t local;
RodColeman 0:8f5825f330b0 85 } ad;
RodColeman 0:8f5825f330b0 86 /** used for do_write */
RodColeman 0:8f5825f330b0 87 struct {
RodColeman 0:8f5825f330b0 88 const void *dataptr;
RodColeman 0:8f5825f330b0 89 size_t len;
RodColeman 0:8f5825f330b0 90 u8_t apiflags;
RodColeman 0:8f5825f330b0 91 } w;
RodColeman 0:8f5825f330b0 92 /** used for do_recv */
RodColeman 0:8f5825f330b0 93 struct {
RodColeman 0:8f5825f330b0 94 u32_t len;
RodColeman 0:8f5825f330b0 95 } r;
RodColeman 0:8f5825f330b0 96 /** used for do_close (/shutdown) */
RodColeman 0:8f5825f330b0 97 struct {
RodColeman 0:8f5825f330b0 98 u8_t shut;
RodColeman 0:8f5825f330b0 99 } sd;
RodColeman 0:8f5825f330b0 100 #if LWIP_IGMP
RodColeman 0:8f5825f330b0 101 /** used for do_join_leave_group */
RodColeman 0:8f5825f330b0 102 struct {
RodColeman 0:8f5825f330b0 103 ip_addr_t *multiaddr;
RodColeman 0:8f5825f330b0 104 ip_addr_t *netif_addr;
RodColeman 0:8f5825f330b0 105 enum netconn_igmp join_or_leave;
RodColeman 0:8f5825f330b0 106 } jl;
RodColeman 0:8f5825f330b0 107 #endif /* LWIP_IGMP */
RodColeman 0:8f5825f330b0 108 #if TCP_LISTEN_BACKLOG
RodColeman 0:8f5825f330b0 109 struct {
RodColeman 0:8f5825f330b0 110 u8_t backlog;
RodColeman 0:8f5825f330b0 111 } lb;
RodColeman 0:8f5825f330b0 112 #endif /* TCP_LISTEN_BACKLOG */
RodColeman 0:8f5825f330b0 113 } msg;
RodColeman 0:8f5825f330b0 114 };
RodColeman 0:8f5825f330b0 115
RodColeman 0:8f5825f330b0 116 /** This struct contains a function to execute in another thread context and
RodColeman 0:8f5825f330b0 117 a struct api_msg_msg that serves as an argument for this function.
RodColeman 0:8f5825f330b0 118 This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
RodColeman 0:8f5825f330b0 119 struct api_msg {
RodColeman 0:8f5825f330b0 120 /** function to execute in tcpip_thread context */
RodColeman 0:8f5825f330b0 121 void (* function)(struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 122 /** arguments for this function */
RodColeman 0:8f5825f330b0 123 struct api_msg_msg msg;
RodColeman 0:8f5825f330b0 124 };
RodColeman 0:8f5825f330b0 125
RodColeman 0:8f5825f330b0 126 #if LWIP_DNS
RodColeman 0:8f5825f330b0 127 /** As do_gethostbyname requires more arguments but doesn't require a netconn,
RodColeman 0:8f5825f330b0 128 it has its own struct (to avoid struct api_msg getting bigger than necessary).
RodColeman 0:8f5825f330b0 129 do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
RodColeman 0:8f5825f330b0 130 (see netconn_gethostbyname). */
RodColeman 0:8f5825f330b0 131 struct dns_api_msg {
RodColeman 0:8f5825f330b0 132 /** Hostname to query or dotted IP address string */
RodColeman 0:8f5825f330b0 133 const char *name;
RodColeman 0:8f5825f330b0 134 /** Rhe resolved address is stored here */
RodColeman 0:8f5825f330b0 135 ip_addr_t *addr;
RodColeman 0:8f5825f330b0 136 /** This semaphore is posted when the name is resolved, the application thread
RodColeman 0:8f5825f330b0 137 should wait on it. */
RodColeman 0:8f5825f330b0 138 sys_sem_t *sem;
RodColeman 0:8f5825f330b0 139 /** Errors are given back here */
RodColeman 0:8f5825f330b0 140 err_t *err;
RodColeman 0:8f5825f330b0 141 };
RodColeman 0:8f5825f330b0 142 #endif /* LWIP_DNS */
RodColeman 0:8f5825f330b0 143
RodColeman 0:8f5825f330b0 144 void do_newconn ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 145 void do_delconn ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 146 void do_bind ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 147 void do_connect ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 148 void do_disconnect ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 149 void do_listen ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 150 void do_send ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 151 void do_recv ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 152 void do_write ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 153 void do_getaddr ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 154 void do_close ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 155 void do_shutdown ( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 156 #if LWIP_IGMP
RodColeman 0:8f5825f330b0 157 void do_join_leave_group( struct api_msg_msg *msg);
RodColeman 0:8f5825f330b0 158 #endif /* LWIP_IGMP */
RodColeman 0:8f5825f330b0 159
RodColeman 0:8f5825f330b0 160 #if LWIP_DNS
RodColeman 0:8f5825f330b0 161 void do_gethostbyname(void *arg);
RodColeman 0:8f5825f330b0 162 #endif /* LWIP_DNS */
RodColeman 0:8f5825f330b0 163
RodColeman 0:8f5825f330b0 164 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
RodColeman 0:8f5825f330b0 165 void netconn_free(struct netconn *conn);
RodColeman 0:8f5825f330b0 166
RodColeman 0:8f5825f330b0 167 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 168 }
RodColeman 0:8f5825f330b0 169 #endif
RodColeman 0:8f5825f330b0 170
RodColeman 0:8f5825f330b0 171 #endif /* LWIP_NETCONN */
RodColeman 0:8f5825f330b0 172
RodColeman 0:8f5825f330b0 173 #endif /* __LWIP_API_MSG_H__ */