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

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,...)
 This hook is to prevent the BSD-socket API being linked in by default. More...
 
int _tcp_fsm (_tcp_Socket **s, const in_Header *ip)
 
static _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.
 
static void tcp_sockreset (_tcp_Socket *s, BOOL proxy)
 Resets a TCP connection.
 
static void tcp_no_arp (_tcp_Socket *s)
 Called for a TCP socket when ARP lookup fails. More...
 
static void tcp_rtt_win (_tcp_Socket *s)
 Update retransmission timer, VJ algorithm and TCP windows. More...
 
static void tcp_upd_win (_tcp_Socket *s, unsigned line)
 Check if receive window needs an update.
 
static BOOL tcp_checksum (const in_Header *ip, const tcp_Header *tcp, int len)
 Verify the TCP header checksum. More...
 
static void udp_close (const _udp_Socket *udp)
 Since UDP is stateless, simply reclaim the local-port and unthread the socket from the list.
 
static void (W32_CALL *system_yield)(void)
 
int W32_CALL udp_listen (_udp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler)
 UDP passive open. More...
 
int W32_CALL udp_open (_udp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler)
 UDP active open. More...
 
int W32_CALL udp_SetTTL (_udp_Socket *s, BYTE ttl)
 Set the TTL on an outgoing UDP datagram.
 
int W32_CALL tcp_open (_tcp_Socket *s, WORD lport, DWORD ip, WORD rport, ProtoHandler handler)
 Actively open a TCP connection. More...
 
int W32_CALL tcp_listen (_tcp_Socket *s, WORD lport, DWORD ip, WORD port, ProtoHandler handler, WORD timeout)
 Passively opens TCP a connection. More...
 
void _tcp_close (_tcp_Socket *s)
 Close a TCP connection. More...
 
_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. More...
 
_tcp_Socket_tcp_unthread (_tcp_Socket *ds, BOOL free_tx)
 Unthread a socket from the tcp socket list, if it's there. More...
 
int W32_CALL 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. More...
 
static BOOL udp_checksum (const in_Header *ip, const udp_Header *udp, int len)
 Verify checksum for an UDP packet.
 
static _udp_Socketudp_demux (const in_Header *ip, BOOL ip_bcast, DWORD destin, WORD srcPort, WORD dstPort, BOOL *udp_err)
 Demultiplexer for incoming UDP packets. More...
 
_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. More...
 
WORD W32_CALL tcp_tick (sock_type *s)
 Must be called periodically by user application (or BSD socket API). More...
 
static int udp_write (_udp_Socket *s, const BYTE *data, int len)
 Write an UDP packet. More...
 
static int udp_read (_udp_Socket *s, BYTE *buf, int maxlen)
 Read from UDP socket. More...
 
static void sock_reduce_mss (sock_type *s, WORD MTU)
 Reduce socket MSS upon receiving ICMP_UNREACH_NEEDFRAG. More...
 
void _udp_cancel (const in_Header *ip, int icmp_type, int icmp_code, const char *msg, const void *arg)
 Cancel an UDP socket. More...
 
static 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. More...
 
static int tcp_read (_tcp_Socket *s, BYTE *buf, int maxlen)
 Read from a TCP socket. More...
 
static int tcp_write (_tcp_Socket *s, const BYTE *data, UINT len)
 Write data to a TCP connection. More...
 
static __inline int tcp_opt_maxsegment (const _tcp_Socket *s, BYTE *opt)
 TCP option routines. More...
 
static __inline int tcp_opt_timestamp (_tcp_Socket *s, BYTE *opt, DWORD ts_echo)
 Insert TimeStamp option. More...
 
static __inline int tcp_opt_md5_sign (BYTE *opt)
 
static __inline void finalise_md5_sign (const in_Header *ip, const tcp_Header *tcp, WORD tcp_len, const char *secret)
 
static __inline int tcp_opt_padding (BYTE *opt, int len)
 Pad options to multiple of 4 bytes.
 
static __inline int tcp_opt_winscale (const _tcp_Socket *s, BYTE *opt)
 
static __inline int tcp_opt_sack_ok (const _tcp_Socket *s, BYTE *opt)
 
static __inline int tcp_opt_sack (const _tcp_Socket *s, BYTE *opt, const struct SACK_list *sack)
 
