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/DHCP\r\n"); // S. Lawson #ifndef SKIPINI // S. Lawson } #endif // SKIPINI S. Lawson if (_bootpon) /* non-zero if we use bootp */ if (_dobootp()) { outs("BOOTP/DHCP failed\r\n"); // S. Lawson if ( !_survivebootp ) return 3; // S. Lawson // S. Lawson exit( 3 ); } return 0; // S. Lawson }
/** * WATTCP.CFG parser for "PCAP." keywords in WATTCP.CFG. */ static BOOL parse_config_pass_1 (void) { static const struct config_table pkt_init_cfg[] = { { "PCAP.DEVICE", ARG_STRCPY, (void*)&_pktdrvrname }, { "PCAP.DUMPFILE", ARG_STRCPY, (void*)&dump_fname }, { "PCAP.TXRETRIES",ARG_ATOB, (void*)&pkt_txretries }, { "PCAP.TXMODE", ARG_FUNC, (void*)&set_txmode }, { "PCAP.RXMODE", ARG_ATOX_W, (void*)&_pkt_forced_rxmode }, { "PCAP.RXBUFS", ARG_ATOI, (void*)&pkt_num_rx_bufs }, { "PCAP.HIGHPRIO", ARG_ATOI, (void*)&thr_realtime }, { NULL, 0, NULL } }; const struct config_table *cfg_save = watt_init_cfg; void (*init_save) (const char*, const char*) = usr_init; int rc; watt_init_cfg = pkt_init_cfg; usr_init = NULL; /* only pkt_init_cfg[] gets parsed */ rc = tcp_config (NULL); usr_init = init_save; watt_init_cfg = cfg_save; return (rc > 0); }
static int tcp_init(listener_context_t *c, const fence_callbacks_t *cb, config_object_t *config, map_object_t *map, void *priv) { tcp_info *info; int listen_sock, ret; /* Initialize NSS; required to do hashing, as silly as that sounds... */ if (NSS_NoDB_Init(NULL) != SECSuccess) { printf("Could not initialize NSS\n"); return 1; } info = calloc(1, sizeof(*info)); if (!info) return -1; info->priv = priv; info->cb = cb; info->map = map; ret = tcp_config(config, &info->args); if (ret < 0) { perror("tcp_config"); return -1; } else if (ret > 0) { printf("%d errors found during configuration\n",ret); return -1; } if (info->args.auth != AUTH_NONE || info->args.hash != HASH_NONE) { info->key_len = read_key_file(info->args.key_file, info->key, sizeof(info->key)); if (info->key_len < 0) { printf("Could not read %s; operating without " "authentication\n", info->args.key_file); info->args.auth = AUTH_NONE; info->args.hash = HASH_NONE; info->key_len = 0; } } if (info->args.family == PF_INET) { listen_sock = ipv4_listen(info->args.addr, info->args.port, 10); } else { listen_sock = ipv6_listen(info->args.addr, info->args.port, 10); } if (listen_sock < 0) { printf("Could not set up listen socket\n"); free(info); return -1; } info->magic = TCP_MAGIC; info->listen_sock = listen_sock; info->history = history_init(check_history, 10, sizeof(fence_req_t)); *c = (listener_context_t)info; return 0; }