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

Go to the source code of this file.

Functions

typedef void (MS_CDECL *_signal_handler)(int)
 
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 its own configuration values into the tcp_config() parser. More...
 
static int do_exit (int code)
 Exit application if _watt_do_exit is TRUE (the default). More...
 
static void pre_except_handler (const struct FAULT_STRUC *exc)
 
static void do_traceback (void)
 
static void except_handler (int sig)
 
static void except_handler (excReg *regs)
 
static void except_handler (int sig, int code)
 
static void setup_sig_handlers (void)
 Install signal-handlers for fatal errors; SIGSEGV, SIGILL, SIGTRAP, SIGFPE etc.
 
static void restore_sig_handlers (void)
 
static void tcp_shutdown (void)
 Abort all TCP sockets, release DHCP lease and restore signal handlers.
 
static int tcp_init (void)
 Initialise the PKTDRVR (calls _eth_init()). More...
 
static void tcp_post_init (void)
 Initialise stuff based on configured values.
 
static int tcp_do_bootp (BOOL try_bootp, BOOL try_dhcp, BOOL try_rarp)
 Try to boot-up the stack using BOOTP, DHCP or RARP. More...
 
static void check_sock_sizes (size_t tcp_Sock_size, size_t udp_Sock_size)
 
static void check_time_t (size_t time_t_size)
 
const char *W32_CALL sock_init_err (int rc)
 
int W32_CALL watt_sock_init (size_t tcp_Sock_size, size_t udp_Sock_size, size_t time_t_size)
 
int W32_CALL sock_init (void)
 
void MS_CDECL sock_exit (void)
 Our only atexit() handler. More...
 
void W32_CALL sock_sig_exit (const char *msg, int sig)
 Exit handler for unhandled signals.
 

Variables

BOOL _bootp_on = FALSE
 Try booting using BOOTP ?
 
BOOL _dhcp_on = FALSE
 Try booting using DHCP ?
 
BOOL _dhcp6_on = FALSE
 Try booting using DHCP6 ?
 
BOOL _rarp_on = FALSE
 Try booting using RARP ?
 
BOOL _do_mask_req = FALSE
 do an "ICMP Mask Request" when configured
 
BOOL _watt_do_exit = TRUE
 exit program when all boot attempts failed
 
BOOL _watt_no_config = FALSE
 run with no config file (embedded/diskless)
 
WattUserConfigFunc _watt_user_config_fn = NULL
 
BOOL survive_eth = 0
 GvB 2002-09, allows us to survive without a (working) packet driver at all - in cases where life still has a meaning without TCP/IP.
 
BOOL survive_bootp = TRUE
 Survive a failed BOOTP attempt. More...
 
BOOL survive_dhcp = TRUE
 Survive a failed DHCP attempt. More...
 
BOOL survive_rarp = FALSE
 Don't survive a failed RARP attempt.
 
BOOL _watt_is_init = FALSE
 watt_sock_init() done (but with possible failed boot)
 
static BOOL tcp_is_init = FALSE
 tcp_init() called okay. More...
 
static int old_break = -1
 Original state of DOS's BREAK handler. More...
 
static BOOL use_except = TRUE
 Some target dependent functions. More...
 
static jmp_buf exc_jmp
 
static struct FAULT_STRUC exc_buf
 
static BOOL sock_init_called = FALSE
 The main initialisation routine. More...
 

Detailed Description

Watt-32 initialisation.

watt_sock_init() - easy way to guarentee:

Version
0.1: May 2, 1991 Erick - reorganized operations.
0.2: 1998 Gisle V. - Major rewrite; added DHCP, additional startup checks for various targets. Exception handler releases PKTDRVR.

Definition in file sock_ini.c.

Function Documentation

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 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 199 of file sock_ini.c.

static int do_exit ( int  code)
static

Exit application if _watt_do_exit is TRUE (the default).

Otherwise return 'code'. Only called during watt_sock_init().

Definition at line 211 of file sock_ini.c.

References _watt_do_exit.

static void except_handler ( int  sig)
static
Todo:
Disassemble crash address. Don't confuse this yet-to-be function with the function ShowStack() in stkwalk.cpp. That one is for Win32 only.

Definition at line 266 of file sock_ini.c.

References _watt_fatal_error.

void MS_CDECL 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 1039 of file sock_ini.c.

References _watt_fatal_error, _watt_is_init, and tcp_shutdown().

static int tcp_do_bootp ( BOOL  try_bootp,
BOOL  try_dhcp,
BOOL  try_rarp 
)
static

Try to boot-up the stack using BOOTP, DHCP or RARP.

Only called if at least one '_*on' flag is set.

Return values
0on success.

Definition at line 593 of file sock_ini.c.

References BOOTP_do_boot(), DHCP_do_boot(), survive_bootp, survive_dhcp, and survive_rarp.

static int tcp_init ( void  )
static

Initialise the PKTDRVR (calls _eth_init()).

  • Reset nameserver table.
  • Initialise local ports.
  • Get machine name (w/o domain) from LAN extension (if any).
  • Prepare parsing TCP configuration.
Note
May be called more than once without hurting.

Definition at line 499 of file sock_ini.c.

References _eth_init(), _get_machine_name(), hostname, init_localport(), and tcp_is_init.

int W32_CALL watt_sock_init ( size_t  tcp_Sock_size,
size_t  udp_Sock_size,
size_t  time_t_size 
)

Variable Documentation

int old_break = -1
static

Original state of DOS's BREAK handler.

Definition at line 160 of file sock_ini.c.

BOOL sock_init_called = FALSE
static

The main initialisation routine.

Called only once (during program startup). sock_init() is a macro in <tcp.h>.

Definition at line 747 of file sock_ini.c.

BOOL survive_bootp = TRUE

Survive a failed BOOTP attempt.

Don't survive a failed BOOTP attempt.

Definition at line 145 of file sock_ini.c.

BOOL survive_dhcp = TRUE

Survive a failed DHCP attempt.

Don't survive a failed DHCP attempt.

Definition at line 151 of file sock_ini.c.

BOOL tcp_is_init = FALSE
static

tcp_init() called okay.

Definition at line 159 of file sock_ini.c.

BOOL use_except = TRUE
static

Some target dependent functions.

Install signal handlers.

Definition at line 223 of file sock_ini.c.