Watt-32 tcp/ip  2.2 dev-rel.10
tcp.h
Go to the documentation of this file.
1 
5 /*
6  * Waterloo TCP
7  *
8  * Copyright (c) 1990-1993 Erick Engelke
9  *
10  * Portions copyright others, see copyright.h for details.
11  *
12  * This library is free software; you can use it or redistribute under
13  * the terms of the license included in LICENSE.H.
14  *
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.
19  *
20  */
21 
22 #ifndef __WATT_TCP_H
23 #define __WATT_TCP_H
24 
25 /*
26  * Version (major.minor.dev-rel), 8-bit each.
27  */
28 #define WATTCP_MAJOR_VER 2
29 #define WATTCP_MINOR_VER 2
30 #define WATTCP_DEVEL_REL 11
31 
32 #define WATTCP_VER ((WATTCP_MAJOR_VER << 16) + \
33  (WATTCP_MINOR_VER << 8) + \
34  WATTCP_DEVEL_REL)
35 
36 #define WATTCP_VER_STRING "2.2.11"
37 
38 #if !defined(RC_INVOKED) /* rest of file */
39 
40 #include <stdio.h>
41 #include <sys/w32api.h> /* W32_FUNC, W32_DATA etc. */
42 #include <sys/wtypes.h> /* fd_set, iovec */
43 #include <sys/wtime.h> /* <time.h>, struct timeval */
44 #include <sys/whide.h> /* hide publics inside W32_NAMESPACE() */
45 #include <sys/cdefs.h> /* MS_CDECL etc. */
46 #include <sys/swap.h> /* intel(), intel16() */
47 
48 #ifdef __WATCOMC__
49 #pragma read_only_directory;
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 W32_DATA const char *wattcpCopyright; /* "See COPYRIGHT.H for details" */
57 
58 W32_FUNC const char *W32_CALL wattcpVersion (void); /* Watt-32 target version/date */
59 W32_FUNC const char *W32_CALL wattcpCapabilities (void); /* what features was been compiled in */
60 W32_FUNC const char *W32_CALL wattcpBuildCC (void); /* what is the compiler __VENDOR__ nane */
61 W32_FUNC const char *W32_CALL wattcpBuildCCexe (void); /* what is the compiler name */
62 W32_FUNC const char *W32_CALL wattcpBuildCflags (void); /* what CFLAGS were used */
63 
64 #if !defined(WATT32_BUILD)
65 
66  /* Hide the details of these structures when using Watt-32.
67  */
68  typedef void sock_type;
69  typedef void in_Header;
70  typedef void udp_Header;
71  typedef void tcp_Header;
72 
73  typedef struct {
74  BYTE undoc [4470];
75  } tcp_Socket;
76 
77  typedef struct {
78  BYTE undoc [1740];
79  } udp_Socket;
80 
81 #else
82 
83  #if !defined(_w32_WATTCP_H)
84  #error "Do not include tcp.h before wattcp.h"
85  #endif
86 
87  #define tcp_Socket struct tcp_Socket /* in wattcp.h */
88  #define udp_Socket struct udp_Socket /* in wattcp.h */
89  #define sock_type union sock_type /* in wattcp.h */
90 
91 #endif /* WATT32_BUILD */
92 
93 #define MAX_COOKIES 10
94 #define MAX_NAMESERVERS 10
95 #define MAX_HOSTLEN 80
96 
97 /* Modes for sock_mode()
98  */
99 #define TCP_MODE_BINARY 0x01 /* deprecated */
100 #define TCP_MODE_ASCII 0x02 /* deprecated */
101 #define SOCK_MODE_BINARY 0x01 /* new name */
102 #define SOCK_MODE_ASCII 0x02 /* new name */
103 #define UDP_MODE_CHK 0x04 /* defaults to checksum */
104 #define UDP_MODE_NOCHK 0x08
105 #define TCP_MODE_NAGLE 0x10 /* Nagle's algorithm */
106 #define TCP_MODE_NONAGLE 0x20
107 
108 /* wait-states for sock_sselect()
109  */
110 #define SOCKESTABLISHED 1
111 #define SOCKDATAREADY 2
112 #define SOCKCLOSED 4
113 
114 #undef sock_init
115 #define sock_init() watt_sock_init (sizeof(tcp_Socket), sizeof(udp_Socket), sizeof(time_t))
116 
117 W32_FUNC int W32_CALL watt_sock_init (size_t tcp_Sock_size,
118  size_t udp_Sock_size,
119  size_t time_t_size);
120 W32_FUNC const char *W32_CALL sock_init_err (int rc);
121 
122 W32_FUNC void MS_CDECL sock_exit (void);
123 W32_FUNC void W32_CALL dbug_init (void); /* effective if compiled with `USE_DEBUG' */
124 W32_FUNC void W32_CALL init_misc (void); /* may be called before sock_init() */
125 W32_FUNC void W32_CALL sock_sig_exit (const char *msg, int sigint);
126 
127 W32_FUNC void W32_CALL assert_fail_test (void);
128 W32_FUNC void W32_CALL abort_test (void);
129 W32_FUNC void W32_CALL leak_test (void);
130 W32_FUNC void W32_CALL except_test (void);
131 
132 /*
133  * `s' is the pointer to a udp or tcp socket
134  */
135 W32_FUNC int W32_CALL sock_read (sock_type *s, BYTE *dp, size_t len);
136 W32_FUNC int W32_CALL sock_preread (const sock_type *s, BYTE *dp, int len);
137 W32_FUNC int W32_CALL sock_fastread (sock_type *s, BYTE *dp, int len);
138 W32_FUNC int W32_CALL sock_write (sock_type *s, const BYTE *dp, int len);
139 W32_FUNC int W32_CALL sock_enqueue (sock_type *s, const BYTE *dp, int len);
140 W32_FUNC int W32_CALL sock_fastwrite (sock_type *s, const BYTE *dp, int len);
141 W32_FUNC size_t W32_CALL sock_setbuf (sock_type *s, BYTE *buf, size_t len);
142 W32_FUNC void W32_CALL sock_flush (sock_type *s);
143 W32_FUNC void W32_CALL sock_noflush (sock_type *s);
144 W32_FUNC void W32_CALL sock_flushnext (sock_type *s);
145 W32_FUNC int W32_CALL sock_puts (sock_type *s, const BYTE *dp);
146 W32_FUNC WORD W32_CALL sock_gets (sock_type *s, BYTE *dp, int n);
147 W32_FUNC BYTE W32_CALL sock_putc (sock_type *s, BYTE c);
148 W32_FUNC int W32_CALL sock_getc (sock_type *s);
149 W32_FUNC WORD W32_CALL sock_dataready (sock_type *s);
150 W32_FUNC int W32_CALL sock_established(sock_type *s);
151 W32_FUNC int W32_CALL sock_close (sock_type *s);
152 W32_FUNC int W32_CALL sock_abort (sock_type *s);
153 
154 W32_FUNC WORD W32_CALL sock_mode (sock_type *s, WORD mode);
155 W32_FUNC int W32_CALL sock_sselect (const sock_type *s, int waitstate);
156 W32_FUNC int W32_CALL sock_timeout (sock_type *s, int seconds);
157 W32_FUNC int W32_CALL sock_recv (sock_type *s, void *buf, unsigned len);
158 W32_FUNC int W32_CALL sock_recv_init (sock_type *s, void *buf, unsigned len);
159 W32_FUNC int W32_CALL sock_recv_from (sock_type *s, DWORD *ip, WORD *port, void *buf, unsigned len, int peek);
160 W32_FUNC int W32_CALL sock_recv_used (const sock_type *s);
161 W32_FUNC int W32_CALL sock_keepalive (sock_type *s);
162 
163 W32_FUNC size_t W32_CALL sock_rbsize (const sock_type *s);
164 W32_FUNC size_t W32_CALL sock_rbused (const sock_type *s);
165 W32_FUNC size_t W32_CALL sock_rbleft (const sock_type *s);
166 W32_FUNC size_t W32_CALL sock_tbsize (const sock_type *s);
167 W32_FUNC size_t W32_CALL sock_tbused (const sock_type *s);
168 W32_FUNC size_t W32_CALL sock_tbleft (const sock_type *s);
169 
170 W32_FUNC VoidProc W32_CALL sock_yield (tcp_Socket *s, VoidProc fn);
171 
172 W32_FUNC int MS_CDECL sock_printf (sock_type *s, const char *fmt, ...)
173  #if defined(__GNUC__)
174  __attribute__((format(printf,2,3)))
175  #endif
176  ;
177 
178 W32_FUNC int MS_CDECL sock_scanf (sock_type *s, const char *fmt, ...)
179  #if defined(__GNUC__)
180  __attribute__((format(scanf,2,3)))
181  #endif
182  ;
183 
184 /*
185  * TCP or UDP specific stuff, must be used for open's and listens, but
186  * sock stuff above is used for everything else
187  */
188 W32_FUNC int W32_CALL udp_open (udp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
189 W32_FUNC int W32_CALL tcp_open (tcp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
190 W32_FUNC int W32_CALL udp_listen (udp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler);
191 W32_FUNC int W32_CALL tcp_listen (tcp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler, WORD timeout);
192 W32_FUNC int W32_CALL tcp_established (const tcp_Socket *s);
193 
194 
195 /*
196  * less general functions
197  */
198 W32_FUNC int W32_CALL tcp_cbreak (int mode);
199 W32_FUNC char *W32_CALL rip (char *s);
200 W32_FUNC int W32_CALL watt_kbhit (void);
201 W32_FUNC int W32_CALL priv_addr (DWORD ip);
202 
203 #define tcp_cbrk(mode) tcp_cbreak(mode) /* old name */
204 
205 /*
206  * Set MD5 secret for TCP option 19 (RFC-2385).
207  * Only if built with USE_TCP_MD5.
208  */
209 W32_FUNC const char *W32_CALL tcp_md5_secret (tcp_Socket *s, const char *secret);
210 
211 W32_FUNC void W32_CALL make_md5_signature (const in_Header *ip,
212  const tcp_Header *tcp,
213  WORD datalen,
214  const char *secret,
215  BYTE *buf);
216 
217 W32_FUNC BOOL W32_CALL check_md5_signature (const tcp_Socket *s,
218  const in_Header *ip);
219 
220 /*
221  * timers
222  */
223 W32_FUNC DWORD W32_CALL set_timeout (DWORD msec);
224 W32_FUNC int W32_CALL chk_timeout (DWORD value);
225 W32_FUNC int W32_CALL cmp_timers (DWORD t1, DWORD t2);
226 W32_FUNC int W32_CALL set_timediff (long msec);
227 W32_FUNC long W32_CALL get_timediff (DWORD now, DWORD t);
228 W32_FUNC int W32_CALL hires_timer (int on);
229 
230 W32_FUNC double W32_CALL timeval_diff (const struct timeval *a, const struct timeval *b);
231 W32_FUNC struct timeval W32_CALL timeval_diff2 (struct timeval *a, struct timeval *b);
232 
233 #if defined(__MSDOS__)
234  W32_FUNC void W32_CALL init_timer_isr (void);
235  W32_FUNC void W32_CALL exit_timer_isr (void);
236 #endif
237 
238 W32_FUNC void W32_CALL init_userSuppliedTimerTick (void);
239 W32_FUNC void W32_CALL userTimerTick (DWORD);
240 
241 W32_FUNC void W32_CALL ip_timer_init (sock_type *s, unsigned delayseconds);
242 W32_FUNC int W32_CALL ip_timer_expired (const sock_type *s);
243 
244 /*
245  * TCP/IP system variables
246  */
247 W32_DATA DWORD my_ip_addr;
248 W32_DATA DWORD sin_mask; /* eg. 0xFFFFFE00L */
249 W32_DATA int sock_delay;
250 W32_DATA int sock_inactive;
251 W32_DATA int sock_data_timeout;
252 W32_DATA WORD multihomes;
253 
254 W32_DATA int block_tcp;
255 W32_DATA int block_udp;
256 W32_DATA int block_icmp;
257 W32_DATA int block_ip;
258 W32_DATA WORD last_cookie;
259 W32_DATA DWORD cookies [MAX_COOKIES];
260 
261 W32_DATA BOOL survive_eth;
262 W32_DATA BOOL survive_bootp;
263 W32_DATA BOOL survive_dhcp;
264 W32_DATA BOOL survive_rarp;
265 
266 W32_DATA unsigned tcp_OPEN_TO;
267 W32_DATA unsigned tcp_CLOSE_TO;
268 W32_DATA unsigned tcp_RTO_ADD;
269 W32_DATA unsigned tcp_RTO_BASE;
270 W32_DATA unsigned tcp_RTO_SCALE;
271 W32_DATA unsigned tcp_RST_TIME;
272 W32_DATA unsigned tcp_RETRAN_TIME;
273 W32_DATA unsigned tcp_MAX_VJSA;
274 W32_DATA unsigned tcp_MAX_VJSD;
275 W32_DATA DWORD tcp_recv_win;
276 
277 W32_DATA int (W32_CALL *loopback_handler) (in_Header *ip);
278 
279 /*
280  * things you probably won't need to know about
281  */
282 
283 /*
284  * sock_debugdump
285  * - dump some socket control block parameters
286  * used for testing the kernal, not recommended
287  */
288 W32_FUNC void W32_CALL sock_debugdump (const sock_type *s);
289 
290 /*
291  * tcp_config - read a configuration file
292  * - if special path desired, call after sock_init()
293  * - NULL reads path WATTCP.CFG env-var or from program's path
294  * see sock_init();
295  */
296 W32_FUNC long W32_CALL tcp_config (const char *path);
297 
298 /*
299  * tcp_config_name - return name of configuration file.
300  */
301 W32_FUNC int W32_CALL tcp_config_name (char *name, int max);
302 
303 /*
304  * tcp_tick - must be called periodically by user application.
305  * - returns NULL when our socket closes
306  */
307 W32_FUNC WORD W32_CALL tcp_tick (sock_type *s);
308 
309 /*
310  * tcp_set_debug_state - set to 1,2 or reset 0
311  */
312 W32_FUNC void W32_CALL tcp_set_debug_state (WORD x);
313 
314 
315 /*
316  * name domain constants, etc.
317  */
318 W32_DATA WORD dns_timeout;
319 W32_DATA BOOL dns_recurse;
320 W32_DATA WORD _watt_handle_cbreak; /* ^C/^Break handle mode */
321 W32_DATA volatile int _watt_cbroke; /* ^C/^Break occured */
322 W32_DATA unsigned _mtu, _mss;
323 W32_DATA int ctrace_on;
324 W32_DATA int debug_on;
325 W32_DATA int has_rdtsc;
326 W32_DATA DWORD clocks_per_usec;
327 W32_DATA unsigned tcp_keep_idle;
328 W32_DATA unsigned tcp_keep_intvl;
329 W32_DATA unsigned tcp_max_idle;
330 
331 #if !defined(WATT32_NO_OLDIES)
332  /* Old compatibility
333  */
334  #define wathndlcbrk _watt_handle_cbreak
335  #define watcbroke _watt_cbroke
336 #endif
337 
338 /*
339  * DNS stuff
340  */
341 W32_DATA int (W32_CALL *_resolve_hook)(void);
342 W32_DATA BOOL _resolve_exit;
343 W32_DATA BOOL _resolve_timeout;
344 
345 W32_DATA char defaultdomain [MAX_HOSTLEN+1];
346 W32_DATA char *def_domain;
347 W32_DATA DWORD def_nameservers [MAX_NAMESERVERS];
348 W32_DATA WORD last_nameserver;
349 W32_DATA int dom_errno;
350 
351 W32_FUNC DWORD W32_CALL resolve (const char *name);
352 W32_FUNC int W32_CALL resolve_ip (DWORD ip, char *name, int len);
353 W32_FUNC int W32_CALL resolve_ip6 (const char *name, void *addr);
354 W32_FUNC DWORD W32_CALL lookup_host (const char *host, char *ip_str);
355 W32_FUNC const char *W32_CALL dom_strerror (int err);
356 W32_FUNC char *W32_CALL dom_remove_dot(char *name);
357 
358 /*
359  * sock_wait_ .. macros
360  */
361 
362 /*
363  * sock_wait_established()
364  * - Waits until connected or aborts if timeout etc.
365  *
366  * sock_wait_input()
367  * - Waits for received input on socket 's'.
368  * - May not be valid input for sock_gets().. check returned length.
369  *
370  * sock_tick()
371  * - Do tick and jump on abort.
372  *
373  * sock_wait_closed()
374  * - Close socket and wait until fully closed.
375  * Discards all received data.
376  *
377  * All these macros jump to label sock_err with contents of *statusptr
378  * set to
379  * 1 on closed normally.
380  * -1 on error, call sockerr(s) for cause.
381  *
382  */
383 W32_FUNC int W32_CALL _ip_delay0 (sock_type *s, int sec, UserHandler fn, int *statusptr);
384 W32_FUNC int W32_CALL _ip_delay1 (sock_type *s, int sec, UserHandler fn, int *statusptr);
385 W32_FUNC int W32_CALL _ip_delay2 (sock_type *s, int sec, UserHandler fn, int *statusptr);
386 
387 
388 #define sock_wait_established(s,seconds,fn,statusptr) \
389  do { \
390  if (_ip_delay0 (s,seconds,fn,statusptr)) \
391  goto sock_err; \
392  } while (0)
393 
394 #define sock_wait_input(s,seconds,fn,statusptr) \
395  do { \
396  if (_ip_delay1 (s,seconds,fn,statusptr)) \
397  goto sock_err; \
398  } while (0)
399 
400 #define sock_tick(s, statusptr) \
401  do { \
402  if (!tcp_tick(s)) { \
403  if (statusptr) *statusptr = -1; \
404  goto sock_err; \
405  } \
406  } while (0)
407 
408 #define sock_wait_closed(s,seconds,fn,statusptr) \
409  do { \
410  if (_ip_delay2(s,seconds,fn,statusptr)) \
411  goto sock_err; \
412  } while (0)
413 
414 /*
415  * User hook for WATTCP.CFG initialisation file.
416  */
417 W32_DATA void (W32_CALL *usr_init) (const char *keyword, const char *value);
418 W32_DATA void (W32_CALL *usr_post_init) (void);
419 
435  };
436 
437 struct config_table {
438  const char *keyword;
439  enum config_tab_types type;
440  void *arg_func;
441  };
442 
443 
444 W32_FUNC int W32_CALL parse_config_table (
445  const struct config_table *tab,
446  const char *section,
447  const char *name,
448  const char *value);
449 
450 /*
451  * Run with no config file (embedded/diskless)
452  */
453 W32_DATA int _watt_no_config;
454 
455 W32_FUNC void W32_CALL tcp_inject_config (
456  const struct config_table *cfg,
457  const char *key,
458  const char *value);
459 
460 typedef long (W32_CALL * WattUserConfigFunc) (int pass, const struct config_table *cfg);
461 
462 W32_FUNC WattUserConfigFunc W32_CALL _watt_user_config (WattUserConfigFunc fn);
463 
464 
465 /*
466  * Bypass standard handling of DHCP transient configuration
467  */
468 #include <sys/pack_on.h>
469 
470 struct DHCP_config {
471  DWORD my_ip;
472  DWORD netmask;
473  DWORD gateway;
474  DWORD nameserver;
475  DWORD server;
476  DWORD iplease;
477  DWORD renewal;
478  DWORD rebind;
479  DWORD tcp_keep_intvl;
480  BYTE default_ttl;
481  char _hostname [MAX_HOSTLEN+1];
482  char domain [MAX_HOSTLEN+1];
483  char loghost [MAX_HOSTLEN+1]; /* Only used if USE_BSD_FUNC defined */
484  };
485 
486 #include <sys/pack_off.h>
487 
488 enum DHCP_config_op {
489  DHCP_OP_READ = 0,
490  DHCP_OP_WRITE = 1,
491  DHCP_OP_ERASE = 2
492  };
493 
494 W32_DATA BOOL DHCP_did_gratuitous_arp;
495 
496 typedef int (W32_CALL * WattDHCPConfigFunc) (enum DHCP_config_op op,
497  struct DHCP_config *cfg);
498 
499 W32_FUNC WattDHCPConfigFunc W32_CALL DHCP_set_config_func (WattDHCPConfigFunc fn);
500 
501 W32_FUNC void W32_CALL DHCP_release (BOOL force);
502 W32_FUNC int W32_CALL DHCP_read_config (void);
503 W32_FUNC DWORD W32_CALL DHCP_get_server (void);
504 
505 /*
506  * Various function-pointer hooks etc.
507  */
508 W32_DATA int (MS_CDECL *_printf) (const char *, ...)
509  #if defined(__GNUC__)
510  __attribute__((format(printf,1,2)))
511  #endif
512  ;
513 
514 W32_DATA int (W32_CALL *_outch) (char c);
515 W32_DATA void (W32_CALL *wintr_chain) (void);
516 W32_DATA int (W32_CALL *_tftp_write) (const void *buf, size_t length);
517 W32_DATA int (W32_CALL *_tftp_close) (void);
518 
519 W32_FUNC void W32_CALL outs (const char *s);
520 W32_FUNC void W32_CALL outsnl (const char *s);
521 W32_FUNC void W32_CALL outsn (const char *s, int n);
522 W32_FUNC void W32_CALL outhexes(const char *s, int n);
523 W32_FUNC void W32_CALL outhex (char ch);
524 
525 W32_FUNC int W32_CALL wintr_enable (void);
526 W32_FUNC void W32_CALL wintr_disable (void);
527 W32_FUNC void W32_CALL wintr_shutdown (void);
528 W32_FUNC void W32_CALL wintr_init (void);
529 
530 W32_FUNC int W32_CALL _ping (DWORD host, DWORD num, const BYTE *pattern, size_t len);
531 W32_FUNC DWORD W32_CALL _chk_ping (DWORD host, DWORD *ping_num);
532 W32_FUNC void W32_CALL add_ping (DWORD host, DWORD tim, DWORD number);
533 
534 W32_FUNC int W32_CALL _eth_init (void);
535 W32_FUNC void W32_CALL _eth_release (void);
536 W32_FUNC void *W32_CALL _eth_formatpacket (const void *eth_dest, WORD eth_type);
537 W32_FUNC void W32_CALL _eth_free (const void *buf);
538 W32_FUNC void *W32_CALL _eth_arrived (WORD *type, BOOL *brdcast);
539 W32_FUNC int W32_CALL _eth_send (WORD len, const void *sock, const char *file, unsigned line);
540 W32_FUNC int W32_CALL _eth_set_addr (const void *addr);
541 W32_FUNC BYTE W32_CALL _eth_get_hwtype (BYTE *hwtype, BYTE *hwlen);
542 
543 W32_DATA void *(W32_CALL *_eth_recv_hook) (WORD *type);
544 W32_DATA int (W32_CALL *_eth_recv_peek) (void *mac_buf);
545 W32_DATA int (W32_CALL *_eth_xmit_hook) (const void *buf, unsigned len);
546 
547 W32_FUNC WORD W32_CALL in_checksum (const void *buf, unsigned len);
548 
549 #define inchksum(buf,len) in_checksum(buf, len)
550 
551 /*
552  * Stuff for Windows only
553  */
554 #if defined(WATT32_ON_WINDOWS)
555  W32_FUNC int MS_CDECL gui_printf (const char *fmt, ...);
556  W32_FUNC char * W32_CALL win_strerror (DWORD err);
557 
558  #define pkt_win_print_GetIfTable W32_NAMESPACE (pkt_win_print_GetIfTable)
559  #define pkt_win_print_GetIfTable2 W32_NAMESPACE (pkt_win_print_GetIfTable2)
560  #define pkt_win_print_GetAdaptersAddresses W32_NAMESPACE (pkt_win_print_GetAdaptersAddresses)
561  #define pkt_win_print_RasEnumConnections W32_NAMESPACE (pkt_win_print_RasEnumConnections)
562  #define pkt_win_print_WlanEnumInterfaces W32_NAMESPACE (pkt_win_print_WlanEnumInterfaces)
563 
564  W32_FUNC int W32_CALL pkt_win_print_GetIfTable (void);
565  W32_FUNC int W32_CALL pkt_win_print_GetIfTable2 (void);
566  W32_FUNC int W32_CALL pkt_win_print_GetAdaptersAddresses (void);
567  W32_FUNC int W32_CALL pkt_win_print_RasEnumConnections (void);
568  W32_FUNC int W32_CALL pkt_win_print_WlanEnumInterfaces (void);
569 #endif
570 
571 /*
572  * BSD-socket similarities.
573  * Refer <sys/socket.h> for the real thing.
574  */
575 
576 struct watt_sockaddr { /* for _getpeername, _getsockname */
577  WORD s_type;
578  WORD s_port;
579  DWORD s_ip;
580  BYTE s_spares[6]; /* unused */
581  };
582 
583 enum CHK_SOCKET_VAL { /* ret-vals from _chk_socket() */
584  VALID_UDP = 1,
585  VALID_TCP,
586  VALID_IP4,
587  VALID_IP6
588  };
589 
590 W32_FUNC DWORD W32_CALL _gethostid (void);
591 W32_FUNC DWORD W32_CALL _sethostid (DWORD ip);
592 W32_FUNC int W32_CALL _getsockname (const sock_type *s, void *dest, int *len);
593 W32_FUNC int W32_CALL _getpeername (const sock_type *s, void *dest, int *len);
594 
595 W32_FUNC int W32_CALL _chk_socket (const sock_type *s);
596 W32_FUNC void W32_CALL psocket (const sock_type *s);
597 W32_FUNC void W32_CALL sock_sturdy (sock_type *s, int level);
598 W32_FUNC const char * W32_CALL sockerr (const sock_type *s); /* UDP / TCP */
599 W32_FUNC void W32_CALL sockerr_clear(sock_type *s); /* UDP / TCP */
600 W32_FUNC const char * W32_CALL sockstate (const sock_type *s); /* UDP / TCP / Raw */
601 
602 /*
603  * Reduce internal states to "user-easy" states, GvB 2002-09
604  */
605 enum TCP_SIMPLE_STATE {
606  TCP_CLOSED,
607  TCP_LISTENING,
608  TCP_OPENING,
609  TCP_OPEN,
610  TCP_CLOSING
611  };
612 
613 W32_FUNC enum TCP_SIMPLE_STATE W32_CALL tcp_simple_state (const tcp_Socket *s);
614 
615 W32_FUNC char *W32_CALL _inet_ntoa (char *s, DWORD x);
616 W32_FUNC DWORD W32_CALL _inet_addr (const char *name);
617 W32_FUNC DWORD W32_CALL aton (const char *name);
618 W32_FUNC int W32_CALL isaddr (const char *name);
619 W32_FUNC DWORD W32_CALL aton_dotless (const char *str);
620 W32_FUNC BOOL W32_CALL isaddr_dotless (const char *str, DWORD *ip);
621 
622 W32_FUNC int W32_CALL addwattcpd (VoidProc p);
623 W32_FUNC int W32_CALL delwattcpd (VoidProc p);
624 W32_FUNC void W32_CALL stopwattcpd (void);
625 
626 
627 /*
628  * BSD functions for read/write/select
629  */
630 W32_FUNC int W32_CALL close_s (int s);
631 W32_FUNC int W32_CALL write_s (int s, const char *buf, int nbyte);
632 W32_FUNC int W32_CALL read_s (int s, char *buf, int nbyte);
633 W32_FUNC int W32_CALL writev_s (int s, const struct iovec *vector, size_t count);
634 W32_FUNC int W32_CALL readv_s (int s, const struct iovec *vector, size_t count);
635 
636 W32_FUNC int W32_CALL select_s (int num_sockets,
637  fd_set *read_events,
638  fd_set *write_events,
639  fd_set *except_events,
640  struct timeval *timeout);
641 
642 /* Some BSD/Winsock replacements.
643  * Normally belongs in djgpp's <unistd.h>.
644  *
645  * When compiling ../src/winadif.c, these prototypes conflicts with the
646  * one in <winsock*.h>.
647  *
648  * Note: gethostname() is also in <sys/socket.h>
649  */
650 #if !defined(__DJGPP__) && !defined(WATT32_COMPILING_WINADINF_C)
651  W32_FUNC int W32_CALL select (int num_sockets,
652  fd_set *read_events,
653  fd_set *write_events,
654  fd_set *except_events,
655  struct timeval *timeout);
656 #endif
657 
658 #if defined(__DJGPP__)
659  W32_FUNC int W32_CALL gethostname (char *name, int len);
660 
661 #elif !defined(WATT32_COMPILING_WINADINF_C)
662  W32_FUNC int W32_CALL gethostname (char *name, size_t len);
663 #endif
664 
665 #if defined(__CYGWIN__)
666  /* CygWin's <unistd.h> doesn't agree with other vendors here.
667  */
668  W32_FUNC long W32_CALL gethostid (void);
669  W32_FUNC long W32_CALL sethostid (u_long ip);
670  W32_FUNC int W32_CALL sethostname (const char *name, size_t len);
671 #else
672  W32_FUNC u_long W32_CALL gethostid (void);
673  W32_FUNC u_long W32_CALL sethostid (u_long ip);
674  W32_FUNC int W32_CALL sethostname (const char *name, int len);
675 #endif
676 
677 /*
678  * Multicast stuff (if built with `USE_MULTICAST')
679  */
680 W32_DATA int _multicast_on, _multicast_intvl;
681 
682 W32_FUNC int W32_CALL join_mcast_group (DWORD ip);
683 W32_FUNC int W32_CALL leave_mcast_group (DWORD ip);
684 W32_FUNC int W32_CALL multi_to_eth (DWORD ip, eth_address *eth);
685 W32_FUNC int W32_CALL udp_SetTTL (udp_Socket *s, BYTE ttl);
686 W32_FUNC int W32_CALL num_mcast_active (void);
687 
688 /*
689  * Commandline parsing.
690  *
691  * The tricky part is that all the below headers declare getopt().
692  * So we fall back to the watt_getopt() in Watt-32 for others who doesn't
693  * have it. But we must allways export / define getopt.c functions and
694  * data.
695  */
696 #if defined(__DJGPP__)
697  #include <unistd.h>
698  #define WATT32_NO_GETOPT
699 
700 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1250) /* OW 1.5+ */
701  #include <unistd.h>
702  #define WATT32_NO_GETOPT
703 
704 #elif defined(__MINGW32__) || defined(__CYGWIN__)
705  #include <unistd.h>
706  #include <getopt.h>
707  #define WATT32_NO_GETOPT
708 #endif
709 
710 enum _watt_optmode {
711  GETOPT_UNIX, /* options at start of argument list (default) */
712  GETOPT_ANY, /* move non-options to the end */
713  GETOPT_KEEP, /* return options in order */
714  };
715 
716 W32_DATA char *watt_optarg; /* argument of current option */
717 W32_DATA int watt_optind; /* index of next argument; default=0: initialize */
718 W32_DATA int watt_opterr; /* 0=disable error messages; default=1: enable */
719 W32_DATA int watt_optopt; /* option char returned from getopt() */
720 W32_DATA char *watt_optswchar; /* characters introducing options; default="-" */
721 
722 W32_FUNC int W32_CALL watt_getopt (int argc, char *const *argv, const char *opt_str);
723 
724 #if !defined(WATT32_NO_GETOPT)
725  #define optarg watt_optarg
726  #define optind watt_optind
727  #define opterr watt_opterr
728  #define optopt watt_optopt
729  #define optswchar watt_optswchar
730  #define getopt watt_getopt
731 #endif
732 
733 #if defined(WATT32_ON_WINDOWS)
734  /* to-do */
735  W32_DATA wchar_t * _w_watt_optarg;
736  W32_DATA wchar_t * _w_watt_optswchar;
737  W32_FUNC int W32_CALL _w_watt_getopt (int argc, wchar_t *const *argv, const wchar_t *opt_str);
738 
739  #if (defined(UNICODE) || defined(_UNICODE)) && !defined(_tgetopt)
740  #define _toptarg _w_watt_optarg
741  #define _toptswchar _w_watt_optswchar
742  #define _tgetopt(c,a,o) _w_watt_getopt (c,a,o)
743  #else
744  #define _toptarg watt_optarg
745  #define _toptswchar watt_optswchar
746  #define _tgetopt(c,a,o) watt_getopt(c,a,o)
747  #endif
748 #endif /* WATT32_ON_WINDOWS */
749 
750 /*
751  * Statistics printing
752  */
753 W32_FUNC void W32_CALL print_mac_stats (void);
754 W32_FUNC void W32_CALL print_pkt_stats (void);
755 W32_FUNC void W32_CALL print_vjc_stats (void);
756 W32_FUNC void W32_CALL print_arp_stats (void);
757 W32_FUNC void W32_CALL print_pppoe_stats(void);
758 W32_FUNC void W32_CALL print_ip4_stats (void);
759 W32_FUNC void W32_CALL print_ip6_stats (void);
760 W32_FUNC void W32_CALL print_icmp_stats (void);
761 W32_FUNC void W32_CALL print_igmp_stats (void);
762 W32_FUNC void W32_CALL print_udp_stats (void);
763 W32_FUNC void W32_CALL print_tcp_stats (void);
764 W32_FUNC void W32_CALL print_all_stats (void);
765 W32_FUNC void W32_CALL reset_stats (void);
766 
767 W32_FUNC int W32_CALL sock_stats (sock_type *s, DWORD *days, WORD *inactive,
768  WORD *cwindow, DWORD *avg, DWORD *sd);
769 
770 /*
771  * PktDrvr/WinPcap interface
772  */
773 
774 /*\struct PktStats
775  *
776  * Driver statistics.
777  */
778 struct PktStats {
779  DWORD in_packets; /* # of packets received */
780  DWORD out_packets; /* # of packets transmitted */
781  DWORD in_bytes; /* # of bytes received */
782  DWORD out_bytes; /* # of bytes transmitted */
783  DWORD in_errors; /* # of reception errors */
784  DWORD out_errors; /* # of transmission errors */
785  DWORD lost; /* # of packets lost (RX) */
786  };
787 
788 #if defined(WATT32_ON_WINDOWS)
789 
792  #define PDCLASS_ETHER 0
793  #define PDCLASS_TOKEN 1
794  #define PDCLASS_FDDI 2
795  #define PDCLASS_ARCNET 6
796  #define PDCLASS_SLIP 0xFF01
797  #define PDCLASS_AX25 0xFF02
798  #define PDCLASS_TOKEN_RIF 0xFF03
799  #define PDCLASS_PPP 0xFF04
800  #define PDCLASS_UNKNOWN 0xFFFF
801 
802  struct PktParameters {
803  int dummy; /* To be defined */
804  };
805 #else
806 
810  #define PDCLASS_ETHER 1
811  #define PDCLASS_TOKEN 3
812  #define PDCLASS_SLIP 6
813  #define PDCLASS_ARCNET 8
814  #define PDCLASS_AX25 9
815  #define PDCLASS_FDDI 12
816  #define PDCLASS_TOKEN_RIF 17
817  #define PDCLASS_PPP 18
818  #define PDCLASS_UNKNOWN 0xFFFF
819 
820  #include <sys/pack_on.h> /* cstate, slcompress etc. must be packed */
821 
822  /*\struct PktParameters
823  *
824  * PKTDRVR parameters.
825  */
826  struct PktParameters {
827  BYTE major_rev; /* Revision of Packet Driver spec */
828  BYTE minor_rev; /* this driver conforms to. */
829  BYTE length; /* Length of structure in bytes */
830  BYTE addr_len; /* Length of a MAC-layer address */
831  WORD mtu; /* MTU, including MAC headers */
832  WORD multicast_avail; /* Buffer size for multicast addr */
833  WORD rcv_bufs; /* (# of back-to-back MTU rcvs) - 1 */
834  WORD xmt_bufs; /* (# of successive xmits) - 1 */
835  WORD int_num; /* interrupt for post-EOI processing */
836  };
837 
838  #include <sys/pack_off.h>
839 #endif
840 
841 W32_FUNC int W32_CALL pkt_eth_init (mac_address *eth);
842 W32_FUNC int W32_CALL pkt_release (void);
843 W32_FUNC int W32_CALL pkt_reset_handle (WORD handle);
844 W32_FUNC int W32_CALL pkt_send (const void *tx, int length);
845 W32_FUNC int W32_CALL pkt_buf_wipe (void);
846 W32_FUNC void W32_CALL pkt_free_pkt (const void *pkt);
847 W32_FUNC int W32_CALL pkt_waiting (void);
848 W32_FUNC int W32_CALL pkt_set_addr (const void *eth);
849 W32_FUNC int W32_CALL pkt_get_addr (mac_address *eth);
850 W32_FUNC int W32_CALL pkt_get_mtu (void);
851 W32_FUNC int W32_CALL pkt_get_drvr_ver (WORD *major, WORD *minor, WORD *unused, WORD *build);
852 W32_FUNC int W32_CALL pkt_get_api_ver (WORD *ver);
853 W32_FUNC int W32_CALL pkt_set_rcv_mode (int mode);
854 W32_FUNC int W32_CALL pkt_get_rcv_mode (void);
855 W32_FUNC BOOL W32_CALL pkt_check_address (DWORD my_ip);
856 W32_FUNC BOOL W32_CALL pkt_is_init (void);
857 W32_FUNC int W32_CALL pkt_get_params (struct PktParameters *params);
858 W32_FUNC int W32_CALL pkt_get_stats (struct PktStats *stats, struct PktStats *total);
859 W32_FUNC DWORD W32_CALL pkt_dropped (void);
860 W32_FUNC int W32_CALL pkt_get_vector (void);
861 
862 W32_FUNC const char * W32_CALL pkt_strerror (int code);
863 W32_FUNC const char * W32_CALL pkt_get_device_name (void); /* "\Device\NPF_{..." */
864 W32_FUNC const char * W32_CALL pkt_get_drvr_name (void); /* NPF.SYS/SwsVpkt.sys/airpcap.sys etc. */
865 W32_FUNC const char * W32_CALL pkt_get_drvr_descr (void); /* Driver description */
866 W32_FUNC WORD W32_CALL pkt_get_drvr_class (void); /* Driver class */
867 
868 
869 /*
870  * Controlling timer interrupt handler for background processing.
871  * Not recommended, little tested
872  */
873 #if !defined(WATT32_ON_WINDOWS)
874  W32_FUNC void W32_CALL backgroundon (void);
875  W32_FUNC void W32_CALL backgroundoff (void);
876  W32_FUNC void W32_CALL backgroundfn (VoidProc func);
877 #endif
878 
879 /*
880  * Misc functions
881  */
882 #if !defined(__DJGPP__) && !defined(__CYGWIN__) && \
883  !(defined(__WATCOMC__) && (__WATCOMC__ >= 1240))
884  #define ffs W32_NAMESPACE (ffs)
885  W32_FUNC int W32_CALL ffs (int mask);
886 #endif
887 
888 #if defined (__HIGHC__)
889  W32_FUNC int W32_CALL system (const char *cmd);
890  pragma Alias (system, "_mw_watt_system");
891 #endif
892 
893 #if defined (__HIGHC__) || (defined(__DMC__) && defined(__MSDOS__))
894  #define delay W32_NAMESPACE (delay)
895  W32_FUNC void W32_CALL delay (unsigned int msec);
896 #endif
897 
898 W32_FUNC unsigned W32_CALL Random (unsigned a, unsigned b);
899 W32_FUNC void W32_CALL RandomWait (unsigned a, unsigned b);
900 
901 
902 /*
903  * Tracing to RS-232 serial port, by Gundolf von Bachhaus <GBachhaus@gmx.net>
904  * Watt-32 library must be compiled with `USE_RS232_DBG' (see .\src\config.h)
905  */
906 W32_FUNC int W32_CALL trace2com_init (WORD portAddress, DWORD baudRate);
907 W32_FUNC int MS_CDECL __trace2com (const char *fmt, ...)
908  #if defined(__GNUC__)
909  __attribute__((format(printf,1,2)))
910  #endif
911  ;
912 
913 #ifdef __cplusplus
914 }
915 #endif
916 
917 #endif /* RC_INVOKED */
918 #endif /* __WATT_TCP_H */
Definition: wtypes.h:197
convert to hex-word
Definition: tcp.h:429
W32_FUNC BOOL W32_CALL isaddr_dotless(const char *str, DWORD *ip)
Check if 'str' is a dotless ip address.
Definition: netaddr.c:148
W32_FUNC WORD W32_CALL sock_dataready(sock_type *s)
sock_dataready - returns number of bytes waiting to be read.
Definition: sock_io.c:246
W32_FUNC int W32_CALL pkt_set_addr(const void *eth)
Set a new MAC source address.
Definition: pcpkt.c:1198
W32_FUNC int W32_CALL pkt_get_params(struct PktParameters *params)
Get PKTDRVR parameters (MTU, version etc.)
Definition: pcpkt.c:466
W32_FUNC int W32_CALL _eth_init(void)
Initialize the network driver interface.
Definition: pcsed.c:659
W32_FUNC DWORD W32_CALL _inet_addr(const char *name)
Convert a string into an IP-address.
Definition: netaddr.c:69
W32_FUNC int W32_CALL isaddr(const char *name)
Check if 'str' is simply an ip address.
Definition: netaddr.c:128
W32_FUNC const char *W32_CALL wattcpVersion(void)
Return string for Watt-32 version.
Definition: version.c:76
W32_DATA volatile int _watt_cbroke
Definition: tcp.h:321
W32_FUNC void W32_CALL init_misc(void)
Initialise various stuff.
Definition: misc.c:324
W32_FUNC int W32_CALL sock_abort(sock_type *s)
Abort a UDP/TCP/Raw socket.
Definition: pctcp.c:2823
convert to int
Definition: tcp.h:424
W32_FUNC void W32_CALL sock_sturdy(sock_type *s, int level)
Keep the socket open inspite of receiving "ICMP Unreachable" For UDP or TCP socket.
Definition: oldstuff.c:69
W32_FUNC void W32_CALL 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.
Definition: pcconfig.c:893
W32_FUNC WORD W32_CALL in_checksum(const void *buf, unsigned len)
This checksum routine is only used by 16-bit targets (and files outside the library).
Definition: chksum.c:29
W32_FUNC char *W32_CALL rip(char *s)
Removes end-of-line termination from a string.
Definition: strings.c:180
call convertion function
Definition: tcp.h:434
W32_FUNC DWORD W32_CALL _chk_ping(DWORD host, DWORD *ping_num)
Check for ICMP echo reply in ping-cache.
Definition: pcping.c:169
W32_FUNC char *W32_CALL _inet_ntoa(char *s, DWORD x)
Convert an IP-address 'ip' into a string.
Definition: netaddr.c:43
W32_FUNC int W32_CALL watt_kbhit(void)
A less CPU hogging kbhit().
Definition: misc.c:900
W32_FUNC int W32_CALL select_s(int num_sockets, fd_set *read_events, fd_set *write_events, fd_set *except_events, struct timeval *timeout)
The select_s() function.
Definition: select.c:112
BOOL _watt_no_config
run with no config file (embedded/diskless)
Definition: sock_ini.c:135
unsigned tcp_RTO_BASE
Base time for RTO calculation.
Definition: pctcp.c:116
W32_FUNC DWORD W32_CALL DHCP_get_server(void)
Return current DHCP server address.
Definition: pcdhcp.c:739
BOOL block_tcp
when application handles TCP itself
Definition: pctcp.c:65
W32_FUNC int W32_CALL _eth_set_addr(const void *addr)
Sets a new MAC address for our interface.
Definition: pcsed.c:731
W32_FUNC int W32_CALL udp_SetTTL(udp_Socket *s, BYTE ttl)
Set the TTL on an outgoing UDP datagram.
Definition: pctcp.c:289
DWORD tcp_recv_win
RWIN for BSD sockets only.
Definition: pctcp.c:135
unsigned tcp_max_idle
max idle time before kill
Definition: pctcp.c:134
W32_DATA BOOL survive_bootp
Survive a failed BOOTP attempt.
Definition: tcp.h:262
W32_FUNC const char *W32_CALL wattcpCapabilities(void)
Return compiled-in capabilities and features.
Definition: version.c:568
W32_FUNC void W32_CALL userTimerTick(DWORD)
Provide timer-ticks from an application.
Definition: timer.c:186
copy string value
Definition: tcp.h:432
W32_FUNC int W32_CALL pkt_waiting(void)
Return number of packets waiting in queue.
Definition: pcpkt.c:1378
W32_FUNC DWORD W32_CALL _sethostid(DWORD ip)
Core-style: Sets local IPv4-address.
Definition: bsdname.c:58
resolve host to IPv4-address
Definition: tcp.h:433
W32_FUNC BYTE W32_CALL _eth_get_hwtype(BYTE *hwtype, BYTE *hwlen)
Fill in hardware address type/length for BOOTP/DHCP packets.
Definition: pcsed.c:751
BOOL has_rdtsc
Never set in Watt-32.
Definition: timer.c:52
DWORD clocks_per_usec
Measured CPU speed (MHz)
Definition: timer.c:62
W32_DATA BOOL survive_rarp
Don't survive a failed RARP attempt.
Definition: tcp.h:264
W32_FUNC DWORD W32_CALL pkt_dropped(void)
Return number of packets dropped.
Definition: pcpkt.c:1394
W32_FUNC unsigned W32_CALL Random(unsigned a, unsigned b)
Returns a random integer in range [a..b].
Definition: misc.c:742
BOOL block_icmp
when application handles ICMP itself
Definition: pctcp.c:67
W32_FUNC int W32_CALL pkt_get_addr(mac_address *eth)
Return the MAC address.
Definition: pcpkt.c:1159
W32_FUNC int W32_CALL sock_close(sock_type *s)
Close a UDP/TCP socket.
Definition: pctcp.c:3139
unsigned tcp_RTO_SCALE
Scaling used in RTO calculation.
Definition: pctcp.c:117
W32_FUNC void MS_CDECL sock_exit(void)
Our only atexit() handler.
Definition: sock_ini.c:1039
W32_FUNC int W32_CALL sock_fastwrite(sock_type *s, const BYTE *dp, int len)
Simpler, non-blocking (non-looping) version of sock_write().
Definition: pctcp.c:3018
W32_FUNC long W32_CALL gethostid(void)
BSD style: returns local IPv4-address.
Definition: bsdname.c:68
W32_FUNC void *W32_CALL _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...
Definition: pcsed.c:135
W32_FUNC const char *W32_CALL wattcpBuildCflags(void)
Return the used.
Definition: version.c:431
W32_FUNC DWORD W32_CALL set_timeout(DWORD msec)
Return time for when given timeout (msec) expires.
Definition: timer.c:503
W32_FUNC DWORD W32_CALL resolve(const char *name)
Convert host name to an address.
Definition: pcdns.c:775
W32_FUNC const char *W32_CALL pkt_strerror(int code)
Return textual error representing error-code.
Definition: pcpkt.c:216
W32_FUNC int W32_CALL _getsockname(const sock_type *s, void *dest, int *len)
Core-style: Return 'watt_sockaddr' for our side of a UDP/TCP connection.
Definition: bsdname.c:147
convert to 8-bit byte
Definition: tcp.h:425
unsigned tcp_RTO_ADD
Time added in RTO calculation.
Definition: pctcp.c:115
W32_FUNC int MS_CDECL W32_FUNC int MS_CDECL W32_FUNC int W32_CALL udp_open(udp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
UDP active open.
Definition: pctcp.c:192
convert to hex-dword
Definition: tcp.h:430
W32_FUNC int W32_CALL udp_listen(udp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
UDP passive open.
Definition: pctcp.c:157
W32_FUNC int W32_CALL sock_fastread(sock_type *s, BYTE *dp, int len)
Read a socket with maximum 'len' bytes.
Definition: pctcp.c:2931
W32_FUNC WattUserConfigFunc W32_CALL _watt_user_config(WattUserConfigFunc fn)
A user application may call the `_watt_user_config()' function prior to calling sock_init() to inject...
Definition: sock_ini.c:199
W32_FUNC int W32_CALL cmp_timers(DWORD t1, DWORD t2)
Compare two timers with expirary at 't1' and 't2'.
Definition: timer.c:359
DWORD sin_mask
our net-mask, 255.255.255.0
Definition: pctcp.c:71
W32_DATA wchar_t * _w_watt_optarg
Definition: getopt.c:182
W32_FUNC void W32_CALL pkt_free_pkt(const void *pkt)
Release a packet from the receive queue.
Definition: pcpkt.c:1349
W32_FUNC const char *W32_CALL wattcpBuildCCexe(void)
Return the the name if the compiler used.
Definition: version.c:456
W32_FUNC void W32_CALL sock_noflush(sock_type *s)
Sets non-flush mode on next TCP write.
Definition: pctcp.c:3088
unsigned tcp_RST_TIME
Don't generate RST too often.
Definition: pctcp.c:118
W32_FUNC DWORD W32_CALL aton_dotless(const char *str)
Converts `[dotless]' or `dotless' to 32 bit long (host order)
Definition: netaddr.c:115
W32_FUNC int W32_CALL pkt_reset_handle(WORD handle)
Reset the driver-state associated with handle.
Definition: pcpkt.c:727
W32_FUNC int W32_CALL DHCP_read_config(void)
Called from watt_sock_init() after "\c WATTCP.CFG" has been parsed.
Definition: pcdhcp.c:1774
void *W32_CALL * _eth_recv_hook(WORD *type)
Pointer to functions that when set changes the behaviour of polling and send functions _eth_arrived()...
W32_FUNC int W32_CALL hires_timer(int on)
Control use of high-resolution timer.
Definition: timer.c:377
unsigned tcp_MAX_VJSA
Default max VJ std.
Definition: pctcp.c:120
Definition: ip.h:67
W32_FUNC int W32_CALL sock_read(sock_type *s, BYTE *dp, size_t len)
Read a socket with maximum 'maxlen' bytes.
Definition: pctcp.c:2875
W32_FUNC int W32_CALL watt_sock_init(size_t tcp_Sock_size, size_t udp_Sock_size, size_t time_t_size)
Definition: sock_ini.c:749
W32_FUNC int W32_CALL pkt_get_drvr_ver(WORD *major, WORD *minor, WORD *unused, WORD *build)
Return version of PKTDRVR.
Definition: pcpkt.c:532
int W32_CALL sethostname(const char *fqdn, SETHOSTNAME_ARG2 len)
BSD-style: Expects a "Fully Qualified Domain Name" in `fqdn'.
Definition: bsdname.c:293
W32_FUNC void W32_CALL sock_sig_exit(const char *msg, int sigint)
Exit handler for unhandled signals.
Definition: sock_ini.c:1057
Definition: wtime.h:38
W32_DATA void(W32_CALL *usr_init)(const char *keyword
Hook to a function called after we're initialised.
W32_FUNC int W32_CALL pkt_eth_init(mac_address *eth)
Initialise Packet driver interface.
Definition: pcpkt.c:1449
W32_FUNC DWORD W32_CALL _gethostid(void)
Core style: Returns local IPv4-address.
Definition: bsdname.c:49
W32_FUNC int W32_CALL _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.
Definition: pcsed.c:306
W32_FUNC int W32_CALL priv_addr(DWORD ip)
Definition: netaddr.c:516
W32_FUNC int W32_CALL pkt_send(const void *tx, int length)
Send a link-layer frame.
Definition: pcpkt.c:1090
W32_FUNC int W32_CALL _getpeername(const sock_type *s, void *dest, int *len)
Core-style: Return 'watt_sockaddr' for peer in a UDP/TCP connection.
Definition: bsdname.c:112
convert to 16-bit word
Definition: tcp.h:426
W32_DATA BOOL survive_dhcp
Survive a failed DHCP attempt.
Definition: tcp.h:263
W32_FUNC long W32_CALL get_timediff(DWORD now, DWORD t)
Return time difference between timers 'now' and 'tim'.
Definition: timer.c:621
Definition: wtypes.h:179
W32_FUNC void W32_CALL add_ping(DWORD host, DWORD tim, DWORD number)
Add an ICMP echo reply to the ping-cache.
Definition: pcping.c:147
W32_FUNC int W32_CALL sock_puts(sock_type *s, const BYTE *dp)
Definition: sock_io.c:39
W32_FUNC int W32_CALL pkt_get_api_ver(WORD *ver)
Return version of spec.
Definition: pcpkt.c:519
W32_FUNC const char *W32_CALL dom_strerror(int err)
Return text for error code (dom_errno).
Definition: pcdns.c:746
W32_FUNC DWORD W32_CALL aton(const char *name)
Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address.
Definition: netaddr.c:86
Definition: zinftree.h:24
W32_DATA BOOL survive_eth
GvB 2002-09, allows us to survive without a (working) packet driver at all - in cases where life stil...
Definition: tcp.h:261
W32_FUNC int W32_CALL pkt_get_mtu(void)
Return PKTDRVR maximum-transmit-units (MTU).
Definition: pcpkt.c:489
W32_FUNC int W32_CALL pkt_get_vector(void)
Return PKTDRVR vector.
Definition: pcpkt.c:546
W32_FUNC void *W32_CALL _eth_arrived(WORD *type, BOOL *brdcast)
Poll for arrival of new packets (IP/ARP/RARP/PPPoE protocol).
Definition: pcsed.c:1026
W32_FUNC void W32_CALL tcp_set_debug_state(WORD x)
Old comptibility function.
Definition: pcconfig.c:853
W32_FUNC int W32_CALL resolve_ip(DWORD ip, char *name, int len)
Resolve an IP-address to a name.
Definition: oldstuff.c:79
BOOL block_ip
when application handles IP itself
Definition: pctcp.c:68
W32_FUNC int W32_CALL pkt_get_stats(struct PktStats *stats, struct PktStats *total)
Get PKTDRVR statistics.
Definition: pcpkt.c:1243
W32_FUNC VoidProc W32_CALL sock_yield(tcp_Socket *s, VoidProc fn)
Enable user defined yield function.
Definition: pctcp.c:2803
W32_FUNC int W32_CALL pkt_set_rcv_mode(int mode)
Sets the receive mode of the interface.
Definition: pcpkt.c:1955
W32_FUNC void W32_CALL sock_flush(sock_type *s)
Send pending TCP data.
Definition: pctcp.c:3103
W32_FUNC int W32_CALL pkt_buf_wipe(void)
Clear the receive queue.
Definition: pcpkt.c:1334
BOOL block_udp
when application handles UDP itself
Definition: pctcp.c:66
duplicate string value
Definition: tcp.h:431
W32_FUNC int W32_CALL chk_timeout(DWORD value)
Check if milli-sec value has expired:
Definition: timer.c:547
W32_FUNC int W32_CALL set_timediff(long msec)
Must be called by user right before or after a time change occurs.
Definition: timer.c:608
W32_FUNC int W32_CALL _ping(DWORD host, DWORD num, const BYTE *pattern, size_t len)
Format and send an ICMP echo request (ping).
Definition: pcping.c:45
W32_FUNC int W32_CALL tcp_open(tcp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler)
Actively open a TCP connection.
Definition: pctcp.c:308
Definition: tcp.h:778
DWORD my_ip_addr
our IP address
Definition: pctcp.c:70
W32_FUNC void W32_CALL DHCP_release(BOOL force)
Possibly send a DHCP release.
Definition: pcdhcp.c:707
W32_FUNC int W32_CALL tcp_cbreak(int mode)
Sets our break mode.
Definition: pc_cbrk.c:207
char defaultdomain[MAX_HOSTLEN+1]
The 2 next variables are loaded from WATTCP.CFG file.
Definition: pcdns.c:71
W32_FUNC int W32_CALL sock_enqueue(sock_type *s, const BYTE *dp, int len)
For UDP, this function is same as sock_write().
Definition: pctcp.c:3044
unsigned tcp_CLOSE_TO
Default close timeout.
Definition: pctcp.c:114
unsigned tcp_MAX_VJSD
Default max VJ std.
Definition: pctcp.c:121
W32_FUNC WORD W32_CALL tcp_tick(sock_type *s)
Must be called periodically by user application (or BSD socket API).
Definition: pctcp.c:1389
W32_FUNC void W32_CALL _eth_free(const void *buf)
Free an input buffer once it is no longer needed.
Definition: pcsed.c:792
W32_FUNC int W32_CALL tcp_listen(tcp_Socket *s, WORD lport, DWORD ina, WORD port, ProtoHandler handler, WORD timeout)
Passively opens TCP a connection.
Definition: pctcp.c:389
unsigned tcp_keep_idle
idle time before sending keepalive
Definition: pctcp.c:132
unsigned tcp_RETRAN_TIME
Default retransmission time.
Definition: pctcp.c:119
config_tab_types
Definition: tcp.h:423
W32_FUNC int W32_CALL tcp_established(const tcp_Socket *s)
Returns 1 if TCP connection is established.
Definition: pctcp.c:635
W32_FUNC int W32_CALL sock_write(sock_type *s, const BYTE *dp, int len)
Writes data and returns length written.
Definition: pctcp.c:2960
XHOSTID_RETV W32_CALL sethostid(DWORD ip)
BSD-style: Sets local IPv4-address.
Definition: bsdname.c:79
convert to ip-address (host order)
Definition: tcp.h:427
W32_FUNC int W32_CALL pkt_release(void)
Definition: pcpkt.c:838
unsigned tcp_keep_intvl
time between keepalive probes
Definition: pctcp.c:133
W32_FUNC void W32_CALL RandomWait(unsigned a, unsigned b)
Wait for a random period in range [a..b] millisec.
Definition: misc.c:759
W32_FUNC void W32_CALL sock_flushnext(sock_type *s)
Causes next transmission to have a flush (PUSH bit set).
Definition: pctcp.c:3124
convert to hex-byte
Definition: tcp.h:428
W32_FUNC int W32_CALL 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'+'.
Definition: pcconfig.c:379
W32_FUNC void W32_CALL init_userSuppliedTimerTick(void)
init_userSuppliedTimerTick() - setup timer handling for programs that are already running a periodic ...
Definition: timer.c:156
W32_FUNC const char *W32_CALL wattcpBuildCC(void)
Return the target/compiler.
Definition: version.c:411
unsigned tcp_OPEN_TO
TCP timer values.
Definition: pctcp.c:113
W32_FUNC void W32_CALL _eth_release(void)
Release the hardware driver.
Definition: pcsed.c:1397
W32_FUNC int W32_CALL pkt_get_rcv_mode(void)
Gets the receive mode of the interface (can never be mode 0).
Definition: pcpkt.c:1999
W32_DATA WORD _watt_handle_cbreak
Turn off stack-checking here because stack may be out of bounds.
Definition: tcp.h:320
W32_FUNC WattDHCPConfigFunc W32_CALL DHCP_set_config_func(WattDHCPConfigFunc fn)
Sets up an application hook for doing DHCP operations (DHCP_config_op)
Definition: pcdhcp.c:1813