|
lwIP 2.2.1
Lightweight IP stack
|
#include "lwip/opt.h"#include "lwip/tcp.h"#include "lwip/mem.h"#include "lwip/pbuf.h"#include "lwip/ip.h"#include "lwip/icmp.h"#include "lwip/err.h"#include "lwip/ip6.h"#include "lwip/ip6_addr.h"#include "lwip/prot/tcp.h"Macros | |
| #define | tcp_do_output_nagle(tpcb) |
| #define | TF_RESET (u8_t)0x08U /* Connection was reset. */ |
| #define | TCP_OVERSIZE_DBGCHECK 0 |
| #define | TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) |
| #define | TCP_BUILD_MSS_OPTION(mss) |
Variables | |
| struct tcp_pcb * | tcp_bound_pcbs |
| union tcp_listen_pcbs_t | tcp_listen_pcbs |
| struct tcp_pcb * | tcp_active_pcbs |
| struct tcp_pcb * | tcp_tw_pcbs |
| struct tcp_pcb **const | tcp_pcb_lists [4] |
TCP internal implementations (do not use in application code)
| #define TCP_BUILD_MSS_OPTION | ( | mss | ) |
This returns a TCP header option for MSS in an u32_t
| #define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) |
Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled
| #define tcp_do_output_nagle | ( | tpcb | ) |
This is the Nagle algorithm: try to combine user data to send as few TCP segments as possible. Only send if
| #define TCP_OVERSIZE_DBGCHECK 0 |
Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled
| #define TF_RESET (u8_t)0x08U /* Connection was reset. */ |
Flags used on input processing, not on pcb->flags
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 |
| struct tcp_pcb * tcp_alloc | ( | u8_t | prio | ) |
Calculates the effective send mss that can be used for a specific IP address by calculating the minimum of TCP_MSS and the mtu (if set) of the target netif (if not NULL).
Enqueue SYN or FIN for transmission.
Called by tcp_connect, tcp_listen_input, and tcp_close (via tcp_send_fin)
| pcb | Protocol control block for the TCP connection. |
| flags | TCP header flags to set in the outgoing segment. |
| err_t tcp_ext_arg_invoke_callbacks_passive_open | ( | struct tcp_pcb_listen * | lpcb, |
| struct tcp_pcb * | cpcb ) |
This function calls the "passive_open" callback for all ext_args if a connection is in the process of being accepted. This is called just after the SYN is received and before a SYN/ACK is sent, to allow to modify the very first segment sent even on passive open. Naturally, the "accepted" callback of the pcb has not been called yet!
Is called every TCP_FAST_INTERVAL (250 ms) and process data previously "refused" by upper layer (application) and sends delayed ACKs or pending FINs.
Automatically called from tcp_tmr().
The initial input processing of TCP. It verifies the TCP header, demultiplexes the segment between the PCBs and passes it on to tcp_process(), which implements the TCP finite state machine. This function is called by the IP layer (in ip_input()).
| p | received TCP segment to process (p->payload pointing to the TCP header) |
| inp | network interface on which this segment was received |
Send keepalive packets to keep a connection active although no data is sent over it.
Called by tcp_slowtmr()
| pcb | the tcp_pcb for which to send a keepalive packet |
This function is called from netif.c when address is changed or netif is removed
| 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 |
| u32_t tcp_next_iss | ( | struct tcp_pcb * | pcb | ) |
Calculates a new initial sequence number for new connections.
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! |
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! |
Default receive callback that is called if the user didn't register a recv callback for the pcb.
Requeue the first unacked segment for retransmission
Called by tcp_receive() for fast retransmit.
| pcb | the tcp_pcb for which to retransmit the first unacked segment |
Handle retransmission after three dupacks received
| pcb | the tcp_pcb for which to retransmit the first unacked segment |
Requeue all unacked segments for retransmission
Called by tcp_process() only, tcp_slowtmr() needs to do some things between "prepare" and "commit".
| pcb | the tcp_pcb for which to re-enqueue all unacked segments |
Requeue all unacked segments for retransmission
Called by tcp_slowtmr() for slow retransmission.
| pcb | the tcp_pcb for which to re-enqueue all unacked segments |
Requeue all unacked segments for retransmission
Called by tcp_slowtmr() for slow retransmission.
| pcb | the tcp_pcb for which to re-enqueue all unacked segments |
| void tcp_rst | ( | const struct tcp_pcb * | pcb, |
| u32_t | seqno, | ||
| u32_t | ackno, | ||
| const ip_addr_t * | local_ip, | ||
| const ip_addr_t * | remote_ip, | ||
| u16_t | local_port, | ||
| u16_t | remote_port ) |
Send a TCP RESET packet (empty segment with RST flag set) to abort a connection.
Called by tcp_abort() (to abort a local connection), tcp_closen() (if not all data has been received by the application), tcp_timewait_input() (if a SYN is received) and tcp_process() (received segment in the wrong state).
Since a RST segment is in most cases not sent for an active connection, tcp_rst() has a number of arguments that are taken from a tcp_pcb for most other segment output functions.
| pcb | TCP pcb (may be NULL if no pcb is available) |
| seqno | the sequence number to use for the outgoing segment |
| ackno | the acknowledge number to use for the outgoing segment |
| local_ip | the local IP address to send the segment from |
| remote_ip | the remote IP address to send the segment to |
| local_port | the local TCP port to send the segment from |
| remote_port | the remote TCP port to send the segment to |
| void tcp_rst_netif | ( | struct netif * | netif, |
| u32_t | seqno, | ||
| u32_t | ackno, | ||
| const ip_addr_t * | local_ip, | ||
| const ip_addr_t * | remote_ip, | ||
| u16_t | local_port, | ||
| u16_t | remote_port ) |
Send a TCP RESET packet (empty segment with RST flag set) to show that there is no matching local connection for a received segment.
Called by tcp_input() (if no matching local pcb was found) and tcp_listen_input() (if incoming segment has ACK flag set).
Since a RST segment is in most cases not sent for an active connection, tcp_rst() has a number of arguments that are taken from a tcp_pcb for most other segment output functions.
| netif | the netif on which to send the RST (since we have no pcb) |
| seqno | the sequence number to use for the outgoing segment |
| ackno | the acknowledge number to use for the outgoing segment |
| local_ip | the local IP address to send the segment from |
| remote_ip | the remote IP address to send the segment to |
| local_port | the local TCP port to send the segment from |
| remote_port | the remote TCP port to send the segment to |
| struct tcp_seg * tcp_seg_copy | ( | struct tcp_seg * | seg | ) |
Returns a copy of the given TCP segment. The pbuf and data are not copied, only the pointers
| seg | the old tcp_seg |
| void tcp_seg_free | ( | struct tcp_seg * | seg | ) |
Frees a TCP segment (tcp_seg structure).
| seg | single tcp_seg to free |
| void tcp_segs_free | ( | struct tcp_seg * | seg | ) |
Deallocates a list of TCP segments (tcp_seg structures).
| seg | tcp_seg list of TCP segments to free |
Send an ACK without data.
| pcb | Protocol control block for the TCP connection to send the ACK |
Called by tcp_close() to send a segment including FIN flag but not data. This FIN may be added to an existing segment or a new, otherwise empty segment is enqueued.
| pcb | the tcp_pcb over which to send a segment |
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().
Split segment on the head of the unsent queue. If return is not ERR_OK, existing head remains intact
The split is accomplished by creating a new TCP segment and pbuf which holds the remainder payload after the split. The original pbuf is trimmed to new length. This allows splitting of read-only pbufs
| pcb | the tcp_pcb for which to split the unsent head |
| split | the amount of payload to remain in the head |
External function (implemented in timers.c), called when TCP detects that a timer is needed (i.e. active- or time-wait-pcb found).
Called from TCP_REG when registering a new PCB: the reason is to have the TCP timer only running when there are active (or time-wait) PCBs.
| 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.
Send persist timer zero-window probes to keep a connection active when a window update is lost.
Called by tcp_slowtmr()
| pcb | the tcp_pcb for which to send a zero-window probe packet |
|
extern |
List of all TCP PCBs that are in a state in which they accept or send data.
|
extern |
List of all TCP PCBs bound but not yet (connected || listening)
|
extern |
List of all TCP PCBs in LISTEN state
|
extern |
An array with all (non-temporary) PCB lists, mainly used for smaller code size
|
extern |
List of all TCP PCBs in TIME-WAIT state