Fix the dhcp state bootstrapping when rfkill is set #2.
This commit is contained in:
parent
a8af406307
commit
2e679ed491
@ -502,7 +502,11 @@ int main(int argc, char *argv[])
|
|||||||
switch (perform_ifup()) {
|
switch (perform_ifup()) {
|
||||||
case 1: cs.ifsPrevState = IFS_UP;
|
case 1: cs.ifsPrevState = IFS_UP;
|
||||||
case 0: break;
|
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");
|
default: suicide("failed to set the interface to up state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ struct client_state_t {
|
|||||||
struct nk_random_state_u32 rnd32_state;
|
struct nk_random_state_u32 rnd32_state;
|
||||||
uint8_t routerArp[6], serverArp[6];
|
uint8_t routerArp[6], serverArp[6];
|
||||||
uint8_t using_dhcp_bpf, init, got_router_arp, got_server_arp;
|
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 {
|
struct client_config_t {
|
||||||
|
13
src/rfkill.c
13
src/rfkill.c
@ -36,6 +36,7 @@
|
|||||||
#include "nk/io.h"
|
#include "nk/io.h"
|
||||||
#include "ndhc.h"
|
#include "ndhc.h"
|
||||||
#include "netlink.h"
|
#include "netlink.h"
|
||||||
|
#include "ifset.h"
|
||||||
#include "rfkill.h"
|
#include "rfkill.h"
|
||||||
|
|
||||||
int rfkill_open(char enable_rfkill[static 1])
|
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;
|
cs->rfkill_set = 0;
|
||||||
if (cs->ifsPrevState == IFS_DOWN) {
|
if (cs->ifsPrevState == IFS_DOWN) {
|
||||||
log_line("rfkill: radio now unblocked; bringing interface up");
|
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;
|
cs->ifsPrevState = IFS_UP;
|
||||||
ifup_action(cs);
|
ifup_action(cs);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user