Files | |
file | tcp.c |
TCP module implementation. | |
file | tcp.h |
TCP module. | |
file | tcp_header.h |
TCP header definition. | |
Data Structures | |
struct | tcp_globals |
TCP global data. More... | |
struct | tcp_header |
Transmission datagram header. More... | |
struct | tcp_max_segment_size_option |
Maximum segment size TCP option. More... | |
struct | tcp_operation |
TCP operation data. More... | |
struct | tcp_option |
Transmission datagram header option. More... | |
struct | tcp_socket_data |
TCP socket specific data. More... | |
struct | tcp_timeout |
TCP reply timeout data. More... | |
Defines | |
#define | IS_IN_INTERVAL_OVERFLOW(lower, value, higher_equal) |
Returns a value indicating whether the value is in the interval respecting the possible overflow. | |
#define | MAX_TCP_FRAGMENT_SIZE 65535 |
Maximum TCP fragment size. | |
#define | NAME "tcp" |
TCP module name. | |
#define | NET_DEFAULT_TCP_INITIAL_TIMEOUT 3000000L |
Initial timeout for new connections. | |
#define | NET_DEFAULT_TCP_TIME_WAIT_TIMEOUT 2000L |
Default timeout for closing. | |
#define | NET_DEFAULT_TCP_WINDOW 10240 |
The TCP window default value. | |
#define | TCP_COMPUTE_HEADER_LENGTH(length) ((uint8_t) ((length) / 4U)) |
Returns the TCP header length. | |
#define | TCP_FAST_RETRANSMIT_COUNT 3 |
The number of acknowledgements before retransmit. | |
#define | TCP_FREE_PORTS_END 65535 |
Free ports pool end. | |
#define | TCP_FREE_PORTS_START 1025 |
Free ports pool start. | |
#define | TCP_HEADER_LENGTH(header) (GET_TCP_HEADER_LENGTH(header) * 4U) |
Returns the actual TCP header length in bytes. | |
#define | TCP_HEADER_SIZE sizeof(tcp_header_t) |
TCP header size in bytes. | |
#define | TCP_INITIAL_SEQUENCE_NUMBER 2999 |
The initial outgoing sequence number. | |
#define | TCP_MAX_TIMEOUTS 8 |
The maximum number of timeouts in a row before singaling connection lost. | |
#define | TCP_SYN_SENT_TIMEOUT 1000000L |
Timeout for connection initialization, SYN sent. | |
Typedefs | |
typedef tcp_globals | tcp_globals_t |
Type definition of the TCP global data. | |
typedef tcp_header | tcp_header_t |
Type definition of the transmission datagram header. | |
typedef tcp_max_segment_size_option | tcp_max_segment_size_option_t |
Type definition of the Maximum segment size TCP option. | |
typedef tcp_operation | tcp_operation_t |
Type definition of the TCP operation data. | |
typedef tcp_option | tcp_option_t |
Type definition of the transmission datagram header option. | |
typedef tcp_socket_data | tcp_socket_data_t |
Type definition of the TCP socket specific data. | |
typedef enum tcp_socket_state | tcp_socket_state_t |
TCP socket state type definition. | |
typedef tcp_timeout | tcp_timeout_t |
Type definition of the TCP timeout. | |
Enumerations | |
enum | tcp_socket_state { TCP_SOCKET_INITIAL, TCP_SOCKET_LISTEN, TCP_SOCKET_SYN_SENT, TCP_SOCKET_SYN_RECEIVED, TCP_SOCKET_ESTABLISHED, TCP_SOCKET_FIN_WAIT_1, TCP_SOCKET_FIN_WAIT_2, TCP_SOCKET_CLOSING, TCP_SOCKET_CLOSE_WAIT, TCP_SOCKET_LAST_ACK, TCP_SOCKET_TIME_WAIT, TCP_SOCKET_CLOSED } |
TCP socket state. More... | |
Functions | |
int | main (int argc, char *argv[]) |
Main entry point. | |
static int | tcp_accept_message (socket_cores_t *, int, int, size_t *, size_t *) |
static int | tcp_close_message (socket_cores_t *, int) |
static int | tcp_connect_core (socket_core_t *, socket_cores_t *, struct sockaddr *, socklen_t) |
static int | tcp_connect_message (socket_cores_t *, int, struct sockaddr *, socklen_t) |
static int | tcp_create_notification_packet (packet_t **, socket_core_t *, tcp_socket_data_t *, int, int) |
static void | tcp_free_socket_data (socket_core_t *) |
static packet_t * | tcp_get_packets_to_send (socket_core_t *, tcp_socket_data_t *) |
static void | tcp_initialize_socket_data (tcp_socket_data_t *) |
static int | tcp_listen_message (socket_cores_t *, int, int) |
static packet_t * | tcp_prepare_copy (socket_core_t *, tcp_socket_data_t *, packet_t *, size_t, size_t) |
static void | tcp_prepare_operation_header (socket_core_t *, tcp_socket_data_t *, tcp_header_t *, int synchronize, int) |
int | tcp_prepare_timeout (int(*timeout_function)(void *tcp_timeout_t), socket_core_t *socket, tcp_socket_data_t *socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only) |
static void | tcp_process_acknowledgement (socket_core_t *, tcp_socket_data_t *, tcp_header_t *) |
static int | tcp_process_client_messages (ipc_callid_t, ipc_call_t) |
static int | tcp_process_established (socket_core_t *, tcp_socket_data_t *, tcp_header_t *, packet_t *, int, size_t) |
static int | tcp_process_listen (socket_core_t *, tcp_socket_data_t *, tcp_header_t *, packet_t *, struct sockaddr *, struct sockaddr *, size_t) |
static int | tcp_process_packet (device_id_t, packet_t *, services_t) |
static int | tcp_process_syn_received (socket_core_t *, tcp_socket_data_t *, tcp_header_t *, packet_t *) |
static int | tcp_process_syn_sent (socket_core_t *, tcp_socket_data_t *, tcp_header_t *, packet_t *) |
static int | tcp_queue_packet (socket_core_t *, tcp_socket_data_t *, packet_t *, size_t) |
static int | tcp_queue_prepare_packet (socket_core_t *, tcp_socket_data_t *, packet_t *, size_t) |
static void | tcp_queue_received_end_of_data (socket_core_t *socket) |
Queue end-of-data marker on the socket. | |
static int | tcp_queue_received_packet (socket_core_t *, tcp_socket_data_t *, packet_t *, int, size_t) |
static int | tcp_received_msg (device_id_t, packet_t *, services_t, services_t) |
static void | tcp_receiver (ipc_callid_t iid, ipc_call_t *icall) |
Process IPC messages from the IP module. | |
static int | tcp_recvfrom_message (socket_cores_t *, int, int, size_t *) |
static void | tcp_refresh_socket_data (tcp_socket_data_t *) |
static int | tcp_release_after_timeout (void *) |
static int | tcp_release_and_return (packet_t *packet, int result) |
Releases the packet and returns the result. | |
void | tcp_retransmit_packet (socket_core_t *, tcp_socket_data_t *, size_t) |
static int | tcp_send_message (socket_cores_t *, int, int, size_t *, int) |
static void | tcp_send_packets (device_id_t, packet_t *) |
static packet_t * | tcp_send_prepare_packet (socket_core_t *, tcp_socket_data_t *, packet_t *, size_t, size_t) |
static int | tcp_timeout (void *) |
void | tl_connection (void) |
Per-connection module initialization. | |
int | tl_initialize (int net_phone) |
Module initialization. | |
int | tl_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count) |
Process the transport layer module message. | |
Variables | |
tcp_globals_t | tcp_globals |
TCP global data. |
#define IS_IN_INTERVAL_OVERFLOW | ( | lower, | |||
value, | |||||
higher_equal | ) |
Value:
((((lower) < (value)) && (((value) <= (higher_equal)) || \ ((higher_equal) < (lower)))) || (((value) <= (higher_equal)) && \ ((higher_equal) < (lower))))
The high end and/or the value may overflow, be lower than the low value.
[in] | lower | The last value before the interval. |
[in] | value | The value to be checked. |
[in] | higher_equal | The last value in the interval. |
#define TCP_COMPUTE_HEADER_LENGTH | ( | length | ) | ((uint8_t) ((length) / 4U)) |
Returns the TCP header length.
[in] | length | The TCP header length in bytes. |
Definition at line 54 of file tcp_header.h.
#define TCP_HEADER_LENGTH | ( | header | ) | (GET_TCP_HEADER_LENGTH(header) * 4U) |
Returns the actual TCP header length in bytes.
[in] | header | The TCP packet header. |
Definition at line 49 of file tcp_header.h.
typedef struct tcp_globals tcp_globals_t |
typedef struct tcp_header tcp_header_t |
Type definition of the transmission datagram header.
Definition at line 59 of file tcp_header.h.
typedef struct tcp_operation tcp_operation_t |
typedef struct tcp_option tcp_option_t |
Type definition of the transmission datagram header option.
Definition at line 64 of file tcp_header.h.
typedef struct tcp_socket_data tcp_socket_data_t |
typedef enum tcp_socket_state tcp_socket_state_t |
typedef struct tcp_timeout tcp_timeout_t |
enum tcp_socket_state |
TCP socket state.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
static void tcp_queue_received_end_of_data | ( | socket_core_t * | socket | ) | [static] |
static void tcp_receiver | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
int tcp_release_and_return | ( | packet_t * | packet, | |
int | result | |||
) | [static] |
void tl_connection | ( | void | ) |
int tl_initialize | ( | int | net_phone | ) |
int tl_message | ( | ipc_callid_t | callid, | |
ipc_call_t * | call, | |||
ipc_call_t * | answer, | |||
size_t * | answer_count | |||
) |
Process the transport layer module message.
[in] | callid | The message identifier. |
[in] | call | The message parameters. |
[out] | answer | The message answer parameters. |
[out] | answer_count | The last parameter for the actual answer in the answer parameter. |
ENOTSUP if the message is not known.