Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

SRC/PCTCP.C File Reference


Detailed Description

Main TCP handler.

PCTCP, the true worker of Waterloo TCP.

Definition in file PCTCP.C.

Go to the source code of this file.

Data Structures

struct  ip4_packet
struct  ip6_packet
struct  tcp_pkt
struct  tcp6_pkt

Functions

void *MS_CDECL * _bsd_socket_hook (enum BSD_SOCKET_OPS op,...)=NULL
 This hook is to prevent the BSD-socket API being linked in by default.
int _tcp_fsm (_tcp_Socket **s, const in_Header *ip)
_tcp_Sockettcp_findseq (const in_Header *ip, const tcp_Header *tcp)
 Find the TCP socket that matches the tripplet: DESTADDR=MYADDR, DESTPORT=MYPORT and ACKNUM=SEQNUM+1 Can only be one socket.
void tcp_sockreset (_tcp_Socket *s, BOOL proxy)
 Resets a TCP connection.
void tcp_no_arp (_tcp_Socket *s)
 Called for a TCP socket when ARP lookup fails.
void tcp_rtt_win (_tcp_Socket *s)
 Update retransmission timer, VJ algorithm and TCP windows.
void tcp_upd_win (_tcp_Socket *s, unsigned line)
 Check if receive window needs an update.
BOOL tcp_checksum (const in_Header *ip, const tcp_Header *tcp, int len)
 Verify the TCP header checksum.
void run_daemons (void)
 Waterloo "background" daemon processes.
void udp_close (const _udp_Socket *s)
 Since UDP is stateless, simply reclaim the local-port and unthread the socket from the list.
int udp_listen (_udp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler)
 UDP passive open.
int udp_open (_udp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler)
 UDP active open.
void udp_SetTTL (_udp_Socket *s, BYTE ttl)
 Set the TTL on an outgoing UDP datagram.
int tcp_open (_tcp_Socket *s, WORD lport, DWORD ip, WORD rport, ProtoHandler handler)
 Actively open a TCP connection.
int tcp_listen (_tcp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler, WORD timeout)
 Passively opens TCP a connection.
void _tcp_close (_tcp_Socket *s)
 Close a TCP connection.
_tcp_Socket_tcp_abort (_tcp_Socket *s, const char *file, unsigned line)
 Abort a TCP connection.
int _tcp_sendsoon (_tcp_Socket *s, const char *file, unsigned line)
 Schedule a transmission pretty soon.
_tcp_Socket_tcp_unthread (_tcp_Socket *ds, BOOL free_tx)
 Unthread a socket from the tcp socket list, if it's there.
int tcp_established (const _tcp_Socket *s)
 Returns 1 if TCP connection is established.
_tcp_Socket_tcp_handler (const in_Header *ip, BOOL broadcast)
 The main TCP input handler.
BOOL udp_checksum (const in_Header *ip, const udp_Header *udp, int len)
 Verify checksum for an UDP packet.
_udp_Socketudp_demux (const in_Header *ip, BOOL ip_bcast, DWORD destin, WORD srcPort, WORD dstPort, BOOL *udp_err)
 Demultiplexer for incoming UDP packets.
_udp_Socket_udp_handler (const in_Header *ip, BOOL broadcast)
 Handler for incoming UDP packets.
void tcp_Retransmitter (BOOL force)
 Called periodically to perform retransmissions.
WORD tcp_tick (sock_type *s)
 Must be called periodically by user application (or BSD socket API).
int udp_write (_udp_Socket *s, const BYTE *data, int len)
 Write an UDP packet.
int udp_read (_udp_Socket *s, BYTE *buf, int maxlen)
 Read from UDP socket.
void sock_reduce_mss (sock_type *s, WORD MTU)
 Reduce socket MSS upon receiving ICMP_UNREACH_NEEDFRAG.
void _udp_cancel (const in_Header *ip, int icmp_type, int icmp_code, const char *msg, const void *arg)
 Cancel an UDP socket.
BOOL tcp_stress_test (_tcp_Socket *s, const char *msg)
void _tcp_cancel (const in_Header *ip, int icmp_type, int icmp_code, const char *msg, const void *arg)
 Cancel a TCP socket.
int tcp_read (_tcp_Socket *s, BYTE *buf, int maxlen)
 Read from a TCP socket.
