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

inc/tcp.h File Reference


Detailed Description

Watt-32 public API.

Definition in file tcp.h.

Go to the source code of this file.

Data Structures

struct  tcp_Socket
struct  udp_Socket
struct  config_table
struct  DHCP_config
struct  watt_sockaddr

Typedefs

typedef BYTE eth_address [6]
typedef BYTE ip6_address [16]
typedef int(* ProtoHandler )(void *sock, const BYTE *data, unsigned len, const void *tcp_phdr, const void *udp_hdr)
typedef int(* UserHandler )(void *sock)
typedef void(* VoidProc )(void)
typedef long(* WattUserConfigFunc )(int pass, const struct config_table *cfg)
typedef int(* WattDHCPConfigFunc )(enum DHCP_config_op op, struct DHCP_config *cfg)

Enumerations

enum  config_tab_types {
  ARG_ATOI,
  ARG_ATOB,
  ARG_ATOW,
  ARG_ATOIP,
  ARG_ATOX_B,
  ARG_ATOX_W,
  ARG_ATOX_D,
  ARG_STRDUP,
  ARG_STRCPY,
  ARG_RESOLVE,
  ARG_FUNC
}
enum  DHCP_config_op {
  DHCP_OP_READ = 0,
  DHCP_OP_WRITE = 1,
  DHCP_OP_ERASE = 2
}
enum  TCP_SIMPLE_STATE {
  TCP_CLOSED,
  TCP_LISTENING,
  TCP_OPENING,
  TCP_OPEN,
  TCP_CLOSING
}
enum  _optmode {
  GETOPT_UNIX,
  GETOPT_ANY,
  GETOPT_KEEP
}

Functions

W32_FUNC const char * wattcpVersion (void)
W32_FUNC const char * wattcpCapabilities (void)
W32_FUNC int watt_sock_init (size_t, size_t, size_t)
W32_FUNC const char * sock_init_err (int rc)
W32_FUNC void sock_exit (void)
 Our only atexit() handler.
W32_FUNC void dbug_init (void)
W32_FUNC void init_misc (void)
 Initialise various stuff.
W32_FUNC void sock_sig_exit (const char *msg, int sigint)
 Exit handler for unhandled signals.
