For examples how to use TCP and write applications that communicate using TCP see inet/demo/main_demo.c, inet/demo/tcp_client_demo.c and inet/demo/tcp_server_demo.c.
Definition in file tcp.c.
Go to the source code of this file.
Functions | |
INT8 | tcp_getsocket (UINT8 soctype, UINT8 tos, UINT16 tout, INT32(*listener)(INT8, UINT8, UINT32, UINT32)) |
Allocate a free socket in TCP socket pool. | |
INT8 | tcp_releasesocket (INT8 sochandle) |
Release a TCP socket. | |
INT8 | tcp_listen (INT8 sochandle, UINT16 port) |
Put TCP socket to listen on a given port. | |
INT8 | tcp_connect (INT8 sochandle, UINT32 ip, UINT16 rport, UINT16 myport) |
Initialize connection establishment towards remote IP&port. | |
INT16 | tcp_send (INT8 sockethandle, UINT8 *buf, UINT16 blen, UINT16 dlen) |
Send user data over TCP using given TCP socket. | |
INT8 | tcp_close (INT8 sochandle) |
Initiate TCP connection closing procedure. | |
INT8 | tcp_getstate (INT8 sochandle) |
Get current state of the socket. | |
INT16 | tcp_checksend (INT8 sochandle) |
Checks if it's possible to send data using given socket. | |
INT8 | tcp_abort (INT8 sochandle) |
Reset connection and place socket to closed state. | |
void | tcp_poll (void) |
Poll TCP sockets periodically. | |
INT8 | tcp_init (void) |
Initialize TCP module. | |
INT16 | process_tcp_in (struct ip_frame *frame, UINT16 len) |
Check and process the received TCP frame. | |
INT16 | process_tcp_out (INT8 sockethandle, UINT8 *buf, UINT16 blen, UINT16 dlen) |
Create and send TCP packet. | |
void | tcp_sendcontrol (INT8 sockethandle) |
Send a TCP control packet (no data). | |
void | tcp_sendreset (struct tcp_frame *frame, UINT32 remip) |
Send a reset (RST) packet to remote host. | |
UINT32 | tcp_initseq (void) |
Get and return initial sequence number. | |
INT8 | tcp_mapsocket (struct ip_frame *ipframe, struct tcp_frame *tcpframe) |
Try to match received TCP packet to a socket. | |
void | tcp_newstate (struct tcb *soc, UINT8 nstate) |
Change TCP socket state and reinitialize timers. | |
UINT16 | tcp_getfreeport (void) |
Returns next free (not used) local port number. | |
UINT8 | tcp_check_cs (struct ip_frame *ipframe, UINT16 len) |
Check if TCP checksum check's out. | |
Variables | |
tcp_frame | received_tcp_packet |
Used for storing field information about the received TCP packet. | |
tcb | tcp_socket [NO_OF_TCPSOCKETS+1] |
TCP table holding connection parameters for every TCP socket. | |
UINT8 | tcp_tempbuf [MIN_TCP_HLEN+1] |
|
Definition at line 155 of file tcp.c. References tcb::event_listener, tcb::flags, tcb::locport, tcb::rem_ip, tcb::remport, tcb::state, TCP_STATE_FREE, TCP_STATE_RESERVED, TCP_TYPE_CLIENT, TCP_TYPE_CLIENT_SERVER, TCP_TYPE_NONE, TCP_TYPE_SERVER, TIMERTIC, tcb::tos, tcb::tout, and tcb::type. Referenced by https_init(), pop3c_init(), and smtpc_init(). |
|
Definition at line 228 of file tcp.c. References tcb::event_listener, tcb::flags, tcb::locport, tcb::rem_ip, tcb::remport, tcb::state, TCP_STATE_CLOSED, TCP_STATE_FREE, TCP_STATE_RESERVED, TCP_TYPE_NONE, tcb::tos, and tcb::type. |
|
Definition at line 290 of file tcp.c. References tcb::event_listener, tcb::flags, tcb::locport, tcb::myflags, tcb::receive_next, tcb::rem_ip, tcb::remport, tcb::retries_left, tcb::send_mtu, tcb::send_next, tcb::send_unacked, tcb::state, TCP_STATE_CLOSED, TCP_STATE_LISTENING, TCP_STATE_RESERVED, TCP_STATE_TIMED_WAIT, TCP_TYPE_SERVER, and tcb::type. Referenced by https_init(). |
|
Definition at line 377 of file tcp.c. References tcb::event_listener, tcb::flags, tcb::locport, tcb::myflags, tcb::rem_ip, tcb::remport, tcb::send_mtu, tcb::send_next, tcb::send_unacked, tcb::state, tcp_getfreeport(), tcp_initseq(), tcp_newstate(), tcp_sendcontrol(), TCP_STATE_CLOSED, TCP_STATE_LISTENING, TCP_STATE_RESERVED, TCP_STATE_SYN_SENT, TCP_TYPE_CLIENT, and tcb::type. |
|
Definition at line 481 of file tcp.c. References tcb::myflags, process_tcp_out(), tcb::send_mtu, tcb::send_next, tcb::send_unacked, tcb::state, and TCP_STATE_CONNECTED. |
|
Definition at line 549 of file tcp.c. References tcb::flags, tcb::myflags, tcb::send_next, tcb::send_unacked, tcb::state, tcp_newstate(), tcp_sendcontrol(), TCP_STATE_CLOSED, TCP_STATE_CLOSING, TCP_STATE_CONNECTED, TCP_STATE_FINW1, TCP_STATE_FINW2, TCP_STATE_LAST_ACK, TCP_STATE_LISTENING, TCP_STATE_SYN_RECEIVED, TCP_STATE_SYN_SENT, and TCP_STATE_TIMED_WAIT. |
|
Definition at line 648 of file tcp.c. References tcb::state. |
|
Definition at line 690 of file tcp.c. References tcb::send_mtu, tcb::send_next, tcb::send_unacked, tcb::state, and TCP_STATE_CONNECTED. |
|
Definition at line 736 of file tcp.c. References tcb::myflags, tcb::state, tcp_newstate(), tcp_sendcontrol(), TCP_STATE_CLOSED, TCP_STATE_CLOSING, TCP_STATE_CONNECTED, TCP_STATE_FINW1, TCP_STATE_FINW2, TCP_STATE_FREE, TCP_STATE_LAST_ACK, TCP_STATE_LISTENING, TCP_STATE_RESERVED, TCP_STATE_SYN_RECEIVED, TCP_STATE_SYN_SENT, and TCP_STATE_TIMED_WAIT. |
|
|
Definition at line 1154 of file tcp.c. References tcb::event_listener, tcb::flags, get_timer(), init_timer(), tcb::locport, tcb::myflags, tcb::persist_timerh, tcb::rem_ip, tcb::remport, tcb::retransmit_timerh, tcb::retries_left, tcb::send_mtu, tcb::state, TCP_STATE_FREE, TCP_TYPE_NONE, tcb::tos, tcb::tout, and tcb::type. |
|
|
Definition at line 2119 of file tcp.c. References ip_checksum(), ip_checksum_buf(), IP_TCP, tcb::locport, tcb::myflags, process_ip_out(), tcb::receive_next, tcb::rem_ip, tcb::remport, tcb::send_mtu, tcb::send_unacked, and tcb::tos. Referenced by tcp_send(), and tcp_sendcontrol(). |
|
Definition at line 2253 of file tcp.c. References process_tcp_out(), and tcp_tempbuf. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_connect(), tcp_poll(), and tcp_sendreset(). |
|
Definition at line 2294 of file tcp.c. References tcp_frame::ackno, tcp_frame::dport, tcp_frame::hlen_flags, tcb::locport, tcb::myflags, tcb::receive_next, tcb::rem_ip, tcb::remport, tcb::send_mtu, tcb::send_unacked, tcp_frame::seqno, tcp_frame::sport, tcp_sendcontrol(), and tcb::tos. Referenced by process_tcp_in(). |
|
Definition at line 2346 of file tcp.c. Referenced by process_tcp_in(), and tcp_connect(). |
|
Definition at line 2369 of file tcp.c. References tcp_frame::dport, tcp_frame::hlen_flags, tcb::locport, tcb::rem_ip, tcb::remport, ip_frame::sip, tcp_frame::sport, tcb::state, and TCP_STATE_LISTENING. Referenced by process_tcp_in(). |
|
Definition at line 2455 of file tcp.c. References init_timer(), tcb::persist_timerh, tcb::retransmit_timerh, tcb::retries_left, tcb::state, TCP_DEF_RETRIES, TCP_DEF_RETRY_TOUT, TCP_INIT_RETRY_TOUT, TCP_STATE_CLOSING, TCP_STATE_CONNECTED, TCP_STATE_FINW1, TCP_STATE_FINW2, TCP_STATE_LAST_ACK, TCP_STATE_SYN_SENT, TCP_STATE_TIMED_WAIT, TIMERTIC, and tcb::tout. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_connect(), and tcp_poll(). |
|
Definition at line 2511 of file tcp.c. References tcb::locport, tcb::state, TCP_PORTS_END, and TCP_STATE_CLOSED. Referenced by tcp_connect(). |
|
Definition at line 2567 of file tcp.c. References ip_frame::dip, ip_checksum(), ip_checksum_buf(), ip_frame::protocol, RECEIVE_NETWORK_B, RECEIVE_NETWORK_BUF, ip_frame::sip, and tcp_tempbuf. Referenced by process_tcp_in(). |
|
Various fields from the TCP packet are stored in this variable. These values are then used to perform the necessary actions as defined by the TCP specification: correctnes of the received TCP packet is checked by analyzing these fields, appropriate socket data is adjusted and/or control packet is sent based on it. See tcp_frame definition for struct information. |
|
TCP table is an array of tcp_socket structures holding all of the necessary information about the state, timers, timeouts and sequence and port numbers of the TCP sockets opened. Number of TCP sockets that can be opened at any given time is defined by the NO_OF_TCPSOCKETS and may be changed in order to change the amount of used RAM memory. See tcb definition for more information about the structure itself.
|
|
Temporary buffer used for sending TCP control packets Definition at line 120 of file tcp.c. Referenced by tcp_check_cs(), and tcp_sendcontrol(). |