Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Enumerations | Functions | Variables
pctcp.h File Reference

Go to the source code of this file.

Data Structures

struct  tcp_rtt
 

Enumerations

enum  BSD_SOCKET_OPS {
  BSO_FIND_SOCK = 1,
  BSO_SYN_CALLBACK,
  BSO_RST_CALLBACK,
  BSO_IP4_RAW,
  BSO_IP6_RAW,
  BSO_DEBUG
}
 

Functions

void _udp_cancel (const in_Header *ip, int icmp_type, int icmp_code, const char *msg, const void *arg)
 Cancel an UDP socket. More...
 
void _tcp_cancel (const in_Header *ip, int icmp_type, int icmp_code, const char *msg, const void *arg)
 Cancel a TCP socket. More...
 
void _tcp_close (_tcp_Socket *s)
 Close a TCP connection. More...
 
void tcp_rtt_add (const _tcp_Socket *s, UINT rto, UINT MTU)
 
void tcp_rtt_clr (const _tcp_Socket *s)
 
BOOL tcp_rtt_get (const _tcp_Socket *s, UINT *rto, UINT *MTU)
 
int _tcp_send (_tcp_Socket *s, const char *file, unsigned line)
 Format and send an outgoing TCP segment. More...
 
int _tcp_sendsoon (_tcp_Socket *s, const char *file, unsigned line)
 Schedule a transmission pretty soon. More...
 
int _tcp_keepalive (_tcp_Socket *s)
 TCP keepalive transmission. More...
 
void tcp_Retransmitter (BOOL force)
 Called periodically to perform retransmissions. More...
 
_udp_Socket_udp_handler (const in_Header *ip, BOOL broadcast)
 Handler for incoming UDP packets.
 
_tcp_Socket_tcp_handler (const in_Header *ip, BOOL broadcast)
 The main TCP input handler. More...
 
_tcp_Socket_tcp_unthread (_tcp_Socket *s, BOOL free_tx)
 Unthread a socket from the tcp socket list, if it's there. More...
 
_tcp_Socket_tcp_abort (_tcp_Socket *s, const char *file, unsigned line)
 Abort a TCP connection.
 
int _tcp_send_reset (_tcp_Socket *s, const in_Header *ip, const tcp_Header *tcp, const char *file, unsigned line)
 Format and send a reset (RST) tcp packet. More...
 
void *MS_CDECL * _bsd_socket_hook (enum BSD_SOCKET_OPS op,...)
 
WORD init_localport (void)
 Allocate the "lport_inuse" bit-array from heap. More...
 
WORD find_free_port (WORD oldport, BOOL sleep_msl)
 
int grab_localport (WORD port)
 
int reuse_localport (WORD port)
 
int maybe_reuse_localport (_tcp_Socket *s)
 

Variables

BOOL mtu_discover
 
BOOL mtu_blackhole
 
BOOL use_rand_lport
 
BOOL tcp_nagle
 Misc TCP values. More...
 
BOOL tcp_opt_ts
 TCP option config flags (RFC 1323).
 
BOOL tcp_opt_sack
 
BOOL tcp_opt_wscale
 
char hostname [MAX_HOSTLEN+1]
 Our configured hostname. More...
 
_tcp_Socket_tcp_allsocs
 list of tcp-sockets
 
_udp_Socket_udp_allsocs
 list of udp-sockets
 

Function Documentation

void _tcp_cancel ( const in_Header ip,
int  icmp_type,
int  icmp_code,
const char *  msg,
const void arg 
)

Cancel a TCP socket.

Called upon receiving ICMP errors: host/port UNREACH, REDIRECT, SOURCEQUENCH, TIMXCEED or PARAMPROB. See icmp_redirect() or icmp_handler().

Note: 'ip' is a small copy of the IP-packet originating the ICMP message. We may not have received a copy of the original TCP-header. But we probably won't do any harm if got less TCP-header data than needed. I.e. src_port/dst_port will be zero.

Definition at line 1735 of file pctcp.c.

References _arp_resolve(), _ip_recursion, tcp_Socket::cwindow, tcp_Socket::next, tcp_Socket::rto, sock_reduce_mss(), tcp_Socket::state, tcp_Socket::vj_sa, tcp_Socket::vj_sd, and tcp_Socket::wwindow.

