diff --git a/ndhc/arp.c b/ndhc/arp.c index 0e03aee..d0a559b 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -1,5 +1,5 @@ /* arp.c - arp ping checking - * Time-stamp: <2011-07-04 22:32:29 njk> + * Time-stamp: <2011-07-04 22:51:19 njk> * * Copyright 2010-2011 Nicholas J. Kain * @@ -356,28 +356,15 @@ static void arp_failed(struct client_state_t *cs) log_line("arp: Offered address is in use -- declining"); arp_close_fd(cs); send_decline(cs, arp_dhcp_packet.yiaddr); - - if (cs->arpPrevState != DS_REQUESTING) - ifchange_deconfig(); - cs->dhcpState = DS_SELECTING; - cs->clientAddr = 0; - cs->timeout = 0; - cs->packetNum = 0; - set_listen_raw(cs); + reinit_selecting(cs, 0); } void arp_gw_failed(struct client_state_t *cs) { log_line("arp: Gateway appears to have changed, getting new lease"); arp_close_fd(cs); - - ifchange_deconfig(); - cs->dhcpState = DS_SELECTING; cs->oldTimeout = 0; - cs->timeout = 0; - cs->clientAddr = 0; - cs->packetNum = 0; - set_listen_raw(cs); + reinit_selecting(cs, 0); } void arp_success(struct client_state_t *cs) diff --git a/ndhc/state.c b/ndhc/state.c index dc79f6f..6770380 100644 --- a/ndhc/state.c +++ b/ndhc/state.c @@ -56,7 +56,7 @@ static int delay_timeout(int numpackets) return to * 1000; } -static void reinit_selecting(struct client_state_t *cs, int timeout) +void reinit_selecting(struct client_state_t *cs, int timeout) { ifchange_deconfig(); cs->dhcpState = DS_SELECTING; diff --git a/ndhc/state.h b/ndhc/state.h index e5eca22..5bcf8f8 100644 --- a/ndhc/state.h +++ b/ndhc/state.h @@ -16,6 +16,8 @@ typedef enum { DS_NUM_STATES, } dhcp_states_t; +void reinit_selecting(struct client_state_t *cs, int timeout); + void packet_action(struct client_state_t *cs, struct dhcpmsg *packet, uint8_t *message); void timeout_action(struct client_state_t *cs);