Definition in file tcp_ip.h.
Go to the source code of this file.
Data Structures | |
struct | udp_frame |
UDP header information. More... | |
struct | ucb |
UDP control block. More... | |
struct | tcp_frame |
TCP header information. More... | |
struct | tcb |
TCP transmission control block. More... | |
Defines | |
#define | NO_OF_TCPSOCKETS 8 |
Defines number of TCP sockets available. | |
#define | NO_OF_UDPSOCKETS 4 |
Defines number of UDP sockets available. | |
#define | TCP_PORTS_END 1023 |
Define reserved-ports space. | |
#define | UDP_PORTS_END 1023 |
Define reserved-ports space. | |
#define | UDP_OPT_NONE 0 |
Disable checksum calculation for UDP socket. | |
#define | UDP_OPT_SEND_CS 1 |
Enable checksum calculation for outgoing UDP packets. | |
#define | UDP_OPT_CHECK_CS 2 |
Enable checksum checking for received UDP packets. | |
#define | UDP_HLEN 8 |
#define | TCP_DEF_RETRIES 7 |
Number of attempted TCP retransmissions before giving up. | |
#define | TCP_DEF_KEEPALIVE 4 |
Defines a number of seconds after which an empty ACK packet is sent. | |
#define | TCP_DEF_RETRY_TOUT 4 |
Default data-retransmission period (in seconds). | |
#define | TCP_INIT_RETRY_TOUT 1 |
Initial retransmission period (in seconds). | |
#define | TCP_SYN_RETRY_TOUT 2 |
Retranmission period for SYN packet. | |
#define | TCP_TOS_NORMAL 0 |
Defines normal type of service for TCP socket. | |
#define | TCP_DEF_TOUT 120 |
Default idle timeout. | |
#define | UDP_STATE_FREE 1 |
Defines that UDP socket is free and available. | |
#define | UDP_STATE_CLOSED 2 |
Defines that UDP socket is allocated but closed. | |
#define | UDP_STATE_OPENED 3 |
Defines that UDP socket is allocated and opened. | |
#define | UDP_EVENT_DATA 64 |
Only UDP event notified to UDP socket event listener. | |
#define | TCP_TYPE_NONE 0x00 |
TCP socket is nor a client nor a server. | |
#define | TCP_TYPE_SERVER 0x01 |
TCP socket represents a server application. | |
#define | TCP_TYPE_CLIENT 0x02 |
TCP socket represents a client application. | |
#define | TCP_TYPE_CLIENT_SERVER 0x03 |
TCP socket can act as client or as server. | |
#define | TCP_STATE_FREE 1 |
#define | TCP_STATE_RESERVED 2 |
#define | TCP_STATE_CLOSED 3 |
#define | TCP_STATE_LISTENING 4 |
#define | TCP_STATE_SYN_RECEIVED 5 |
#define | TCP_STATE_SYN_SENT 6 |
#define | TCP_STATE_FINW1 7 |
#define | TCP_STATE_FINW2 8 |
#define | TCP_STATE_CLOSING 9 |
#define | TCP_STATE_LAST_ACK 10 |
#define | TCP_STATE_TIMED_WAIT 11 |
#define | TCP_STATE_CONNECTED 12 |
#define | TCP_EVENT_CONREQ 1 |
Connection request event. | |
#define | TCP_EVENT_CONNECTED 2 |
Connection established event. | |
#define | TCP_EVENT_CLOSE 4 |
Connection closed event. | |
#define | TCP_EVENT_ABORT 8 |
Connection aborted event. | |
#define | TCP_EVENT_ACK 16 |
Data acknowledged event. | |
#define | TCP_EVENT_REGENERATE 32 |
Regenerate data event. | |
#define | TCP_EVENT_DATA 64 |
Data arrival event. | |
#define | TCP_APP_OFFSET MIN_TCP_HLEN |
Transmit buffer offset for TCP applications. | |
#define | UDP_APP_OFFSET UDP_HLEN |
Transmit buffer offset for UDP applications. | |
Functions | |
INT16 | process_icmp_in (struct ip_frame *, UINT16) |
Process recieved ICMP datagram. | |
INT8 | udp_init (void) |
Initialize UDP socket pool. | |
INT8 | udp_getsocket (UINT8, INT32(*)(INT8, UINT8, UINT32, UINT16, UINT16, UINT16), UINT8) |
Allocate a free socket in UDP socket pool. | |
INT8 | udp_releasesocket (INT8) |
Release a given socket. | |
INT8 | udp_open (INT8, UINT16) |
Open a given UDP socket for communication. | |
INT8 | udp_close (INT8) |
Close given socket for communication. | |
INT16 | udp_send (INT8, UINT32, UINT16, UINT8 *, UINT16, UINT16) |
Send data to remote host using given UDP socket. | |
INT16 | process_udp_in (struct ip_frame *, UINT16) |
Process received UDP frame. | |
UINT16 | udp_getfreeport (void) |
Returns next free (not used) local port number. | |
INT16 | process_tcp_in (struct ip_frame *, UINT16) |
Check and process the received TCP frame. | |
INT16 | process_tcp_out (INT8, UINT8 *, UINT16, UINT16) |
Create and send TCP packet. | |
INT8 | tcp_init (void) |
Initialize TCP module. | |
INT8 | tcp_listen (INT8, UINT16) |
Put TCP socket to listen on a given port. | |
INT8 | tcp_mapsocket (struct ip_frame *, struct tcp_frame *) |
Try to match received TCP packet to a socket. | |
UINT8 | tcp_check_cs (struct ip_frame *, UINT16) |
Check if TCP checksum check's out. | |
void | tcp_sendcontrol (INT8) |
Send a TCP control packet (no data). | |
UINT32 | tcp_initseq (void) |
Get and return initial sequence number. | |
void | tcp_poll (void) |
Poll TCP sockets periodically. | |
void | tcp_newstate (struct tcb *, UINT8) |
Change TCP socket state and reinitialize timers. | |
INT8 | tcp_getsocket (UINT8, UINT8, UINT16, INT32(*)(INT8, UINT8, UINT32, UINT32)) |
Allocate a free socket in TCP socket pool. | |
INT8 | tcp_releasesocket (INT8) |
Release a TCP socket. | |
INT8 | tcp_connect (INT8, UINT32, UINT16, UINT16) |
Initialize connection establishment towards remote IP&port. | |
INT16 | tcp_send (INT8, UINT8 *, UINT16, UINT16) |
Send user data over TCP using given TCP socket. | |
INT8 | tcp_close (INT8) |
Initiate TCP connection closing procedure. | |
void | tcp_sendreset (struct tcp_frame *, UINT32) |
Send a reset (RST) packet to remote host. | |
INT8 | tcp_getstate (INT8) |
Get current state of the socket. | |
UINT16 | tcp_getfreeport (void) |
Returns next free (not used) local port number. | |
INT16 | tcp_checksend (INT8) |
Checks if it's possible to send data using given socket. | |
INT8 | tcp_abort (INT8) |
Reset connection and place socket to closed state. |
|
By choosing only this option for UDP socket, checksum calculation will be disabled for both incoming/outgoing UDP packets. This will make UDP extremely fast, but also more prone to errors. This is usually not a big limitation considering that checksum is not so good in error-detection anyway. |
|
When only this option is chosen, checksum is calculated for outgoing UDP packets. This is sometimes neccessary since certain applications can disable reception of UDP packets without a calculated checksum. Definition at line 132 of file tcp_ip.h. Referenced by bootpc_init(), dhcpc_init(), dns_init(), tftps_init(), udp_getsocket(), udp_init(), udp_releasesocket(), and udp_send(). |
|
When this option is enabled, checksum is checked for all received UDP packets to check for transmission errors. Definition at line 140 of file tcp_ip.h. Referenced by bootpc_init(), dhcpc_init(), dns_init(), process_udp_in(), tftps_init(), udp_getsocket(), udp_init(), and udp_releasesocket(). |
|
UDP Header Length Definition at line 144 of file tcp_ip.h. Referenced by process_udp_in(), and udp_send(). |
|
This defines normal (and for now the only one implemented) type of service for the TCP socket. Definition at line 214 of file tcp_ip.h. Referenced by https_init(), pop3c_init(), and smtpc_init(). |
|
If an entry of ucb type has this as a state value, then it is free and can be allocated by the udp_getsocket(). Definition at line 249 of file tcp_ip.h. Referenced by udp_getsocket(), udp_init(), and udp_releasesocket(). |
|
Entries of ucb type that have this as their state value were allocated by udp_getsocket() but they are in the closed state, so no data can be received/sent through the socket. Definition at line 258 of file tcp_ip.h. Referenced by udp_close(), udp_getfreeport(), and udp_getsocket(). |
|
Corresponding UDP socket was allocated and opened so data can be transmitted/received through it. Definition at line 266 of file tcp_ip.h. Referenced by process_udp_in(), udp_open(), and udp_send(). |
|
For now, this is the only UDP event that is notified to the UDP sockets' event listener. Definition at line 276 of file tcp_ip.h. Referenced by dhcpc_eventlistener(), dns_eventlistener(), and process_udp_in(). |
|
If TCP socket entry is of this type it can not be used for anything. This may only be used for testing, debugging, etc. purposes or if application is not sure what it wants to be it can reserve a TCP socket by getting a socket of type TCP_TYPE_NONE. Definition at line 300 of file tcp_ip.h. Referenced by tcp_getsocket(), tcp_init(), and tcp_releasesocket(). |
|
If TCP socket entry is of server type, application using it can only listen on a given socket for incoming connections. No connections can be opened towards some outside host unless the outside host initiates the connection. Definition at line 310 of file tcp_ip.h. Referenced by https_init(), process_tcp_in(), tcp_getsocket(), tcp_listen(), and tcp_poll(). |
|
If TCP socket entry is of client type, application using it can establish connection through it towards other Internet hosts but can not accept any incoming connections on the port (execute tcp_listen() on it that is). Definition at line 320 of file tcp_ip.h. Referenced by pop3c_init(), smtpc_init(), tcp_connect(), and tcp_getsocket(). |
|
If TCP socket entry is of this type, application using it can both listen on a given socket or establish connection towards an outside host. Definition at line 329 of file tcp_ip.h. Referenced by tcp_getsocket(). |
|
Entry is free and unused Definition at line 333 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_getsocket(), tcp_init(), tcp_poll(), and tcp_releasesocket(). |
|
Entry is reserved for use Definition at line 334 of file tcp_ip.h. Referenced by tcp_abort(), tcp_connect(), tcp_getsocket(), tcp_listen(), tcp_poll(), and tcp_releasesocket(). |
|
Entry allocated, socket still closed Definition at line 335 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_connect(), tcp_getfreeport(), tcp_listen(), tcp_poll(), and tcp_releasesocket(). |
|
Socket in listening state, waiting for incoming connections Definition at line 336 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_connect(), tcp_listen(), tcp_mapsocket(), and tcp_poll(). |
|
SYN packet received (either first SYN packet or response to SYN that we have previously sent) Definition at line 339 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), and tcp_poll(). |
|
SYN packet sent as an attempt to establish a connection Definition at line 343 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_connect(), tcp_newstate(), and tcp_poll(). |
|
User issued tcp_close request issued so FIN packet was sent Definition at line 346 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_newstate(), and tcp_poll(). |
|
Received ACK of our FIN, now waiting for other side to send FIN Definition at line 349 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_newstate(), and tcp_poll(). |
|
Received FIN independently of our FIN Definition at line 353 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_newstate(), and tcp_poll(). |
|
Waiting for last ACK packet as a response to our FIN Definition at line 356 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_newstate(), and tcp_poll(). |
|
Waiting for 2MSL to prevent erroneous connection duplication Definition at line 359 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_close(), tcp_listen(), tcp_newstate(), and tcp_poll(). |
|
Connection established and data flowing freely to both sides :-) Definition at line 362 of file tcp_ip.h. Referenced by process_tcp_in(), tcp_abort(), tcp_checksend(), tcp_close(), tcp_newstate(), tcp_poll(), and tcp_send(). |
|
Connection request event is notified to TCP server applications' event listener when SYN packet is received for it's socket. Event listener can then, if it wants to, inspect IP addres and port number of the remote host, or some other internal parameters, to decide whether it should allow connection establishment or not. One of the following values must then be returned from the event listener:
Definition at line 387 of file tcp_ip.h. Referenced by process_tcp_in(). |
|
Applications' event listener is informed by this event that connection is established and that it may start sending/receiving data. Definition at line 397 of file tcp_ip.h. Referenced by process_tcp_in(). |
|
TCP connection was properly closed (either by calling tcp_close() by application or remote host initialized closing sequence). Definition at line 405 of file tcp_ip.h. Referenced by process_tcp_in(), and tcp_poll(). |
|
Connection is, for some reason, aborted. This can happen for a number of reasons:
Definition at line 418 of file tcp_ip.h. Referenced by process_tcp_in(), and tcp_poll(). |
|
TCP/IP stack has received correct acknowledgment packet for the previously sent data and is informing the application about it. After this event, application can send new data packet to remote host. Definition at line 428 of file tcp_ip.h. Referenced by process_tcp_in(). |
|
Previously sent data packet was not acknowledged (or the acknowledgment packet did not arrive) so retransmission needs to be peformed. Application must resend the data that was sent in the previous packet. Definition at line 437 of file tcp_ip.h. Referenced by tcp_poll(). |
|
TCP received some data from remote host and is informing application that it is available for reading from the Ethernet controller. Definition at line 445 of file tcp_ip.h. Referenced by process_tcp_in(). |
|
This value defines offset that TCP applications must use when writing to transmit buffer. This many bytes will be used before the first byte of applications data in the transmit buffer to store TCP header. Definition at line 459 of file tcp_ip.h. Referenced by smtpc_init(). |
|
This value defines offset that UDP applications must use when writing to transmit buffer. This many bytes will be used before the first byte of applications data in the transmit buffer to store UDP header. Definition at line 471 of file tcp_ip.h. Referenced by bootpc_run(), dhcpc_send_message(), and get_host_by_name(). |
|
This function simply checks correctnes of received ICMP message and send ICMP replies when requested. Definition at line 97 of file icmp.c. References ip_frame::buf_index, ip_frame::dip, ip_checksum(), ip_checksum_buf(), IP_ICMP, NETWORK_RECEIVE_INITIALIZE, NETWORK_TX_BUFFER_SIZE, process_ip_out(), ip_frame::protocol, RECEIVE_NETWORK_B, RECEIVE_NETWORK_BUF, ip_frame::sip, and TXBUF. |
|
Definition at line 684 of file udp.c. References ucb::locport, ucb::state, UDP_PORTS_END, and UDP_STATE_CLOSED. Referenced by udp_open(). |
|
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 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 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(). |
|
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 2346 of file tcp.c. Referenced by process_tcp_in(), and tcp_connect(). |
|
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 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 2511 of file tcp.c. References tcb::locport, tcb::state, TCP_PORTS_END, and TCP_STATE_CLOSED. Referenced by tcp_connect(). |