void _tcp_close ( _tcp_Socket s)

Close a TCP connection.

Send a FIN on a particular port – only works if it is open. Must still allow receives.

Definition at line 455 of file pctcp.c.

References _tcp_unthread(), tcp_Socket::flags, tcp_Socket::rtt_time, set_timeout(), tcp_Socket::state, tcp_Socket::timeout, tcp_Socket::tx_datalen, and tcp_Socket::unhappy.

_tcp_Socket* _tcp_handler ( const in_Header ip,
BOOL  broadcast 
)
int _tcp_keepalive ( _tcp_Socket tcp)

TCP keepalive transmission.

If connection is idle (tx_datalen == 0), force the peer to send us a segment by sending a keep-alive packet:

*    <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
*  

Definition at line 2698 of file pctcp.c.

References tcp_Socket::flags, tcp_Socket::karn_count, tcp_Socket::recv_next, tcp_Socket::send_next, tcp_Socket::send_una, tcp_Socket::state, tcp_Socket::tx_data, and tcp_Socket::tx_datalen.

int _tcp_send ( _tcp_Socket s,
const char *  file,
unsigned  line 
)
int _tcp_send_reset ( _tcp_Socket s,
const in_Header his_ip,
const tcp_Header org_tcp,
const char *  file,
unsigned  line 
)

Format and send a reset (RST) tcp packet.

Note
We modify the orignal segment (orig_tcp) to use it for sending.

Definition at line 2555 of file pctcp.c.

References _default_ttl, _eth_formatpacket(), _ip4_output(), _ip6_checksum(), _ip6_output(), chk_timeout(), tcp_Socket::secret, set_timeout(), and tcp_RST_TIME.

int _tcp_sendsoon ( _tcp_Socket s,
const char *  file,
unsigned  line 
)

Schedule a transmission pretty soon.

This one has an imperfection at midnight, but it is not significant to the connection performance.

Note
gv: Added - 5 May 2000: Relax retransmission period to tcp_CLOSE_TO when CLOSEWT state is entered.
Relax retransmission period to tcp_OPEN_TO in SYNSENT state.

Definition at line 555 of file pctcp.c.

References _tcp_send(), cmp_timers(), tcp_Socket::karn_count, tcp_Socket::recent, tcp_Socket::rto, tcp_Socket::rtt_time, set_timeout(), tcp_Socket::state, tcp_CLOSE_TO, tcp_OPEN_TO, tcp_RTO_BASE, tcp_RTO_SCALE, tcp_Socket::tx_datalen, and tcp_Socket::unhappy.

_tcp_Socket* _tcp_unthread ( _tcp_Socket ds,
BOOL  free_tx 
)

Unthread a socket from the tcp socket list, if it's there.

Free Tx-buffer if set in tcp_SetWindow().

Definition at line 596 of file pctcp.c.

References tcp_Socket::next, tcp_Socket::state, tcp_Socket::tx_buf, tcp_Socket::tx_data, and tcp_Socket::tx_datalen.

void _udp_cancel ( const in_Header ip,
int  icmp_type,
int  icmp_code,
const char *  msg,
const void arg 
)

Cancel an UDP socket.

Called upon receiving ICMP errors: REDIRECT, TIMXCEED, PARAMPROB, or host/port UNREACH. See icmp_redirect() or icmp_handler().

Definition at line 1627 of file pctcp.c.

References _arp_resolve(), _ip_recursion, sock_reduce_mss(), and udp_close().

WORD init_localport ( void  )

Allocate the "lport_inuse" bit-array from heap.

Return values
Highestusable port.
Todo:

Make empherical port range configurable.

Use some hashing technique to speed up find_free_port().

Definition at line 52 of file ports.c.

References exit_localport().

void tcp_Retransmitter ( BOOL  force)

Variable Documentation

char hostname[MAX_HOSTLEN+1]

Our configured hostname.

Not the FQDN.

Definition at line 59 of file pctcp.c.

BOOL mtu_blackhole
Todo:
Add PMTU blackhole detection

Definition at line 64 of file pctcp.c.

BOOL mtu_discover
Todo:
Add PMTU discovery method

Definition at line 63 of file pctcp.c.

BOOL tcp_nagle

Misc TCP values.

Nagle algo. is on globally

Definition at line 131 of file pctcp.c.