int tcp_write (_tcp_Socket *s, const BYTE *data, UINT len)
 Write data to a TCP connection.
__inline int tcp_opt_maxsegment (const _tcp_Socket *s, BYTE *opt)
 Insert MSS option.
__inline int tcp_opt_timestamp (_tcp_Socket *s, BYTE *opt, DWORD ts_echo)
 Insert TimeStamp option.
__inline int tcp_opt_md5_sign (BYTE *opt)
__inline void finalise_md5_sign (const in_Header *ip, const tcp_Header *tcp, WORD tcp_len, const char *secret)
__inline int tcp_opt_padding (BYTE *opt, int len)
 Pad options to multiple of 4 bytes.
__inline int tcp_opt_winscale (const _tcp_Socket *s, BYTE *opt)
__inline int tcp_opt_sack_ok (const _tcp_Socket *s, BYTE *opt)
__inline int tcp_opt_sack (const _tcp_Socket *s, BYTE *opt, const struct SACK_list *sack)
__inline int tcp_options (_tcp_Socket *s, BYTE *opt, BOOL is_syn)
 Append options to output TCP header.
int _tcp_send (_tcp_Socket *s, const char *file, unsigned line)
 Format and send an outgoing TCP segment.
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.
int _tcp_keepalive (_tcp_Socket *tcp)
 TCP keepalive transmission.
int sock_keepalive (sock_type *s)
WORD sock_mode (sock_type *s, WORD mode)
void(*)(void) sock_yield (_tcp_Socket *s, void(*fn)(void))
 Enable user defined yield function.
void sock_abort (sock_type *s)
 Abort a UDP/TCP/Raw socket.
int raw_read (_raw_Socket *raw, BYTE *buf, int maxlen)
 Read data from a raw-socket.
int sock_read (sock_type *s, BYTE *buf, int maxlen)
 Read a socket with maximum 'maxlen' bytes.
int sock_fastread (sock_type *s, BYTE *buf, int len)
 Read a socket with maximum 'len' bytes.
int sock_write (sock_type *s, const BYTE *data, int len)
 Writes data and returns length written.
int sock_fastwrite (sock_type *s, const BYTE *data, int len)
 Simpler, non-blocking (non-looping) version of sock_write().
int sock_enqueue (sock_type *s, const BYTE *data, int len)
 For UDP, this function is same as sock_write().
void sock_noflush (sock_type *s)
 Sets non-flush mode on next TCP write.
void sock_flush (sock_type *s)
 Send pending TCP data.
void sock_flushnext (sock_type *s)
 Causes next transmission to have a flush (PUSH bit set).
int sock_close (sock_type *s)
 Close a UDP/TCP socket.
int addwattcpd (void(*func)(void))
 Add a function to background daemon list.
int delwattcpd (void(*func)(void))
 Remove a function from background daemon list.
void stopwattcpd (void)
void tcp_rtt_add (const _tcp_Socket *s, UINT rto, UINT MTU)
BOOL tcp_rtt_get (const _tcp_Socket *s, UINT *rto, UINT *MTU)
void tcp_rtt_clr (const _tcp_Socket *s)

Variables

char hostname [MAX_HOSTLEN+1] = "random-pc"
 Our configured hostname.
unsigned _mss = ETH_MAX_DATA - TCP_OVERHEAD
unsigned _mtu = ETH_MAX_DATA
BOOL mtu_discover = 0
BOOL mtu_blackhole = 0
BOOL block_tcp = 0
 when application handles TCP itself
BOOL block_udp = 0
 when application handles UDP itself
BOOL block_icmp = 0
 when application handles ICMP itself
BOOL block_ip = 0
 when application handles IP itself
DWORD my_ip_addr = 0L
 our IP address
DWORD sin_mask = 0xFFFFFF00L
 our net-mask, 255.255.255.0
_udp_Socket_udp_allsocs = NULL
 list of udp-sockets
unsigned tcp_OPEN_TO = DEF_OPEN_TO
 Default open timeout.
unsigned tcp_CLOSE_TO = DEF_CLOSE_TO
 Default close timeout.
unsigned tcp_RTO_ADD = DEF_RTO_ADD
 Time added in RTO calculation.
unsigned tcp_RTO_BASE = DEF_RTO_BASE
 Base time for RTO calculation.
unsigned tcp_RTO_SCALE = DEF_RTO_SCALE
 Scaling used in RTO calculation.
