SOCK_INI.C
资源名称:wattcp.rar [点击查看]
上传用户:better800
上传日期:2022-06-13
资源大小:1853k
文件大小:2k
源码类别:
TCP/IP协议栈
开发平台:
DOS
- /*
- * sock_init - easy way to guarentee:
- * - card is ready
- * - shutdown is handled
- * - cbreaks are handled
- * - config file is read
- * - bootp is run
- *
- * 0.1 : May 2, 1991 Erick - reorganized operations
- */
- #include <copyright.h>
- #include <wattcp.h>
- #include <stdlib.h>
- int _survivebootp = 0;
- static char _initialized = 0; // S. Lawson
- void sock_exit( void )
- {
- if (_initialized) // S. Lawson
- tcp_shutdown();
- _initialized = 0; // S. Lawson
- }
- // S. Lawson - keep an exiting sock_init()
- void sock_init(void)
- {
- int r;
- r=sock_init_noexit();
- if (r) exit(r);
- }
- int sock_init_noexit(void ) // S. Lawson
- {
- int r; // S. Lawson
- if (_initialized) return 0; // S. Lawson
- // S. Lawson tcp_init(); /* must precede tcp_config because we need eth addr */
- r=tcp_init_noexit(); /* (S. Lawson) must precede tcp_config because we need eth addr */
- if (r) return r; // S. Lawson
- _initialized=1; // S. Lawson
- atexit(sock_exit); /* must not precede tcp_init() incase no PD */
- tcp_cbrk( 0x10 ); /* allow control breaks, give message */
- #ifndef SKIPINI // S. Lawson
- if (tcp_config( NULL )) { /* if no config file use BOOTP w/broadcast */
- #endif // SKIPINI S. Lawson
- _bootpon = 1;
- outs("Configuring through BOOTP/DHCPrn"); // S. Lawson
- #ifndef SKIPINI // S. Lawson
- }
- #endif // SKIPINI S. Lawson
- if (_bootpon) /* non-zero if we use bootp */
- if (_dobootp()) {
- outs("BOOTP/DHCP failedrn"); // S. Lawson
- if ( !_survivebootp )
- return 3; // S. Lawson
- // S. Lawson exit( 3 );
- }
- return 0; // S. Lawson
- }