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_TCP_H__
RodColeman 0:8f5825f330b0 33 #define __LWIP_TCP_H__
RodColeman 0:8f5825f330b0 34
RodColeman 0:8f5825f330b0 35 #include "lwip/opt.h"
RodColeman 0:8f5825f330b0 36
RodColeman 0:8f5825f330b0 37 #if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
RodColeman 0:8f5825f330b0 38
RodColeman 0:8f5825f330b0 39 #include "lwip/sys.h"
RodColeman 0:8f5825f330b0 40 #include "lwip/mem.h"
RodColeman 0:8f5825f330b0 41 #include "lwip/pbuf.h"
RodColeman 0:8f5825f330b0 42 #include "lwip/ip.h"
RodColeman 0:8f5825f330b0 43 #include "lwip/icmp.h"
RodColeman 0:8f5825f330b0 44 #include "lwip/err.h"
RodColeman 0:8f5825f330b0 45
RodColeman 0:8f5825f330b0 46 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 47 extern "C" {
RodColeman 0:8f5825f330b0 48 #endif
RodColeman 0:8f5825f330b0 49
RodColeman 0:8f5825f330b0 50 struct tcp_pcb;
RodColeman 0:8f5825f330b0 51
RodColeman 0:8f5825f330b0 52 /** Function prototype for tcp accept callback functions. Called when a new
RodColeman 0:8f5825f330b0 53 * connection can be accepted on a listening pcb.
RodColeman 0:8f5825f330b0 54 *
RodColeman 0:8f5825f330b0 55 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 56 * @param newpcb The new connection pcb
RodColeman 0:8f5825f330b0 57 * @param err An error code if there has been an error accepting.
RodColeman 0:8f5825f330b0 58 * Only return ERR_ABRT if you have called tcp_abort from within the
RodColeman 0:8f5825f330b0 59 * callback function!
RodColeman 0:8f5825f330b0 60 */
RodColeman 0:8f5825f330b0 61 typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);
RodColeman 0:8f5825f330b0 62
RodColeman 0:8f5825f330b0 63 /** Function prototype for tcp receive callback functions. Called when data has
RodColeman 0:8f5825f330b0 64 * been received.
RodColeman 0:8f5825f330b0 65 *
RodColeman 0:8f5825f330b0 66 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 67 * @param tpcb The connection pcb which received data
RodColeman 0:8f5825f330b0 68 * @param p The received data (or NULL when the connection has been closed!)
RodColeman 0:8f5825f330b0 69 * @param err An error code if there has been an error receiving
RodColeman 0:8f5825f330b0 70 * Only return ERR_ABRT if you have called tcp_abort from within the
RodColeman 0:8f5825f330b0 71 * callback function!
RodColeman 0:8f5825f330b0 72 */
RodColeman 0:8f5825f330b0 73 typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
RodColeman 0:8f5825f330b0 74 struct pbuf *p, err_t err);
RodColeman 0:8f5825f330b0 75
RodColeman 0:8f5825f330b0 76 /** Function prototype for tcp sent callback functions. Called when sent data has
RodColeman 0:8f5825f330b0 77 * been acknowledged by the remote side. Use it to free corresponding resources.
RodColeman 0:8f5825f330b0 78 * This also means that the pcb has now space available to send new data.
RodColeman 0:8f5825f330b0 79 *
RodColeman 0:8f5825f330b0 80 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 81 * @param tpcb The connection pcb for which data has been acknowledged
RodColeman 0:8f5825f330b0 82 * @param len The amount of bytes acknowledged
RodColeman 0:8f5825f330b0 83 * @return ERR_OK: try to send some data by calling tcp_output
RodColeman 0:8f5825f330b0 84 * Only return ERR_ABRT if you have called tcp_abort from within the
RodColeman 0:8f5825f330b0 85 * callback function!
RodColeman 0:8f5825f330b0 86 */
RodColeman 0:8f5825f330b0 87 typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb,
RodColeman 0:8f5825f330b0 88 u16_t len);
RodColeman 0:8f5825f330b0 89
RodColeman 0:8f5825f330b0 90 /** Function prototype for tcp poll callback functions. Called periodically as
RodColeman 0:8f5825f330b0 91 * specified by @see tcp_poll.
RodColeman 0:8f5825f330b0 92 *
RodColeman 0:8f5825f330b0 93 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 94 * @param tpcb tcp pcb
RodColeman 0:8f5825f330b0 95 * @return ERR_OK: try to send some data by calling tcp_output
RodColeman 0:8f5825f330b0 96 * Only return ERR_ABRT if you have called tcp_abort from within the
RodColeman 0:8f5825f330b0 97 * callback function!
RodColeman 0:8f5825f330b0 98 */
RodColeman 0:8f5825f330b0 99 typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb);
RodColeman 0:8f5825f330b0 100
RodColeman 0:8f5825f330b0 101 /** Function prototype for tcp error callback functions. Called when the pcb
RodColeman 0:8f5825f330b0 102 * receives a RST or is unexpectedly closed for any other reason.
RodColeman 0:8f5825f330b0 103 *
RodColeman 0:8f5825f330b0 104 * @note The corresponding pcb is already freed when this callback is called!
RodColeman 0:8f5825f330b0 105 *
RodColeman 0:8f5825f330b0 106 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 107 * @param err Error code to indicate why the pcb has been closed
RodColeman 0:8f5825f330b0 108 * ERR_ABRT: aborted through tcp_abort or by a TCP timer
RodColeman 0:8f5825f330b0 109 * ERR_RST: the connection was reset by the remote host
RodColeman 0:8f5825f330b0 110 */
RodColeman 0:8f5825f330b0 111 typedef void (*tcp_err_fn)(void *arg, err_t err);
RodColeman 0:8f5825f330b0 112
RodColeman 0:8f5825f330b0 113 /** Function prototype for tcp connected callback functions. Called when a pcb
RodColeman 0:8f5825f330b0 114 * is connected to the remote side after initiating a connection attempt by
RodColeman 0:8f5825f330b0 115 * calling tcp_connect().
RodColeman 0:8f5825f330b0 116 *
RodColeman 0:8f5825f330b0 117 * @param arg Additional argument to pass to the callback function (@see tcp_arg())
RodColeman 0:8f5825f330b0 118 * @param tpcb The connection pcb which is connected
RodColeman 0:8f5825f330b0 119 * @param err An unused error code, always ERR_OK currently ;-) TODO!
RodColeman 0:8f5825f330b0 120 * Only return ERR_ABRT if you have called tcp_abort from within the
RodColeman 0:8f5825f330b0 121 * callback function!
RodColeman 0:8f5825f330b0 122 *
RodColeman 0:8f5825f330b0 123 * @note When a connection attempt fails, the error callback is currently called!
RodColeman 0:8f5825f330b0 124 */
RodColeman 0:8f5825f330b0 125 typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
RodColeman 0:8f5825f330b0 126
RodColeman 0:8f5825f330b0 127 enum tcp_state {
RodColeman 0:8f5825f330b0 128 CLOSED = 0,
RodColeman 0:8f5825f330b0 129 LISTEN = 1,
RodColeman 0:8f5825f330b0 130 SYN_SENT = 2,
RodColeman 0:8f5825f330b0 131 SYN_RCVD = 3,
RodColeman 0:8f5825f330b0 132 ESTABLISHED = 4,
RodColeman 0:8f5825f330b0 133 FIN_WAIT_1 = 5,
RodColeman 0:8f5825f330b0 134 FIN_WAIT_2 = 6,
RodColeman 0:8f5825f330b0 135 CLOSE_WAIT = 7,
RodColeman 0:8f5825f330b0 136 CLOSING = 8,
RodColeman 0:8f5825f330b0 137 LAST_ACK = 9,
RodColeman 0:8f5825f330b0 138 TIME_WAIT = 10
RodColeman 0:8f5825f330b0 139 };
RodColeman 0:8f5825f330b0 140
RodColeman 0:8f5825f330b0 141 #if LWIP_CALLBACK_API
RodColeman 0:8f5825f330b0 142 /* Function to call when a listener has been connected.
RodColeman 0:8f5825f330b0 143 * @param arg user-supplied argument (tcp_pcb.callback_arg)
RodColeman 0:8f5825f330b0 144 * @param pcb a new tcp_pcb that now is connected
RodColeman 0:8f5825f330b0 145 * @param err an error argument (TODO: that is current always ERR_OK?)
RodColeman 0:8f5825f330b0 146 * @return ERR_OK: accept the new connection,
RodColeman 0:8f5825f330b0 147 * any other err_t abortsthe new connection
RodColeman 0:8f5825f330b0 148 */
RodColeman 0:8f5825f330b0 149 #define DEF_ACCEPT_CALLBACK tcp_accept_fn accept;
RodColeman 0:8f5825f330b0 150 #else /* LWIP_CALLBACK_API */
RodColeman 0:8f5825f330b0 151 #define DEF_ACCEPT_CALLBACK
RodColeman 0:8f5825f330b0 152 #endif /* LWIP_CALLBACK_API */
RodColeman 0:8f5825f330b0 153
RodColeman 0:8f5825f330b0 154 /**
RodColeman 0:8f5825f330b0 155 * members common to struct tcp_pcb and struct tcp_listen_pcb
RodColeman 0:8f5825f330b0 156 */
RodColeman 0:8f5825f330b0 157 #define TCP_PCB_COMMON(type) \
RodColeman 0:8f5825f330b0 158 type *next; /* for the linked list */ \
RodColeman 0:8f5825f330b0 159 enum tcp_state state; /* TCP state */ \
RodColeman 0:8f5825f330b0 160 u8_t prio; \
RodColeman 0:8f5825f330b0 161 void *callback_arg; \
RodColeman 0:8f5825f330b0 162 /* the accept callback for listen- and normal pcbs, if LWIP_CALLBACK_API */ \
RodColeman 0:8f5825f330b0 163 DEF_ACCEPT_CALLBACK \
RodColeman 0:8f5825f330b0 164 /* ports are in host byte order */ \
RodColeman 0:8f5825f330b0 165 u16_t local_port
RodColeman 0:8f5825f330b0 166
RodColeman 0:8f5825f330b0 167
RodColeman 0:8f5825f330b0 168 /* the TCP protocol control block */
RodColeman 0:8f5825f330b0 169 struct tcp_pcb {
RodColeman 0:8f5825f330b0 170 /** common PCB members */
RodColeman 0:8f5825f330b0 171 IP_PCB;
RodColeman 0:8f5825f330b0 172 /** protocol specific PCB members */
RodColeman 0:8f5825f330b0 173 TCP_PCB_COMMON(struct tcp_pcb);
RodColeman 0:8f5825f330b0 174
RodColeman 0:8f5825f330b0 175 /* ports are in host byte order */
RodColeman 0:8f5825f330b0 176 u16_t remote_port;
RodColeman 0:8f5825f330b0 177
RodColeman 0:8f5825f330b0 178 u8_t flags;
RodColeman 0:8f5825f330b0 179 #define TF_ACK_DELAY ((u8_t)0x01U) /* Delayed ACK. */
RodColeman 0:8f5825f330b0 180 #define TF_ACK_NOW ((u8_t)0x02U) /* Immediate ACK. */
RodColeman 0:8f5825f330b0 181 #define TF_INFR ((u8_t)0x04U) /* In fast recovery. */
RodColeman 0:8f5825f330b0 182 #define TF_TIMESTAMP ((u8_t)0x08U) /* Timestamp option enabled */
RodColeman 0:8f5825f330b0 183 #define TF_RXCLOSED ((u8_t)0x10U) /* rx closed by tcp_shutdown */
RodColeman 0:8f5825f330b0 184 #define TF_FIN ((u8_t)0x20U) /* Connection was closed locally (FIN segment enqueued). */
RodColeman 0:8f5825f330b0 185 #define TF_NODELAY ((u8_t)0x40U) /* Disable Nagle algorithm */
RodColeman 0:8f5825f330b0 186 #define TF_NAGLEMEMERR ((u8_t)0x80U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */
RodColeman 0:8f5825f330b0 187
RodColeman 0:8f5825f330b0 188 /* the rest of the fields are in host byte order
RodColeman 0:8f5825f330b0 189 as we have to do some math with them */
RodColeman 0:8f5825f330b0 190 /* receiver variables */
RodColeman 0:8f5825f330b0 191 u32_t rcv_nxt; /* next seqno expected */
RodColeman 0:8f5825f330b0 192 u16_t rcv_wnd; /* receiver window available */
RodColeman 0:8f5825f330b0 193 u16_t rcv_ann_wnd; /* receiver window to announce */
RodColeman 0:8f5825f330b0 194 u32_t rcv_ann_right_edge; /* announced right edge of window */
RodColeman 0:8f5825f330b0 195
RodColeman 0:8f5825f330b0 196 /* Timers */
RodColeman 0:8f5825f330b0 197 u32_t tmr;
RodColeman 0:8f5825f330b0 198 u8_t polltmr, pollinterval;
RodColeman 0:8f5825f330b0 199
RodColeman 0:8f5825f330b0 200 /* Retransmission timer. */
RodColeman 0:8f5825f330b0 201 s16_t rtime;
RodColeman 0:8f5825f330b0 202
RodColeman 0:8f5825f330b0 203 u16_t mss; /* maximum segment size */
RodColeman 0:8f5825f330b0 204
RodColeman 0:8f5825f330b0 205 /* RTT (round trip time) estimation variables */
RodColeman 0:8f5825f330b0 206 u32_t rttest; /* RTT estimate in 500ms ticks */
RodColeman 0:8f5825f330b0 207 u32_t rtseq; /* sequence number being timed */
RodColeman 0:8f5825f330b0 208 s16_t sa, sv; /* @todo document this */
RodColeman 0:8f5825f330b0 209
RodColeman 0:8f5825f330b0 210 s16_t rto; /* retransmission time-out */
RodColeman 0:8f5825f330b0 211 u8_t nrtx; /* number of retransmissions */
RodColeman 0:8f5825f330b0 212
RodColeman 0:8f5825f330b0 213 /* fast retransmit/recovery */
RodColeman 0:8f5825f330b0 214 u32_t lastack; /* Highest acknowledged seqno. */
RodColeman 0:8f5825f330b0 215 u8_t dupacks;
RodColeman 0:8f5825f330b0 216
RodColeman 0:8f5825f330b0 217 /* congestion avoidance/control variables */
RodColeman 0:8f5825f330b0 218 u16_t cwnd;
RodColeman 0:8f5825f330b0 219 u16_t ssthresh;
RodColeman 0:8f5825f330b0 220
RodColeman 0:8f5825f330b0 221 /* sender variables */
RodColeman 0:8f5825f330b0 222 u32_t snd_nxt; /* next new seqno to be sent */
RodColeman 0:8f5825f330b0 223 u16_t snd_wnd; /* sender window */
RodColeman 0:8f5825f330b0 224 u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last
RodColeman 0:8f5825f330b0 225 window update. */
RodColeman 0:8f5825f330b0 226 u32_t snd_lbb; /* Sequence number of next byte to be buffered. */
RodColeman 0:8f5825f330b0 227
RodColeman 0:8f5825f330b0 228 u16_t acked;
RodColeman 0:8f5825f330b0 229
RodColeman 0:8f5825f330b0 230 u16_t snd_buf; /* Available buffer space for sending (in bytes). */
RodColeman 0:8f5825f330b0 231 #define TCP_SNDQUEUELEN_OVERFLOW (0xffff-3)
RodColeman 0:8f5825f330b0 232 u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */
RodColeman 0:8f5825f330b0 233
RodColeman 0:8f5825f330b0 234 #if TCP_OVERSIZE
RodColeman 0:8f5825f330b0 235 /* Extra bytes available at the end of the last pbuf in unsent. */
RodColeman 0:8f5825f330b0 236 u16_t unsent_oversize;
RodColeman 0:8f5825f330b0 237 #endif /* TCP_OVERSIZE */
RodColeman 0:8f5825f330b0 238
RodColeman 0:8f5825f330b0 239 /* These are ordered by sequence number: */
RodColeman 0:8f5825f330b0 240 struct tcp_seg *unsent; /* Unsent (queued) segments. */
RodColeman 0:8f5825f330b0 241 struct tcp_seg *unacked; /* Sent but unacknowledged segments. */
RodColeman 0:8f5825f330b0 242 #if TCP_QUEUE_OOSEQ
RodColeman 0:8f5825f330b0 243 struct tcp_seg *ooseq; /* Received out of sequence segments. */
RodColeman 0:8f5825f330b0 244 #endif /* TCP_QUEUE_OOSEQ */
RodColeman 0:8f5825f330b0 245
RodColeman 0:8f5825f330b0 246 struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */
RodColeman 0:8f5825f330b0 247
RodColeman 0:8f5825f330b0 248 #if LWIP_CALLBACK_API
RodColeman 0:8f5825f330b0 249 /* Function to be called when more send buffer space is available. */
RodColeman 0:8f5825f330b0 250 tcp_sent_fn sent;
RodColeman 0:8f5825f330b0 251 /* Function to be called when (in-sequence) data has arrived. */
RodColeman 0:8f5825f330b0 252 tcp_recv_fn recv;
RodColeman 0:8f5825f330b0 253 /* Function to be called when a connection has been set up. */
RodColeman 0:8f5825f330b0 254 tcp_connected_fn connected;
RodColeman 0:8f5825f330b0 255 /* Function which is called periodically. */
RodColeman 0:8f5825f330b0 256 tcp_poll_fn poll;
RodColeman 0:8f5825f330b0 257 /* Function to be called whenever a fatal error occurs. */
RodColeman 0:8f5825f330b0 258 tcp_err_fn errf;
RodColeman 0:8f5825f330b0 259 #endif /* LWIP_CALLBACK_API */
RodColeman 0:8f5825f330b0 260
RodColeman 0:8f5825f330b0 261 #if LWIP_TCP_TIMESTAMPS
RodColeman 0:8f5825f330b0 262 u32_t ts_lastacksent;
RodColeman 0:8f5825f330b0 263 u32_t ts_recent;
RodColeman 0:8f5825f330b0 264 #endif /* LWIP_TCP_TIMESTAMPS */
RodColeman 0:8f5825f330b0 265
RodColeman 0:8f5825f330b0 266 /* idle time before KEEPALIVE is sent */
RodColeman 0:8f5825f330b0 267 u32_t keep_idle;
RodColeman 0:8f5825f330b0 268 #if LWIP_TCP_KEEPALIVE
RodColeman 0:8f5825f330b0 269 u32_t keep_intvl;
RodColeman 0:8f5825f330b0 270 u32_t keep_cnt;
RodColeman 0:8f5825f330b0 271 #endif /* LWIP_TCP_KEEPALIVE */
RodColeman 0:8f5825f330b0 272
RodColeman 0:8f5825f330b0 273 /* Persist timer counter */
RodColeman 0:8f5825f330b0 274 u32_t persist_cnt;
RodColeman 0:8f5825f330b0 275 /* Persist timer back-off */
RodColeman 0:8f5825f330b0 276 u8_t persist_backoff;
RodColeman 0:8f5825f330b0 277
RodColeman 0:8f5825f330b0 278 /* KEEPALIVE counter */
RodColeman 0:8f5825f330b0 279 u8_t keep_cnt_sent;
RodColeman 0:8f5825f330b0 280 };
RodColeman 0:8f5825f330b0 281
RodColeman 0:8f5825f330b0 282 struct tcp_pcb_listen {
RodColeman 0:8f5825f330b0 283 /* Common members of all PCB types */
RodColeman 0:8f5825f330b0 284 IP_PCB;
RodColeman 0:8f5825f330b0 285 /* Protocol specific PCB members */
RodColeman 0:8f5825f330b0 286 TCP_PCB_COMMON(struct tcp_pcb_listen);
RodColeman 0:8f5825f330b0 287
RodColeman 0:8f5825f330b0 288 #if TCP_LISTEN_BACKLOG
RodColeman 0:8f5825f330b0 289 u8_t backlog;
RodColeman 0:8f5825f330b0 290 u8_t accepts_pending;
RodColeman 0:8f5825f330b0 291 #endif /* TCP_LISTEN_BACKLOG */
RodColeman 0:8f5825f330b0 292 };
RodColeman 0:8f5825f330b0 293
RodColeman 0:8f5825f330b0 294 #if LWIP_EVENT_API
RodColeman 0:8f5825f330b0 295
RodColeman 0:8f5825f330b0 296 enum lwip_event {
RodColeman 0:8f5825f330b0 297 LWIP_EVENT_ACCEPT,
RodColeman 0:8f5825f330b0 298 LWIP_EVENT_SENT,
RodColeman 0:8f5825f330b0 299 LWIP_EVENT_RECV,
RodColeman 0:8f5825f330b0 300 LWIP_EVENT_CONNECTED,
RodColeman 0:8f5825f330b0 301 LWIP_EVENT_POLL,
RodColeman 0:8f5825f330b0 302 LWIP_EVENT_ERR
RodColeman 0:8f5825f330b0 303 };
RodColeman 0:8f5825f330b0 304
RodColeman 0:8f5825f330b0 305 err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
RodColeman 0:8f5825f330b0 306 enum lwip_event,
RodColeman 0:8f5825f330b0 307 struct pbuf *p,
RodColeman 0:8f5825f330b0 308 u16_t size,
RodColeman 0:8f5825f330b0 309 err_t err);
RodColeman 0:8f5825f330b0 310
RodColeman 0:8f5825f330b0 311 #endif /* LWIP_EVENT_API */
RodColeman 0:8f5825f330b0 312
RodColeman 0:8f5825f330b0 313 /* Application program's interface: */
RodColeman 0:8f5825f330b0 314 struct tcp_pcb * tcp_new (void);
RodColeman 0:8f5825f330b0 315
RodColeman 0:8f5825f330b0 316 void tcp_arg (struct tcp_pcb *pcb, void *arg);
RodColeman 0:8f5825f330b0 317 void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept);
RodColeman 0:8f5825f330b0 318 void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv);
RodColeman 0:8f5825f330b0 319 void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent);
RodColeman 0:8f5825f330b0 320 void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval);
RodColeman 0:8f5825f330b0 321 void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err);
RodColeman 0:8f5825f330b0 322
RodColeman 0:8f5825f330b0 323 #define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss)
RodColeman 0:8f5825f330b0 324 #define tcp_sndbuf(pcb) ((pcb)->snd_buf)
RodColeman 0:8f5825f330b0 325 #define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen)
RodColeman 0:8f5825f330b0 326 #define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY)
RodColeman 0:8f5825f330b0 327 #define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY)
RodColeman 0:8f5825f330b0 328 #define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0)
RodColeman 0:8f5825f330b0 329
RodColeman 0:8f5825f330b0 330 #if TCP_LISTEN_BACKLOG
RodColeman 0:8f5825f330b0 331 #define tcp_accepted(pcb) do { \
RodColeman 0:8f5825f330b0 332 LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \
RodColeman 0:8f5825f330b0 333 (((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0)
RodColeman 0:8f5825f330b0 334 #else /* TCP_LISTEN_BACKLOG */
RodColeman 0:8f5825f330b0 335 #define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \
RodColeman 0:8f5825f330b0 336 pcb->state == LISTEN)
RodColeman 0:8f5825f330b0 337 #endif /* TCP_LISTEN_BACKLOG */
RodColeman 0:8f5825f330b0 338
RodColeman 0:8f5825f330b0 339 void tcp_recved (struct tcp_pcb *pcb, u16_t len);
RodColeman 0:8f5825f330b0 340 err_t tcp_bind (struct tcp_pcb *pcb, ip_addr_t *ipaddr,
RodColeman 0:8f5825f330b0 341 u16_t port);
RodColeman 0:8f5825f330b0 342 err_t tcp_connect (struct tcp_pcb *pcb, ip_addr_t *ipaddr,
RodColeman 0:8f5825f330b0 343 u16_t port, tcp_connected_fn connected);
RodColeman 0:8f5825f330b0 344
RodColeman 0:8f5825f330b0 345 struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog);
RodColeman 0:8f5825f330b0 346 #define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
RodColeman 0:8f5825f330b0 347
RodColeman 0:8f5825f330b0 348 void tcp_abort (struct tcp_pcb *pcb);
RodColeman 0:8f5825f330b0 349 err_t tcp_close (struct tcp_pcb *pcb);
RodColeman 0:8f5825f330b0 350 err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx);
RodColeman 0:8f5825f330b0 351
RodColeman 0:8f5825f330b0 352 /* Flags for "apiflags" parameter in tcp_write */
RodColeman 0:8f5825f330b0 353 #define TCP_WRITE_FLAG_COPY 0x01
RodColeman 0:8f5825f330b0 354 #define TCP_WRITE_FLAG_MORE 0x02
RodColeman 0:8f5825f330b0 355
RodColeman 0:8f5825f330b0 356 err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
RodColeman 0:8f5825f330b0 357 u8_t apiflags);
RodColeman 0:8f5825f330b0 358
RodColeman 0:8f5825f330b0 359 void tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
RodColeman 0:8f5825f330b0 360
RodColeman 0:8f5825f330b0 361 #define TCP_PRIO_MIN 1
RodColeman 0:8f5825f330b0 362 #define TCP_PRIO_NORMAL 64
RodColeman 0:8f5825f330b0 363 #define TCP_PRIO_MAX 127
RodColeman 0:8f5825f330b0 364
RodColeman 0:8f5825f330b0 365 err_t tcp_output (struct tcp_pcb *pcb);
RodColeman 0:8f5825f330b0 366
RodColeman 0:8f5825f330b0 367
RodColeman 0:8f5825f330b0 368 const char* tcp_debug_state_str(enum tcp_state s);
RodColeman 0:8f5825f330b0 369
RodColeman 0:8f5825f330b0 370
RodColeman 0:8f5825f330b0 371 #ifdef __cplusplus
RodColeman 0:8f5825f330b0 372 }
RodColeman 0:8f5825f330b0 373 #endif
RodColeman 0:8f5825f330b0 374
RodColeman 0:8f5825f330b0 375 #endif /* LWIP_TCP */
RodColeman 0:8f5825f330b0 376
RodColeman 0:8f5825f330b0 377 #endif /* __LWIP_TCP_H__ */