I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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