Fix the dhcp state bootstrapping when rfkill is set #2.

This commit is contained in:
Nicholas J. Kain 2015-02-13 18:35:44 -05:00
parent a8af406307
commit 2e679ed491
3 changed files with 19 additions and 2 deletions

View File

@ -502,7 +502,11 @@ int main(int argc, char *argv[])
switch (perform_ifup()) {
case 1: cs.ifsPrevState = IFS_UP;
case 0: break;
case -3: cs.rfkill_set = 1; cs.ifsPrevState = IFS_DOWN; break;
case -3:
cs.rfkill_set = 1;
cs.rfkill_at_init = 1;
cs.ifsPrevState = IFS_DOWN;
break;
default: suicide("failed to set the interface to up state");
}

View File

@ -47,7 +47,7 @@ struct client_state_t {
struct nk_random_state_u32 rnd32_state;
uint8_t routerArp[6], serverArp[6];
uint8_t using_dhcp_bpf, init, got_router_arp, got_server_arp;
uint8_t rfkill_set;
uint8_t rfkill_set, rfkill_at_init;
};
struct client_config_t {

View File

@ -36,6 +36,7 @@
#include "nk/io.h"
#include "ndhc.h"
#include "netlink.h"
#include "ifset.h"
#include "rfkill.h"
int rfkill_open(char enable_rfkill[static 1])
@ -81,6 +82,18 @@ void handle_rfkill_notice(struct client_state_t cs[static 1], uint32_t rfkidx)
cs->rfkill_set = 0;
if (cs->ifsPrevState == IFS_DOWN) {
log_line("rfkill: radio now unblocked; bringing interface up");
if (cs->rfkill_at_init) {
cs->rfkill_at_init = 0;
switch (perform_ifup()) {
case 1: case 0: break;
case -3:
cs->rfkill_set = 1;
cs->rfkill_at_init = 1;
log_line("rfkill: radio immediately blocked again; spurious?");
return;
default: suicide("failed to set the interface to up state");
}
}
cs->ifsPrevState = IFS_UP;
ifup_action(cs);
} else {