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

SRC/SOCK_INI.C File Reference


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.

Go to the source code of this file.

Functions

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.
int do_exit (int code)
 Exit application if _watt_do_exit is TRUE (the default).
void pre_except_handler (const struct FAULT_STRUC *exc)
void do_traceback (void)
void except_handler (int sig)
void except_handler (excReg *regs)
void except_handler (int sig, int code)
void setup_sig_handlers (void)
 Install signal-handlers for fatal errors; SIGSEGV, SIGILL, SIGTRAP, SIGFPE etc.
void restore_sig_handlers (void)
void tcp_shutdown (void)
 Abort all TCP sockets, release DHCP lease and restore signal handlers.
int tcp_init (void)
 Initialise the PKTDRVR (calls _eth_init()).
void tcp_post_init (void)
 Initialise stuff based on configured values.
int tcp_do_boot (BOOL try_bootp, BOOL try_dhcp, BOOL try_rarp)
 Try to boot using BOOTP, DHCP or RARP.
void check_sock_sizes (size_t tcp_Sock_size, size_t udp_Sock_size)
void check_time_t (size_t time_t_size)
const char * sock_init_err (int rc)
int watt_sock_init (size_t tcp_Sock_size, size_t udp_Sock_size, size_t time_t_size)
int sock_init (void)
void MS_CDECL sock_exit (void)
 Our only atexit() handler.
void 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.
BOOL survive_dhcp = TRUE
 Survive a failed DHCP attempt.
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)
BOOL tcp_is_init = FALSE
 tcp_init() called okay
int old_break = -1
 Original state of DOS's BREAK handler.
BOOL use_except = TRUE
 Some target dependent functions.
jmp_buf exc_jmp
FAULT_STRUC exc_buf
BOOL sock_init_called = FALSE
 The main initialisation routine.


Function Documentation

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.

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 198 of file SOCK_INI.C.

References _watt_do_exit.

void except_handler int  sig  )  [static]
 

Todo:
Disassemble crash address
Definition at line 253 of file SOCK_INI.C.

References _watt_fatal_error, except_handler(), and rundown_run().

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 1016 of file SOCK_INI.C.

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

int tcp_do_boot BOOL  try_bootp,
BOOL  try_dhcp,
BOOL  try_rarp
[static]
 

Try to boot using BOOTP, DHCP or RARP.

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

Return values:
0 on success.
Definition at line 573 of file SOCK_INI.C.

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

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 483 of file SOCK_INI.C.

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

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


Variable Documentation

BOOL sock_init_called = FALSE [static]
 

The main initialisation routine.

Called only once (during program startup). sock_init() is not a macro in <tcp.h>. Definition at line 719 of file SOCK_INI.C.

BOOL use_except = TRUE [static]
 

Some target dependent functions.

Install signal handlers. Definition at line 210 of file SOCK_INI.C.


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