NetServices Stack source
Dependents: HelloWorld ServoInterfaceBoardExample1 4180_Lab4
tcp_out.c File Reference
Transmission Control Protocol, outgoing traffic. More...
Go to the source code of this file.
Functions | |
static void | tcp_output_segment (struct tcp_seg *seg, struct tcp_pcb *pcb) |
Called by tcp_output() to actually send a TCP segment over IP. | |
static struct pbuf * | tcp_output_alloc_header (struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, u32_t seqno_be) |
Allocate a pbuf and create a tcphdr at p->payload, used for output functions other than the default tcp_output -> tcp_output_segment (e.g. | |
err_t | tcp_send_fin (struct tcp_pcb *pcb) |
Called by tcp_close() to send a segment including FIN flag but not data. | |
static struct tcp_seg * | tcp_create_segment (struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, u8_t optflags) |
Create a TCP segment with prefilled header. | |
static struct pbuf * | tcp_pbuf_prealloc (pbuf_layer layer, u16_t length, u16_t max_length, u16_t *oversize, struct tcp_pcb *pcb, u8_t apiflags, u8_t first_seg) |
Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. | |
static void | tcp_seg_add_chksum (u16_t chksum, u16_t len, u16_t *seg_chksum, u8_t *seg_chksum_swapped) |
Add a checksum of newly added data to the segment. | |
static err_t | tcp_write_checks (struct tcp_pcb *pcb, u16_t len) |
Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen). | |
err_t | tcp_write (struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) |
Write data for sending (but does not send it immediately). | |
err_t | tcp_enqueue_flags (struct tcp_pcb *pcb, u8_t flags) |
Enqueue TCP options for transmission. | |
err_t | tcp_send_empty_ack (struct tcp_pcb *pcb) |
Send an ACK without data. | |
err_t | tcp_output (struct tcp_pcb *pcb) |
Find out what we can send and send it. | |
void | tcp_rst (u32_t seqno, u32_t ackno, ip_addr_t *local_ip, ip_addr_t *remote_ip, u16_t local_port, u16_t remote_port) |
Send a TCP RESET packet (empty segment with RST flag set) either to abort a connection or to show that there is no matching local connection for a received segment. | |
void | tcp_rexmit_rto (struct tcp_pcb *pcb) |
Requeue all unacked segments for retransmission. | |
void | tcp_rexmit (struct tcp_pcb *pcb) |
Requeue the first unacked segment for retransmission. | |
void | tcp_rexmit_fast (struct tcp_pcb *pcb) |
Handle retransmission after three dupacks received. | |
void | tcp_keepalive (struct tcp_pcb *pcb) |
Send keepalive packets to keep a connection active although no data is sent over it. | |
void | tcp_zero_window_probe (struct tcp_pcb *pcb) |
Send persist timer zero-window probes to keep a connection active when a window update is lost. |
Detailed Description
Transmission Control Protocol, outgoing traffic.
The output functions of TCP.
Definition in file tcp_out.c.
Function Documentation
static struct tcp_seg* tcp_create_segment | ( | struct tcp_pcb * | pcb, |
struct pbuf * | p, | ||
u8_t | flags, | ||
u32_t | seqno, | ||
u8_t | optflags | ||
) | [static, read] |
Create a TCP segment with prefilled header.
Called by tcp_write and tcp_enqueue_flags.
- Parameters:
-
pcb Protocol control block for the TCP connection. p pbuf that is used to hold the TCP header. flags TCP flags for header. seqno TCP sequence number of this packet optflags options to include in TCP header
- Returns:
- a new tcp_seg pointing to p, or NULL. The TCP header is filled in except ackno and wnd. p is freed on failure.
err_t tcp_enqueue_flags | ( | struct tcp_pcb * | pcb, |
u8_t | flags | ||
) |
Enqueue TCP options for transmission.
Called by tcp_connect(), tcp_listen_input(), and tcp_send_ctrl().
- Parameters:
-
pcb Protocol control block for the TCP connection. flags TCP header flags to set in the outgoing segment. optdata pointer to TCP options, or NULL. optlen length of TCP options in bytes.
void tcp_keepalive | ( | struct tcp_pcb * | pcb ) |
Send keepalive packets to keep a connection active although no data is sent over it.
Called by tcp_slowtmr()
- Parameters:
-
pcb the tcp_pcb for which to send a keepalive packet
err_t tcp_output | ( | struct tcp_pcb * | pcb ) |
static struct pbuf* tcp_output_alloc_header | ( | struct tcp_pcb * | pcb, |
u16_t | optlen, | ||
u16_t | datalen, | ||
u32_t | seqno_be | ||
) | [static, read] |
Allocate a pbuf and create a tcphdr at p->payload, used for output functions other than the default tcp_output -> tcp_output_segment (e.g.
tcp_send_empty_ack, etc.)
- Parameters:
-
pcb tcp pcb for which to send a packet (used to initialize tcp_hdr) optlen length of header-options datalen length of tcp data to reserve in pbuf seqno_be seqno in network byte order (big-endian)
- Returns:
- pbuf with p->payload being the tcp_hdr
static void tcp_output_segment | ( | struct tcp_seg * | seg, |
struct tcp_pcb * | pcb | ||
) | [static] |
Called by tcp_output() to actually send a TCP segment over IP.
- Parameters:
-
seg the tcp_seg to send pcb the tcp_pcb for the TCP connection used to send the segment
static struct pbuf* tcp_pbuf_prealloc | ( | pbuf_layer | layer, |
u16_t | length, | ||
u16_t | max_length, | ||
u16_t * | oversize, | ||
struct tcp_pcb * | pcb, | ||
u8_t | apiflags, | ||
u8_t | first_seg | ||
) | [static, read] |
Allocate a PBUF_RAM pbuf, perhaps with extra space at the end.
This function is like pbuf_alloc(layer, length, PBUF_RAM) except there may be extra bytes available at the end.
- Parameters:
-
layer flag to define header size. length size of the pbuf's payload. max_length maximum usable size of payload+oversize. oversize pointer to a u16_t that will receive the number of usable tail bytes. pcb The TCP connection that willo enqueue the pbuf. apiflags API flags given to tcp_write. first_seg true when this pbuf will be used in the first enqueued segment.
void tcp_rexmit | ( | struct tcp_pcb * | pcb ) |
Requeue the first unacked segment for retransmission.
Called by tcp_receive() for fast retramsmit.
- Parameters:
-
pcb the tcp_pcb for which to retransmit the first unacked segment
void tcp_rexmit_fast | ( | struct tcp_pcb * | pcb ) |
void tcp_rexmit_rto | ( | struct tcp_pcb * | pcb ) |
Requeue all unacked segments for retransmission.
Called by tcp_slowtmr() for slow retransmission.
- Parameters:
-
pcb the tcp_pcb for which to re-enqueue all unacked segments
void tcp_rst | ( | u32_t | seqno, |
u32_t | ackno, | ||
ip_addr_t * | local_ip, | ||
ip_addr_t * | remote_ip, | ||
u16_t | local_port, | ||
u16_t | remote_port | ||
) |
Send a TCP RESET packet (empty segment with RST flag set) either to abort a connection or to show that there is no matching local connection for a received segment.
Called by tcp_abort() (to abort a local connection), tcp_input() (if no matching local pcb was found), tcp_listen_input() (if incoming segment has ACK flag set) 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.
- Parameters:
-
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
static void tcp_seg_add_chksum | ( | u16_t | chksum, |
u16_t | len, | ||
u16_t * | seg_chksum, | ||
u8_t * | seg_chksum_swapped | ||
) | [static] |
err_t tcp_send_empty_ack | ( | struct tcp_pcb * | pcb ) |
err_t tcp_send_fin | ( | struct tcp_pcb * | pcb ) |
Called by tcp_close() to send a segment including FIN flag but not data.
- Parameters:
-
pcb the tcp_pcb over which to send a segment
- Returns:
- ERR_OK if sent, another err_t otherwise
err_t tcp_write | ( | struct tcp_pcb * | pcb, |
const void * | arg, | ||
u16_t | len, | ||
u8_t | apiflags | ||
) |
Write data for sending (but does not send it immediately).
It waits in the expectation of more data being sent soon (as it can send them more efficiently by combining them together). To prompt the system to send data now, call tcp_output() after calling tcp_write().
- Parameters:
-
pcb Protocol control block for the TCP connection to enqueue data for. arg Pointer to the data to be enqueued for sending. len Data length in bytes apiflags combination of following flags : - TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack
- TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will be set on last segment sent,
- Returns:
- ERR_OK if enqueued, another err_t on error
static err_t tcp_write_checks | ( | struct tcp_pcb * | pcb, |
u16_t | len | ||
) | [static] |
void tcp_zero_window_probe | ( | struct tcp_pcb * | pcb ) |
Send persist timer zero-window probes to keep a connection active when a window update is lost.
Called by tcp_slowtmr()
- Parameters:
-
pcb the tcp_pcb for which to send a zero-window probe packet
Generated on Tue Jul 12 2022 11:52:59 by 1.7.2