Webserver+3d print
tcp_misc.c File Reference
Helper functions for TCP. More...
Go to the source code of this file.
Functions | |
error_t | tcpSendSegment (Socket *socket, uint8_t flags, uint32_t seqNum, uint32_t ackNum, size_t length, bool_t addToQueue) |
Send a TCP segment. | |
error_t | tcpSendResetSegment (NetInterface *interface, IpPseudoHeader *pseudoHeader, TcpHeader *segment, size_t length) |
Send a TCP reset in response to an invalid segment. | |
error_t | tcpAddOption (TcpHeader *segment, uint8_t kind, const void *value, uint8_t length) |
Append an option to a TCP segment. | |
TcpOption * | tcpGetOption (TcpHeader *segment, uint8_t kind) |
Find a specified option in a TCP segment. | |
error_t | tcpCheckSequenceNumber (Socket *socket, TcpHeader *segment, size_t length) |
Test the sequence number of an incoming segment. | |
error_t | tcpCheckSyn (Socket *socket, TcpHeader *segment, size_t length) |
Check the SYN bit of an incoming segment. | |
error_t | tcpCheckAck (Socket *socket, TcpHeader *segment, size_t length) |
Test the ACK field of an incoming segment. | |
bool_t | tcpIsDuplicateAck (Socket *socket, TcpHeader *segment, size_t length) |
Test whether the incoming acknowledgment is a duplicate. | |
void | tcpFastRetransmit (Socket *socket) |
Fast retransmit procedure. | |
void | tcpFastRecovery (Socket *socket, TcpHeader *segment, uint_t n) |
Fast recovery procedure. | |
void | tcpFastLossRecovery (Socket *socket, TcpHeader *segment) |
Fast loss recovery procedure. | |
void | tcpProcessSegmentData (Socket *socket, TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length) |
Process the segment text. | |
void | tcpDeleteControlBlock (Socket *socket) |
Delete TCB structure. | |
void | tcpUpdateRetransmitQueue (Socket *socket) |
Remove acknowledged segments from retransmission queue. | |
void | tcpFlushRetransmitQueue (Socket *socket) |
Flush retransmission queue. | |
void | tcpFlushSynQueue (Socket *socket) |
Flush SYN queue. | |
void | tcpUpdateSackBlocks (Socket *socket, uint32_t *leftEdge, uint32_t *rightEdge) |
Update the list of non-contiguous blocks that have been received. | |
void | tcpUpdateSendWindow (Socket *socket, TcpHeader *segment) |
Update send window. | |
void | tcpUpdateReceiveWindow (Socket *socket) |
Update receive window so as to avoid Silly Window Syndrome. | |
bool_t | tcpComputeRto (Socket *socket) |
Compute retransmission timeout. | |
error_t | tcpRetransmitSegment (Socket *socket) |
TCP segment retransmission. | |
error_t | tcpNagleAlgo (Socket *socket, uint_t flags) |
Nagle algorithm implementation. | |
void | tcpChangeState (Socket *socket, TcpState newState) |
Update TCP FSM current state. | |
void | tcpUpdateEvents (Socket *socket) |
Update TCP related events. | |
uint_t | tcpWaitForEvents (Socket *socket, uint_t eventMask, systime_t timeout) |
Wait for a particular TCP event. | |
void | tcpWriteTxBuffer (Socket *socket, uint32_t seqNum, const uint8_t *data, size_t length) |
Copy incoming data to the send buffer. | |
error_t | tcpReadTxBuffer (Socket *socket, uint32_t seqNum, NetBuffer *buffer, size_t length) |
Copy data from the send buffer. | |
void | tcpWriteRxBuffer (Socket *socket, uint32_t seqNum, const NetBuffer *data, size_t dataOffset, size_t length) |
Copy incoming data to the receive buffer. | |
void | tcpReadRxBuffer (Socket *socket, uint32_t seqNum, uint8_t *data, size_t length) |
Copy data from the receive buffer. | |
void | tcpDumpHeader (const TcpHeader *segment, size_t length, uint32_t iss, uint32_t irs) |
Dump TCP header for debugging purpose. |
Detailed Description
Helper functions for TCP.
License
Copyright (C) 2010-2017 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:
- 1.7.6
Definition in file tcp_misc.c.
Function Documentation
error_t tcpAddOption | ( | TcpHeader * | segment, |
uint8_t | kind, | ||
const void * | value, | ||
uint8_t | length | ||
) |
Append an option to a TCP segment.
- Parameters:
-
[in] segment Pointer to the TCP header [in] kind Option code [in] value Option value [in] length Length of the option value
- Returns:
- Error code
Definition at line 414 of file tcp_misc.c.
void tcpChangeState | ( | Socket * | socket, |
TcpState | newState | ||
) |
Update TCP FSM current state.
- Parameters:
-
[in] socket Handle referencing the socket [in] newState New TCP state to switch to
Definition at line 1630 of file tcp_misc.c.
error_t tcpCheckAck | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
Test the ACK field of an incoming segment.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the TCP segment to check [in] length Length of the segment data
- Returns:
- NO_ERROR if the acknowledgment is acceptable, ERROR_FAILURE otherwise
Definition at line 615 of file tcp_misc.c.
error_t tcpCheckSequenceNumber | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
Test the sequence number of an incoming segment.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the TCP segment to check [in] length Length of the segment data
- Returns:
- NO_ERROR if the incoming segment is acceptable, ERROR_FAILURE otherwise
Definition at line 517 of file tcp_misc.c.
error_t tcpCheckSyn | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
Check the SYN bit of an incoming segment.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the TCP segment to check [in] length Length of the segment data
- Returns:
- ERROR_FAILURE if the SYN is in the window, NO_ERROR otherwise
Definition at line 586 of file tcp_misc.c.
bool_t tcpComputeRto | ( | Socket * | socket ) |
Compute retransmission timeout.
- Parameters:
-
[in] socket Handle referencing the socket
- Returns:
- TRUE if the RTT measurement is complete, else FALSE
Definition at line 1332 of file tcp_misc.c.
void tcpDeleteControlBlock | ( | Socket * | socket ) |
Delete TCB structure.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1036 of file tcp_misc.c.
void tcpDumpHeader | ( | const TcpHeader * | segment, |
size_t | length, | ||
uint32_t | iss, | ||
uint32_t | irs | ||
) |
Dump TCP header for debugging purpose.
- Parameters:
-
[in] segment Pointer to the TCP header [in] length Length of the segment data [in] iss Initial send sequence number (needed to compute relative SEQ number) [in] irs Initial receive sequence number (needed to compute relative ACK number)
Definition at line 1971 of file tcp_misc.c.
void tcpFastLossRecovery | ( | Socket * | socket, |
TcpHeader * | segment | ||
) |
Fast loss recovery procedure.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the incoming TCP segment
Definition at line 934 of file tcp_misc.c.
void tcpFastRecovery | ( | Socket * | socket, |
TcpHeader * | segment, | ||
uint_t | n | ||
) |
Fast recovery procedure.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the incoming TCP segment [in] n Number of bytes acknowledged by the incoming ACK
Definition at line 885 of file tcp_misc.c.
void tcpFastRetransmit | ( | Socket * | socket ) |
Fast retransmit procedure.
- Parameters:
-
[in] socket Handle referencing the current socket
Definition at line 846 of file tcp_misc.c.
void tcpFlushRetransmitQueue | ( | Socket * | socket ) |
Flush retransmission queue.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1135 of file tcp_misc.c.
void tcpFlushSynQueue | ( | Socket * | socket ) |
Flush SYN queue.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1164 of file tcp_misc.c.
TcpOption* tcpGetOption | ( | TcpHeader * | segment, |
uint8_t | kind | ||
) |
Find a specified option in a TCP segment.
- Parameters:
-
[in] segment Pointer to the TCP header [in] kind Code of the option to find
- Returns:
- If the specified option is found, a pointer to the corresponding option is returned. Otherwise NULL pointer is returned
Definition at line 461 of file tcp_misc.c.
bool_t tcpIsDuplicateAck | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
Test whether the incoming acknowledgment is a duplicate.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the TCP segment to check [in] length Length of the segment data
- Returns:
- TRUE if the ACK is duplicate, else FALSE
Definition at line 806 of file tcp_misc.c.
error_t tcpNagleAlgo | ( | Socket * | socket, |
uint_t | flags | ||
) |
Nagle algorithm implementation.
- Parameters:
-
[in] socket Handle referencing the socket [in] flags Set of flags that influences the behavior of this function
- Returns:
- Error code
Definition at line 1500 of file tcp_misc.c.
void tcpProcessSegmentData | ( | Socket * | socket, |
TcpHeader * | segment, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
size_t | length | ||
) |
Process the segment text.
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Pointer to the TCP header [in] buffer Multi-part buffer containing the incoming TCP segment [in] offset Offset to the first data byte [in] length Length of the segment data
Definition at line 972 of file tcp_misc.c.
void tcpReadRxBuffer | ( | Socket * | socket, |
uint32_t | seqNum, | ||
uint8_t * | data, | ||
size_t | length | ||
) |
Copy data from the receive buffer.
- Parameters:
-
[in] socket Handle referencing the socket [in] seqNum Sequence number of the first data to read [out] data Pointer to the output buffer [in] length Number of data to read
Definition at line 1939 of file tcp_misc.c.
Copy data from the send buffer.
- Parameters:
-
[in] socket Handle referencing the socket [in] seqNum Sequence number of the first data to read [out] buffer Pointer to the output buffer [in] length Number of data to read
- Returns:
- Error code
Definition at line 1862 of file tcp_misc.c.
error_t tcpRetransmitSegment | ( | Socket * | socket ) |
TCP segment retransmission.
- Parameters:
-
[in] socket Handle referencing the socket
- Returns:
- Error code
Definition at line 1399 of file tcp_misc.c.
error_t tcpSendResetSegment | ( | NetInterface * | interface, |
IpPseudoHeader * | pseudoHeader, | ||
TcpHeader * | segment, | ||
size_t | length | ||
) |
Send a TCP reset in response to an invalid segment.
- Parameters:
-
[in] interface Underlying network interface [in] pseudoHeader TCP pseudo header describing the incoming segment [in] segment Incoming TCP segment [in] length Length of the incoming segment data
- Returns:
- Error code
Definition at line 280 of file tcp_misc.c.
error_t tcpSendSegment | ( | Socket * | socket, |
uint8_t | flags, | ||
uint32_t | seqNum, | ||
uint32_t | ackNum, | ||
size_t | length, | ||
bool_t | addToQueue | ||
) |
Send a TCP segment.
- Parameters:
-
[in] socket Handle referencing a socket [in] flags Value that contains bitwise OR of flags (see TcpFlags enumeration) [in] seqNum Sequence number [in] ackNum Acknowledgment number [in] length Length of the segment data [in] addToQueue Add the segment to retransmission queue
- Returns:
- Error code
Definition at line 62 of file tcp_misc.c.
void tcpUpdateEvents | ( | Socket * | socket ) |
Update TCP related events.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1661 of file tcp_misc.c.
void tcpUpdateReceiveWindow | ( | Socket * | socket ) |
Update receive window so as to avoid Silly Window Syndrome.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1295 of file tcp_misc.c.
void tcpUpdateRetransmitQueue | ( | Socket * | socket ) |
Remove acknowledged segments from retransmission queue.
- Parameters:
-
[in] socket Handle referencing the socket
Definition at line 1057 of file tcp_misc.c.
void tcpUpdateSackBlocks | ( | Socket * | socket, |
uint32_t * | leftEdge, | ||
uint32_t * | rightEdge | ||
) |
Update the list of non-contiguous blocks that have been received.
- Parameters:
-
[in] socket Handle referencing the socket [in,out] leftEdge First sequence number occupied by the incoming data [in,out] rightEdge Sequence number immediately following the incoming data
Definition at line 1192 of file tcp_misc.c.
void tcpUpdateSendWindow | ( | Socket * | socket, |
TcpHeader * | segment | ||
) |
Update send window.
- Parameters:
-
[in] socket Handle referencing the socket [in] segment Pointer to the incoming TCP segment
Definition at line 1245 of file tcp_misc.c.
uint_t tcpWaitForEvents | ( | Socket * | socket, |
uint_t | eventMask, | ||
systime_t | timeout | ||
) |
Wait for a particular TCP event.
- Parameters:
-
[in] socket Handle referencing the socket [in] eventMask Logic OR of all the TCP events that will complete the wait [in] timeout Maximum time to wait
- Returns:
- Logic OR of all the TCP events that satisfied the wait
Definition at line 1790 of file tcp_misc.c.
void tcpWriteRxBuffer | ( | Socket * | socket, |
uint32_t | seqNum, | ||
const NetBuffer * | data, | ||
size_t | dataOffset, | ||
size_t | length | ||
) |
Copy incoming data to the receive buffer.
- Parameters:
-
[in] socket Handle referencing the socket [in] seqNum First sequence number occupied by the incoming data [in] data Multi-part buffer containing the incoming data [in] dataOffset Offset to the first data byte [in] length Number of data to write
Definition at line 1906 of file tcp_misc.c.
void tcpWriteTxBuffer | ( | Socket * | socket, |
uint32_t | seqNum, | ||
const uint8_t * | data, | ||
size_t | length | ||
) |
Copy incoming data to the send buffer.
- Parameters:
-
[in] socket Handle referencing the socket [in] seqNum First sequence number occupied by the incoming data [in] data Data to write [in] length Number of data to write
Definition at line 1828 of file tcp_misc.c.
Generated on Tue Jul 12 2022 17:10:22 by
