Rtos API example
Transmission Control Protocol for IP See also TCP. More...
Go to the source code of this file.
Functions | |
static u16_t | tcp_new_port (void) |
Allocate a new local TCP port. | |
void | tcp_init (void) |
Initialize this module. | |
void | tcp_tmr (void) |
Called periodically to dispatch TCP timers. | |
static void | tcp_remove_listener (struct tcp_pcb *list, struct tcp_pcb_listen *lpcb) |
Called when a listen pcb is closed. | |
static void | tcp_listen_closed (struct tcp_pcb *pcb) |
Called when a listen pcb is closed. | |
void | tcp_backlog_delayed (struct tcp_pcb *pcb) |
Delay accepting a connection in respect to the listen backlog: the number of outstanding connections is increased until tcp_backlog_accepted() is called. | |
void | tcp_backlog_accepted (struct tcp_pcb *pcb) |
A delayed-accept a connection is accepted (or closed/aborted): decreases the number of outstanding connections after calling tcp_backlog_delayed(). | |
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. | |
err_t | tcp_close (struct tcp_pcb *pcb) |
Closes the connection held by the PCB. | |
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. | |
void | tcp_abandon (struct tcp_pcb *pcb, int reset) |
Abandons a connection and optionally sends a RST to the remote host. | |
void | tcp_abort (struct tcp_pcb *pcb) |
Aborts the connection by sending a RST (reset) segment to the remote host. | |
err_t | tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) |
Binds the connection to a local port number and IP address. | |
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. | |
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. | |
struct tcp_pcb * | tcp_listen_with_backlog_and_err (struct tcp_pcb *pcb, u8_t backlog, err_t *err) |
Set the state of the connection to be LISTEN, which means that it is able to accept incoming connections. | |
u32_t | tcp_update_rcv_ann_wnd (struct tcp_pcb *pcb) |
Update the state that tracks the available window space to advertise. | |
void | tcp_recved (struct tcp_pcb *pcb, u16_t len) |
This function should be called by the application when it has processed the data. | |
err_t | tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port, tcp_connected_fn connected) |
Connects to another host. | |
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. | |
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. | |
void | tcp_txnow (void) |
Call tcp_output for all active pcbs that have TF_NAGLEMEMERR set. | |
err_t | tcp_process_refused_data (struct tcp_pcb *pcb) |
Pass pcb->refused_data to the recv callback. | |
void | tcp_segs_free (struct tcp_seg *seg) |
Deallocates a list of TCP segments (tcp_seg structures). | |
void | tcp_seg_free (struct tcp_seg *seg) |
Frees a TCP segment (tcp_seg structure). | |
void | tcp_setprio (struct tcp_pcb *pcb, u8_t prio) |
Sets the priority of a connection. | |
struct tcp_seg * | tcp_seg_copy (struct tcp_seg *seg) |
Returns a copy of the given TCP segment. | |
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. | |
static void | tcp_kill_prio (u8_t prio) |
Kills the oldest active connection that has the same or lower priority than 'prio'. | |
static void | tcp_kill_state (enum tcp_state state) |
Kills the oldest connection that is in specific state. | |
static void | tcp_kill_timewait (void) |
Kills the oldest connection that is in TIME_WAIT state. | |
struct tcp_pcb * | tcp_alloc (u8_t prio) |
Allocate a new tcp_pcb structure. | |
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. | |
struct tcp_pcb * | tcp_new_ip_type (u8_t type) |
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists. | |
void | tcp_arg (struct tcp_pcb *pcb, void *arg) |
Used to specify the argument that should be passed callback functions. | |
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. | |
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. | |
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 occurred on the connection. | |
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. | |
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. | |
void | tcp_pcb_purge (struct tcp_pcb *pcb) |
Purges a TCP PCB. | |
void | tcp_pcb_remove (struct tcp_pcb **pcblist, struct tcp_pcb *pcb) |
Purges the PCB and removes it from a PCB list. | |
u32_t | tcp_next_iss (struct tcp_pcb *pcb) |
Calculates a new initial sequence number for new connections. | |
u16_t | tcp_eff_send_mss_impl (u16_t sendmss, const ip_addr_t *dest#if LWIP_IPV6||LWIP_IPV4_SRC_ROUTING, const ip_addr_t *src#endif) |
Calculates the effective send mss that can be used for a specific IP address by using ip_route to determine the netif used to send to the address and calculating the minimum of TCP_MSS and that netif's mtu (if set). | |
static void | tcp_netif_ip_addr_changed_pcblist (const ip_addr_t *old_addr, struct tcp_pcb *pcb_list) |
Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list. | |
void | tcp_netif_ip_addr_changed (const ip_addr_t *old_addr, const ip_addr_t *new_addr) |
This function is called from netif.c when address is changed or netif is removed. | |
void | tcp_debug_print (struct tcp_hdr *tcphdr) |
Print a tcp header for debugging purposes. | |
void | tcp_debug_print_state (enum tcp_state s) |
Print a tcp state for debugging purposes. | |
void | tcp_debug_print_flags (u8_t flags) |
Print tcp flags for debugging purposes. | |
void | tcp_debug_print_pcbs (void) |
Print all tcp_pcbs in every list for debugging purposes. | |
s16_t | tcp_pcbs_sane (void) |
Check state consistency of the tcp_pcb lists. | |
Variables | |
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. | |
struct tcp_pcb * | tcp_active_pcbs |
List of all TCP PCBs that are in a state in which they accept or send data. | |
struct tcp_pcb * | tcp_tw_pcbs |
List of all TCP PCBs in TIME-WAIT state. | |
struct tcp_pcb **const | tcp_pcb_lists [] |
An array with all (non-temporary) PCB lists, mainly used for smaller code size. | |
static u8_t | tcp_timer |
Timer counter to handle calling slow-timer from tcp_tmr() |
Detailed Description
Transmission Control Protocol for IP See also TCP.
Definition in file lwip_tcp.c.
Function Documentation
void tcp_abandon | ( | struct tcp_pcb * | pcb, |
int | reset | ||
) |
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.
- Parameters:
-
pcb the tcp_pcb to abort reset boolean to indicate whether a reset should be sent
Definition at line 464 of file lwip_tcp.c.
Default accept callback if no accept callback is specified by the user.
Definition at line 631 of file lwip_tcp.c.
struct tcp_pcb* tcp_alloc | ( | u8_t | prio ) | [read] |
Allocate a new tcp_pcb structure.
- Parameters:
-
prio priority for the new pcb
- Returns:
- a new tcp_pcb that initially is in state CLOSED
Definition at line 1549 of file lwip_tcp.c.
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.
- Parameters:
-
pcb the tcp_pcb to close
- Returns:
- ERR_OK if connection has been closed another err_t if closing failed and pcb is not freed
Definition at line 265 of file lwip_tcp.c.
void tcp_debug_print | ( | struct tcp_hdr * | tcphdr ) |
Print a tcp header for debugging purposes.
- Parameters:
-
tcphdr pointer to a struct tcp_hdr
Definition at line 2036 of file lwip_tcp.c.
void tcp_debug_print_flags | ( | u8_t | flags ) |
Print tcp flags for debugging purposes.
- Parameters:
-
flags tcp flags, all active flags are printed
Definition at line 2083 of file lwip_tcp.c.
void tcp_debug_print_pcbs | ( | void | ) |
Print all tcp_pcbs in every list for debugging purposes.
Definition at line 2116 of file lwip_tcp.c.
void tcp_debug_print_state | ( | enum tcp_state | s ) |
Print a tcp state for debugging purposes.
- Parameters:
-
s enum tcp_state to print
Definition at line 2072 of file lwip_tcp.c.
u16_t tcp_eff_send_mss_impl | ( | u16_t | sendmss, |
const ip_addr_t *dest#if LWIP_IPV6|| | LWIP_IPV4_SRC_ROUTING, | ||
const ip_addr_t *src# | endif | ||
) |
Calculates the effective send mss that can be used for a specific IP address by using ip_route to determine the netif used to send to the address and calculating the minimum of TCP_MSS and that netif's mtu (if set).
Definition at line 1910 of file lwip_tcp.c.
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.
Automatically called from tcp_tmr().
Definition at line 1245 of file lwip_tcp.c.
void tcp_init | ( | void | ) |
Initialize this module.
Definition at line 145 of file lwip_tcp.c.
static void tcp_kill_prio | ( | u8_t | prio ) | [static] |
Kills the oldest active connection that has the same or lower priority than 'prio'.
- Parameters:
-
prio minimum priority
Definition at line 1458 of file lwip_tcp.c.
static void tcp_kill_state | ( | enum tcp_state | state ) | [static] |
Kills the oldest connection that is in specific state.
Called from tcp_alloc() for LAST_ACK and CLOSING if no more connections are available.
Definition at line 1489 of file lwip_tcp.c.
static void tcp_kill_timewait | ( | void | ) | [static] |
Kills the oldest connection that is in TIME_WAIT state.
Called from tcp_alloc() if no more connections are available.
Definition at line 1521 of file lwip_tcp.c.
static void tcp_listen_closed | ( | struct tcp_pcb * | pcb ) | [static] |
Called when a listen pcb is closed.
Iterates all pcb lists and removes the closed listener pcb from pcb->listener if matching.
Definition at line 188 of file lwip_tcp.c.
This function is called from netif.c when address is changed or netif is removed.
- Parameters:
-
old_addr IP address of the netif before change new_addr IP address of the netif after change or NULL if netif has been removed
Definition at line 2000 of file lwip_tcp.c.
static void tcp_netif_ip_addr_changed_pcblist | ( | const ip_addr_t * | old_addr, |
struct tcp_pcb * | pcb_list | ||
) | [static] |
Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list.
Definition at line 1971 of file lwip_tcp.c.
static u16_t tcp_new_port | ( | void | ) | [static] |
Allocate a new local TCP port.
- Returns:
- a new (free) local TCP port number
Definition at line 832 of file lwip_tcp.c.
u32_t tcp_next_iss | ( | struct tcp_pcb * | pcb ) |
Calculates a new initial sequence number for new connections.
- Returns:
- u32_t pseudo random sequence number
Definition at line 1889 of file lwip_tcp.c.
void tcp_pcb_purge | ( | struct tcp_pcb * | pcb ) |
Purges a TCP PCB.
Removes any buffered data and frees the buffer memory (pcb->ooseq, pcb->unsent and pcb->unacked are freed).
- Parameters:
-
pcb tcp_pcb to purge. The pcb itself is not deallocated!
Definition at line 1805 of file lwip_tcp.c.
Purges the PCB and removes it from a PCB list.
Any delayed ACKs are sent first.
- Parameters:
-
pcblist PCB list to purge. pcb tcp_pcb to purge. The pcb itself is NOT deallocated!
Definition at line 1854 of file lwip_tcp.c.
s16_t tcp_pcbs_sane | ( | void | ) |
Check state consistency of the tcp_pcb lists.
Definition at line 2148 of file lwip_tcp.c.
Pass pcb->refused_data to the recv callback.
Definition at line 1305 of file lwip_tcp.c.
Default receive callback that is called if the user didn't register a recv callback for the pcb.
Definition at line 1438 of file lwip_tcp.c.
static void tcp_remove_listener | ( | struct tcp_pcb * | list, |
struct tcp_pcb_listen * | lpcb | ||
) | [static] |
Called when a listen pcb is closed.
Iterates one pcb list and removes the closed listener pcb from pcb->listener if matching.
Definition at line 173 of file lwip_tcp.c.
struct tcp_seg* tcp_seg_copy | ( | struct tcp_seg * | seg ) | [read] |
Returns a copy of the given TCP segment.
The pbuf and data are not copied, only the pointers
- Parameters:
-
seg the old tcp_seg
- Returns:
- a copy of seg
Definition at line 1418 of file lwip_tcp.c.
void tcp_seg_free | ( | struct tcp_seg * | seg ) |
Frees a TCP segment (tcp_seg structure).
- Parameters:
-
seg single tcp_seg to free
Definition at line 1384 of file lwip_tcp.c.
void tcp_segs_free | ( | struct tcp_seg * | seg ) |
Deallocates a list of TCP segments (tcp_seg structures).
- Parameters:
-
seg tcp_seg list of TCP segments to free
Definition at line 1369 of file lwip_tcp.c.
void tcp_setprio | ( | struct tcp_pcb * | pcb, |
u8_t | prio | ||
) |
Sets the priority of a connection.
- Parameters:
-
pcb the tcp_pcb to manipulate prio new priority
Definition at line 1404 of file lwip_tcp.c.
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.
It also increments various timers such as the inactivity timer in each PCB.
Automatically called from tcp_tmr().
Definition at line 980 of file lwip_tcp.c.
void tcp_tmr | ( | void | ) |
Called periodically to dispatch TCP timers.
Definition at line 156 of file lwip_tcp.c.
void tcp_txnow | ( | void | ) |
Call tcp_output for all active pcbs that have TF_NAGLEMEMERR set.
Definition at line 1292 of file lwip_tcp.c.
u32_t tcp_update_rcv_ann_wnd | ( | struct tcp_pcb * | pcb ) |
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.
Definition at line 753 of file lwip_tcp.c.
Variable Documentation
struct tcp_pcb* tcp_active_pcbs |
List of all TCP PCBs that are in a state in which they accept or send data.
Definition at line 124 of file lwip_tcp.c.
struct tcp_pcb* tcp_bound_pcbs |
List of all TCP PCBs bound but not yet (connected || listening)
Definition at line 119 of file lwip_tcp.c.
union tcp_listen_pcbs_t tcp_listen_pcbs |
List of all TCP PCBs in LISTEN state.
Definition at line 121 of file lwip_tcp.c.
struct tcp_pcb** const tcp_pcb_lists[] |
{&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, &tcp_active_pcbs, &tcp_tw_pcbs}
An array with all (non-temporary) PCB lists, mainly used for smaller code size.
Definition at line 129 of file lwip_tcp.c.
u8_t tcp_timer [static] |
Timer counter to handle calling slow-timer from tcp_tmr()
Definition at line 135 of file lwip_tcp.c.
struct tcp_pcb* tcp_tw_pcbs |
List of all TCP PCBs in TIME-WAIT state.
Definition at line 126 of file lwip_tcp.c.
Generated on Sun Jul 17 2022 08:25:35 by 1.7.2