static __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. More...
 
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. More...
 
int _tcp_keepalive (_tcp_Socket *tcp)
 TCP keepalive transmission. More...
 
int W32_CALL sock_keepalive (sock_type *s)
 
WORD W32_CALL sock_mode (sock_type *s, WORD mode)
 
VoidProc W32_CALL sock_yield (_tcp_Socket *s, VoidProc func)
 Enable user defined yield function. More...
 
int W32_CALL sock_abort (sock_type *s)
 Abort a UDP/TCP/Raw socket.
 
static int raw_read (_raw_Socket *raw, BYTE *buf, int maxlen)
 Read data from a raw-socket. More...
 
int W32_CALL sock_read (sock_type *s, BYTE *buf, size_t maxlen)
 Read a socket with maximum 'maxlen' bytes. More...
 
int W32_CALL sock_fastread (sock_type *s, BYTE *buf, int len)
 Read a socket with maximum 'len' bytes. More...
 
int W32_CALL sock_write (sock_type *s, const BYTE *data, int len)
 Writes data and returns length written. More...
 
int W32_CALL sock_fastwrite (sock_type *s, const BYTE *data, int len)
 Simpler, non-blocking (non-looping) version of sock_write(). More...
 
int W32_CALL sock_enqueue (sock_type *s, const BYTE *data, int len)
 For UDP, this function is same as sock_write(). More...
 
void W32_CALL sock_noflush (sock_type *s)
 Sets non-flush mode on next TCP write.
 
void W32_CALL sock_flush (sock_type *s)
 Send pending TCP data. More...
 
void W32_CALL sock_flushnext (sock_type *s)
 Causes next transmission to have a flush (PUSH bit set).
 
int W32_CALL sock_close (sock_type *s)
 Close a UDP/TCP socket.
 
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. More...
 
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
 TCP timer values. More...
 
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. More...
 
unsigned tcp_MAX_VJSD = DEF_MAX_VJSD
 Default max VJ std. More...
 
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
 Misc TCP values. More...
 
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
 
static BYTE * sign_opt
 Prepare to insert MD5 option.
 
static struct tcp_rtt rtt_cache [RTTCACHE]
 Round-trip timing cache routines. More...
 

Detailed Description

Main TCP handler.

PCTCP, the true worker of Waterloo TCP.

Definition in file pctcp.c.

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 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().

static 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 2849 of file pctcp.c.

References _raw_Socket::used.

int W32_CALL 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 3044 of file pctcp.c.

References tcp_Socket::tx_datalen, tcp_Socket::tx_queuelen, and udp_write().

int W32_CALL 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 2931 of file pctcp.c.

References _raw_Socket::ip_type, raw_read(), tcp_read(), and udp_read().

int W32_CALL 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 3018 of file pctcp.c.

References tcp_write(), and udp_write().

void W32_CALL sock_flush ( sock_type s)

Send pending TCP data.

If there is Tx-data to be sent, set the PUSH bit.

Definition at line 3103 of file pctcp.c.

References tcp_Socket::flags, tcp_Socket::send_una, and tcp_Socket::tx_datalen.

int W32_CALL sock_read ( sock_type s,
BYTE *  buf,
size_t  maxlen 
)

Read a socket with maximum 'maxlen' bytes.

Note
busywaits until 'buf' is full (and call 's->usr_yield').
Return values
0socket is not open.
<=maxlensocket has data to be read.

Definition at line 2875 of file pctcp.c.

References raw_read(), tcp_read(), tcp_tick(), and udp_read().

static 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 1598 of file pctcp.c.

References _inet_ntoa(), and tcp_Socket::max_seg.

int W32_CALL 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
0if some error in lower layer.
'len'if all data sent okay.

Definition at line 2960 of file pctcp.c.

References tcp_Socket::flags, tcp_tick(), tcp_write(), and udp_write().

VoidProc W32_CALL sock_yield ( _tcp_Socket s,
VoidProc  func 
)

Enable user defined yield function.

Return address of previous yield function.

Definition at line 2803 of file pctcp.c.

static 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 2037 of file pctcp.c.

int W32_CALL tcp_listen ( _tcp_Socket s,
WORD  lport,
DWORD  ip,
WORD  port,
ProtoHandler  handler,
WORD  timeout 
)
static 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 2012 of file pctcp.c.