W32_FUNC int sock_read (void *s, char *dp, int len)
W32_FUNC int sock_preread (void *s, char *dp, int len)
W32_FUNC int sock_fastread (void *s, char *dp, int len)
W32_FUNC int sock_write (void *s, const char *dp, int len)
W32_FUNC int sock_enqueue (void *s, const char *dp, int len)
W32_FUNC int sock_fastwrite (void *s, const char *dp, int len)
W32_FUNC size_t sock_setbuf (void *s, char *buf, size_t len)
W32_FUNC void sock_flush (void *s)
W32_FUNC void sock_noflush (void *s)
W32_FUNC void sock_flushnext (void *s)
W32_FUNC int sock_puts (void *s, const char *dp)
W32_FUNC WORD sock_gets (void *s, char *dp, int n)
W32_FUNC BYTE sock_putc (void *s, char c)
W32_FUNC int sock_getc (void *s)
W32_FUNC WORD sock_dataready (void *s)
W32_FUNC int sock_established (void *s)
W32_FUNC int sock_close (void *s)
W32_FUNC int sock_abort (void *s)
W32_FUNC int sock_mode (void *s, WORD mode)
W32_FUNC int sock_sselect (void *s, int waitstate)
W32_FUNC int sock_timeout (void *s, int seconds)
W32_FUNC int sock_recv (void *s, char *buf, unsigned len)
W32_FUNC int sock_recv_init (void *s, char *buf, unsigned len)
W32_FUNC int sock_recv_from (void *s, DWORD *ip, WORD *port, char *buf, unsigned len, int peek)
W32_FUNC int sock_recv_used (void *s)
W32_FUNC int sock_keepalive (void *s)
W32_FUNC size_t sock_rbsize (const void *s)
W32_FUNC size_t sock_rbused (const void *s)
W32_FUNC size_t sock_rbleft (const void *s)
W32_FUNC size_t sock_tbsize (const void *s)
W32_FUNC size_t sock_tbused (const void *s)
W32_FUNC size_t sock_tbleft (const void *s)
W32_FUNC int MS_CDECL sock_printf (void *s, const char *fmt,...) __attribute__((format(printf
W32_FUNC int MS_CDECL sock_scanf (void *s, const char *fmt,...) __attribute__((format(scanf
W32_FUNC int udp_open (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
W32_FUNC int tcp_open (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
W32_FUNC int udp_listen (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
W32_FUNC int tcp_listen (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler, WORD timeout)
W32_FUNC int tcp_established (const void *s)
W32_FUNC DWORD resolve (const char *name)
 Convert host name to an address.
W32_FUNC int resolve_ip (DWORD ip, char *name, int len)
W32_FUNC DWORD lookup_host (const char *host, char *ip_str)
W32_FUNC const char * dom_strerror (int err)
 Return text for error code (dom_errno).
W32_FUNC int tcp_cbreak (int mode)
 Sets our break mode.
W32_FUNC DWORD aton (const char *name)
 Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address.
W32_FUNC int isaddr (const char *name)
 Check if 'str' is simply an ip address.
W32_FUNC char * rip (char *s)
 Removes end-of-line termination from a string.
W32_FUNC int watt_kbhit (void)
 A less CPU hogging kbhit().
W32_FUNC const char * tcp_md5_secret (void *s, const char *secret)
W32_FUNC DWORD set_timeout (DWORD msec)
 Return time for when given timeout (msec) expires.
W32_FUNC int chk_timeout (DWORD value)
 Check if milli-sec value has expired:.
W32_FUNC int cmp_timers (DWORD t1, DWORD t2)
 Compare two timers with expirary at 't1' and 't2'.
W32_FUNC int set_timediff (long msec)
 Must be called by user right before or after a time change occurs.
W32_FUNC long get_timediff (DWORD now, DWORD t)
 Return time difference between timers 'now' and 'tim'.
W32_FUNC int hires_timer (int on)
 Control use of high-resolution timer.
W32_FUNC double timeval_diff (const struct timeval *a, const struct timeval *b)
W32_FUNC void init_timer_isr (void)
W32_FUNC void exit_timer_isr (void)
W32_FUNC void init_userSuppliedTimerTick (void)
 init_userSuppliedTimerTick() - setup timer handling for programs that are already running a periodic interrupt or whatever (i.e.
W32_FUNC void userTimerTick (DWORD)
 Provide timer-ticks from an application.
W32_FUNC void ip_timer_init (sock_type *s, unsigned delayseconds)
W32_FUNC int ip_timer_expired (const sock_type *s)
W32_FUNC void sock_debugdump (const sock_type *s)
W32_FUNC long tcp_config (const char *path)
W32_FUNC WORD tcp_tick (sock_type *s)
 Must be called periodically by user application (or BSD socket API).
W32_FUNC void tcp_set_debug_state (WORD x)
 Used when DEBUG=x is defined in the config file Moved from pctcp.c.
W32_FUNC int _ip_delay0 (void *s, int sec, UserHandler fn, void *statusptr)
W32_FUNC int _ip_delay1 (void *s, int sec, UserHandler fn, void *statusptr)
W32_FUNC int _ip_delay2 (void *s, int sec, UserHandler fn, void *statusptr)
W32_FUNC int parse_config_table (const struct config_table *tab, const char *section, const char *name, const char *value)
 Parse the config-table and if a match is found for ('section'+'.'+)'name' either store variable to 'value' or call function with 'value'.
W32_FUNC void tcp_inject_config (const struct config_table *cfg, const char *key, const char *value)
 Callable from a user application to inject config values before the normal WATTCP.CFG is loaded and parsed.
W32_FUNC WattUserConfigFunc _watt_user_config (WattUserConfigFunc fn)
 A user application may call the `_watt_user_config()' function prior to calling sock_init() to inject its own configuration values into the tcp_config() parser.
W32_FUNC WattDHCPConfigFunc dhcp_set_config_func (WattDHCPConfigFunc fn)
 Sets up an application hook for doing DHCP operations (DHCP_config_op).
W32_DATA int (MS_CDECL *_printf)(const char *
W32_FUNC void outs (const char *s)
W32_FUNC void outsnl (const char *s)
W32_FUNC void outsn (const char *s, int n)
W32_FUNC void outhexes (const char *s, int n)
W32_FUNC void outhex (char ch)
W32_FUNC int wintr_enable (void)
W32_FUNC void wintr_disable (void)
W32_FUNC void wintr_shutdown (void)
W32_FUNC void wintr_init (void)
W32_FUNC int _ping (DWORD host, DWORD num, const BYTE *pattern, long len)
W32_FUNC DWORD _chk_ping (DWORD host, DWORD *ping_num)
 Check for ICMP echo reply in ping-cache.
W32_FUNC int _eth_init (void)
 Initialize the network driver interface.
W32_FUNC void _eth_release (void)
 Release the hardware driver.
W32_FUNC void * _eth_formatpacket (const void *eth_dest, WORD eth_type)
 _eth_format_packet() places the next packet to be transmitted into the above link-layer output packet.
W32_FUNC void _eth_free (const void *buf)
 Free an input buffer once it is no longer needed.
W32_FUNC void * _eth_arrived (WORD *type, BOOL *brdcast)
 Poll for arrival of new packets (IP/ARP/RARP/PPPoE protocol).
W32_FUNC int _eth_send (WORD len, const void *sock, const char *file, unsigned line)
 _eth_send() does the actual transmission once we are complete with filling the buffer.
W32_FUNC int _eth_set_addr (const void *addr)
 Sets a new MAC address for our interface.
W32_FUNC BYTE _eth_get_hwtype (BYTE *hwtype, BYTE *hwlen)
 Fill in hardware address type/length for BOOTP/DHCP packets.
W32_FUNC WORD in_checksum (const void *buf, unsigned len)
 This checksum routine is only used by 16-bit targets (and files outside the library).
W32_FUNC DWORD _gethostid (void)
 Core style: Returns local IPv4-address.
W32_FUNC DWORD _sethostid (DWORD ip)
 Core-style: Sets local IPv4-address.
W32_FUNC int _getsockname (const void *s, void *dest, int *len)
W32_FUNC int _getpeername (const void *s, void *dest, int *len)
W32_FUNC int _chk_socket (const void *s)
W32_FUNC void psocket (const void *s)
W32_FUNC const char * sockerr (const void *s)
W32_FUNC void sockerr_clear (void *s)
W32_FUNC const char * sockstate (const void *s)
W32_FUNC enum TCP_SIMPLE_STATE tcp_simple_state (const tcp_Socket *s)
W32_FUNC char * _inet_ntoa (char *s, DWORD x)
 Convert an IP-address 'ip' into a string.
W32_FUNC DWORD _inet_addr (const char *name)
 Convert a string into an IP-address.
W32_FUNC BOOL _arp_register (DWORD use, DWORD instead_of)
 ICMP redirection.
W32_FUNC BOOL _arp_resolve (DWORD ina, eth_address *res)
 Blocking ARP resolve functions.
W32_FUNC int addwattcpd (VoidProc p)
W32_FUNC int delwattcpd (VoidProc p)
W32_FUNC void stopwattcpd (void)
W32_FUNC void _sock_debug_on (void)
W32_FUNC void _sock_debug_off (void)
W32_FUNC int close_s (int s)
W32_FUNC int write_s (int s, const char *buf, int nbyte)
W32_FUNC int read_s (int s, char *buf, int nbyte)
W32_FUNC int writev_s (int s, const struct iovec *vector, size_t count)
W32_FUNC int readv_s (int s, const struct iovec *vector, size_t count)
W32_FUNC const sock_type__get_sock_from_s (int s, int proto)
 Hack function if user application needs to use Wattcp core functions for BSD sockets.
W32_FUNC int select_s (int num_sockets, fd_set *read_events, fd_set *write_events, fd_set *except_events, struct timeval *timeout)
 The select_s() function.
W32_FUNC int W32_CALL select (int num_sockets, fd_set *read_events, fd_set *write_events, fd_set *except_events, struct timeval *timeout)
W32_FUNC int W32_CALL gethostname (char *name, int len)
W32_FUNC int join_mcast_group (DWORD ip)
W32_FUNC int leave_mcast_group (DWORD ip)
W32_FUNC int _ip4_is_multicast (DWORD ip)
W32_FUNC int multi_to_eth (DWORD ip, eth_address *eth)
W32_FUNC int udp_SetTTL (udp_Socket *s, BYTE ttl)
W32_FUNC int getopt (int argc, char *const *argv, const char *opt_str)
W32_FUNC void print_mac_stats (void)
W32_FUNC void print_pkt_stats (void)
W32_FUNC void print_vjc_stats (void)
W32_FUNC void print_arp_stats (void)
W32_FUNC void print_pppoe_stats (void)
W32_FUNC void print_ip4_stats (void)
W32_FUNC void print_ip6_stats (void)
W32_FUNC void print_icmp_stats (void)
W32_FUNC void print_igmp_stats (void)
W32_FUNC void print_udp_stats (void)
W32_FUNC void print_tcp_stats (void)
W32_FUNC void print_all_stats (void)
W32_FUNC void reset_stats (void)
W32_FUNC int sock_stats (void *s, DWORD *days, WORD *inactive, WORD *cwindow, DWORD *avg, DWORD *sd)
W32_FUNC void backgroundon (void)
W32_FUNC void backgroundoff (void)
W32_FUNC void backgroundfn (VoidProc func)
W32_FUNC int ffs (int mask)
W32_FUNC int system (const char *cmd)
pragma Alias (system,"_mw_watt_system")
W32_FUNC unsigned Random (unsigned a, unsigned b)
 Returns a random integer in range [a..b].
W32_FUNC int trace2com_init (WORD portAddress, DWORD baudRate)
W32_FUNC int MS_CDECL __trace2com (const char *fmt,...) __attribute__((format(printf

Variables

W32_FUNC void(*)(void) sock_yield (void *s, VoidProc fn)
W32_DATA DWORD my_ip_addr
W32_DATA DWORD sin_mask
W32_DATA int sock_delay
W32_DATA int sock_inactive
W32_DATA int sock_data_timeout
W32_DATA WORD multihomes
W32_DATA int block_tcp
W32_DATA int block_udp
W32_DATA int block_icmp
W32_DATA int block_ip
W32_DATA WORD last_cookie
W32_DATA DWORD cookies [MAX_COOKIES]
W32_DATA BOOL survive_eth
W32_DATA BOOL survive_bootp
W32_DATA BOOL survive_dhcp
W32_DATA BOOL survive_rarp
W32_DATA void(* loopback_handler )(void *ip)
W32_DATA char * def_domain
W32_DATA int dom_errno
W32_DATA DWORD def_nameservers [MAX_NAMESERVERS]
W32_DATA WORD dns_timeout
W32_DATA WORD last_nameserver
W32_DATA WORD _watt_handle_cbreak
W32_DATA volatile int _watt_cbroke
W32_DATA unsigned _mtu
W32_DATA unsigned _mss
W32_DATA int ctrace_on
W32_DATA int has_rdtsc
W32_DATA DWORD clocks_per_usec
W32_DATA void(* usr_init )(const char *keyword, const char *value)
W32_DATA void(* usr_post_init )(void)
W32_DATA int _watt_no_config
W32_DATA void(* _outch )(char c)
W32_DATA int(* _resolve_hook )(void)
W32_DATA void(* wintr_chain )(void)
W32_DATA int(* tftp_writer )(const void *buf, unsigned length)
W32_DATA int(* tftp_terminator )(void)
W32_DATA void *(* _eth_recv_hook )(WORD *type)
W32_DATA int(* _eth_recv_peek )(void *mac_buf)
W32_DATA int(* _eth_xmit_hook )(const void *buf, unsigned len)
W32_DATA int _multicast_on
W32_DATA char * optarg
W32_DATA int optind
W32_DATA int opterr
W32_DATA int optopt
W32_DATA char * optswchar
W32_DATA enum _optmode optmode


Function Documentation

W32_FUNC const sock_type* __get_sock_from_s int  s,
int  proto
 

Hack function if user application needs to use Wattcp core functions for BSD sockets.

Must *not* modify return value in any way. Definition at line 293 of file SOCKET.C.

References _socklist_find().

W32_FUNC BOOL _arp_register DWORD  use_this_gateway_ip,
DWORD  for_this_host_ip
 

ICMP redirection.

Called on ICMP-redirects.

Redirects are sent from a gateway/router, telling us that a different gateway is better suited to connect to the specified host than the one we were using. Definition at line 718 of file pcarp.c.

References DWORD, route_entry::gate_ip, is_on_LAN(), LAN_lookup(), and LAN_start_lookup().

W32_FUNC BOOL _arp_resolve DWORD  ina,
eth_address res
 

Blocking ARP resolve functions.

Doesn't return until success or time-out. Definition at line 1108 of file pcarp.c.

References _eth_addr, _pktserial, arp_daemon(), DWORD, eth_address, is_on_LAN(), LAN_lookup(), LAN_lookup_pending(), LAN_start_lookup(), route_lookup(), route_lookup_pending(), route_start_lookup(), tcp_tick(), and WORD.

W32_FUNC DWORD _chk_ping DWORD  host,
DWORD number
 

Check for ICMP echo reply in ping-cache.

Return values:
reply time in system ticks.
(DWORD)-1 on failure
Definition at line 172 of file pcping.c.

References DWORD, ping_cache::host, ping_cache::number, and ping_cache::time.

W32_FUNC void* _eth_arrived WORD type_ptr,
BOOL *  broadcast
 

Poll for arrival of new packets (IP/ARP/RARP/PPPoE protocol).

Sets protocol-type of packet received in 'type'.

For Ethernet/TokenRing-type drivers:

Return values:
Pointer past the MAC-header to the IP/ARP/RARP protocol header. Also check for link-layer broadcast.
For PPP/SLIP-type drivers (no MAC-headers):
Return values:
Pointer to the IP-packet itself. IP-protocol is assumed. Can never be link-layer broadcast.

<

Todo:
push back packet, else it's lost
Definition at line 1016 of file pcsed.c.

References _eth_brdcast, _eth_free(), _eth_is_init, _eth_recv_hook, _ip_recursion, _pktdevclass, _pktserial, BYTE, fix_llc_head(), macstat::num_ip_recurse, poll_recv_queue(), update_in_stat(), and WORD.

W32_FUNC void* _eth_formatpacket const void *  mac_dest,
WORD  eth_type
 

_eth_format_packet() places the next packet to be transmitted into the above link-layer output packet.

Returns:
address of higher-level protocol (IP/RARP/RARP) header.
Definition at line 131 of file pcsed.c.

References WORD.

W32_FUNC BYTE _eth_get_hwtype BYTE hwtype,
BYTE hwlen
 

Fill in hardware address type/length for BOOTP/DHCP packets.

Also used for ARP/RARP packets. Should never be called for PPP/SLIP. Definition at line 740 of file pcsed.c.

References _pktdevclass, arcnet_address, ax25_address, BYTE, eth_address, fddi_address, and tok_address.

W32_FUNC int _eth_init void   ) 
 

Initialize the network driver interface.

Returns:
0 okay.

error-code otherwise.

Definition at line 648 of file pcsed.c.

References _eth_addr, _eth_brdcast, _eth_get_hwtype(), _eth_is_init, _eth_loop_addr, _eth_mac_len, _eth_ndis3pkt, _eth_real_addr, _eth_release(), _eth_SwsVpkt, _pktdevclass, arcnet_mac_format(), eth_address, eth_mac_format(), eth_mac_xmit(), fddi_mac_format(), mac_tx_format, null_mac_format(), pkt_buf_wipe(), pkt_eth_init(), and tok_mac_format().

W32_FUNC int _eth_send WORD  len,
const void *  sock,
const char *  file,
unsigned  line
 

_eth_send() does the actual transmission once we are complete with filling the buffer.

Do any last minute patches here, like fix the size. Send to "loopback" device if it's IP and destination matches loopback network (127.x.x.x.).

Return length of network-layer packet (not length of link-layer packet). Definition at line 302 of file pcsed.c.

References _eth_is_init, _eth_last, _pkt_ip_ofs, _pktdevclass, in6_Header::destination, in_Header::destination, has_rdtsc, send_loopback(), update_out_stat(), and WORD.

W32_FUNC DWORD _gethostid void   ) 
 

Core style: Returns local IPv4-address.

Return values:
address on host order.
Definition at line 32 of file bsdname.c.

References DWORD, and my_ip_addr.

W32_FUNC DWORD _inet_addr const char *  s  ) 
 

Convert a string into an IP-address.

Return values:
address on host order.
0 string isn't a (dotless) address.
Definition at line 66 of file netaddr.c.

References aton(), DWORD, isaddr(), and isaddr_dotless().

W32_FUNC char* _inet_ntoa char *  s,
DWORD  ip
 

Convert an IP-address 'ip' into a string.

Return values:
'p'. 
Note:
'ip' is on host order.
Definition at line 40 of file netaddr.c.

References DWORD.

W32_FUNC DWORD _sethostid DWORD  ip  ) 
 

Core-style: Sets local IPv4-address.

Return values:
address on host order.
Definition at line 41 of file bsdname.c.

References DWORD, and my_ip_addr.

W32_FUNC WattUserConfigFunc _watt_user_config WattUserConfigFunc  fn  ) 
 

A user application may call the `_watt_user_config()' function prior to calling sock_init() to inject its own configuration values into the tcp_config() parser.

Useful when running diskless and setting `_watt_no_config = 0'.

Example:

  • 'pass' is 1 for first pass (PKTDRVR/WinPcap configuration), 2 for second pass.
  • 'cfg' is a pointer to the configuration table and must be passed to tcp_inject_config() as-is.

In most cases 'pass' can probably be ignored.

static long my_config_fn (int pass, const struct config_table *cfg) { // Keyword case is not significant (tcp_inject_config will convert // all keys to uppercase)

tcp_inject_config (cfg, "My_IP", "192.168.0.98"); tcp_inject_config (cfg, "NetMask", "255.255.255.0"); tcp_inject_config (cfg, "Gateway", "192.168.0.1"); (void)pass; return (1); // Returning 0 would make tcp_config() return 0 too, // as if the config file was not found }

int main (void) { _watt_no_config = 1; _watt_user_config (my_config_fn); if (sock_init()) return (-1); ... }

Never called inside Watt-32. Definition at line 186 of file SOCK_INI.C.

W32_FUNC DWORD aton const char *  str  ) 
 

Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address.

Return values:
0 on error (safer than -1)
IPv4 address (host order)
Definition at line 83 of file netaddr.c.

References DWORD.

W32_FUNC int chk_timeout DWORD  value  ) 
 

Check if milli-sec value has expired:.

Return values:
\li TRUE timer expired
  • FALSE not expired (or value not set)
Definition at line 522 of file timer.c.

References DWORD, has_8254, and set_timeout().

W32_FUNC int cmp_timers DWORD  t1,
DWORD  t2
 

Compare two timers with expirary at 't1' and 't2'.

Return values:
\li -1 if t1 expires before t2
  • 0 if t1 == t2
  • +1 if t1 expires after t2
Note:
This logic fails when timers approaches ULONG_MAX after approx. 50 days.
Definition at line 335 of file timer.c.

References DWORD.

W32_FUNC long get_timediff DWORD  now,
DWORD  tim
 

Return time difference between timers 'now' and 'tim'.

Check for day rollover. Max timer distance is 24 hours. This function should be called immediately after chk_timeout() is called. Definition at line 596 of file timer.c.

References DWORD, and has_8254.

W32_FUNC int hires_timer int  on  ) 
 

Control use of high-resolution timer.

When using Watt-32 together with programs that reprogram the PIT (8254 timer chip), the millisec_clock() function may return wrong values. In such cases it's best to use old-style 55ms timers. Using Watt-32 with Allegro graphics library is one such case where application program should call `hires_timer(0)' after `sock_init()' has been called. Definition at line 351 of file timer.c.

References chk_timeout(), and has_8254.

W32_FUNC WORD in_checksum const void *  ptr,
unsigned  len
 

This checksum routine is only used by 16-bit targets (and files outside the library).

32-bit targets use in_checksum_fast() in chksum0.s + chksum0.asm.

Note:
`in_check_sum()' and `in_checksum_fast()' are equally fast on a Pentium 4 CPU. But on a Pentium 2 the ASM version is approx. 10 times faster.
Definition at line 29 of file chksum.c.

References BYTE, and WORD.

W32_FUNC void init_misc void   ) 
 

Initialise various stuff.

Todo:
Definition at line 322 of file misc.c.

References _watt_assert_buf, _watt_dosFp, _watt_os_ver, DWORD, has_rdtsc, init_timers(), and win32_dos_box.

W32_FUNC void init_userSuppliedTimerTick void   ) 
 

init_userSuppliedTimerTick() - setup timer handling for programs that are already running a periodic interrupt or whatever (i.e.

ALLEGRO & more). This is called to signify that the 'user task' will periodically call userTimerTick() to supply the elapsed time since the last call. Best called once before sock_init(). There is no way to revert to original timer handling once this is called. By GvB 2002-09 Definition at line 135 of file timer.c.

References has_8254.

W32_FUNC int isaddr const char *  str  ) 
 

Check if 'str' is simply an ip address.

Accepts 'a.b.c.d' or '[a.b.c.d]' forms.

Return values:
TRUE if 'str' is an IPv4 address.
Definition at line 125 of file netaddr.c.

W32_FUNC DWORD resolve const char *  name  ) 
 

Convert host name to an address.

Returns 0 if name is unresolvable right now. Return value is host-order. Definition at line 756 of file udp_dom.c.

References aton(), called_from_resolve, dom_strerror(), DWORD, isaddr(), lookup_domain(), my_ip_addr, next_domain(), query_init(), rip(), set_timeout(), UINT, and WORD.

W32_FUNC char* rip char *  s  ) 
 

Removes end-of-line termination from a string.

Removes "\n" (Unix), "\r" (MacOS) or "\r\n" (DOS/net-ascii) terminations, but not single "\n\r" (who uses that?). Definition at line 193 of file strings.c.

W32_FUNC int select_s int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout
 

The select_s() function.

Note:
It supports more sockets than would fit in a fd_set. I.e. it handles an array of 'fd_set's on input/output. Thus it is the user's responsibilty to not use a too high 'nfds' value. I.e. If nfs > 512*8 and user fd_set's on input is smaller than 512*, select_s() could trash the fd_set's on output.

Clear our "working" fd_sets.

Note:
Don't use FD_ZERO() since our working fd_sets contain more than FD_SETSIZE sockets.
Definition at line 112 of file select.c.

References _sock_crit_start(), _sock_crit_stop(), DWORD, exc_select(), sel_min_block, socket(), and tcp_tick().

W32_FUNC int set_timediff long  msec  ) 
 

Must be called by user right before or after a time change occurs.

Not used in Watt-32. Definition at line 583 of file timer.c.

W32_FUNC DWORD set_timeout DWORD  msec  ) 
 

Return time for when given timeout (msec) expires.

Make sure it never returns 0 (it will confuse chk_timeout). Definition at line 478 of file timer.c.

References DWORD, and has_8254.

W32_FUNC void sock_exit void   ) 
 

Our only atexit() handler.

Called only once during normal program shutdown. Exception handlers exit differently (see except_handler() above) Definition at line 321 of file djimport.c.

References _watt_fatal_error, _watt_is_init, exit_misc(), rundown_run(), sock_init_called, and tcp_shutdown().

W32_FUNC int tcp_cbreak int  mode  ) 
 

Sets our break mode.

  • `mode' is composed of the following flags
    • 0x01: disallow breakouts
    • 0x10: display a message upon ^C/^BREAK (default)
Definition at line 172 of file pc_cbrk.c.

References set_cbreak(), sig_handler_watt(), sock_sig_exit(), and win32_dos_box.

W32_FUNC void tcp_inject_config const struct config_table *  cfg,
const char *  key,
const char *  value
 

Callable from a user application to inject config values before the normal WATTCP.CFG is loaded and parsed.

See '_watt_user_config' in sock_ini.c. Definition at line 850 of file PCCONFIG.C.

References strntrimcpy(), tcp_inject_config_direct(), and UINT.

W32_FUNC 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.

W32_FUNC void userTimerTick DWORD  elapsed_time_msec  ) 
 

Provide timer-ticks from an application.

This should be periodically called from user code to increment the timer count once activated via init_userSuppliedTimerTick(). Best called from a periodic interrupt handler (int 8/1Ch/70h) which is the case now with init_timer_isr(). GvB 2002-09 Definition at line 162 of file timer.c.

References DWORD.

W32_FUNC int watt_sock_init size_t  tcp_Sock_size,
size_t  udp_Sock_size,
size_t  time_t_size
 

Todo:
Use auto-configuration and set 'my_ip_addr' to 169.254/16
Definition at line 721 of file SOCK_INI.C.

References _arp_check_gateways(), _arp_init(), _bootp_on, _dhcp_on, _do_mask_req, _inet_ntoa(), _pkt_inf, _rarp_on, _watt_is_init, _watt_no_config, addwattcpd(), DHCP_init(), DHCP_read_config(), do_exit(), echo_discard_init(), echo_discard_start(), get_day_num(), init_misc(), my_ip_addr, old_break, pppoe_init(), pppoe_start(), reverse_lookup_myip(), set_timeout(), setup_sig_handlers(), sin_mask, sock_init_called, start_day, start_time, survive_eth, tcp_cbreak(), tcp_do_boot(), tcp_init(), tcp_post_init(), and tftp_init().

W32_FUNC const char* wattcpVersion void   ) 
 

Todo:
not tested

not tested

Definition at line 333 of file djimport.c.


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