If physical link state changes to UP and a lease is bound, check to see if
the currently assigned gateway/router still replies to ARP queries. If so, keep the lease. If not, get a new lease. Save the IP address of the current gateway/router. Remove an outdated check for a buggy compiler. Fix a typo in the previous commit that caused timeouts to be 1000x faster than they should be.
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
|
||||
#include "netlink.h"
|
||||
#include "ifchange.h"
|
||||
#include "arp.h"
|
||||
#include "log.h"
|
||||
|
||||
#define NLMSG_RECVSIZE 8192
|
||||
@ -95,6 +96,18 @@ void nl_queryifstatus(int ifidx, struct client_state_t *cs)
|
||||
send(cs->nlFd, &req, sizeof req, 0);
|
||||
}
|
||||
|
||||
static void takedown_if(struct client_state_t *cs)
|
||||
{
|
||||
log_line("nl: taking down interface");
|
||||
// Same as packet.c: line 258
|
||||
ifchange(NULL, IFCHANGE_DECONFIG);
|
||||
cs->dhcpState = DS_INIT_SELECTING;
|
||||
cs->timeout = 0;
|
||||
cs->requestedIP = 0;
|
||||
cs->packetNum = 0;
|
||||
change_listen_mode(cs, LM_RAW);
|
||||
}
|
||||
|
||||
// Decode netlink messages and process them
|
||||
static void nl_handlemsg(struct nlmsghdr *msg, unsigned int len,
|
||||
struct client_state_t *cs)
|
||||
@ -130,24 +143,14 @@ static void nl_handlemsg(struct nlmsghdr *msg, unsigned int len,
|
||||
* If we don't have a lease, state -> INIT.
|
||||
*/
|
||||
if (cs->dhcpState == DS_BOUND) {
|
||||
/* arp_check_gw(cs); */
|
||||
} else if (cs->dhcpState != DS_INIT_SELECTING) {
|
||||
log_line("nl: taking down interface");
|
||||
// Same as packet.c: line 258
|
||||
ifchange(NULL, IFCHANGE_DECONFIG);
|
||||
cs->dhcpState = DS_INIT_SELECTING;
|
||||
cs->timeout = 0;
|
||||
cs->requestedIP = 0;
|
||||
cs->packetNum = 0;
|
||||
change_listen_mode(cs, LM_RAW);
|
||||
}
|
||||
arp_gw_check(cs);
|
||||
} else if (cs->dhcpState != DS_INIT_SELECTING)
|
||||
takedown_if(cs);
|
||||
}
|
||||
} else {
|
||||
if (cs->ifsPrevState != IFS_DOWN) {
|
||||
cs->ifsPrevState = IFS_DOWN;
|
||||
/*
|
||||
* state -> DOWN
|
||||
*/
|
||||
takedown_if(cs);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user