References _bsd_socket_hook().

int W32_CALL 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
0on 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()
Todo:
use TCP_NODELAY set in setsockopt()

Definition at line 308 of file pctcp.c.

References _arp_start_lookup(), _default_ttl, _eth_is_init, _inet_ntoa(), _tcp_allsocs, _tcp_unthread(), tcp_Socket::cwindow, tcp_Socket::flags, tcp_Socket::max_seg, tcp_Socket::max_tx_data, my_ip_addr, tcp_Socket::next, tcp_Socket::rto, tcp_Socket::rx_buf, tcp_Socket::safetysig, tcp_Socket::safetytcp, tcp_Socket::send_next, tcp_Socket::state, tcp_nagle, tcp_OPEN_TO, tcp_Socket::tx_buf, tcp_Socket::tx_data, tcp_Socket::unhappy, tcp_Socket::vj_sa, and tcp_Socket::wwindow.

static __inline int tcp_opt_maxsegment ( const _tcp_Socket s,
BYTE *  opt 
)
static

TCP option routines.

Note
Each of these MUST add multiple of 4 bytes of options. Insert MSS option.

Definition at line 2179 of file pctcp.c.

References tcp_Socket::max_seg.

static __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 2192 of file pctcp.c.

References set_timeout(), start_time, and tcp_Socket::ts_sent.

static 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 1828 of file pctcp.c.

References _tcp_close(), tcp_Socket::missed_seq, tcp_Socket::recv_next, tcp_Socket::state, and tcp_upd_win().

void tcp_Retransmitter ( BOOL  force)
static 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 the threshold to signify "end-of-Slow-Start" (equilibrium)

Definition at line 2063 of file pctcp.c.

References chk_timeout(), cmp_timers(), tcp_Socket::cwindow, tcp_Socket::datatimer, 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 W32_CALL 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
0if 's' is non-NULL and 's' closes.
!0if '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 1389 of file pctcp.c.

References _arp_handler(), _eth_arrived(), _eth_free(), _ip4_handler(), _rarp_handler(), _tcp_unthread(), pppoe_handler(), tcp_Socket::state, and tcp_Retransmitter().

static int tcp_write ( _tcp_Socket s,
const BYTE *  data,
UINT  len 
)
static

Write data to a TCP connection.

Return values
>0Number of bytes written.
0Connection is not established.
-1Error in lower layer.

Definition at line 1876 of file pctcp.c.

References 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, and tcp_Socket::unhappy.

static _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 873 of file pctcp.c.

References udp_Socket::his6addr, udp_Socket::my6addr, udp_Socket::safetysig, and sin_mask.

int W32_CALL 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 157 of file pctcp.c.

References _default_ttl, _eth_is_init, _udp_allsocs, udp_Socket::rx_buf, udp_Socket::safetysig, and udp_close().

int W32_CALL 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 192 of file pctcp.c.

References _arp_resolve(), _default_ttl, _eth_is_init, _inet_ntoa(), _udp_allsocs, my_ip_addr, udp_Socket::rx_buf, udp_Socket::safetysig, sin_mask, and udp_close().

static 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 1571 of file pctcp.c.

static 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 1491 of file pctcp.c.

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

Variable Documentation

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

Our configured hostname.

Not the FQDN.

Definition at line 59 of file pctcp.c.

BOOL mtu_blackhole = 0
Todo:
Add PMTU blackhole detection

Definition at line 64 of file pctcp.c.

BOOL mtu_discover = 0
Todo:
Add PMTU discovery method

Definition at line 63 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 3173 of file pctcp.c.

unsigned tcp_MAX_VJSA = DEF_MAX_VJSA

Default max VJ std.

average

Definition at line 120 of file pctcp.c.

unsigned tcp_MAX_VJSD = DEF_MAX_VJSD

Default max VJ std.

deviation

Definition at line 121 of file pctcp.c.

BOOL tcp_nagle = TRUE

Misc TCP values.

Nagle algo. is on globally

Definition at line 131 of file pctcp.c.

unsigned tcp_OPEN_TO = DEF_OPEN_TO

TCP timer values.

Default open timeout

Definition at line 113 of file pctcp.c.