Transmission Control Protocol (TCP) Service
[Transport layer]


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_ttcp_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_ttcp_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_ttcp_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 Documentation

#define IS_IN_INTERVAL_OVERFLOW ( lower,
value,
higher_equal   ) 

Value:

((((lower) < (value)) && (((value) <= (higher_equal)) || \
        ((higher_equal) < (lower)))) || (((value) <= (higher_equal)) && \
        ((higher_equal) < (lower))))
Returns a value indicating whether the value is in the interval respecting the possible overflow.

The high end and/or the value may overflow, be lower than the low value.

Parameters:
[in] lower The last value before the interval.
[in] value The value to be checked.
[in] higher_equal The last value in the interval.

Definition at line 117 of file tcp.c.

#define TCP_COMPUTE_HEADER_LENGTH ( length   )     ((uint8_t) ((length) / 4U))

Returns the TCP header length.

Parameters:
[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.

Parameters:
[in] header The TCP packet header.

Definition at line 49 of file tcp_header.h.


Typedef Documentation

typedef struct tcp_globals tcp_globals_t

Type definition of the TCP global data.

See also:
tcp_globals

Definition at line 50 of file tcp.h.

typedef struct tcp_header tcp_header_t

Type definition of the transmission datagram header.

See also:
tcp_header

Definition at line 59 of file tcp_header.h.

typedef struct tcp_operation tcp_operation_t

Type definition of the TCP operation data.

See also:
tcp_operation

Definition at line 60 of file tcp.h.

typedef struct tcp_option tcp_option_t

Type definition of the transmission datagram header option.

See also:
tcp_option

Definition at line 64 of file tcp_header.h.

typedef struct tcp_socket_data tcp_socket_data_t

Type definition of the TCP socket specific data.

See also:
tcp_socket_data

Definition at line 55 of file tcp.h.

typedef enum tcp_socket_state tcp_socket_state_t

TCP socket state type definition.

See also:
tcp_socket_state

Definition at line 65 of file tcp.h.

typedef struct tcp_timeout tcp_timeout_t

Type definition of the TCP timeout.

See also:
tcp_timeout

Definition at line 125 of file tcp.c.


Enumeration Type Documentation

enum tcp_socket_state

TCP socket state.

Enumerator:
TCP_SOCKET_INITIAL  Initial.

Not connected or bound.

TCP_SOCKET_LISTEN  Listening.

Awaiting a connection request from another TCP layer. When SYN is received a new bound socket in the TCP_SOCKET_SYN_RECEIVED state should be created.

TCP_SOCKET_SYN_SENT  Connecting issued.

A SYN has been sent, and TCP is awaiting the response SYN. Should continue to the TCP_SOCKET_ESTABLISHED state.

TCP_SOCKET_SYN_RECEIVED  Connecting received.

A SYN has been received, a SYN has been sent, and TCP is awaiting an ACK. Should continue to the TCP_SOCKET_ESTABLISHED state.

TCP_SOCKET_ESTABLISHED  Connected.

The three-way handshake has been completed.

TCP_SOCKET_FIN_WAIT_1  Closing started.

The local application has issued a CLOSE. TCP has sent a FIN, and is awaiting an ACK or a FIN. Should continue to the TCP_SOCKET_FIN_WAIT_2 state when an ACK is received. Should continue to the TCP_SOCKET_CLOSING state when a FIN is received.

TCP_SOCKET_FIN_WAIT_2  Closing confirmed.

A FIN has been sent, and an ACK received. TCP is awaiting a~FIN from the remote TCP layer. Should continue to the TCP_SOCKET_CLOSING state.

TCP_SOCKET_CLOSING  Closing.

A FIN has been sent, a FIN has been received, and an ACK has been sent. TCP is awaiting an ACK for the FIN that was sent. Should continue to the TCP_SOCKET_TIME_WAIT state.

TCP_SOCKET_CLOSE_WAIT  Closing received.

TCP has received a FIN, and has sent an ACK. It is awaiting a close request from the local application before sending a FIN. Should continue to the TCP_SOCKET_SOCKET_LAST_ACK state.

TCP_SOCKET_LAST_ACK  A FIN has been received, and an ACK and a FIN have been sent.

TCP is awaiting an ACK. Should continue to the TCP_SOCKET_TIME_WAIT state.

TCP_SOCKET_TIME_WAIT  Closing finished.

FINs have been received and ACK’d, and TCP is waiting two MSLs to remove the connection from the table.

TCP_SOCKET_CLOSED  Closed.

Imaginary, this indicates that a connection has been removed from the connection table.

Definition at line 68 of file tcp.h.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 2507 of file tcp.c.

static void tcp_queue_received_end_of_data ( socket_core_t socket  )  [static]

Queue end-of-data marker on the socket.

Next element in the sequence space is FIN. Queue end-of-data marker on the socket.

Parameters:
socket Socket

Definition at line 817 of file tcp.c.

static void tcp_receiver ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Process IPC messages from the IP module.

Parameters:
[in] iid Message identifier.
[in,out] icall Message parameters.

Definition at line 2443 of file tcp.c.

int tcp_release_and_return ( packet_t packet,
int  result 
) [static]

Releases the packet and returns the result.

Parameters:
[in] packet The packet queue to be released.
[in] result The result to be returned.
Returns:
The result parameter.

Definition at line 2431 of file tcp.c.

void tl_connection ( void   ) 

Per-connection module initialization.

Initialize client-specific global variables.

Definition at line 1209 of file tcp.c.

int tl_initialize ( int  net_phone  ) 

Module initialization.

Parameters:
[in] net_phone Network module phone.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Definition at line 2475 of file tcp.c.

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.

Parameters:
[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.
Returns:
EOK on success.

ENOTSUP if the message is not known.

See also:
tcp_interface.h

IS_NET_TCP_MESSAGE()

Definition at line 1226 of file tcp.c.


Generated on Thu Jun 2 07:45:55 2011 for HelenOS/USB by  doxygen 1.4.7