Nut/OS  4.10.3
API Reference
tcpout.c File Reference
#include <cfg/os.h>
#include <string.h>
#include <errno.h>
#include <sys/heap.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/icmp.h>
#include <netinet/ip_icmp.h>
#include <netinet/ipcsum.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <sys/thread.h>
#include <net/netdebug.h>
Include dependency graph for tcpout.c:

Go to the source code of this file.


int NutTcpOutput (TCPSOCKET *sock, CONST uint8_t *data, uint16_t size)
 Initiate TCP segment transmission.
int NutTcpReject (NETBUF *nb)
 Reject an incoming segment.

Function Documentation

int NutTcpOutput ( TCPSOCKET sock,
CONST uint8_t data,
uint16_t  size 

Initiate TCP segment transmission.

Check the TCP socket status and send any segment waiting for transmission.

The function will not return until the data has been stored in the network device hardware for transmission. If the device is not ready for transmitting a new packet, the calling thread will be suspended until the device becomes ready again.

If the target host is connected through an Ethernet network and if the hardware address of that host is currently unknown, an ARP request is sent out and the function will block until a response is received or an ARP timeout occurs.

Segments containing data or SYN and FIN flags are added to a special queue for unacknowledged segments and will be retransmitted by the TCP timer thread, if not acknowledged by the remote within a specific time. The state machine will remove these segments from the queue as soon as they are acknowledged.

This function is mainly used by the TCP state machine. Applications typically do not call this function but use NutTcpSend(), which is part of the TCP socket interface.
sockSocket descriptor. This pointer must have been retrieved by calling NutTcpCreateSocket().
dataPointer to TCP segment contents.
sizeTCP segment length.
0 on success, -1 otherwise. Returning 0 does not imply that the data has been successfully delivered, because flow control and retransmission is still handled in the background.

Definition at line 209 of file tcpout.c.

References __tcp_trf, __tcp_trs, ENOBUFS, htonl, htons, IPPROTO_TCP, memcpy(), _NETBUF::nb_ap, _NETBUF::nb_next, _NETBUF::nb_tp, NBAF_APPLICATION, NBAF_TRANSPORT, ntohl, NutDumpTcpHeader(), NutGetMillis(), NutIpChkSum(), NutIpChkSumPartial(), NutIpOutput(), NutIpPseudoChkSumPartial(), NutNetBufAlloc(), NutNetBufClonePart(), NutNetBufFree(), SO_ACK, SO_FIN, SO_FORCE, tcp_socket::so_last_error, tcp_socket::so_local_addr, tcp_socket::so_local_port, tcp_socket::so_mss, tcp_socket::so_remote_addr, tcp_socket::so_remote_port, tcp_socket::so_retran_time, tcp_socket::so_rtt_seq, tcp_socket::so_rx_nxt, tcp_socket::so_rx_win, SO_SYN, tcp_socket::so_tx_flags, tcp_socket::so_tx_nbq, tcp_socket::so_tx_nxt, _NBDATA::sz, TCPOLEN_MAXSEG, TCPOPT_MAXSEG, TH_ACK, tcphdr::th_ack, tcphdr::th_dport, TH_FIN, tcphdr::th_flags, tcphdr::th_off, TH_PUSH, tcphdr::th_seq, tcphdr::th_sport, tcphdr::th_sum, TH_SYN, tcphdr::th_urp, tcphdr::th_win, tcphdr::th_x2, and _NBDATA::vp.

Referenced by NutTcpSend(), NutTcpSm(), and NutTcpStateWindowEvent().

Here is the call graph for this function:

int NutTcpReject ( NETBUF nb)

Reject an incoming segment.

Send RST in response to an incoming segment, which should be rejected.

The function avoids to send out a RST segment in response to an incoming RST segment.

This function is mainly used by the TCP state machine. Applications typically do not call this function.
nbNetwork buffer structure of the incoming segment. Will be released within this function.
0 on success, -1 otherwise.

Definition at line 395 of file tcpout.c.

References __tcp_trf, __tcp_trs, htonl, htons, ip::ip_dst, ip::ip_src, IPPROTO_TCP, _NETBUF::nb_ap, _NETBUF::nb_nw, _NETBUF::nb_tp, ntohl, NutDumpTcpHeader(), NutIpChkSum(), NutIpOutput(), NutIpPseudoChkSumPartial(), NutNetBufFree(), _NBDATA::sz, TH_ACK, TH_RST, TH_SYN, and _NBDATA::vp.

Referenced by NutTcpSm(), and NutTcpStateMachine().

Here is the call graph for this function: