Transmission Control Protocol for IP.
This file contains common functions for the TCP implementation, such as functinos for manipulating the data structures and the TCP timer functions. TCP functions related to input and output is found in tcp_in.c and tcp_out.c respectively.
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/snmp.h"
#include "lwip/tcp.h"
#include "lwip/tcp_impl.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include <string.h>
Macros | |
#define | NUM_TCP_PCB_LISTS 4 |
#define | NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 |
#define | TCP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) |
#define | TCP_KEEP_DUR(pcb) TCP_MAXIDLE |
#define | TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT |
#define | TCP_LOCAL_PORT_RANGE_END 0xffff |
#define | TCP_LOCAL_PORT_RANGE_START 0xc000 |
Functions | |
void | tcp_abandon (struct tcp_pcb *pcb, int reset) |
Abandons a connection and optionally sends a RST to the remote host. More... | |
void | tcp_abort (struct tcp_pcb *pcb) |
Aborts the connection by sending a RST (reset) segment to the remote host. More... | |
void | tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept) |
Used for specifying the function that should be called when a LISTENing connection has been connected to another host. More... | |
static err_t | tcp_accept_null (void *arg, struct tcp_pcb *pcb, err_t err) |
Default accept callback if no accept callback is specified by the user. More... | |
struct tcp_pcb * | tcp_alloc (u8_t prio) |
Allocate a new tcp_pcb structure. More... | |
void | tcp_arg (struct tcp_pcb *pcb, void *arg) |
Used to specify the argument that should be passed callback functions. More... | |
err_t | tcp_bind (struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) |
Binds the connection to a local portnumber and IP address. More... | |
err_t | tcp_close (struct tcp_pcb *pcb) |
Closes the connection held by the PCB. More... | |
static err_t | tcp_close_shutdown (struct tcp_pcb *pcb, u8_t rst_on_unacked_data) |
Closes the TX side of a connection held by the PCB. More... | |
err_t | tcp_connect (struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, tcp_connected_fn connected) |
Connects to another host. More... | |
const char * | tcp_debug_state_str (enum tcp_state s) |
u16_t | tcp_eff_send_mss (u16_t sendmss, ip_addr_t *addr) |
Calcluates the effective send mss that can be used for a specific IP address by using ip_route to determin the netif used to send to the address and calculating the minimum of TCP_MSS and that netif's mtu (if set). More... | |
void | tcp_err (struct tcp_pcb *pcb, tcp_err_fn err) |
Used to specify the function that should be called when a fatal error has occured on the connection. More... | |
void | tcp_fasttmr (void) |
Is called every TCP_FAST_INTERVAL (250 ms) and process data previously "refused" by upper layer (application) and sends delayed ACKs. More... | |
void | tcp_init (void) |
Initialize this module. More... | |
static void | tcp_kill_prio (u8_t prio) |
Kills the oldest active connection that has the same or lower priority than 'prio'. More... | |
static void | tcp_kill_timewait (void) |
Kills the oldest connection that is in TIME_WAIT state. More... | |
struct tcp_pcb * | tcp_listen_with_backlog (struct tcp_pcb *pcb, u8_t backlog) |
Set the state of the connection to be LISTEN, which means that it is able to accept incoming connections. More... | |
struct tcp_pcb * | tcp_new (void) |
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists. More... | |
static u16_t | tcp_new_port (void) |
Allocate a new local TCP port. More... | |
u32_t | tcp_next_iss (void) |
Calculates a new initial sequence number for new connections. More... | |
void | tcp_pcb_purge (struct tcp_pcb *pcb) |
Purges a TCP PCB. More... | |
void | tcp_pcb_remove (struct tcp_pcb **pcblist, struct tcp_pcb *pcb) |
Purges the PCB and removes it from a PCB list. More... | |
void | tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) |
Used to specify the function that should be called periodically from TCP. More... | |
err_t | tcp_process_refused_data (struct tcp_pcb *pcb) |
Pass pcb->refused_data to the recv callback. More... | |
void | tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv) |
Used to specify the function that should be called when a TCP connection receives data. More... | |
err_t | tcp_recv_null (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) |
Default receive callback that is called if the user didn't register a recv callback for the pcb. More... | |
void | tcp_recved (struct tcp_pcb *pcb, u16_t len) |
This function should be called by the application when it has processed the data. More... | |
struct tcp_seg * | tcp_seg_copy (struct tcp_seg *seg) |
Returns a copy of the given TCP segment. More... | |
void | tcp_seg_free (struct tcp_seg *seg) |
Frees a TCP segment (tcp_seg structure). More... | |
void | tcp_segs_free (struct tcp_seg *seg) |
Deallocates a list of TCP segments (tcp_seg structures). More... | |
void | tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent) |
Used to specify the function that should be called when TCP data has been successfully delivered to the remote host. More... | |
void | tcp_setprio (struct tcp_pcb *pcb, u8_t prio) |
Sets the priority of a connection. More... | |
err_t | tcp_shutdown (struct tcp_pcb *pcb, int shut_rx, int shut_tx) |
Causes all or part of a full-duplex connection of this PCB to be shut down. More... | |
void | tcp_slowtmr (void) |
Called every 500 ms and implements the retransmission timer and the timer that removes PCBs that have been in TIME-WAIT for enough time. More... | |
void | tcp_tmr (void) |
Called periodically to dispatch TCP timers. More... | |
u32_t | tcp_update_rcv_ann_wnd (struct tcp_pcb *pcb) |
Update the state that tracks the available window space to advertise. More... | |
Variables | |
struct tcp_pcb * | tcp_active_pcbs |
List of all TCP PCBs that are in a state in which they accept or send data. More... | |
u8_t | tcp_active_pcbs_changed |
const u8_t | tcp_backoff [13] |
struct tcp_pcb * | tcp_bound_pcbs |
List of all TCP PCBs bound but not yet (connected || listening) More... | |
union tcp_listen_pcbs_t | tcp_listen_pcbs |
List of all TCP PCBs in LISTEN state. More... | |
struct tcp_pcb **const | tcp_pcb_lists [] |
An array with all (non-temporary) PCB lists, mainly used for smaller code size. More... | |
const u8_t | tcp_persist_backoff [7] = { 3, 6, 12, 24, 48, 96, 120 } |
static u16_t | tcp_port = TCP_LOCAL_PORT_RANGE_START |
const char *const | tcp_state_str [] |
u32_t | tcp_ticks |
static u8_t | tcp_timer |
Timer counter to handle calling slow-timer from tcp_tmr() More... | |
static u8_t | tcp_timer_ctr |
struct tcp_pcb * | tcp_tmp_pcb |
Only used for temporary storage. More... | |
struct tcp_pcb * | tcp_tw_pcbs |
List of all TCP PCBs in TIME-WAIT state. More... | |
#define NUM_TCP_PCB_LISTS 4 |
Referenced by tcp_bind(), tcp_connect(), and tcp_new_port().
#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 |
Referenced by tcp_bind().
#define TCP_ENSURE_LOCAL_PORT_RANGE | ( | port | ) | (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) |
Referenced by tcp_init().
#define TCP_KEEP_DUR | ( | pcb | ) | TCP_MAXIDLE |
Referenced by tcp_slowtmr().
#define TCP_KEEP_INTVL | ( | pcb | ) | TCP_KEEPINTVL_DEFAULT |
Referenced by tcp_slowtmr().
#define TCP_LOCAL_PORT_RANGE_END 0xffff |
Referenced by tcp_new_port().
#define TCP_LOCAL_PORT_RANGE_START 0xc000 |
Referenced by tcp_new_port().
Abandons a connection and optionally sends a RST to the remote host.
Deletes the local protocol control block. This is done when a connection is killed because of shortage of memory.
pcb | the tcp_pcb to abort |
reset | boolean to indicate whether a reset should be sent |
References ackno, ERR_ABRT, tcp_pcb::errf, LISTEN, LWIP_ASSERT, LWIP_DEBUGF, memp_free(), NULL, tcp_pcb::ooseq, tcp_pcb::rcv_nxt, tcp_pcb::remote_port, seqno, tcp_pcb::snd_nxt, TCP_EVENT_ERR, tcp_pcb_remove(), TCP_PCB_REMOVE_ACTIVE, tcp_rst(), TCP_RST_DEBUG, tcp_segs_free(), TIME_WAIT, tcp_pcb::unacked, and tcp_pcb::unsent.
Referenced by tcp_abort(), and tcp_listen_input().
Aborts the connection by sending a RST (reset) segment to the remote host.
The pcb is deallocated. This function never fails.
ATTENTION: When calling this from one of the TCP callbacks, make sure you always return ERR_ABRT (and never return ERR_ABRT otherwise or you will risk accessing deallocated memory or memory leaks!
pcb | the tcp pcb to abort |
References tcp_abandon().
Referenced by http_poll(), netif_set_ipaddr(), tcp_input(), tcp_kill_prio(), tcp_kill_timewait(), and tcp_process().
void tcp_accept | ( | struct tcp_pcb * | pcb, |
tcp_accept_fn | accept | ||
) |
Used for specifying the function that should be called when a LISTENing connection has been connected to another host.
pcb | tcp_pcb to set the accept callback |
accept | callback function to call for this pcb when LISTENing connection has been connected to another host |
Referenced by httpd_init().
Default accept callback if no accept callback is specified by the user.
References ERR_ABRT, and LWIP_UNUSED_ARG.
Referenced by tcp_listen_with_backlog().
Allocate a new tcp_pcb structure.
prio | priority for the new pcb |
References tcp_pcb::cwnd, tcp_pcb::keep_cnt_sent, tcp_pcb::keep_idle, tcp_pcb::last_timer, tcp_pcb::lastack, LWIP_DEBUGF, memp_malloc(), MEMP_STATS_DEC, tcp_pcb::mss, NULL, tcp_pcb::polltmr, tcp_pcb::rcv_ann_wnd, tcp_pcb::rcv_wnd, tcp_pcb::recv, tcp_pcb::rtime, tcp_pcb::rto, tcp_pcb::sa, tcp_pcb::snd_buf, tcp_pcb::snd_lbb, tcp_pcb::snd_nxt, tcp_pcb::snd_queuelen, tcp_pcb::snd_wl2, tcp_pcb::sv, TCP_DEBUG, TCP_KEEPCNT_DEFAULT, TCP_KEEPIDLE_DEFAULT, TCP_KEEPINTVL_DEFAULT, tcp_kill_prio(), tcp_kill_timewait(), TCP_MSS, tcp_next_iss(), tcp_recv_null(), TCP_SLOW_INTERVAL, TCP_SND_BUF, tcp_ticks, tcp_timer_ctr, TCP_WND, and tcp_pcb::tmr.
Referenced by tcp_listen_input(), and tcp_new().
Used to specify the argument that should be passed callback functions.
pcb | tcp_pcb to set the callback argument |
arg | void pointer argument to pass to callback functions |
References arg.
Referenced by http_accept(), and http_close_conn().
Binds the connection to a local portnumber and IP address.
If the IP address is not given (i.e., ipaddr == NULL), the IP address of the outgoing network interface is used instead.
pcb | the tcp_pcb to bind (no check is done whether this pcb is already bound!) |
ipaddr | the local ip address to bind to (use IP_ADDR_ANY to bind to any local address |
port | the local port to bind to |
References CLOSED, ERR_BUF, ERR_OK, ERR_USE, ERR_VAL, ip_addr_cmp, ip_addr_isany, ip_get_option, LWIP_DEBUGF, LWIP_ERROR(), NULL, NUM_TCP_PCB_LISTS, NUM_TCP_PCB_LISTS_NO_TIME_WAIT, SOF_REUSEADDR, TCP_DEBUG, tcp_new_port(), TCP_REG, and U16_F.
Referenced by httpd_init().
Closes the connection held by the PCB.
Listening pcbs are freed and may not be referenced any more. Connection pcbs are freed if not yet connected and may not be referenced any more. If a connection is established (at least SYN received or in a closing state), the connection is closed, and put in a closing state. The pcb is then automatically freed in tcp_slowtmr(). It is therefore unsafe to reference it (unless an error is returned).
pcb | the tcp_pcb to close |
References tcp_pcb::flags, LISTEN, LWIP_DEBUGF, tcp_close_shutdown(), TCP_DEBUG, tcp_debug_print_state, and TF_RXCLOSED.
Referenced by http_close_conn(), and tcp_recv_null().
Closes the TX side of a connection held by the PCB.
For tcp_close(), a RST is sent if the application didn't receive all data (tcp_recved() not called for all data passed to recv callback).
Listening pcbs are freed and may not be referenced any more. Connection pcbs are freed if not yet connected and may not be referenced any more. If a connection is established (at least SYN received or in a closing state), the connection is closed, and put in a closing state. The pcb is then automatically freed in tcp_slowtmr(). It is therefore unsafe to reference it.
pcb | the tcp_pcb to close |
References CLOSE_WAIT, CLOSED, ERR_OK, ESTABLISHED, FIN_WAIT_1, tcp_pcb::flags, LAST_ACK, LISTEN, LWIP_ASSERT, memp_free(), NULL, tcp_listen_pcbs_t::pcbs, tcp_pcb::rcv_nxt, tcp_pcb::rcv_wnd, tcp_pcb::refused_data, tcp_pcb::remote_port, tcp_pcb::snd_nxt, snmp_inc_tcpattemptfails, snmp_inc_tcpestabresets, SYN_RCVD, SYN_SENT, tcp_listen_pcbs, tcp_output(), tcp_pcb_purge(), tcp_pcb_remove(), TCP_PCB_REMOVE_ACTIVE, TCP_REG, TCP_RMV, TCP_RMV_ACTIVE, tcp_rst(), tcp_send_fin(), TCP_WND, TF_RXCLOSED, and TIME_WAIT.
Referenced by tcp_close(), and tcp_shutdown().
err_t tcp_connect | ( | struct tcp_pcb * | pcb, |
ip_addr_t * | ipaddr, | ||
u16_t | port, | ||
tcp_connected_fn | connected | ||
) |
Connects to another host.
The function given as the "connected" argument will be called when the connection has been established.
pcb | the tcp_pcb used to establish the connection |
ipaddr | the remote ip address to connect to |
port | the remote tcp port to connect to |
connected | callback function to call when connected (or on error) |
References CLOSED, tcp_pcb::connected, tcp_pcb::cwnd, ERR_BUF, ERR_ISCONN, ERR_OK, ERR_RTE, ERR_USE, ERR_VAL, netif::ip_addr, ip_addr_cmp, ip_addr_copy, ip_addr_isany, ip_get_option, ip_route(), tcp_pcb::lastack, LWIP_DEBUGF, LWIP_ERROR(), LWIP_UNUSED_ARG, tcp_pcb::mss, NULL, NUM_TCP_PCB_LISTS, tcp_pcb::rcv_ann_right_edge, tcp_pcb::rcv_ann_wnd, tcp_pcb::rcv_nxt, tcp_pcb::rcv_wnd, tcp_pcb::remote_port, tcp_pcb::snd_lbb, tcp_pcb::snd_nxt, tcp_pcb::snd_wnd, snmp_inc_tcpactiveopens, SOF_REUSEADDR, tcp_pcb::ssthresh, SYN_SENT, TCP_DEBUG, tcp_eff_send_mss(), tcp_enqueue_flags(), TCP_MSS, tcp_new_port(), tcp_next_iss(), tcp_output(), TCP_REG_ACTIVE, TCP_RMV, TCP_SYN, TCP_WND, and U16_F.
const char* tcp_debug_state_str | ( | enum tcp_state | s | ) |
References tcp_state_str.
Calcluates the effective send mss that can be used for a specific IP address by using ip_route to determin the netif used to send to the address and calculating the minimum of TCP_MSS and that netif's mtu (if set).
References IP_HLEN, ip_route(), LWIP_MIN, netif::mtu, NULL, and TCP_HLEN.
Referenced by tcp_connect(), tcp_listen_input(), tcp_output_segment(), and tcp_process().
void tcp_err | ( | struct tcp_pcb * | pcb, |
tcp_err_fn | err | ||
) |
Used to specify the function that should be called when a fatal error has occured on the connection.
pcb | tcp_pcb to set the err callback |
err | callback function to call for this pcb when a fatal error has occured on the connection |
References tcp_pcb::errf, LISTEN, and LWIP_ASSERT.
Referenced by http_accept().
Is called every TCP_FAST_INTERVAL (250 ms) and process data previously "refused" by upper layer (application) and sends delayed ACKs.
Automatically called from tcp_tmr().
References tcp_pcb::flags, tcp_pcb::last_timer, LWIP_DEBUGF, next, NULL, tcp_pcb::refused_data, tcp_ack_now, tcp_active_pcbs, tcp_active_pcbs_changed, TCP_DEBUG, tcp_output(), tcp_process_refused_data(), tcp_timer_ctr, TF_ACK_DELAY, and TF_ACK_NOW.
Referenced by tcp_tmr().
Initialize this module.
References TCP_ENSURE_LOCAL_PORT_RANGE, and tcp_port.
Referenced by lwip_init().
Kills the oldest active connection that has the same or lower priority than 'prio'.
prio | minimum priority |
References LWIP_DEBUGF, NULL, S32_F, tcp_abort(), TCP_DEBUG, TCP_PRIO_MAX, tcp_ticks, and tcp_pcb::tmr.
Referenced by tcp_alloc().
Kills the oldest connection that is in TIME_WAIT state.
Called from tcp_alloc() if no more connections are available.
References LWIP_DEBUGF, NULL, S32_F, tcp_abort(), TCP_DEBUG, tcp_ticks, and tcp_pcb::tmr.
Referenced by tcp_alloc().
Set the state of the connection to be LISTEN, which means that it is able to accept incoming connections.
The protocol control block is reallocated in order to consume less memory. Setting the connection to LISTEN is an irreversible process.
pcb | the original tcp_pcb |
backlog | the incoming connections queue limit |
References CLOSED, ip_addr_cmp, ip_addr_copy, ip_get_option, ip_set_option, LISTEN, tcp_listen_pcbs_t::listen_pcbs, LWIP_ERROR(), LWIP_UNUSED_ARG, memp_free(), memp_malloc(), NULL, tcp_listen_pcbs_t::pcbs, SOF_ACCEPTCONN, SOF_REUSEADDR, tcp_accept_null(), tcp_listen_pcbs, TCP_REG, and TCP_RMV.
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists.
The pcb is not put on any list until binding using tcp_bind().
: Maybe there should be a idle TCP PCB list where these PCBs are put on. Port reservation using tcp_bind() is implemented but allocated pcbs that are not bound can't be killed automatically if wanting to allocate a pcb with higher prio (
References tcp_alloc(), and TCP_PRIO_NORMAL.
Referenced by httpd_init().
Allocate a new local TCP port.
References NULL, NUM_TCP_PCB_LISTS, TCP_LOCAL_PORT_RANGE_END, TCP_LOCAL_PORT_RANGE_START, and tcp_port.
Referenced by tcp_bind(), and tcp_connect().
Calculates a new initial sequence number for new connections.
References tcp_ticks.
Referenced by tcp_alloc(), and tcp_connect().
Purges a TCP PCB.
Removes any buffered data and frees the buffer memory (pcb->ooseq, pcb->unsent and pcb->unacked are freed).
pcb | tcp_pcb to purge. The pcb itself is not deallocated! |
References CLOSED, ip_addr_cmp, ip_addr_isany, LISTEN, tcp_listen_pcbs_t::listen_pcbs, LWIP_ASSERT, LWIP_DEBUGF, NULL, tcp_pcb::ooseq, pbuf_free(), tcp_pcb::refused_data, tcp_pcb::rtime, SYN_RCVD, TCP_DEBUG, tcp_listen_pcbs, tcp_segs_free(), TIME_WAIT, tcp_pcb::unacked, tcp_pcb::unsent, and tcp_pcb::unsent_oversize.
Referenced by tcp_close_shutdown(), tcp_pcb_remove(), tcp_process(), and tcp_slowtmr().
Purges the PCB and removes it from a PCB list.
Any delayed ACKs are sent first.
pcblist | PCB list to purge. |
pcb | tcp_pcb to purge. The pcb itself is NOT deallocated! |
References CLOSED, tcp_pcb::flags, LISTEN, LWIP_ASSERT, NULL, tcp_pcb::ooseq, tcp_output(), tcp_pcb_purge(), tcp_pcbs_sane, TCP_RMV, TF_ACK_DELAY, TF_ACK_NOW, TIME_WAIT, tcp_pcb::unacked, and tcp_pcb::unsent.
Referenced by tcp_abandon(), tcp_close_shutdown(), and tcp_input().
void tcp_poll | ( | struct tcp_pcb * | pcb, |
tcp_poll_fn | poll, | ||
u8_t | interval | ||
) |
Used to specify the function that should be called periodically from TCP.
The interval is specified in terms of the TCP coarse timer interval, which is called twice a second.
References LISTEN, LWIP_ASSERT, LWIP_UNUSED_ARG, tcp_pcb::poll, and tcp_pcb::pollinterval.
Referenced by http_accept().
Pass pcb->refused_data to the recv callback.
References ERR_ABRT, ERR_OK, pbuf::flags, LWIP_DEBUGF, NULL, PBUF_FLAG_TCP_FIN, tcp_pcb::rcv_wnd, tcp_pcb::refused_data, TCP_EVENT_CLOSED, TCP_EVENT_RECV, TCP_INPUT_DEBUG, and TCP_WND.
Referenced by tcp_fasttmr(), and tcp_input().
void tcp_recv | ( | struct tcp_pcb * | pcb, |
tcp_recv_fn | recv | ||
) |
Used to specify the function that should be called when a TCP connection receives data.
pcb | tcp_pcb to set the recv callback |
recv | callback function to call for this pcb when data is received |
References LISTEN, LWIP_ASSERT, and tcp_pcb::recv.
Referenced by http_accept(), and http_close_conn().
Default receive callback that is called if the user didn't register a recv callback for the pcb.
References ERR_OK, LWIP_UNUSED_ARG, NULL, pbuf_free(), tcp_close(), tcp_recved(), and pbuf::tot_len.
Referenced by tcp_alloc().
This function should be called by the application when it has processed the data.
The purpose is to advertise a larger window when the data has been processed.
pcb | the tcp_pcb for which data is read |
len | the amount of bytes that have been read by the application |
References LISTEN, LWIP_ASSERT, LWIP_DEBUGF, tcp_pcb::rcv_wnd, tcp_ack_now, TCP_DEBUG, tcp_output(), tcp_update_rcv_ann_wnd(), TCP_WND, and U16_F.
Referenced by http_recv(), and tcp_recv_null().
Returns a copy of the given TCP segment.
The pbuf and data are not copied, only the pointers
seg | the old tcp_seg |
References memp_malloc(), NULL, tcp_seg::p, and pbuf_ref().
Referenced by tcp_receive().
Frees a TCP segment (tcp_seg structure).
seg | single tcp_seg to free |
References memp_free(), NULL, tcp_seg::p, and pbuf_free().
Referenced by tcp_create_segment(), tcp_oos_insert_segment(), tcp_output(), tcp_process(), tcp_receive(), and tcp_segs_free().
Deallocates a list of TCP segments (tcp_seg structures).
seg | tcp_seg list of TCP segments to free |
References next, tcp_seg::next, NULL, and tcp_seg_free().
Referenced by pbuf_free_ooseq(), tcp_abandon(), tcp_oos_insert_segment(), tcp_pcb_purge(), tcp_receive(), tcp_slowtmr(), and tcp_write().
void tcp_sent | ( | struct tcp_pcb * | pcb, |
tcp_sent_fn | sent | ||
) |
Used to specify the function that should be called when TCP data has been successfully delivered to the remote host.
pcb | tcp_pcb to set the sent callback |
sent | callback function to call for this pcb when data is successfully sent |
References LISTEN, LWIP_ASSERT, and tcp_pcb::sent.
Referenced by http_close_conn(), and http_write().
Sets the priority of a connection.
pcb | the tcp_pcb to manipulate |
prio | new priority |
Referenced by http_accept().
Causes all or part of a full-duplex connection of this PCB to be shut down.
This doesn't deallocate the PCB unless shutting down both sides! Shutting down both sides is the same as calling tcp_close, so if it succeds, the PCB should not be referenced any more.
pcb | PCB to shutdown |
shut_rx | shut down receive side if this is != 0 |
shut_tx | shut down send side if this is != 0 |
References CLOSE_WAIT, ERR_CONN, ERR_OK, ESTABLISHED, tcp_pcb::flags, LISTEN, NULL, pbuf_free(), tcp_pcb::refused_data, SYN_RCVD, tcp_close_shutdown(), and TF_RXCLOSED.
Called every 500 ms and implements the retransmission timer and the timer that removes PCBs that have been in TIME-WAIT for enough time.
It also increments various timers such as the inactivity timer in each PCB.
Automatically called from tcp_tmr().
References CLOSE_WAIT, CLOSED, tcp_pcb::cwnd, ERR_ABRT, ERR_OK, tcp_pcb::errf, ESTABLISHED, FIN_WAIT_2, tcp_pcb::flags, ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, ip_get_option, tcp_pcb::keep_cnt_sent, tcp_pcb::keep_idle, LAST_ACK, tcp_pcb::last_timer, LISTEN, LWIP_ASSERT, LWIP_DEBUGF, LWIP_MIN, memp_free(), tcp_pcb::mss, tcp_pcb::nrtx, NULL, tcp_pcb::ooseq, tcp_pcb::persist_backoff, tcp_pcb::persist_cnt, tcp_pcb::pollinterval, tcp_pcb::polltmr, tcp_pcb::rcv_nxt, tcp_pcb::remote_port, tcp_pcb::rtime, tcp_pcb::rto, S16_F, tcp_pcb::sa, tcp_pcb::snd_nxt, tcp_pcb::snd_wnd, SOF_KEEPALIVE, tcp_pcb::ssthresh, tcp_pcb::sv, SYN_RCVD, SYN_SENT, tcp_active_pcbs, tcp_active_pcbs_changed, tcp_backoff, TCP_CWND_DEBUG, TCP_DEBUG, TCP_EVENT_ERR, TCP_EVENT_POLL, TCP_FIN_WAIT_TIMEOUT, TCP_KEEP_DUR, TCP_KEEP_INTVL, tcp_keepalive(), TCP_MSL, TCP_OOSEQ_TIMEOUT, tcp_output(), tcp_pcb_purge(), tcp_persist_backoff, tcp_rexmit_rto(), tcp_rst(), TCP_RTO_DEBUG, tcp_segs_free(), TCP_SLOW_INTERVAL, TCP_SYN_RCVD_TIMEOUT, tcp_ticks, tcp_timer_ctr, tcp_tw_pcbs, tcp_zero_window_probe(), TF_RXCLOSED, TIME_WAIT, tcp_pcb::tmr, U16_F, and tcp_pcb::unacked.
Referenced by tcp_tmr().
Called periodically to dispatch TCP timers.
References tcp_fasttmr(), tcp_slowtmr(), and tcp_timer.
Referenced by tcpip_tcp_timer().
Update the state that tracks the available window space to advertise.
Returns how much extra window would be advertised if we sent an update now.
References LWIP_ASSERT, LWIP_MIN, tcp_pcb::mss, tcp_pcb::rcv_ann_right_edge, tcp_pcb::rcv_ann_wnd, tcp_pcb::rcv_nxt, tcp_pcb::rcv_wnd, TCP_SEQ_GEQ, TCP_SEQ_GT, and TCP_WND.
Referenced by tcp_receive(), and tcp_recved().
struct tcp_pcb* tcp_active_pcbs |
List of all TCP PCBs that are in a state in which they accept or send data.
Referenced by netif_set_ipaddr(), pbuf_free_ooseq(), tcp_fasttmr(), tcp_input(), tcp_slowtmr(), tcp_timer_needed(), and tcpip_tcp_timer().
u8_t tcp_active_pcbs_changed |
Referenced by tcp_fasttmr(), and tcp_slowtmr().
const u8_t tcp_backoff[13] |
Referenced by tcp_slowtmr().
struct tcp_pcb* tcp_bound_pcbs |
List of all TCP PCBs bound but not yet (connected || listening)
union tcp_listen_pcbs_t tcp_listen_pcbs |
List of all TCP PCBs in LISTEN state.
Referenced by netif_set_ipaddr(), tcp_close_shutdown(), tcp_input(), tcp_listen_with_backlog(), and tcp_pcb_purge().
struct tcp_pcb** const tcp_pcb_lists[] |
An array with all (non-temporary) PCB lists, mainly used for smaller code size.
const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 } |
Referenced by tcp_slowtmr().
|
static |
Referenced by tcp_init(), and tcp_new_port().
const char* const tcp_state_str[] |
Referenced by tcp_debug_state_str().
u32_t tcp_ticks |
|
static |
|
static |
Referenced by tcp_alloc(), tcp_fasttmr(), and tcp_slowtmr().
struct tcp_pcb* tcp_tmp_pcb |
Only used for temporary storage.
struct tcp_pcb* tcp_tw_pcbs |
List of all TCP PCBs in TIME-WAIT state.
Referenced by tcp_input(), tcp_process(), tcp_slowtmr(), tcp_timer_needed(), and tcpip_tcp_timer().