TCP (Transmission Control Protocol) More...
Go to the source code of this file.
Data Structures | |
struct _TcpQueueItem | |
Retransmission queue item. More... | |
struct _TcpSynQueueItem | |
SYN queue item. More... | |
struct TcpSackBlock | |
SACK block. More... | |
struct TcpTxBuffer | |
Transmit buffer. More... | |
struct TcpRxBuffer | |
Receive buffer. More... | |
Typedefs | |
typedef struct _TcpQueueItem TcpQueueItem | |
Retransmission queue item. More... | |
typedef struct _TcpSynQueueItem TcpSynQueueItem | |
SYN queue item. More... | |
Enumerations | |
enum TcpState { TCP_STATE_CLOSED = 0, TCP_STATE_LISTEN = 1, TCP_STATE_SYN_SENT = 2, TCP_STATE_SYN_RECEIVED = 3, TCP_STATE_ESTABLISHED = 4, TCP_STATE_CLOSE_WAIT = 5, TCP_STATE_LAST_ACK = 6, TCP_STATE_FIN_WAIT_1 = 7, TCP_STATE_FIN_WAIT_2 = 8, TCP_STATE_CLOSING = 9, TCP_STATE_TIME_WAIT = 10 } | |
TCP FSM states. More... | |
enum TcpCongestState { TCP_CONGEST_STATE_IDLE = 0, TCP_CONGEST_STATE_RECOVERY = 1, TCP_CONGEST_STATE_LOSS_RECOVERY = 2 } | |
TCP congestion states. More... | |
enum TcpFlags { TCP_FLAG_FIN = 0x01, TCP_FLAG_SYN = 0x02, TCP_FLAG_RST = 0x04, TCP_FLAG_PSH = 0x08, TCP_FLAG_ACK = 0x10, TCP_FLAG_URG = 0x20 } | |
TCP control flags. More... | |
enum TcpOptionKind { TCP_OPTION_END = 0, TCP_OPTION_NOP = 1, TCP_OPTION_MAX_SEGMENT_SIZE = 2, TCP_OPTION_WINDOW_SCALE_FACTOR = 3, TCP_OPTION_SACK_PERMITTED = 4, TCP_OPTION_SACK = 5, TCP_OPTION_TIMESTAMP = 8 } | |
TCP option types. More... | |
Functions | |
error_t tcpInit (void) | |
TCP related initialization. More... | |
error_t tcpSetInitialRto (NetInterface *interface, systime_t initialRto) | |
Set TCP initial retransmission timeout. More... | |
uint16_t tcpGetDynamicPort (void) | |
Get an ephemeral port number. More... | |
error_t tcpConnect (Socket *socket, const IpAddr *remoteIpAddr, uint16_t remotePort) | |
Establish a TCP connection. More... | |
error_t tcpListen (Socket *socket, uint_t backlog) | |
Place a socket in the listening state. More... | |
Socket * tcpAccept (Socket *socket, IpAddr *clientIpAddr, uint16_t *clientPort) | |
Permit an incoming connection attempt on a TCP socket. More... | |
error_t tcpSend (Socket *socket, const uint8_t *data, size_t length, size_t *written, uint_t flags) | |
Send data to a connected socket. More... | |
error_t tcpReceive (Socket *socket, uint8_t *data, size_t size, size_t *received, uint_t flags) | |
Receive data from a connected socket. More... | |
error_t tcpShutdown (Socket *socket, uint_t how) | |
Shutdown gracefully reception, transmission, or both. More... | |
error_t tcpAbort (Socket *socket) | |
Abort an existing TCP connection. More... | |
TcpState tcpGetState (Socket *socket) | |
Get the current state of the TCP FSM. More... | |
Socket * tcpKillOldestConnection (void) | |
Kill the oldest socket in the TIME-WAIT state. More... | |
Variables | |
typedef __packed_struct | |
TCP header. More... | |
uint16_t destPort | |
uint32_t seqNum | |
uint32_t ackNum | |
uint8_t reserved1 | |
uint8_t dataOffset | |
uint8_t flags | |
uint8_t reserved2 | |
uint16_t window | |
uint16_t checksum | |
uint16_t urgentPointer | |
uint8_t options [] | |
TcpHeader | |
uint8_t length | |
uint8_t value [] | |
TcpOption | |
systime_t tcpTickCounter | |
Detailed Description
TCP (Transmission Control Protocol)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.0
Definition in file tcp.h.
Macro Definition Documentation
◆ TCP_2MSL_TIMER
◆ TCP_CMP_SEQ
◆ TCP_CONGEST_CONTROL_SUPPORT
◆ TCP_DEFAULT_KEEP_ALIVE_IDLE
◆ TCP_DEFAULT_KEEP_ALIVE_INTERVAL
◆ TCP_DEFAULT_KEEP_ALIVE_PROBES
◆ TCP_DEFAULT_MSS
◆ TCP_DEFAULT_PROBE_INTERVAL
◆ TCP_DEFAULT_RX_BUFFER_SIZE
◆ TCP_DEFAULT_SYN_QUEUE_SIZE
◆ TCP_DEFAULT_TX_BUFFER_SIZE
◆ TCP_FAST_RETRANSMIT_THRES
◆ TCP_FIN_WAIT_2_TIMER
◆ TCP_INITIAL_RTO
◆ TCP_INITIAL_WINDOW
◆ TCP_KEEP_ALIVE_SUPPORT
◆ TCP_LOSS_WINDOW
◆ TCP_MAX_HEADER_LENGTH
◆ TCP_MAX_MSS
◆ TCP_MAX_PROBE_INTERVAL
◆ TCP_MAX_RETRIES
◆ TCP_MAX_RTO
◆ TCP_MAX_RX_BUFFER_SIZE
◆ TCP_MAX_SACK_BLOCKS
◆ TCP_MAX_SYN_QUEUE_SIZE
◆ TCP_MAX_TX_BUFFER_SIZE
◆ TCP_MIN_MSS
◆ TCP_MIN_RTO
◆ TCP_OVERRIDE_TIMEOUT
◆ TCP_SACK_SUPPORT
◆ TCP_SECURE_ISN_SUPPORT
◆ TCP_SUPPORT
◆ TCP_TICK_INTERVAL
◆ TCP_WINDOW_SCALE_SUPPORT
Typedef Documentation
◆ TcpQueueItem
typedef struct _TcpQueueItem TcpQueueItem |
Retransmission queue item.
◆ TcpSynQueueItem
typedef struct _TcpSynQueueItem TcpSynQueueItem |
SYN queue item.
Enumeration Type Documentation
◆ TcpCongestState
enum TcpCongestState |
◆ TcpFlags
enum TcpFlags |
◆ TcpOptionKind
enum TcpOptionKind |
◆ TcpState
enum TcpState |
Function Documentation
◆ tcpAbort()
◆ tcpAccept()
Permit an incoming connection attempt on a TCP socket.
- Parameters
-
[in] socket Handle to a socket previously placed in a listening state [out] clientIpAddr IP address of the client [out] clientPort Port number used by the client
- Returns
- Handle to the socket in which the actual connection is made
◆ tcpConnect()
◆ tcpGetDynamicPort()
uint16_t tcpGetDynamicPort | ( | void | ) |
◆ tcpGetState()
◆ tcpInit()
error_t tcpInit | ( | void | ) |
◆ tcpKillOldestConnection()
Socket* tcpKillOldestConnection | ( | void | ) |
◆ tcpListen()
Place a socket in the listening state.
Place a socket in a state in which it is listening for an incoming connection
- Parameters
-
[in] socket Socket to place in the listening state [in] backlog backlog The maximum length of the pending connection queue. If this parameter is zero, then the default backlog value is used instead
- Returns
- Error code
◆ tcpReceive()
error_t tcpReceive | ( | Socket * | socket, |
uint8_t * | data, | ||
size_t | size, | ||
size_t * | received, | ||
uint_t | flags | ||
) |
Receive data from a connected socket.
- Parameters
-
[in] socket Handle that identifies a connected socket [out] data Buffer where to store the incoming data [in] size Maximum number of bytes that can be received [out] received Number of bytes that have been received [in] flags Set of flags that influences the behavior of this function
- Returns
- Error code
◆ tcpSend()
error_t tcpSend | ( | Socket * | socket, |
const uint8_t * | data, | ||
size_t | length, | ||
size_t * | written, | ||
uint_t | flags | ||
) |
Send data to a connected socket.
- Parameters
-
[in] socket Handle that identifies a connected socket [in] data Pointer to a buffer containing the data to be transmitted [in] length Number of bytes to be transmitted [out] written Actual number of bytes written (optional parameter) [in] flags Set of flags that influences the behavior of this function
- Returns
- Error code
◆ tcpSetInitialRto()
error_t tcpSetInitialRto | ( | NetInterface * | interface, |
systime_t | initialRto | ||
) |
◆ tcpShutdown()
Shutdown gracefully reception, transmission, or both.
Note that socketShutdown() does not close the socket, and resources attached to the socket will not be freed until socketClose() is invoked
- Parameters
-
[in] socket Handle to a socket [in] how Flag that describes what types of operation will no longer be allowed
- Returns
- Error code
Variable Documentation
◆ __packed_struct
typedef __packed_struct |