|
iPXE
|
TCP protocol. More...
#include <string.h>#include <stdlib.h>#include <stdio.h>#include <assert.h>#include <errno.h>#include <byteswap.h>#include <ipxe/timer.h>#include <ipxe/iobuf.h>#include <ipxe/malloc.h>#include <ipxe/init.h>#include <ipxe/retry.h>#include <ipxe/refcnt.h>#include <ipxe/pending.h>#include <ipxe/xfer.h>#include <ipxe/open.h>#include <ipxe/uri.h>#include <ipxe/netdevice.h>#include <ipxe/profile.h>#include <ipxe/process.h>#include <ipxe/job.h>#include <ipxe/tcpip.h>#include <ipxe/tcp.h>Go to the source code of this file.
Data Structures | |
| struct | tcp_connection |
| A TCP connection. More... | |
| struct | tcp_rx_queued_header |
| TCP internal header. More... | |
Enumerations | |
| enum | tcp_flags { TCP_XFER_CLOSED = 0x0001, TCP_TS_ENABLED = 0x0002, TCP_ACK_PENDING = 0x0004, TCP_SACK_ENABLED = 0x0008 } |
| TCP flags. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| static | LIST_HEAD (tcp_conns) |
| List of registered TCP connections. More... | |
| static void | tcp_expired (struct retry_timer *timer, int over) |
| Retransmission timer expired. More... | |
| static void | tcp_keepalive_expired (struct retry_timer *timer, int over __unused) |
| Keepalive timer expired. More... | |
| static void | tcp_wait_expired (struct retry_timer *timer, int over __unused) |
| Shutdown timer expired. More... | |
| static struct tcp_connection * | tcp_demux (unsigned int local_port) |
| Identify TCP connection by local port number. More... | |
| static int | tcp_rx_ack (struct tcp_connection *tcp, uint32_t ack, uint32_t win) |
| Handle TCP received ACK. More... | |
| static const char * | tcp_state (int state) |
| Name TCP state. More... | |
| static void | tcp_dump_state (struct tcp_connection *tcp) |
| Dump TCP state transition. More... | |
| static void | tcp_dump_flags (struct tcp_connection *tcp, unsigned int flags) |
| Dump TCP flags. More... | |
| static int | tcp_port_available (int port) |
| Check if local TCP port is available. More... | |
| static int | tcp_open (struct interface *xfer, struct sockaddr *peer, struct sockaddr *local) |
| Open a TCP connection. More... | |
| static void | tcp_close (struct tcp_connection *tcp, int rc) |
| Close TCP connection. More... | |
| static size_t | tcp_xmit_win (struct tcp_connection *tcp) |
| Calculate transmission window. More... | |
| static size_t | tcp_xfer_window (struct tcp_connection *tcp) |
| Check data-transfer flow control window. More... | |
| static uint32_t | tcp_sack_block (struct tcp_connection *tcp, uint32_t seq, struct tcp_sack_block *sack) |
| Find selective acknowledgement block. More... | |
| static unsigned int | tcp_sack (struct tcp_connection *tcp, uint32_t seq) |
| Update TCP selective acknowledgement list. More... | |
| static size_t | tcp_process_tx_queue (struct tcp_connection *tcp, size_t max_len, struct io_buffer *dest, int remove) |
| Process TCP transmit queue. More... | |
| static void | tcp_xmit_sack (struct tcp_connection *tcp, uint32_t sack_seq) |
| Transmit any outstanding data (with selective acknowledgement) More... | |
| static void | tcp_xmit (struct tcp_connection *tcp) |
| Transmit any outstanding data. More... | |
| static int | tcp_xmit_reset (struct tcp_connection *tcp, struct sockaddr_tcpip *st_dest, struct tcp_header *in_tcphdr) |
| Send RST response to incoming packet. More... | |
| static int | tcp_rx_opts (struct tcp_connection *tcp, const struct tcp_header *tcphdr, size_t hlen, struct tcp_options *options) |
| Parse TCP received options. More... | |
| static void | tcp_rx_seq (struct tcp_connection *tcp, uint32_t seq_len) |
| Consume received sequence space. More... | |
| static int | tcp_rx_syn (struct tcp_connection *tcp, uint32_t seq, struct tcp_options *options) |
| Handle TCP received SYN. More... | |
| static int | tcp_rx_data (struct tcp_connection *tcp, uint32_t seq, struct io_buffer *iobuf) |
| Handle TCP received data. More... | |
| static int | tcp_rx_fin (struct tcp_connection *tcp, uint32_t seq) |
| Handle TCP received FIN. More... | |
| static int | tcp_rx_rst (struct tcp_connection *tcp, uint32_t seq) |
| Handle TCP received RST. More... | |
| static void | tcp_rx_enqueue (struct tcp_connection *tcp, uint32_t seq, uint8_t flags, struct io_buffer *iobuf) |
| Enqueue received TCP packet. More... | |
| static void | tcp_process_rx_queue (struct tcp_connection *tcp) |
| Process receive queue. More... | |
| static int | tcp_rx (struct io_buffer *iobuf, struct net_device *netdev __unused, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest __unused, uint16_t pshdr_csum) |
| Process received packet. More... | |
| static unsigned int | tcp_discard (void) |
| Discard some cached TCP data. More... | |
| struct cache_discarder tcp_discarder | __cache_discarder (CACHE_NORMAL) |
| TCP cache discarder. More... | |
| static struct tcp_connection * | tcp_first_unclosed (void) |
| Find first TCP connection that has not yet been closed. More... | |
| static struct tcp_connection * | tcp_first_unfinished (void) |
| Find first TCP connection that has not yet finished all operations. More... | |
| static void | tcp_shutdown (int booting __unused) |
| Shut down all TCP connections. More... | |
| struct startup_fn tcp_startup_fn | __startup_fn (STARTUP_LATE) |
| TCP shutdown function. More... | |
| static void | tcp_xfer_close (struct tcp_connection *tcp, int rc) |
| Close interface. More... | |
| static int | tcp_xfer_deliver (struct tcp_connection *tcp, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
| Deliver datagram as I/O buffer. More... | |
| static int | tcp_progress (struct tcp_connection *tcp, struct job_progress *progress) |
| Report job progress. More... | |
| static int | tcp_open_uri (struct interface *xfer, struct uri *uri) |
| Open TCP URI. More... | |
Variables | |
| struct tcp_statistics | tcp_stats |
| TCP statistics. More... | |
| static struct profiler tcp_tx_profiler | __profiler = { .name = "tcp.tx" } |
| Transmit profiler. More... | |
| static struct process_descriptor | tcp_process_desc |
| TCP process descriptor. More... | |
| static struct interface_descriptor | tcp_xfer_desc |
| TCP data transfer interface descriptor. More... | |
| struct tcpip_protocol tcp_protocol | __tcpip_protocol |
| TCP protocol. More... | |
| static struct interface_operation | tcp_xfer_operations [] |
| TCP data transfer interface operations. More... | |
| struct socket_opener tcp_socket_opener | __socket_opener |
| TCP socket opener. More... | |
| int | tcp_sock_stream = TCP_SOCK_STREAM |
| Linkage hack. More... | |
| struct uri_opener tcp_uri_opener | __uri_opener |
| TCP URI opener. More... | |
TCP protocol.
Definition in file tcp.c.
| enum tcp_flags |
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
static |
List of registered TCP connections.
|
static |
Retransmission timer expired.
| timer | Retransmission timer |
| over | Failure indicator |
Definition at line 789 of file tcp.c.
References assert(), container_of, DBGC, ETIMEDOUT, tcp_connection::rcv_ack, tcp_connection::snd_sent, tcp_connection::snd_seq, tcp_close(), TCP_CLOSE_WAIT, TCP_CLOSED, TCP_CLOSING_OR_LAST_ACK, tcp_dump_state(), TCP_ESTABLISHED, TCP_FIN_WAIT_1, tcp_connection::tcp_state, tcp_state(), TCP_SYN_RCVD, TCP_SYN_SENT, and tcp_xmit().
Referenced by tcp_open().
|
static |
Keepalive timer expired.
| timer | Keepalive timer |
| over | Failure indicator |
Definition at line 823 of file tcp.c.
References container_of, DBGC, tcp_connection::flags, tcp_connection::keepalive, start_timer_fixed(), TCP_ACK_PENDING, TCP_KEEPALIVE_DELAY, and tcp_xmit().
Referenced by tcp_open().
|
static |
Shutdown timer expired.
| timer | Shutdown timer |
| over | Failure indicator |
Definition at line 849 of file tcp.c.
References assert(), container_of, DBGC, tcp_connection::rcv_ack, tcp_connection::snd_sent, tcp_connection::snd_seq, tcp_close(), TCP_CLOSED, tcp_dump_state(), tcp_connection::tcp_state, tcp_state(), TCP_TIME_WAIT, and tcp_connection::wait.
Referenced by tcp_open().
|
static |
Identify TCP connection by local port number.
| local_port | Local port |
| tcp | TCP connection, or NULL |
Definition at line 933 of file tcp.c.
References tcp_connection::list, list_for_each_entry, tcp_connection::local_port, and NULL.
Referenced by tcp_port_available(), and tcp_rx().
|
static |
Handle TCP received ACK.
| tcp | TCP connection |
| ack | ACK value (in host-endian order) |
| win | WIN value (in host-endian order) |
| rc | Return status code |
Definition at line 1119 of file tcp.c.
References DBGC, EINVAL, tcp_connection::flags, tcp_connection::keepalive, len, list_empty, NULL, tcp_connection::pending_flags, pending_get(), pending_put(), tcp_connection::snd_sent, tcp_connection::snd_seq, tcp_connection::snd_win, start_timer_fixed(), stop_timer(), TCP_FIN, TCP_FLAGS_SENDING, TCP_HAS_BEEN_ESTABLISHED, TCP_KEEPALIVE_DELAY, tcp_process_tx_queue(), tcp_connection::tcp_state, TCP_STATE_ACKED, TCP_STATE_SENT, TCP_SYN, TCP_XFER_CLOSED, tcp_connection::timer, and tcp_connection::tx_queue.
Referenced by tcp_close(), and tcp_rx().
|
inlinestatic |
Name TCP state.
| state | TCP state |
| name | Name of TCP state |
Definition at line 200 of file tcp.c.
References state, TCP_CLOSE_WAIT, TCP_CLOSED, TCP_CLOSING_OR_LAST_ACK, TCP_ESTABLISHED, TCP_FIN_WAIT_1, TCP_FIN_WAIT_2, TCP_LISTEN, TCP_SYN_RCVD, TCP_SYN_SENT, and TCP_TIME_WAIT.
Referenced by tcp_dump_state(), tcp_expired(), and tcp_wait_expired().
|
inlinestatic |
Dump TCP state transition.
| tcp | TCP connection |
Definition at line 222 of file tcp.c.
References DBGC, tcp_connection::prev_tcp_state, tcp_connection::tcp_state, and tcp_state().
Referenced by tcp_close(), tcp_expired(), tcp_open(), tcp_rx(), tcp_rx_rst(), tcp_shutdown(), and tcp_wait_expired().
|
inlinestatic |
|
static |
Check if local TCP port is available.
| port | Local port number |
| port | Local port number, or negative error |
Definition at line 264 of file tcp.c.
References EADDRINUSE, port, and tcp_demux().
Referenced by tcp_open().
|
static |
Open a TCP connection.
| xfer | Data transfer interface |
| peer | Peer socket address |
| local | Local socket address, or NULL |
| rc | Return status code |
Definition at line 277 of file tcp.c.
References DBGC, ENETUNREACH, ENOMEM, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), tcp_connection::keepalive, tcp_connection::list, list_add, tcp_connection::local_port, memcpy(), tcp_connection::mss, mtu, NULL, peer, tcp_connection::peer, tcp_connection::pending_flags, pending_get(), port, tcp_connection::prev_tcp_state, tcp_connection::process, process_init_stopped(), random(), rc, ref_init, ref_put, tcp_connection::refcnt, tcp_connection::rx_queue, tcp_connection::snd_seq, sock_ntoa(), start_timer_nodelay(), strerror(), TCP_CLOSED, tcp_dump_state(), tcp_expired(), tcp_keepalive_expired(), tcp_port_available(), tcp_process_desc, tcp_connection::tcp_state, TCP_STATE_SENT, TCP_SYN, tcp_wait_expired(), tcp_xfer_desc, tcpip_bind(), tcpip_mtu(), tcp_connection::timer, tcp_connection::tx_queue, tcp_connection::wait, tcp_connection::xfer, and zalloc().
|
static |
Close TCP connection.
| tcp | TCP connection |
| rc | Reason for close |
Closes the data transfer interface. If the TCP state machine is in a suitable state, the connection will be deleted.
Definition at line 353 of file tcp.c.
References assert(), DBGC, tcp_connection::flags, free_iob(), intf_shutdown(), is_pending(), tcp_connection::keepalive, io_buffer::list, tcp_connection::list, list_del, list_empty, list_for_each_entry_safe, tcp_connection::pending_data, tcp_connection::pending_flags, pending_get(), pending_put(), tcp_connection::process, process_add(), process_del(), rc, ref_put, tcp_connection::refcnt, tcp_connection::rx_queue, tcp_connection::snd_seq, stop_timer(), TCP_CLOSED, tcp_dump_state(), TCP_FIN, tcp_rx_ack(), tcp_connection::tcp_state, TCP_STATE_ACKED, TCP_STATE_RCVD, TCP_STATE_SENT, TCP_SYN, TCP_XFER_CLOSED, tcp_connection::timer, tmp, tcp_connection::tx_queue, tcp_connection::wait, and tcp_connection::xfer.
Referenced by tcp_expired(), tcp_rx_fin(), tcp_rx_rst(), tcp_shutdown(), tcp_wait_expired(), and tcp_xfer_close().
|
static |
Calculate transmission window.
| tcp | TCP connection |
| len | Maximum length that can be sent in a single packet |
Definition at line 436 of file tcp.c.
References len, tcp_connection::snd_win, TCP_CAN_SEND_DATA, TCP_PATH_MTU, and tcp_connection::tcp_state.
Referenced by tcp_xfer_window(), and tcp_xmit_sack().
|
static |
Check data-transfer flow control window.
| tcp | TCP connection |
| len | Length of window |
Definition at line 457 of file tcp.c.
References list_empty, tcp_xmit_win(), and tcp_connection::tx_queue.
Referenced by tcp_rx().
|
static |
Find selective acknowledgement block.
| tcp | TCP connection |
| seq | SEQ value in SACK block (in host-endian order) |
| sack | SACK block to fill in (in host-endian order) |
| len | Length of SACK block |
Definition at line 478 of file tcp.c.
References io_buffer::data, tcp_sack_block::left, list_for_each_entry, tcp_rx_queued_header::nxt, tcp_connection::rcv_ack, tcp_sack_block::right, tcp_connection::rx_queue, seq, tcp_rx_queued_header::seq, and tcp_cmp().
Referenced by tcp_sack().
|
static |
Update TCP selective acknowledgement list.
| tcp | TCP connection |
| seq | SEQ value in first SACK block (in host-endian order) |
| count | Number of SACK blocks |
Definition at line 514 of file tcp.c.
References tcp_sack_block::left, len, memcpy(), memset(), old, tcp_sack_block::right, tcp_connection::sack, seq, tcp_sack_block(), and TCP_SACK_MAX.
Referenced by tcp_xmit_sack().
|
static |
Process TCP transmit queue.
| tcp | TCP connection |
| max_len | Maximum length to process |
| dest | I/O buffer to fill with data, or NULL |
| remove | Remove data from queue |
| len | Length of data processed |
This processes at most max_len bytes from the TCP connection's transmit queue. Data will be copied into the dest I/O buffer (if provided) and, if remove is true, removed from the transmit queue.
Definition at line 572 of file tcp.c.
References io_buffer::data, dest, free_iob(), iob_len(), iob_pull, iob_put, len, io_buffer::list, list_del, list_for_each_entry_safe, memcpy(), tcp_connection::pending_data, pending_put(), remove, tmp, and tcp_connection::tx_queue.
Referenced by tcp_rx_ack(), and tcp_xmit_sack().
|
static |
Transmit any outstanding data (with selective acknowledgement)
| tcp | TCP connection |
| sack_seq | SEQ for first selective acknowledgement (if any) |
Transmits any outstanding data on the connection.
Note that even if an error is returned, the retransmission timer will have been started if necessary, and so the stack will eventually attempt to retransmit the failed packet.
Definition at line 613 of file tcp.c.
References tcp_header::ack, alloc_iob(), assert(), tcp_header::csum, currticks(), io_buffer::data, DBGC, DBGC2, tcp_header::dest, flags, tcp_header::flags, tcp_connection::flags, tcp_header::hlen, htonl, htons, iob_len(), iob_push, iob_reserve, tcp_mss_option::kind, tcp_window_scale_option::kind, tcp_sack_permitted_option::kind, tcp_sack_option::kind, tcp_timestamp_option::kind, tcp_sack_block::left, len, tcp_mss_option::length, tcp_window_scale_option::length, tcp_sack_permitted_option::length, tcp_sack_option::length, tcp_timestamp_option::length, list_empty, tcp_connection::local_port, memset(), tcp_connection::mss, tcp_mss_option::mss, tcp_sack_permitted_padded_option::nop, tcp_sack_padded_option::nop, tcp_timestamp_padded_option::nop, ntohl, ntohs, NULL, tcp_connection::peer, profile_start(), profile_stop(), rc, tcp_connection::rcv_ack, tcp_connection::rcv_win, tcp_connection::rcv_win_scale, tcp_sack_block::right, tcp_connection::rx_queue, tcp_connection::sack, tcp_sack_padded_option::sackopt, tcp_window_scale_option::scale, tcp_header::seq, tcp_connection::snd_sent, tcp_connection::snd_seq, tcp_sack_permitted_padded_option::spopt, tcp_header::src, sockaddr_tcpip::st_port, start_timer(), strerror(), TCP_ACK_PENDING, TCP_CAN_SEND_DATA, tcp_dump_flags(), TCP_FIN, TCP_FLAGS_SENDING, TCP_MAX_HEADER_LEN, TCP_MAX_WINDOW_SIZE, TCP_OPTION_MSS, TCP_OPTION_NOP, TCP_OPTION_SACK, TCP_OPTION_SACK_PERMITTED, TCP_OPTION_TS, TCP_OPTION_WS, tcp_process_tx_queue(), TCP_PSH, TCP_RX_WINDOW_SCALE, tcp_sack(), TCP_SACK_ENABLED, tcp_connection::tcp_state, TCP_SYN, TCP_TS_ENABLED, tcp_xmit_win(), tcpip_chksum(), tcpip_tx(), tcp_connection::timer, tcp_connection::ts_recent, tcp_timestamp_option::tsecr, tcp_timestamp_padded_option::tsopt, tcp_timestamp_option::tsval, tcp_header::win, wsopt, tcp_connection::xfer, and xfer_window().
Referenced by tcp_rx(), and tcp_xmit().
|
static |
Transmit any outstanding data.
| tcp | TCP connection |
Definition at line 773 of file tcp.c.
References tcp_connection::rcv_ack, and tcp_xmit_sack().
Referenced by tcp_expired(), tcp_keepalive_expired(), tcp_xfer_close(), and tcp_xfer_deliver().
|
static |
Send RST response to incoming packet.
| in_tcphdr | TCP header of incoming packet |
| rc | Return status code |
Definition at line 870 of file tcp.c.
References tcp_header::ack, alloc_iob(), tcp_header::csum, io_buffer::data, DBGC, DBGC2, tcp_header::dest, ENOMEM, tcp_header::flags, tcp_header::hlen, htons, iob_len(), iob_push, iob_reserve, memset(), ntohl, ntohs, NULL, rc, tcp_header::seq, tcp_header::src, strerror(), TCP_ACK, tcp_dump_flags(), TCP_MAX_HEADER_LEN, TCP_RST, tcpip_chksum(), tcpip_tx(), and tcp_header::win.
Referenced by tcp_rx().
|
static |
Parse TCP received options.
| tcp | TCP connection (may be NULL) |
| tcphdr | TCP header |
| hlen | TCP header length |
| options | Options structure to fill in |
| rc | Return status code |
Definition at line 952 of file tcp.c.
References assert(), data, DBGC, EINVAL, end, tcp_option::kind, memset(), min, options, TCP_OPTION_END, TCP_OPTION_MSS, TCP_OPTION_NOP, TCP_OPTION_SACK, TCP_OPTION_SACK_PERMITTED, TCP_OPTION_TS, and TCP_OPTION_WS.
Referenced by tcp_rx().
|
static |
Consume received sequence space.
| tcp | TCP connection |
| seq_len | Sequence space length to consume |
Definition at line 1034 of file tcp.c.
References assert(), tcp_connection::flags, tcp_sack_block::left, tcp_connection::rcv_ack, tcp_connection::rcv_win, tcp_sack_block::right, tcp_connection::sack, TCP_ACK_PENDING, tcp_cmp(), TCP_SACK_MAX, tcp_connection::ts_recent, and tcp_connection::ts_val.
Referenced by tcp_rx_data(), tcp_rx_fin(), and tcp_rx_syn().
|
static |
Handle TCP received SYN.
| tcp | TCP connection |
| seq | SEQ value (in host-endian order) |
| options | TCP options |
| rc | Return status code |
Definition at line 1075 of file tcp.c.
References DBGC, tcp_connection::flags, options, tcp_connection::rcv_ack, tcp_connection::rcv_win_scale, seq, tcp_connection::snd_win_scale, TCP_ACK, tcp_rx_seq(), TCP_RX_WINDOW_SCALE, TCP_SACK_ENABLED, tcp_connection::tcp_state, TCP_STATE_RCVD, TCP_STATE_SENT, TCP_SYN, and TCP_TS_ENABLED.
Referenced by tcp_rx().
|
static |
Handle TCP received data.
| tcp | TCP connection |
| seq | SEQ value (in host-endian order) |
| iobuf | I/O buffer |
| rc | Return status code |
This function takes ownership of the I/O buffer.
Definition at line 1204 of file tcp.c.
References DBGC, free_iob(), tcp_statistics::in_octets_good, iob_len(), iob_pull, len, profile_start(), profile_stop(), rc, tcp_connection::rcv_ack, seq, strerror(), tcp_rx_seq(), tcp_stats, tcp_connection::xfer, and xfer_deliver_iob().
Referenced by tcp_process_rx_queue().
|
static |
Handle TCP received FIN.
| tcp | TCP connection |
| seq | SEQ value (in host-endian order) |
| rc | Return status code |
Definition at line 1245 of file tcp.c.
References tcp_connection::rcv_ack, seq, tcp_close(), TCP_FIN, tcp_rx_seq(), tcp_connection::tcp_state, and TCP_STATE_RCVD.
Referenced by tcp_process_rx_queue().
|
static |
Handle TCP received RST.
| tcp | TCP connection |
| seq | SEQ value (in host-endian order) |
| rc | Return status code |
Definition at line 1270 of file tcp.c.
References DBGC, ECONNRESET, tcp_connection::rcv_ack, tcp_connection::rcv_win, seq, tcp_close(), TCP_CLOSED, tcp_dump_state(), tcp_in_window(), tcp_connection::tcp_state, TCP_STATE_ACKED, TCP_STATE_RCVD, and TCP_SYN.
Referenced by tcp_rx().
|
static |
Enqueue received TCP packet.
| tcp | TCP connection |
| seq | SEQ value (in host-endian order) |
| flags | TCP flags |
| iobuf | I/O buffer |
Definition at line 1302 of file tcp.c.
References io_buffer::data, flags, tcp_rx_queued_header::flags, free_iob(), tcp_statistics::in_out_of_order, iob_len(), iob_push, len, io_buffer::list, list_add_tail, list_for_each_entry, tcp_rx_queued_header::nxt, tcp_connection::rcv_ack, tcp_connection::rcv_win, tcp_connection::rx_queue, seq, tcp_rx_queued_header::seq, tcp_cmp(), TCP_FIN, tcp_connection::tcp_state, TCP_STATE_RCVD, tcp_stats, and TCP_SYN.
Referenced by tcp_rx().
|
static |
Process receive queue.
| tcp | TCP connection |
Definition at line 1360 of file tcp.c.
References io_buffer::data, flags, tcp_rx_queued_header::flags, iob_disown, iob_len(), iob_pull, len, io_buffer::list, list_del, list_first_entry, tcp_connection::rcv_ack, tcp_connection::rx_queue, seq, tcp_rx_queued_header::seq, tcp_cmp(), TCP_FIN, tcp_rx_data(), and tcp_rx_fin().
Referenced by tcp_rx().
|
static |
Process received packet.
| iobuf | I/O buffer |
| netdev | Network device |
| st_src | Partially-filled source address |
| st_dest | Partially-filled destination address |
| pshdr_csum | Pseudo-header checksum |
| rc | Return status code |
Definition at line 1409 of file tcp.c.
References tcp_header::ack, io_buffer::data, DBG, DBGC2, tcp_header::dest, EINVAL, ENOTCONN, flags, tcp_header::flags, tcp_connection::flags, free_iob(), tcp_header::hlen, tcp_statistics::in_octets, tcp_statistics::in_segs, iob_disown, iob_len(), iob_pull, len, list_empty, ntohl, ntohs, options, tcp_connection::process, process_add(), profile_start(), profile_stop(), rc, tcp_connection::rcv_ack, tcp_connection::rx_queue, seq, tcp_header::seq, tcp_connection::snd_win_scale, tcp_header::src, start_timer_fixed(), stop_timer(), TCP_ACK, TCP_ACK_PENDING, TCP_CLOSED_GRACEFULLY, tcp_demux(), tcp_dump_flags(), tcp_dump_state(), TCP_FIN, TCP_MASK_HLEN, TCP_MSL, tcp_process_rx_queue(), TCP_RST, tcp_rx_ack(), tcp_rx_enqueue(), tcp_rx_opts(), tcp_rx_rst(), tcp_rx_syn(), tcp_connection::tcp_state, TCP_STATE_RCVD, tcp_stats, TCP_SYN, tcp_xfer_window(), tcp_xmit_reset(), tcp_xmit_sack(), tcpip_continue_chksum(), tcp_connection::ts_val, tcp_connection::wait, tcp_header::win, tcp_connection::xfer, and xfer_window_changed().
|
static |
Discard some cached TCP data.
| discarded | Number of cached items discarded |
Definition at line 1577 of file tcp.c.
References free_iob(), tcp_statistics::in_discards, io_buffer::list, list_del, list_for_each_entry, list_for_each_entry_reverse, tcp_connection::rx_queue, and tcp_stats.
| struct cache_discarder tcp_discarder __cache_discarder | ( | CACHE_NORMAL | ) |
TCP cache discarder.
|
static |
Find first TCP connection that has not yet been closed.
| tcp | First unclosed connection, or NULL |
Definition at line 1612 of file tcp.c.
References tcp_connection::flags, tcp_connection::list, list_for_each_entry, NULL, and TCP_XFER_CLOSED.
Referenced by tcp_shutdown().
|
static |
Find first TCP connection that has not yet finished all operations.
| tcp | First unfinished connection, or NULL |
Definition at line 1628 of file tcp.c.
References tcp_connection::list, list_for_each_entry, NULL, tcp_connection::process, process_running(), TCP_CLOSED_GRACEFULLY, and tcp_connection::tcp_state.
Referenced by tcp_shutdown().
|
static |
Shut down all TCP connections.
Definition at line 1648 of file tcp.c.
References currticks(), DBGC, ECANCELED, tcp_connection::list, list_first_entry, NULL, start, step(), tcp_close(), TCP_CLOSED, tcp_dump_state(), TCP_FINISH_TIMEOUT, tcp_first_unclosed(), tcp_first_unfinished(), and tcp_connection::tcp_state.
| struct startup_fn tcp_startup_fn __startup_fn | ( | STARTUP_LATE | ) |
TCP shutdown function.
|
static |
Close interface.
| tcp | TCP connection |
| rc | Reason for close |
Definition at line 1696 of file tcp.c.
References rc, tcp_close(), and tcp_xmit().
|
static |
Deliver datagram as I/O buffer.
| tcp | TCP connection |
| iobuf | Datagram I/O buffer |
| meta | Data transfer metadata |
| rc | Return status code |
Definition at line 1713 of file tcp.c.
References io_buffer::list, list_add_tail, tcp_connection::pending_data, pending_get(), tcp_xmit(), and tcp_connection::tx_queue.
|
static |
Report job progress.
| tcp | TCP connection |
| progress | Progress report to fill in |
| ongoing_rc | Ongoing job status code (if known) |
Definition at line 1736 of file tcp.c.
References job_progress::message, snprintf(), TCP_HAS_BEEN_ESTABLISHED, and tcp_connection::tcp_state.
Open TCP URI.
| xfer | Data transfer interface |
| uri | URI |
| rc | Return status code |
Definition at line 1783 of file tcp.c.
References EINVAL, uri::host, htons, memset(), NULL, peer, SOCK_STREAM, uri_port(), and xfer_open_named_socket().
| struct tcp_statistics tcp_stats |
TCP statistics.
Definition at line 172 of file tcp.c.
Referenced by ipstat(), tcp_discard(), tcp_rx(), tcp_rx_data(), and tcp_rx_enqueue().
|
static |
TCP process descriptor.
Definition at line 184 of file tcp.c.
Referenced by tcp_open().
|
static |
TCP data transfer interface descriptor.
Definition at line 185 of file tcp.c.
Referenced by tcp_open().
| struct tcpip_protocol tcp_protocol __tcpip_protocol |
TCP protocol.
ICMPv4 TCP/IP protocol.
|
static |
TCP data transfer interface operations.
| struct socket_opener tcp_socket_opener __socket_opener |
TCP socket opener.
| struct uri_opener tcp_uri_opener __uri_opener |
TCP URI opener.
1.8.15