TCP
[Protocols]


Detailed Description

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.


Defines

#define max(a, b)   ((a>b)?a:b)
#define min(a, b)   ((a>b)?b:a)

Functions

int IsInLimits (u_long x, u_long low, u_long high)
 Sequence number comparisons.
int NutTcpAbortSocket (TCPSOCKET *sock, u_short last_error)
 Closes socket with error.
void NutTcpCalcRtt (TCPSOCKET *sock)
int NutTcpInitStateMachine (void)
 Start TCP state machine.
void NutTcpInput (NETBUF *nb)
 Process incoming TCP segments from IP layer.
int NutTcpStateActiveOpenEvent (TCPSOCKET *sock)
 Initiated by the application.
int NutTcpStateCloseEvent (TCPSOCKET *sock)
 Socket close by application.
void NutTcpStateMachine (NETBUF *nb)
 Process incoming TCP segments.
int NutTcpStatePassiveOpenEvent (TCPSOCKET *sock)
 Initiated by the application.
int NutTcpStateRetranTimeout (TCPSOCKET *sock)
 Retransmit a segment after ACK timeout.
int NutTcpStateWindowEvent (TCPSOCKET *sock)
 Initiated by the application.
 THREAD (NutTcpSm, arg)

Variables

NETBUF *volatile tcp_in_nbq
HANDLE tcp_in_rdy


Function Documentation

int IsInLimits ( u_long  x,
u_long  low,
u_long  high 
)

Sequence number comparisons.

Return true if x is between low and high inclusive, false otherwise

int NutTcpAbortSocket ( TCPSOCKET sock,
u_short  last_error 
)

Closes socket with error.

Aborts any socket activity and sets last error.

Parameters:
sock Socket descriptor.
last_error Error number to report
Note:
This routine is called internally by Nut/Net. Applications typically do not call this function.
Returns:
0 on success, -1 otherwise.

int NutTcpInitStateMachine ( void   ) 

Start TCP state machine.

The socket interface will automatically call this routine as soon as the first socket is created.

Returns:
0 on success, -1 otherwise.

void NutTcpInput ( NETBUF nb  ) 

Process incoming TCP segments from IP layer.

Warning:
The caller must take care not to pass broadcast or multicast segments.
Note:
This routine is called by the IP layer on incoming TCP segments. Applications typically do not call this function.

int NutTcpStateActiveOpenEvent ( TCPSOCKET sock  ) 

Initiated by the application.

The caller must make sure, that the socket is in closed state.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().
Returns:
0 if granted, -1 otherwise.

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.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().

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.

Note:
This routine is called by the IP layer on incoming TCP segments. Applications typically do not call this function.

int NutTcpStatePassiveOpenEvent ( TCPSOCKET sock  ) 

Initiated by the application.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().
Returns:
0 if granted, error code otherwise.

int NutTcpStateRetranTimeout ( TCPSOCKET sock  ) 

Retransmit a segment after ACK timeout.

This function is called by the TCP timer.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().
Returns:
Nonzero if socket was aborted due to reach of retransmit limit or network error.

int NutTcpStateWindowEvent ( TCPSOCKET sock  ) 

Initiated by the application.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().


Generated on Tue Jan 23 21:12:26 2007 for BTnut System Software by doxygen 1.4.7