unsigned tcp_RST_TIME = DEF_RST_TIME
 Don't generate RST too often.
unsigned tcp_RETRAN_TIME = DEF_RETRAN_TIME
 Default retransmission time.
unsigned tcp_MAX_VJSA = DEF_MAX_VJSA
 Default max VJ std.
unsigned tcp_MAX_VJSD = DEF_MAX_VJSD
 Default max VJ std.
BOOL tcp_opt_ts = FALSE
 TCP option config flags (RFC 1323).
BOOL tcp_opt_wscale = FALSE
BOOL tcp_opt_sack = FALSE
BOOL tcp_nagle = TRUE
 Nagle algo.
unsigned tcp_keep_idle = 2*60
 idle time before sending keepalive
unsigned tcp_keep_intvl = 30
 time between keepalive probes
unsigned tcp_max_idle = 60
 max idle time before kill
DWORD tcp_recv_win = DEF_RECV_WIN
 RWIN for BSD sockets only.
_tcp_Socket_tcp_allsocs = NULL
 list of tcp-sockets
DWORD daemon_timer = 0UL
 When to run "background" processes.
void(* system_yield )(void)=NULL
BYTEsign_opt
 Prepare to insert MD5 option.
struct {
   void(*   func )(void)
   BOOL   running
MAX_DAEMONS
 List of background processes.
tcp_rtt rtt_cache [RTTCACHE]
 Round-trip timing cache routines.


Function Documentation

void* MS_CDECL* _bsd_socket_hook enum BSD_SOCKET_OPS  op,
  ...
 

This hook is to prevent the BSD-socket API being linked in by default.

It is only set from the BSD functions when needed.

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 1747 of file PCTCP.C.

References _arp_resolve(), _ip_recursion, _tcp_allsocs, BYTE, _tcp_Socket::cwindow, in_Header::destination, DWORD, _tcp_Socket::next, _tcp_Socket::rto, sock_reduce_mss(), _tcp_Socket::state, _tcp_Socket::vj_sa, _tcp_Socket::vj_sd, WORD, 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 464 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
 

The main TCP input handler.

All TCP input processing is done from here. Definition at line 653 of file PCTCP.C.

References _ip6_tcp_checksum(), _tcp_allsocs, _tcp_Socket::adv_win, block_tcp, BYTE, in_Header::destination, in6_Header::destination, DWORD, _tcp_Socket::his6addr, _tcp_Socket::inactive_to, ip6_address, in6_Header::len, in_Header::length, _tcp_Socket::my6addr, _tcp_Socket::next, _tcp_Socket::recv_next, _tcp_Socket::safetysig, _tcp_Socket::safetytcp, set_timeout(), in_Header::source, in6_Header::source, tcp_checksum(), tcp_findseq(), tcp_rtt_win(), tcp_sockreset(), _tcp_Socket::unhappy, in_Header::ver, and WORD.

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 2710 of file PCTCP.C.

References BYTE, and DWORD.

int _tcp_send _tcp_Socket s,
const char *  file,
unsigned  line
 

Format and send an outgoing TCP segment.

Several packets may be sent depending on peer's window. Definition at line 2351 of file PCTCP.C.

References _eth_formatpacket(), _ip4_output(), _ip6_checksum(), _ip6_output(), _pktserial, _tcp_Socket::adv_win, BYTE, tcp_PseudoHeader::checksum, _tcp_Socket::cwindow, tcp_PseudoHeader::dst, _tcp_Socket::flags, _tcp_Socket::his6addr, _tcp_Socket::karn_count, tcp_PseudoHeader::length, _tcp_Socket::max_seg, _tcp_Socket::my6addr, tcp_PseudoHeader::protocol, _tcp_Socket::recent, _tcp_Socket::recv_next, _tcp_Socket::rto, _tcp_Socket::rtt_lasttran, _tcp_Socket::rtt_time, _tcp_Socket::safetysig, _tcp_Socket::safetytcp, _tcp_Socket::secret, _tcp_Socket::send_next, _tcp_Socket::send_una, set_timeout(), tcp_PseudoHeader::src, tcp_options(), tcp_RTO_ADD, _tcp_Socket::tos, _tcp_Socket::tx_data, _tcp_Socket::tx_datalen, _tcp_Socket::tx_queue, _tcp_Socket::tx_queuelen, _tcp_Socket::unhappy, _tcp_Socket::vj_last, _tcp_Socket::window, and WORD.

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 2567 of file PCTCP.C.

References _default_ttl, _eth_formatpacket(), _ip4_output(), _ip6_checksum(), _ip6_output(), tcp_Header::acknum, BYTE, chk_timeout(), in6_Header::destination, in_Header::destination, tcp_Header::dstPort, DWORD, tcp_Header::flags, in6_Header::len, in_Header::length, tcp_Header::offset, _tcp_Socket::secret, tcp_Header::seqnum, set_timeout(), in6_Header::source, in_Header::source, tcp_Header::srcPort, tcp_RST_TIME, in_Header::tos, in_Header::ver, and WORD.

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 563 of file PCTCP.C.

References _tcp_send(), cmp_timers(), DWORD, _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 604 of file PCTCP.C.

References _tcp_allsocs, DWORD, _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 1639 of file PCTCP.C.

References _arp_resolve(), _ip_recursion, _udp_allsocs, BYTE, in_Header::destination, DWORD, _udp_Socket::next, sock_reduce_mss(), udp_close(), and WORD.

int raw_read _raw_Socket raw,
BYTE buf,
int  maxlen
[static]
 

Read data from a raw-socket.

Don't copy IP-header to buf. Definition at line 2860 of file PCTCP.C.

References BYTE, _raw_Socket::ip, in_Header::length, and _raw_Socket::used.

void run_daemons void   )  [static]
 

