A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
Transmission Control Protocol for IP. More...
Go to the source code of this file.
Functions | |
static u16_t | tcp_new_port (void) |
A nastly hack featuring 'goto' statements that allocates a new TCP local port. | |
void | tcp_tmr (void) |
Called periodically to dispatch TCP timers. | |
err_t | tcp_close (struct tcp_pcb *pcb) |
Closes the connection held by the PCB. | |
void | tcp_abort (struct tcp_pcb *pcb) |
Aborts a connection by sending a RST to the remote host and deletes the local protocol control block. | |
err_t | tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) |
Binds the connection to a local portnumber 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. | |
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, struct ip_addr *ipaddr, u16_t port, err_t(*connected)(void *arg, struct tcp_pcb *tpcb, err_t err)) |
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. | |
u8_t | tcp_segs_free (struct tcp_seg *seg) |
Deallocates a list of TCP segments (tcp_seg structures). | |
u8_t | 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. | |
static 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 lower priority than prio. | |
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. | |
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, err_t(*recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)) |
Used to specify the function that should be called when a TCP connection receives data. | |
void | tcp_sent (struct tcp_pcb *pcb, err_t(*sent)(void *arg, struct tcp_pcb *tpcb, u16_t len)) |
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, void(*errf)(void *arg, err_t err)) |
Used to specify the function that should be called when a fatal error has occured on the connection. | |
void | tcp_accept (struct tcp_pcb *pcb, err_t(*accept)(void *arg, struct tcp_pcb *newpcb, err_t err)) |
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, err_t(*poll)(void *arg, struct tcp_pcb *tpcb), 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 (void) |
Calculates a new initial sequence number for new connections. | |
u16_t | tcp_eff_send_mss (u16_t sendmss, struct ip_addr *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). | |
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. |
Detailed Description
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.
Definition in file tag/0.5/lwIP/core/tcp.c.
Function Documentation
void tcp_abort | ( | struct tcp_pcb * | pcb ) |
Aborts a connection by sending a RST to the remote host and 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
Definition at line 196 of file tag/0.5/lwIP/core/tcp.c.
void tcp_accept | ( | struct tcp_pcb * | pcb, |
err_t(*)(void *arg, struct tcp_pcb *newpcb, err_t err) | accept | ||
) |
Used for specifying the function that should be called when a LISTENing connection has been connected to another host.
- Parameters:
-
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
Definition at line 1112 of file tag/0.5/lwIP/core/tcp.c.
static err_t tcp_accept_null | ( | void * | arg, |
struct tcp_pcb * | pcb, | ||
err_t | err | ||
) | [static] |
Default accept callback if no accept callback is specified by the user.
Definition at line 322 of file tag/0.5/lwIP/core/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 966 of file tag/0.5/lwIP/core/tcp.c.
void tcp_arg | ( | struct tcp_pcb * | pcb, |
void * | arg | ||
) |
Used to specify the argument that should be passed callback functions.
- Parameters:
-
pcb tcp_pcb to set the callback argument arg void pointer argument to pass to callback functions
Definition at line 1054 of file tag/0.5/lwIP/core/tcp.c.
err_t tcp_bind | ( | struct tcp_pcb * | pcb, |
struct ip_addr * | ipaddr, | ||
u16_t | port | ||
) |
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.
- Parameters:
-
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
- Returns:
- ERR_USE if the port is already in use ERR_OK if bound
Definition at line 257 of file tag/0.5/lwIP/core/tcp.c.
err_t tcp_close | ( | struct tcp_pcb * | pcb ) |
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.
- 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 111 of file tag/0.5/lwIP/core/tcp.c.
err_t tcp_connect | ( | struct tcp_pcb * | pcb, |
struct ip_addr * | ipaddr, | ||
u16_t | port, | ||
err_t(*)(void *arg, struct tcp_pcb *tpcb, err_t err) | connected | ||
) |
Connects to another host.
The function given as the "connected" argument will be called when the connection has been established.
- Parameters:
-
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)
- Returns:
- ERR_VAL if invalid arguments are given ERR_OK if connect request has been sent other err_t values if connect request couldn't be sent
Definition at line 485 of file tag/0.5/lwIP/core/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 1259 of file tag/0.5/lwIP/core/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 1341 of file tag/0.5/lwIP/core/tcp.c.
void tcp_debug_print_pcbs | ( | void | ) |
Print all tcp_pcbs in every list for debugging purposes.
Definition at line 1373 of file tag/0.5/lwIP/core/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 1295 of file tag/0.5/lwIP/core/tcp.c.
u16_t tcp_eff_send_mss | ( | u16_t | sendmss, |
struct ip_addr * | 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).
Definition at line 1235 of file tag/0.5/lwIP/core/tcp.c.
void tcp_err | ( | struct tcp_pcb * | pcb, |
void(*)(void *arg, err_t err) | errf | ||
) |
Used to specify the function that should be called when a fatal error has occured on the connection.
- Parameters:
-
pcb tcp_pcb to set the err callback errf callback function to call for this pcb when a fatal error has occured on the connection
Definition at line 1097 of file tag/0.5/lwIP/core/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 779 of file tag/0.5/lwIP/core/tcp.c.
static void tcp_kill_prio | ( | u8_t | prio ) | [static] |
Kills the oldest active connection that has lower priority than prio.
- Parameters:
-
prio minimum priority
Definition at line 905 of file tag/0.5/lwIP/core/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 938 of file tag/0.5/lwIP/core/tcp.c.
struct tcp_pcb* tcp_listen_with_backlog | ( | struct tcp_pcb * | pcb, |
u8_t | backlog | ||
) | [read] |
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.
- Parameters:
-
pcb the original tcp_pcb backlog the incoming connections queue limit
- Returns:
- tcp_pcb used for listening, consumes less memory.
- Note:
- The original tcp_pcb is freed. This function therefore has to be called like this: tpcb = tcp_listen(tpcb);
Definition at line 347 of file tag/0.5/lwIP/core/tcp.c.
struct tcp_pcb* tcp_new | ( | void | ) | [read] |
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().
Definition at line 1041 of file tag/0.5/lwIP/core/tcp.c.
static u16_t tcp_new_port | ( | void | ) | [static] |
A nastly hack featuring 'goto' statements that allocates a new TCP local port.
- Returns:
- a new (free) local TCP port number
Definition at line 440 of file tag/0.5/lwIP/core/tcp.c.
u32_t tcp_next_iss | ( | void | ) |
Calculates a new initial sequence number for new connections.
- Returns:
- u32_t pseudo random sequence number
Definition at line 1220 of file tag/0.5/lwIP/core/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 1143 of file tag/0.5/lwIP/core/tcp.c.
void tcp_pcb_remove | ( | struct tcp_pcb ** | pcblist, |
struct tcp_pcb * | pcb | ||
) |
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 also deallocated!
Definition at line 1187 of file tag/0.5/lwIP/core/tcp.c.
s16_t tcp_pcbs_sane | ( | void | ) |
Check state consistency of the tcp_pcb lists.
Definition at line 1403 of file tag/0.5/lwIP/core/tcp.c.
void tcp_poll | ( | struct tcp_pcb * | pcb, |
err_t(*)(void *arg, struct tcp_pcb *tpcb) | 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.
Definition at line 1127 of file tag/0.5/lwIP/core/tcp.c.
void tcp_recv | ( | struct tcp_pcb * | pcb, |
err_t(*)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) | recv | ||
) |
Used to specify the function that should be called when a TCP connection receives data.
- Parameters:
-
pcb tcp_pcb to set the recv callback recv callback function to call for this pcb when data is received
Definition at line 1068 of file tag/0.5/lwIP/core/tcp.c.
static err_t tcp_recv_null | ( | void * | arg, |
struct tcp_pcb * | pcb, | ||
struct pbuf * | p, | ||
err_t | err | ||
) | [static] |
Default receive callback that is called if the user didn't register a recv callback for the pcb.
Definition at line 887 of file tag/0.5/lwIP/core/tcp.c.
void tcp_recved | ( | struct tcp_pcb * | pcb, |
u16_t | len | ||
) |
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.
- Parameters:
-
pcb the tcp_pcb for which data is read len the amount of bytes that have been read by the application
Definition at line 392 of file tag/0.5/lwIP/core/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 867 of file tag/0.5/lwIP/core/tcp.c.
u8_t tcp_seg_free | ( | struct tcp_seg * | seg ) |
Frees a TCP segment (tcp_seg structure).
- Parameters:
-
seg single tcp_seg to free
- Returns:
- the number of pbufs that were deallocated
Definition at line 830 of file tag/0.5/lwIP/core/tcp.c.
u8_t 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
- Returns:
- the number of pbufs that were deallocated
Definition at line 811 of file tag/0.5/lwIP/core/tcp.c.
void tcp_sent | ( | struct tcp_pcb * | pcb, |
err_t(*)(void *arg, struct tcp_pcb *tpcb, u16_t len) | sent | ||
) |
Used to specify the function that should be called when TCP data has been successfully delivered to the remote host.
- Parameters:
-
pcb tcp_pcb to set the sent callback sent callback function to call for this pcb when data is successfully sent
Definition at line 1082 of file tag/0.5/lwIP/core/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 853 of file tag/0.5/lwIP/core/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 546 of file tag/0.5/lwIP/core/tcp.c.
void tcp_tmr | ( | void | ) |
Called periodically to dispatch TCP timers.
Definition at line 84 of file tag/0.5/lwIP/core/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 70 of file tag/0.5/lwIP/core/tcp.c.
struct tcp_pcb* tcp_bound_pcbs |
List of all TCP PCBs bound but not yet (connected || listening)
Definition at line 65 of file tag/0.5/lwIP/core/tcp.c.
union tcp_listen_pcbs_t tcp_listen_pcbs |
List of all TCP PCBs in LISTEN state.
Definition at line 67 of file tag/0.5/lwIP/core/tcp.c.
struct tcp_pcb* tcp_tw_pcbs |
List of all TCP PCBs in TIME-WAIT state.
Definition at line 72 of file tag/0.5/lwIP/core/tcp.c.
Generated on Tue Jul 12 2022 16:06:31 by 1.7.2