RFC 793 Transmission Control Protocol. More...
![]() |
Defines | |
#define | TCP_RTTO_MAX 20000 |
#define | min(a, b) ((a>b)?b:a) |
#define | max(a, b) ((a>b)?a:b) |
Functions | |
int | NutTcpInput (NUTDEVICE *dev, NETBUF *nb) |
Process incoming TCP segments from IP layer. | |
int | NutTcpStatePassiveOpenEvent (TCPSOCKET *sock) |
Initiated by the application. | |
int | NutTcpStateActiveOpenEvent (TCPSOCKET *sock) |
Initiated by the application. | |
int | NutTcpStateCloseEvent (TCPSOCKET *sock) |
Socket close by application. | |
int | NutTcpStateWindowEvent (TCPSOCKET *sock) |
Initiated by the application. | |
int | NutTcpStateRetranTimeout (TCPSOCKET *sock) |
Retransmit a segment after ACK timeout. | |
void | NutTcpSm (void *arg) |
TCP state machine thread. | |
void | NutTcpStateMachine (NETBUF *nb) |
Process incoming TCP segments. | |
int | NutTcpInitStateMachine (void) |
Start TCP state machine. | |
int | NutTcpAbortSocket (TCPSOCKET *sock, uint16_t last_error) |
Closes socket with error. | |
void | NutTcpCalcRtt (TCPSOCKET *sock) |
Variables | |
HANDLE | tcp_in_rdy |
NETBUF *volatile | tcp_in_nbq |
RFC 793 Transmission Control Protocol.
TCP provides reliable, in-sequence delivery of a full-duplex stream of octets. It is used by applications which need a reliable, connection-oriented data transport.
Applications should call the TCP Socket API when using this protocol.
#define TCP_RTTO_MAX 20000 |
Definition at line 77 of file tcputil.c.
Referenced by NutTcpCalcRtt().
#define min | ( | a, | |||
b | ) | ((a>b)?b:a) |
Definition at line 80 of file tcputil.c.
Referenced by NutTcpCalcRtt().
#define max | ( | a, | |||
b | ) | ((a>b)?a:b) |
Definition at line 81 of file tcputil.c.
Referenced by NutTcpCalcRtt().
int NutTcpInput | ( | NUTDEVICE * | dev, | |
NETBUF * | nb | |||
) |
Process incoming TCP segments from IP layer.
Definition at line 148 of file tcpin.c.
References NBAF_UNICAST, NutNetBufFree(), NutTcpStateMachine(), and TCPHDR::th_off.
Referenced by NutTcpCreateSocket().
int NutTcpStatePassiveOpenEvent | ( | TCPSOCKET * | sock | ) |
Initiated by the application.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). |
Definition at line 826 of file tcpsm.c.
References EISCONN, NutEventWait(), TCPS_CLOSED, and TCPS_LISTEN.
Referenced by NutTcpAccept().
int NutTcpStateActiveOpenEvent | ( | TCPSOCKET * | sock | ) |
Initiated by the application.
The caller must make sure, that the socket is in closed state.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). |
Definition at line 851 of file tcpsm.c.
References NutEventWait(), TCPS_CLOSE_WAIT, TCPS_ESTABLISHED, and TCPS_SYN_SENT.
Referenced by NutTcpConnect().
int NutTcpStateCloseEvent | ( | TCPSOCKET * | sock | ) |
Socket close by application.
If socket is in state SYN_RECEIVED or ESTABLISHED, it is changed to FINWAIT1.
No further data sending is accepted. Receiving is still allowed.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). |
Definition at line 883 of file tcpsm.c.
References EALREADY, ENOTCONN, NutTcpDestroySocket(), NutThreadYield(), TCPS_CLOSE_WAIT, TCPS_CLOSED, TCPS_CLOSING, TCPS_ESTABLISHED, TCPS_FIN_WAIT_1, TCPS_FIN_WAIT_2, TCPS_LAST_ACK, TCPS_LISTEN, TCPS_SYN_RECEIVED, TCPS_SYN_SENT, and TCPS_TIME_WAIT.
Referenced by NutTcpCloseSocket().
int NutTcpStateWindowEvent | ( | TCPSOCKET * | sock | ) |
Initiated by the application.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). |
Definition at line 938 of file tcpsm.c.
References NutTcpOutput(), SO_ACK, and SO_FORCE.
Referenced by NutTcpReceive().
int NutTcpStateRetranTimeout | ( | TCPSOCKET * | sock | ) |
Retransmit a segment after ACK timeout.
This function is called by the TCP timer.
sock | Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket(). |
Definition at line 963 of file tcpsm.c.
References __tcp_trf, __tcp_trs, ENETDOWN, ETIMEDOUT, IPPROTO_TCP, NutDumpTcpHeader(), NutGetMillis(), NutIpOutput(), and NutTcpAbortSocket().
Referenced by NutTcpSm().
NutTcpSm | ( | void * | arg | ) |
TCP state machine thread.
The TCP state machine serves two purposes: It processes incoming TCP segments and handles TCP timers.
Definition at line 1675 of file tcpsm.c.
References __tcp_trf, __tcp_trs, NutDumpTcpHeader(), NutEventWait(), NutGetMillis(), NutTcpDestroySocket(), NutTcpFindSocket(), NutTcpOutput(), NutTcpReject(), NutTcpStateRetranTimeout(), NutThreadSetPriority(), SO_ACK, SO_FORCE, tcp_in_nbq, tcp_in_rdy, TCPS_FIN_WAIT_2, TCPS_LISTEN, TCPS_SYN_RECEIVED, TCPS_TIME_WAIT, tcpSocketList, TCPHDR::th_dport, and TCPHDR::th_sport.
Referenced by NutTcpInitStateMachine().
void NutTcpStateMachine | ( | NETBUF * | nb | ) |
Process incoming TCP segments.
All incoming TCP packets are passed to this routine. They will be added to a global queue and processed by the TCP state machine, which is running on a separate thread.
Definition at line 1772 of file tcpsm.c.
References NutEventPost(), NutHeapAvailable, NutNetBufFree(), NutTcpReject(), tcp_in_nbq, and tcp_in_rdy.
Referenced by NutTcpInput().
int NutTcpInitStateMachine | ( | void | ) |
Start TCP state machine.
The socket interface will automatically call this routine as soon as the first socket is created.
Definition at line 1814 of file tcpsm.c.
References NUT_THREAD_STACK_ADD, NUT_THREAD_TCPSMSTACK, NutTcpSm(), and NutThreadCreate().
Referenced by NutTcpCreateSocket().
int NutTcpAbortSocket | ( | TCPSOCKET * | sock, | |
uint16_t | last_error | |||
) |
Closes socket with error.
Aborts any socket activity and sets last error.
sock | Socket descriptor. | |
last_error | Error number to report |
Definition at line 1835 of file tcpsm.c.
References NutEventBroadcast(), NutTcpDiscardBuffers(), TCPS_CLOSED, TCPS_FIN_WAIT_1, and TCPS_TIME_WAIT.
Referenced by NutTcpStateRetranTimeout().
void NutTcpCalcRtt | ( | TCPSOCKET * | sock | ) |
Definition at line 86 of file tcputil.c.
References max, min, NutGetMillis(), and TCP_RTTO_MAX.
Definition at line 282 of file tcpsm.c.
Referenced by NutTcpSm(), and NutTcpStateMachine().
NETBUF* volatile tcp_in_nbq |
Definition at line 283 of file tcpsm.c.
Referenced by NutTcpSm(), and NutTcpStateMachine().