Waterloo "background" daemon processes.

Called from tcp_tick() at each DAEMON_PERIOD interval. Definition at line 3178 of file PCTCP.C.

int sock_enqueue sock_type s,
const BYTE data,
int  len
 

For UDP, this function is same as sock_write().

For TCP, this function enqueues 'data' to transmit queue.

Note:
user must not touch 'data' while sock_tbused() returns > 0.
Definition at line 3050 of file PCTCP.C.

int sock_fastread sock_type s,
BYTE buf,
int  len
 

Read a socket with maximum 'len' bytes.

Note:
does not busywait until buffer is full.
Definition at line 2938 of file PCTCP.C.

int sock_fastwrite sock_type s,
const BYTE data,
int  len
 

Simpler, non-blocking (non-looping) version of sock_write().

Note:
UDP writes may truncate; check the return value.
Definition at line 3024 of file PCTCP.C.

void sock_flush sock_type s  ) 
 

Send pending TCP data.

If there is Tx-data to be sent, set the PUSH bit. Definition at line 3109 of file PCTCP.C.

int sock_read sock_type s,
BYTE buf,
int  maxlen
 

Read a socket with maximum 'maxlen' bytes.

Note:
busywaits until 'buf' is full (and call 's->usr_yield').
Return values:
0 socket is not open.
<=maxlen socket has data to be read.
Definition at line 2886 of file PCTCP.C.

void sock_reduce_mss sock_type s,
WORD  MTU
[static]
 

Reduce socket MSS upon receiving ICMP_UNREACH_NEEDFRAG.

'MTU' is next-hop suggested MTU or 0 if router doesn't support RFC-1191. Definition at line 1610 of file PCTCP.C.

References _inet_ntoa(), sock_type::tcp, and WORD.

int sock_write sock_type s,
const BYTE data,
int  len
 

Writes data and returns length written.

Note:
sends with PUSH-bit (flush data).

repeatedly calls 's->usr_yield'.

UDP packetsare sent in chunks of MTU-28.

Return values:
0 if some error in lower layer.
'len' if all data sent okay.
Definition at line 2967 of file PCTCP.C.

void(*)(void) sock_yield  ) 
 

Enable user defined yield function.

Return address of previous yield function. Definition at line 2815 of file PCTCP.C.

BOOL tcp_checksum const in_Header ip,
const tcp_Header tcp,
int  len
[static]
 

Verify the TCP header checksum.

Note:
Not used for IPv6.
Definition at line 2049 of file PCTCP.C.

References tcp_PseudoHeader::checksum, in_Header::destination, tcp_PseudoHeader::dst, tcp_PseudoHeader::length, tcp_PseudoHeader::protocol, in_Header::source, and tcp_PseudoHeader::src.

int tcp_listen _tcp_Socket s,
WORD  lport,
DWORD  ip,
WORD  port,
ProtoHandler  handler,
WORD  timeout
 

