Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Committer:
segundo
Date:
Tue Nov 09 20:54:15 2010 +0000
Revision:
0:ac1725ba162c

        

Who changed what in which revision?

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