diff --git a/ndhc/ndhc.c b/ndhc/ndhc.c index be013df..da32ea1 100644 --- a/ndhc/ndhc.c +++ b/ndhc/ndhc.c @@ -63,19 +63,7 @@ struct client_state_t cs = { .dhcpState = DS_SELECTING, .arpPrevState = DS_SELECTING, .ifsPrevState = IFS_NONE, - .listenMode = 0, - .packetNum = 0, - .xid = 0, - .timeout = 0, .init = 1, - .oldTimeout = 0, - .leaseStartTime = 0, - .requestedIP = 0, - .serverAddr = 0, - .routerAddr = 0, - .lease = 0, - .renewTime = 0, - .rebindTime = 0, .epollFd = -1, .signalFd = -1, .listenFd = -1, @@ -86,14 +74,9 @@ struct client_state_t cs = { struct client_config_t client_config = { /* Default options. */ - .abort_if_no_lease = 0, - .foreground = 0, - .quit_after_lease = 0, - .background_if_no_lease = 0, .interface = "eth0", .clientid = NULL, .hostname = NULL, - .ifindex = 0, .arp = "\0\0\0\0\0\0", }; diff --git a/ndhc/packet.c b/ndhc/packet.c index 77fe7c3..0093d5e 100644 --- a/ndhc/packet.c +++ b/ndhc/packet.c @@ -447,11 +447,12 @@ static void change_listen_mode(struct client_state_t *cs, int new_mode) close(cs->listenFd); cs->listenFd = -1; } - if (new_mode != (LM_RAW || LM_COOKED)) { + if (new_mode == LM_NONE) { log_line("Stopped listening for DHCP packets."); return; } - cs->listenFd = LM_RAW ? create_raw_listen_socket(client_config.ifindex) : + cs->listenFd = new_mode == LM_RAW ? + create_raw_listen_socket(client_config.ifindex) : create_udp_listen_socket(INADDR_ANY, DHCP_CLIENT_PORT, client_config.interface); if (cs->listenFd < 0) {