Passively opens TCP a connection.

Listen for a connection on a particular port

<

Todo:
use mss from setsockopt()
Definition at line 398 of file PCTCP.C.

void tcp_no_arp _tcp_Socket s  )  [static]
 

Called for a TCP socket when ARP lookup fails.

If socket allocated by BSD API, do a read wakeup on it. Definition at line 2024 of file PCTCP.C.

References _bsd_socket_hook().

int tcp_open _tcp_Socket s,
WORD  lport,
DWORD  ip,
WORD  rport,
ProtoHandler  handler
 

Actively open a TCP connection.

Make connection to a particular destination. Not used for IPv6 (see _TCP6_open()).

Return values:
0 on error. 's->err_msg' filled.
Note:
'lport' is local port to associate with the connection.

'rport' is remote port for same connection.

<

Todo:
use mss from setsockopt()

use TCP_NODELAY set in setsockopt()

Definition at line 317 of file PCTCP.C.

__inline int tcp_opt_timestamp _tcp_Socket s,
BYTE opt,
DWORD  ts_echo
[static]
 

Insert TimeStamp option.

nmap uses TSval (ts_now) as indication of uptime, so send # of msec since started. Definition at line 2204 of file PCTCP.C.

References BYTE, DWORD, set_timeout(), start_time, and _tcp_Socket::ts_sent.

int tcp_read _tcp_Socket s,
BYTE buf,
int  maxlen
[static]
 

Read from a TCP socket.

  • buf where to put data.
    Note:
    does large buffering.
Definition at line 1840 of file PCTCP.C.

References _tcp_close(), BYTE, _tcp_Socket::missed_seq, _tcp_Socket::recv_next, _tcp_Socket::state, tcp_read(), and tcp_upd_win().

void tcp_Retransmitter BOOL  force  ) 
 

Called periodically to perform retransmissions.

  • if 'force == 1' do it now.

< dup ACK counter ?

<

Todo:
set "Slow-start" threshold

Allow for 3 SYN before giving up

< Definition at line 1217 of file PCTCP.C.

References _tcp_allsocs, _tcp_unthread(), arp_lookup(), arp_lookup_pending(), BYTE, chk_timeout(), DWORD, get_timediff(), _tcp_Socket::next, _tcp_Socket::rtt_time, set_timeout(), sock_close(), _tcp_Socket::state, tcp_no_arp(), tcp_OPEN_TO, tcp_RETRAN_TIME, _tcp_Socket::timeout, and UINT.

void tcp_rtt_win _tcp_Socket s  )  [static]
 

Update retransmission timer, VJ algorithm and TCP windows.

Only called after we received something on socket.

Todo:
Use TimeStamp option values

Use the threshold to signify "end-of-Slow-Start" (equilibrium)

Definition at line 2075 of file PCTCP.C.

References chk_timeout(), cmp_timers(), _tcp_Socket::cwindow, _tcp_Socket::datatimer, DWORD, get_timediff(), _tcp_Socket::karn_count, _tcp_Socket::max_seg, _tcp_Socket::rto, _tcp_Socket::rtt_time, _tcp_Socket::send_una, set_timeout(), tcp_MAX_VJSA, tcp_MAX_VJSD, tcp_RTO_ADD, tcp_RTO_BASE, _tcp_Socket::ts_echo, _tcp_Socket::ts_sent, _tcp_Socket::vj_last, _tcp_Socket::vj_sa, _tcp_Socket::vj_sd, and _tcp_Socket::wwindow.

WORD tcp_tick sock_type s  ) 
 

Must be called periodically by user application (or BSD socket API).

  • if 's != NULL', check this socket for timeout.
  • if 's == NULL', check all sockets in list.
Return values:
0 if 's' is non-NULL and 's' closes.
!0 if 's' is NULL or 's' is still open.

Don't enter this loop if reentered. That could return the same packet twice (before we call _eth_free() on the 1st packet).

