8 * Copyright (c) 1990-1993 Erick Engelke
10 * Portions copyright others, see copyright.h for details.
12 * This library is free software; you can use it or redistribute under
13 * the terms of the license included in LICENSE.H.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * file LICENSE.H for more details.
26 * Version (major.minor.dev-rel), 8-bit each.
28 #define WATTCP_MAJOR_VER 2
29 #define WATTCP_MINOR_VER 2
30 #define WATTCP_DEVEL_REL 10
32 #define WATTCP_VER ((WATTCP_MAJOR_VER << 16) + \
33 (WATTCP_MINOR_VER << 8) + \
36 #define WATTCP_VER_STRING "2.2.10"
38 #if !defined(RC_INVOKED)
41 #include <sys/wtypes.h> /* fd_set, iovec */
42 #include <sys/wtime.h> /* struct timeval, cdecl */
43 #include <sys/swap.h> /* intel(), intel16() */
44 #include <sys/w32api.h> /* W32_FUNC, W32_DATA etc. */
47 #pragma read_only_directory;
52 #if 0 /* keep Emacs's auto-indent happy */
57 W32_DATA const char *wattcpCopyright; /* "See COPYRIGHT.H for details" */
59 W32_FUNC const char *wattcpVersion (void); /* WatTCP target version/date */
60 W32_FUNC const char *wattcpCapabilities (void); /* what's been compiled in */
62 #if !defined(WATT32_BUILD)
65 * Typedefs and constants
68 #define BYTE unsigned char
72 #define WORD unsigned short
76 #define DWORD unsigned long
84 #define sock_type void
91 #define byte unsigned char
95 #define word unsigned short
99 #define dword unsigned long
103 #define longword unsigned long
109 typedef BYTE eth_address[6];
110 typedef BYTE ip6_address[16];
112 typedef int (*ProtoHandler) (void *sock, const BYTE *data, unsigned len,
113 const void *tcp_phdr, const void *udp_hdr);
115 typedef int (*UserHandler) (void *sock);
117 #endif /* WATT32_BUILD */
129 /* Silly C++ compilers needs this to supress warning at max warning level
131 typedef void (*VoidProc)(void);
133 #define MAX_COOKIES 10
134 #define MAX_NAMESERVERS 10
135 #define MAX_HOSTLEN 80
137 /* Modes for sock_mode()
139 #define TCP_MODE_BINARY 0x01 /* deprecated */
140 #define TCP_MODE_ASCII 0x02 /* deprecated */
141 #define SOCK_MODE_BINARY 0x01 /* new name */
142 #define SOCK_MODE_ASCII 0x02 /* new name */
143 #define UDP_MODE_CHK 0x04 /* defaults to checksum */
144 #define UDP_MODE_NOCHK 0x08
145 #define TCP_MODE_NAGLE 0x10 /* Nagle's algorithm */
146 #define TCP_MODE_NONAGLE 0x20
148 /* wait-states for sock_sselect()
150 #define SOCKESTABLISHED 1
151 #define SOCKDATAREADY 2
155 * Hide "private" symbols by prefixing with "_w32_"
158 #define W32_NAMESPACE(x) _w32_ ## x
160 #define init_misc W32_NAMESPACE (init_misc)
161 #define Random W32_NAMESPACE (Random)
162 #define set_timeout W32_NAMESPACE (set_timeout)
163 #define chk_timeout W32_NAMESPACE (chk_timeout)
164 #define cmp_timeout W32_NAMESPACE (cmp_timeout)
165 #define hires_timer W32_NAMESPACE (hires_timer)
166 #define set_timediff W32_NAMESPACE (set_timediff)
167 #define get_timediff W32_NAMESPACE (get_timediff)
168 #define timeval_diff W32_NAMESPACE (timeval_diff)
170 #define my_ip_addr W32_NAMESPACE (my_ip_addr)
171 #define sin_mask W32_NAMESPACE (sin_mask)
172 #define sock_delay W32_NAMESPACE (sock_delay)
173 #define sock_inactive W32_NAMESPACE (sock_inactive)
174 #define sock_data_timeout W32_NAMESPACE (sock_data_timeout)
175 #define multihomes W32_NAMESPACE (multihomes)
176 #define block_tcp W32_NAMESPACE (block_tcp)
177 #define block_udp W32_NAMESPACE (block_udp)
178 #define block_ip W32_NAMESPACE (block_ip)
179 #define block_icmp W32_NAMESPACE (block_icmp)
180 #define last_cookie W32_NAMESPACE (last_cookie)
181 #define cookies W32_NAMESPACE (cookies)
182 #define survive_eth W32_NAMESPACE (survive_eth)
183 #define survive_bootp W32_NAMESPACE (survive_bootp)
184 #define survive_dhcp W32_NAMESPACE (survive_dhcp)
185 #define survive_rarp W32_NAMESPACE (survive_rarp)
186 #define loopback_handler W32_NAMESPACE (loopback_handler)
187 #define usr_init W32_NAMESPACE (usr_init)
188 #define usr_post_init W32_NAMESPACE (usr_post_init)
189 #define in_checksum W32_NAMESPACE (in_checksum)
190 #define aton W32_NAMESPACE (aton)
191 #define isaddr W32_NAMESPACE (isaddr)
192 #define _printf W32_NAMESPACE (_printf)
193 #define _outch W32_NAMESPACE (_outch)
194 #define outs W32_NAMESPACE (outs)
195 #define outsnl W32_NAMESPACE (outsnl)
196 #define outsn W32_NAMESPACE (outsn)
197 #define outhexes W32_NAMESPACE (outhexes)
198 #define outhex W32_NAMESPACE (outhex)
199 #define rip W32_NAMESPACE (rip)
200 #define parse_config_table W32_NAMESPACE (parse_config_table)
201 #define init_timer_isr W32_NAMESPACE (init_timer_isr)
202 #define exit_timer_isr W32_NAMESPACE (exit_timer_isr)
205 #define sock_init() watt_sock_init (sizeof(tcp_Socket), sizeof(udp_Socket))
207 W32_FUNC int watt_sock_init (size_t, size_t);
208 W32_FUNC const char *sock_init_err (int rc);
210 W32_FUNC void sock_exit (void);
211 W32_FUNC void dbug_init (void); /* effective if compiled with `USE_DEBUG' */
212 W32_FUNC void init_misc (void); /* may be called before sock_init() */
213 W32_FUNC void sock_sig_exit (const char *msg, int sigint);
215 #if !defined(WATT32_BUILD)
217 * `s' is the pointer to a udp or tcp socket
219 W32_FUNC int sock_read (void *s, char *dp, int len);
220 W32_FUNC int sock_preread (void *s, char *dp, int len);
221 W32_FUNC int sock_fastread (void *s, char *dp, int len);
222 W32_FUNC int sock_write (void *s, const char *dp, int len);
223 W32_FUNC int sock_enqueue (void *s, const char *dp, int len);
224 W32_FUNC int sock_fastwrite (void *s, const char *dp, int len);
225 W32_FUNC size_t sock_setbuf (void *s, char *buf, size_t len);
226 W32_FUNC void sock_flush (void *s);
227 W32_FUNC void sock_noflush (void *s);
228 W32_FUNC void sock_flushnext (void *s);
229 W32_FUNC int sock_puts (void *s, const char *dp);
230 W32_FUNC WORD sock_gets (void *s, char *dp, int n);
231 W32_FUNC BYTE sock_putc (void *s, char c);
232 W32_FUNC int sock_getc (void *s);
233 W32_FUNC WORD sock_dataready (void *s);
234 W32_FUNC int sock_established(void *s);
235 W32_FUNC int sock_close (void *s);
236 W32_FUNC int sock_abort (void *s);
237 W32_FUNC void (*sock_yield (void *s, VoidProc fn)) (void);
238 W32_FUNC int sock_mode (void *s, WORD mode);
239 W32_FUNC int sock_sselect (void *s, int waitstate);
240 W32_FUNC int sock_timeout (void *s, int seconds);
241 W32_FUNC int sock_recv (void *s, char *buf, unsigned len);
242 W32_FUNC int sock_recv_init (void *s, char *buf, unsigned len);
243 W32_FUNC int sock_recv_from (void *s, DWORD *ip, WORD *port, char *buf, unsigned len, int peek);
244 W32_FUNC int sock_recv_used (void *s);
245 W32_FUNC int sock_keepalive (void *s);
247 W32_FUNC size_t sock_rbsize (const void *s);
248 W32_FUNC size_t sock_rbused (const void *s);
249 W32_FUNC size_t sock_rbleft (const void *s);
250 W32_FUNC size_t sock_tbsize (const void *s);
251 W32_FUNC size_t sock_tbused (const void *s);
252 W32_FUNC size_t sock_tbleft (const void *s);
254 W32_FUNC int MS_CDECL sock_printf (void *s, const char *fmt, ...)
255 #if defined(__GNUC__)
256 __attribute__((format(printf,2,3)))
260 W32_FUNC int MS_CDECL sock_scanf (void *s, const char *fmt, ...)
261 #if defined(__GNUC__)
262 __attribute__((format(scanf,2,3)))
267 * TCP or UDP specific stuff, must be used for open's and listens, but
268 * sock stuff above is used for everything else
270 W32_FUNC int udp_open (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
271 W32_FUNC int tcp_open (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
272 W32_FUNC int udp_listen (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
273 W32_FUNC int tcp_listen (void *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler, WORD timeout);
274 W32_FUNC int tcp_established (const void *s);
276 #endif /* WATT32_BUILD */
279 W32_FUNC DWORD resolve (const char *name);
280 W32_FUNC int resolve_ip (DWORD ip, char *name, int len);
281 W32_FUNC DWORD lookup_host(const char *host, char *ip_str);
282 W32_FUNC const char *dom_strerror (int err);
285 * less general functions
287 W32_FUNC int tcp_cbreak (int mode);
289 W32_FUNC DWORD aton (const char *name);
290 W32_FUNC int isaddr (const char *name);
291 W32_FUNC char *rip (char *s);
292 W32_FUNC int watt_kbhit (void);
294 #define tcp_cbrk(mode) tcp_cbreak(mode) /* old name */
297 * Set MD5 secret for TCP option 19 (RFC-2385).
298 * Only if built with USE_TCP_MD5.
300 W32_FUNC const char *tcp_md5_secret (void *s, const char *secret);
305 W32_FUNC DWORD set_timeout (DWORD msec);
306 W32_FUNC int chk_timeout (DWORD value);
307 W32_FUNC int cmp_timers (DWORD t1, DWORD t2);
308 W32_FUNC int set_timediff (long msec);
309 W32_FUNC long get_timediff (DWORD now, DWORD t);
310 W32_FUNC int hires_timer (int on);
311 W32_FUNC double timeval_diff (const struct timeval *a, const struct timeval *b);
313 W32_FUNC void init_timer_isr (void);
314 W32_FUNC void exit_timer_isr (void);
316 W32_FUNC void init_userSuppliedTimerTick (void);
317 W32_FUNC void userTimerTick (DWORD);
319 W32_FUNC void ip_timer_init (sock_type *s , unsigned delayseconds);
320 W32_FUNC int ip_timer_expired (const sock_type *s);
323 * TCP/IP system variables
325 W32_DATA DWORD my_ip_addr;
326 W32_DATA DWORD sin_mask; /* eg. 0xFFFFFE00L */
327 W32_DATA int sock_delay;
328 W32_DATA int sock_inactive;
329 W32_DATA int sock_data_timeout;
330 W32_DATA WORD multihomes;
332 W32_DATA int block_tcp;
333 W32_DATA int block_udp;
334 W32_DATA int block_icmp;
335 W32_DATA int block_ip;
336 W32_DATA WORD last_cookie;
337 W32_DATA DWORD cookies [MAX_COOKIES];
339 W32_DATA BOOL survive_eth;
340 W32_DATA BOOL survive_bootp;
341 W32_DATA BOOL survive_dhcp;
342 W32_DATA BOOL survive_rarp;
344 W32_DATA void (*loopback_handler) (void *ip);
347 * things you probably won't need to know about
352 * - dump some socket control block parameters
353 * used for testing the kernal, not recommended
355 W32_FUNC void sock_debugdump (const sock_type *s);
358 * tcp_config - read a configuration file
359 * - if special path desired, call after sock_init()
360 * - NULL reads path WATTCP.CFG env-var or from program's path
363 W32_FUNC long tcp_config (const char *path);
366 * tcp_tick - must be called periodically by user application.
367 * - returns NULL when our socket closes
369 W32_FUNC WORD tcp_tick (sock_type *s);
372 * tcp_set_debug_state - set to 1,2 or reset 0
374 W32_FUNC void tcp_set_debug_state (WORD x);
378 * name domain constants, etc.
380 #define def_domain W32_NAMESPACE (def_domain)
381 #define def_nameservers W32_NAMESPACE (def_nameservers)
382 #define dns_timeout W32_NAMESPACE (dns_timeout)
383 #define dom_errno W32_NAMESPACE (dom_errno)
384 #define last_nameserver W32_NAMESPACE (last_nameserver)
385 #define _mtu W32_NAMESPACE (_mtu)
386 #define _mss W32_NAMESPACE (_mss)
387 #define ctrace_on W32_NAMESPACE (ctrace_on)
388 #define has_rdtsc W32_NAMESPACE (has_rdtsc)
389 #define clocks_per_usec W32_NAMESPACE (clocks_per_usec)
390 #define psocket W32_NAMESPACE (psocket)
391 #define _inet_ntoa W32_NAMESPACE (_inet_ntoa)
392 #define _inet_addr W32_NAMESPACE (_inet_addr)
394 W32_DATA char *def_domain;
395 W32_DATA int dom_errno;
396 W32_DATA DWORD def_nameservers [MAX_NAMESERVERS];
397 W32_DATA WORD dns_timeout;
398 W32_DATA WORD last_nameserver;
399 W32_DATA WORD _watt_handle_cbreak; /* ^C/^Break handle mode */
400 W32_DATA volatile int _watt_cbroke; /* ^C/^Break occured */
401 W32_DATA unsigned _mtu, _mss;
402 W32_DATA int ctrace_on;
403 W32_DATA int has_rdtsc;
404 W32_DATA DWORD clocks_per_usec;
408 #define wathndlcbrk _watt_handle_cbreak
409 #define watcbroke _watt_cbroke
412 * sock_wait_ .. macros
416 * sock_wait_established()
417 * - Waits until connected or aborts if timeout etc.
420 * - Waits for received input on socket 's'.
421 * - May not be valid input for sock_gets().. check returned length.
424 * - Do tick and jump on abort.
427 * - Close socket and wait until fully closed.
428 * Discards all received data.
430 * All these macros jump to label sock_err with contents of *statusptr
432 * 1 on closed normally.
433 * -1 on error, call sockerr(s) for cause.
436 #if !defined(WATT32_BUILD)
438 W32_FUNC int _ip_delay0 (void *s, int sec, UserHandler fn, void *statusptr);
439 W32_FUNC int _ip_delay1 (void *s, int sec, UserHandler fn, void *statusptr);
440 W32_FUNC int _ip_delay2 (void *s, int sec, UserHandler fn, void *statusptr);
443 #define sock_wait_established(s,seconds,fn,statusptr) \
445 if (_ip_delay0 (s,seconds,fn,statusptr)) \
449 #define sock_wait_input(s,seconds,fn,statusptr) \
451 if (_ip_delay1 (s,seconds,fn,statusptr)) \
455 #define sock_tick(s, statusptr) \
457 if (!tcp_tick(s)) { \
458 if (statusptr) *statusptr = -1; \
463 #define sock_wait_closed(s,seconds,fn,statusptr) \
465 if (_ip_delay2(s,seconds,fn,statusptr)) \
469 #endif /* WATT32_BUILD */
472 * User hook for WATTCP.CFG initialisation file.
474 W32_DATA void (*usr_init) (const char *keyword, const char *value);
475 W32_DATA void (*usr_post_init) (void);
477 enum config_tab_types {
478 ARG_ATOI, /* convert to int */
479 ARG_ATOB, /* convert to 8-bit byte */
480 ARG_ATOW, /* convert to 16-bit word */
481 ARG_ATOIP, /* convert to ip-address on host order */
482 ARG_ATOX_B, /* convert to hex-byte */
483 ARG_ATOX_W, /* convert to hex-word */
484 ARG_ATOX_D, /* convert to hex-word */
485 ARG_STRDUP, /* duplicate string value */
486 ARG_STRCPY, /* copy string value */
487 ARG_RESOLVE, /* resolve host to ip-address */
488 ARG_FUNC /* call convertion function */
491 struct config_table {
493 enum config_tab_types type;
498 W32_FUNC int parse_config_table (const struct config_table *tab,
504 * Run with no config file (embedded/diskless)
506 W32_DATA int _watt_no_config;
508 W32_FUNC void tcp_inject_config (
509 const struct config_table *cfg,
513 typedef long (*WattUserConfigFunc) (int pass, const struct config_table *cfg);
515 W32_FUNC WattUserConfigFunc _watt_user_config (WattUserConfigFunc fn);
519 * Bypass standard handling of DHCP transient configuration
521 #include <sys/packon.h>
532 DWORD tcp_keep_intvl;
534 char hostname [MAX_HOSTLEN+1];
535 char domain [MAX_HOSTLEN+1];
536 char loghost [MAX_HOSTLEN+1]; /* Only used if USE_BSD_FUNC defined */
539 #include <sys/packoff.h>
541 enum DHCP_config_op {
547 typedef int (*WattDHCPConfigFunc) (enum DHCP_config_op op,
548 struct DHCP_config *cfg);
550 W32_FUNC WattDHCPConfigFunc dhcp_set_config_func (WattDHCPConfigFunc fn);
554 * Various function-pointer hooks etc.
556 W32_DATA int (MS_CDECL *_printf) (const char *, ...);
557 W32_DATA void (*_outch) (char c);
558 W32_DATA int (*_resolve_hook) (void);
559 W32_DATA void (*wintr_chain) (void);
561 W32_DATA int (*tftp_writer) (const void *buf, unsigned length);
562 W32_DATA int (*tftp_terminator) (void);
564 W32_FUNC void outs (const char *s);
565 W32_FUNC void outsnl (const char *s);
566 W32_FUNC void outsn (const char *s, int n);
567 W32_FUNC void outhexes(const char *s, int n);
568 W32_FUNC void outhex (char ch);
570 W32_FUNC int wintr_enable (void);
571 W32_FUNC void wintr_disable (void);
572 W32_FUNC void wintr_shutdown (void);
573 W32_FUNC void wintr_init (void);
575 W32_FUNC int _ping (DWORD host, DWORD num, const BYTE *pattern, long len);
576 W32_FUNC DWORD _chk_ping (DWORD host, DWORD *ping_num);
578 W32_FUNC int _eth_init (void);
579 W32_FUNC void _eth_release (void);
580 W32_FUNC void *_eth_formatpacket (const void *eth_dest, WORD eth_type);
581 W32_FUNC void _eth_free (const void *buf);
582 W32_FUNC void *_eth_arrived (WORD *type, BOOL *brdcast);
583 W32_FUNC int _eth_send (WORD len, const void *sock, const char *file, unsigned line);
584 W32_FUNC int _eth_set_addr (const void *addr);
585 W32_FUNC BYTE _eth_get_hwtype (BYTE *hwtype, BYTE *hwlen);
587 W32_DATA void *(*_eth_recv_hook) (WORD *type);
588 W32_DATA int (*_eth_recv_peek) (void *mac_buf);
589 W32_DATA int (*_eth_xmit_hook) (const void *buf, unsigned len);
590 W32_FUNC WORD in_checksum (const void *buf, unsigned len);
592 #define inchksum(buf,len) in_checksum(buf, len)
596 * BSD-socket similarities.
597 * Refer <sys/socket.h> for the real thing.
599 #if !defined(WATT32_BUILD)
601 struct watt_sockaddr { /* for _getpeername, _getsockname */
605 BYTE s_spares[6]; /* unused */
608 W32_FUNC DWORD _gethostid (void);
609 W32_FUNC DWORD _sethostid (DWORD ip);
610 W32_FUNC int _getsockname (const void *s, void *dest, int *len);
611 W32_FUNC int _getpeername (const void *s, void *dest, int *len);
613 W32_FUNC int _chk_socket (const void *s);
614 W32_FUNC void psocket (const void *s);
618 W32_FUNC char *_inet_ntoa (char *s, DWORD x);
619 W32_FUNC DWORD _inet_addr (const char *name);
621 W32_FUNC BOOL _arp_register (DWORD use, DWORD instead_of);
622 W32_FUNC BOOL _arp_resolve (DWORD ina, eth_address *res);
624 W32_FUNC int addwattcpd (VoidProc p);
625 W32_FUNC int delwattcpd (VoidProc p);
627 W32_FUNC void _sock_debug_on (void);
628 W32_FUNC void _sock_debug_off (void);
630 #if !defined(WATT32_BUILD)
632 W32_FUNC const char *sockerr (const void *s); /* UDP / TCP */
633 W32_FUNC void sockerr_clear (void *s); /* UDP / TCP */
635 W32_FUNC const char *sockstate (const void *s); /* UDP / TCP / Raw */
638 * Reduce internal states to "user-easy" states, GvB 2002-09
640 enum TCP_SIMPLE_STATE {
648 W32_FUNC enum TCP_SIMPLE_STATE tcp_simple_state (const tcp_Socket *s);
650 #endif /* WATT32_BUILD */
654 * BSD functions for read/write/select
656 W32_FUNC int close_s (int s);
657 W32_FUNC int write_s (int s, const char *buf, int nbyte);
658 W32_FUNC int read_s (int s, char *buf, int nbyte);
659 W32_FUNC int writev_s (int s, const struct iovec *vector, size_t count);
660 W32_FUNC int readv_s (int s, const struct iovec *vector, size_t count);
662 W32_FUNC const sock_type *__get_sock_from_s (int s, int proto);
663 /* Use 'IPPROTO_x' for proto */
665 W32_FUNC int select_s (int num_sockets,
667 fd_set *write_events,
668 fd_set *except_events,
669 struct timeval *timeout);
671 /* The only BSD/Winsock replacement in this file.
672 * Normally belongs in djgpp's <unistd.h>.
675 W32_FUNC int W32_CALL select (int num_sockets,
677 fd_set *write_events,
678 fd_set *except_events,
679 struct timeval *timeout);
682 /* Duplicated from <sys/socket.h>
684 W32_FUNC int W32_CALL gethostname (char *name, int len);
687 * Multicast stuff (if built with `USE_MULTICAST')
689 W32_DATA int _multicast_on;
691 W32_FUNC int join_mcast_group (DWORD ip);
692 W32_FUNC int leave_mcast_group (DWORD ip);
693 W32_FUNC int _ip4_is_multicast (DWORD ip);
694 W32_FUNC int multi_to_eth (DWORD ip, eth_address *eth);
695 W32_FUNC int udp_SetTTL (udp_Socket *s, BYTE ttl);
699 * Commandline parsing
701 #if defined(__DJGPP__)
704 #elif defined(__MINGW32__)
707 #elif !defined(_GETOPT_H) /* not using a local getopt.c */
708 #define optarg W32_NAMESPACE (optarg)
709 #define optind W32_NAMESPACE (optind)
710 #define opterr W32_NAMESPACE (opterr)
711 #define optopt W32_NAMESPACE (optopt)
712 #define optswchar W32_NAMESPACE (optswchar)
713 #define optmode W32_NAMESPACE (optmode)
714 #define getopt W32_NAMESPACE (getopt)
716 W32_DATA char *optarg; /* argument of current option */
717 W32_DATA int optind; /* index of next argument; default=0: initialize */
718 W32_DATA int opterr; /* 0=disable error messages; default=1: enable */
719 W32_DATA int optopt; /* option char returned from getopt() */
720 W32_DATA char *optswchar; /* characters introducing options; default="-" */
722 W32_DATA enum _optmode {
723 GETOPT_UNIX, /* options at start of argument list (default) */
724 GETOPT_ANY, /* move non-options to the end */
725 GETOPT_KEEP, /* return options in order */
728 W32_FUNC int getopt (int argc, char *const *argv, const char *opt_str);
733 * Statistics printing
735 W32_FUNC void print_mac_stats (void);
736 W32_FUNC void print_pkt_stats (void);
737 W32_FUNC void print_vjc_stats (void);
738 W32_FUNC void print_arp_stats (void);
739 W32_FUNC void print_pppoe_stats(void);
740 W32_FUNC void print_ip4_stats (void);
741 W32_FUNC void print_ip6_stats (void);
742 W32_FUNC void print_icmp_stats (void);
743 W32_FUNC void print_igmp_stats (void);
744 W32_FUNC void print_udp_stats (void);
745 W32_FUNC void print_tcp_stats (void);
746 W32_FUNC void print_all_stats (void);
747 W32_FUNC void reset_stats (void);
749 #if !defined(WATT32_BUILD)
750 W32_FUNC int sock_stats (void *s, DWORD *days, WORD *inactive,
751 WORD *cwindow, DWORD *avg, DWORD *sd);
756 * Controlling timer interrupt handler for background processing.
757 * Not recommended, little tested
759 W32_FUNC void backgroundon (void);
760 W32_FUNC void backgroundoff (void);
761 W32_FUNC void backgroundfn (VoidProc func);
767 #if !defined(__DJGPP__) && !(defined(__WATCOMC__) && (__WATCOMC__ >= 1240))
768 #define ffs W32_NAMESPACE (ffs)
769 W32_FUNC int ffs (int mask);
772 #if defined (__HIGHC__)
773 W32_FUNC int system (const char *cmd);
774 pragma Alias (system, "_mw_watt_system");
777 W32_FUNC unsigned Random (unsigned a, unsigned b);
781 * Tracing to RS-232 serial port, by Gundolf von Bachhaus <GBachhaus@gmx.net>
782 * Watt-32 library must be compiled with `USE_RS232_DBG' (see .\src\config.h)
784 W32_FUNC int trace2com_init (WORD portAddress, DWORD baudRate);
785 W32_FUNC int MS_CDECL __trace2com (const char *fmt, ...)
786 #if defined(__GNUC__)
787 __attribute__((format(printf,1,2)))
795 #endif /* RC_INVOKED */
796 #endif /* __WATT_TCP_H */