Todo:
Limit the time spent here (clamp # of loops)
Definition at line 1397 of file PCTCP.C.

References _arp_handler(), _eth_arrived(), _eth_free(), _ip4_handler(), _rarp_handler(), _tcp_unthread(), chk_timeout(), daemon_timer, pppoe_handler(), run_daemons(), set_timeout(), _tcp_Socket::state, sock_type::tcp, tcp_Retransmitter(), and WORD.

int tcp_write _tcp_Socket s,
const BYTE data,
UINT  len
[static]
 

Write data to a TCP connection.

Return values:
>0 Number of bytes written.
0 Connection is not established.
-1 Error in lower layer.
Definition at line 1888 of file PCTCP.C.

References BYTE, _tcp_Socket::datatimer, _tcp_Socket::max_seg, _tcp_Socket::max_tx_data, set_timeout(), _tcp_Socket::state, _tcp_Socket::tx_data, _tcp_Socket::tx_datalen, UINT, and _tcp_Socket::unhappy.

_udp_Socket* udp_demux const in_Header ip,
BOOL  ip_bcast,
DWORD  destin,
WORD  srcPort,
WORD  dstPort,
BOOL *  udp_err
[static]
 

Demultiplexer for incoming UDP packets.

Don't debug packet if no match was found (except if '*udp_err').

Demux to active sockets.

Todo:
use some kind of hashing to speed up the search.
Definition at line 881 of file PCTCP.C.

References _udp_allsocs, in6_Header::destination, DWORD, _udp_Socket::his6addr, ip6_address, _udp_Socket::my6addr, _udp_Socket::next, _udp_Socket::safetysig, sin_mask, in_Header::source, in6_Header::source, in_Header::ver, and WORD.

int udp_listen _udp_Socket s,
WORD  lport,
DWORD  ip,
WORD  port,
ProtoHandler  handler
 

UDP passive open.

Listen for a connection on a particular port. Definition at line 167 of file PCTCP.C.

int udp_open _udp_Socket s,
WORD  lport,
DWORD  ip,
WORD  port,
ProtoHandler  handler
 

UDP active open.

Open a connection on a particular port. Definition at line 202 of file PCTCP.C.

int udp_read _udp_Socket s,
BYTE buf,
int  maxlen
[static]
 

Read from UDP socket.

  • buf where data is put.
  • maxlen read max this amount.
    Note:
    does large buffering.
Definition at line 1583 of file PCTCP.C.

References BYTE, and udp_read().

int udp_write _udp_Socket s,
const BYTE data,
int  len
[static]
 

Write an UDP packet.

Note:
Assumes data fits in one datagram, else only the first fragment will be sent! Because MTU is used for splits, the guaranteed max data size is 'MTU - UDP_OVERHEAD = 548' for a non-fragmented datagram. Routers should handle at least 576 bytes datagrams.
Definition at line 1503 of file PCTCP.C.

References _default_tos, _eth_formatpacket(), _ip6_checksum(), _pktserial, BYTE, and _udp_Socket::his6addr.


Variable Documentation

char hostname[MAX_HOSTLEN+1] = "random-pc"
 

Our configured hostname.

Not the FQDN. Definition at line 66 of file PCTCP.C.

struct { ... } MAX_DAEMONS [static]
 

List of background processes.

Note:
there can be no more than MAX_DAEMONS background processes.

BOOL mtu_blackhole = 0
 

Todo:
Add PMTU blackhole detection
Definition at line 71 of file PCTCP.C.

BOOL mtu_discover = 0
 

Todo:
Add PMTU discovery method
Definition at line 70 of file PCTCP.C.

struct tcp_rtt rtt_cache[RTTCACHE] [static]
 

Round-trip timing cache routines.

These functions implement a very simple system for keeping track of network performance for future use in new connections. The emphasis here is on speed of update (rather than optimum cache hit ratio) since tcp_rtt_add() is called every time a TCP connection updates its round trip estimate.

Note:
'rto' is either in ticks or milli-sec depending on if PC has an 8254 Time chip.
These routines are modified versions from KA9Q by Phil Karn. Definition at line 3265 of file PCTCP.C.

unsigned tcp_MAX_VJSA = DEF_MAX_VJSA
 

Default max VJ std.

average Definition at line 127 of file PCTCP.C.

unsigned tcp_MAX_VJSD = DEF_MAX_VJSD
 

Default max VJ std.

deviation Definition at line 128 of file PCTCP.C.

BOOL tcp_nagle = TRUE
 

Nagle algo.

is on globally Definition at line 138 of file PCTCP.C.


Generated on Wed Aug 4 08:55:58 2010 for Watt-32 tcp/ip by doxygen 1.3.8