Convert logically boolean client_state_t variables from uint8_t to bool.
This commit is contained in:
parent
b8ee0bd5c2
commit
931530786b
12
src/arp.c
12
src/arp.c
@ -306,15 +306,15 @@ static int arp_get_gw_hwaddr(struct client_state_t cs[static 1])
|
|||||||
else
|
else
|
||||||
log_line("%s: arp: Searching for dhcp server address...",
|
log_line("%s: arp: Searching for dhcp server address...",
|
||||||
client_config.interface);
|
client_config.interface);
|
||||||
cs->got_server_arp = 0;
|
cs->got_server_arp = false;
|
||||||
if (arp_ping(cs, cs->srcAddr) < 0)
|
if (arp_ping(cs, cs->srcAddr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (cs->routerAddr) {
|
if (cs->routerAddr) {
|
||||||
cs->got_router_arp = 0;
|
cs->got_router_arp = false;
|
||||||
if (arp_ping(cs, cs->routerAddr) < 0)
|
if (arp_ping(cs, cs->routerAddr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
cs->got_router_arp = 1;
|
cs->got_router_arp = true;
|
||||||
garp.wake_ts[AS_GW_QUERY] =
|
garp.wake_ts[AS_GW_QUERY] =
|
||||||
garp.send_stats[ASEND_GW_PING].ts + ARP_RETRANS_DELAY + 250;
|
garp.send_stats[ASEND_GW_PING].ts + ARP_RETRANS_DELAY + 250;
|
||||||
return 0;
|
return 0;
|
||||||
@ -495,7 +495,7 @@ int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts)
|
|||||||
log_line("%s: Lease of %s obtained. Lease time is %ld seconds.",
|
log_line("%s: Lease of %s obtained. Lease time is %ld seconds.",
|
||||||
client_config.interface, clibuf, cs->lease);
|
client_config.interface, clibuf, cs->lease);
|
||||||
cs->clientAddr = garp.dhcp_packet.yiaddr;
|
cs->clientAddr = garp.dhcp_packet.yiaddr;
|
||||||
cs->init = 0;
|
cs->init = false;
|
||||||
garp.last_conflict_ts = 0;
|
garp.last_conflict_ts = 0;
|
||||||
garp.wake_ts[AS_COLLISION_CHECK] = -1;
|
garp.wake_ts[AS_COLLISION_CHECK] = -1;
|
||||||
if (ifchange_bind(cs, &garp.dhcp_packet) < 0) {
|
if (ifchange_bind(cs, &garp.dhcp_packet) < 0) {
|
||||||
@ -576,7 +576,7 @@ int arp_do_gw_query(struct client_state_t cs[static 1])
|
|||||||
client_config.interface, cs->routerArp[0], cs->routerArp[1],
|
client_config.interface, cs->routerArp[0], cs->routerArp[1],
|
||||||
cs->routerArp[2], cs->routerArp[3],
|
cs->routerArp[2], cs->routerArp[3],
|
||||||
cs->routerArp[4], cs->routerArp[5]);
|
cs->routerArp[4], cs->routerArp[5]);
|
||||||
cs->got_router_arp = 1;
|
cs->got_router_arp = true;
|
||||||
if (cs->routerAddr == cs->srcAddr)
|
if (cs->routerAddr == cs->srcAddr)
|
||||||
goto server_is_router;
|
goto server_is_router;
|
||||||
if (cs->got_server_arp) {
|
if (cs->got_server_arp) {
|
||||||
@ -597,7 +597,7 @@ server_is_router:
|
|||||||
client_config.interface, cs->serverArp[0], cs->serverArp[1],
|
client_config.interface, cs->serverArp[0], cs->serverArp[1],
|
||||||
cs->serverArp[2], cs->serverArp[3],
|
cs->serverArp[2], cs->serverArp[3],
|
||||||
cs->serverArp[4], cs->serverArp[5]);
|
cs->serverArp[4], cs->serverArp[5]);
|
||||||
cs->got_server_arp = 1;
|
cs->got_server_arp = true;
|
||||||
if (cs->got_router_arp) {
|
if (cs->got_router_arp) {
|
||||||
garp.wake_ts[AS_GW_QUERY] = -1;
|
garp.wake_ts[AS_GW_QUERY] = -1;
|
||||||
if (arp_open_fd(cs, true) < 0)
|
if (arp_open_fd(cs, true) < 0)
|
||||||
|
@ -68,8 +68,8 @@ static int get_raw_listen_socket(struct client_state_t cs[static 1])
|
|||||||
char resp;
|
char resp;
|
||||||
int fd = request_sockd_fd("L", 1, &resp);
|
int fd = request_sockd_fd("L", 1, &resp);
|
||||||
switch (resp) {
|
switch (resp) {
|
||||||
case 'L': cs->using_dhcp_bpf = 1; break;
|
case 'L': cs->using_dhcp_bpf = true; break;
|
||||||
case 'l': cs->using_dhcp_bpf = 0; break;
|
case 'l': cs->using_dhcp_bpf = false; break;
|
||||||
default: suicide("%s: (%s) expected l or L sockd reply but got %c",
|
default: suicide("%s: (%s) expected l or L sockd reply but got %c",
|
||||||
client_config.interface, __func__, resp);
|
client_config.interface, __func__, resp);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
#include "rfkill.h"
|
#include "rfkill.h"
|
||||||
|
|
||||||
struct client_state_t cs = {
|
struct client_state_t cs = {
|
||||||
.init = 1,
|
.init = true,
|
||||||
.epollFd = -1,
|
.epollFd = -1,
|
||||||
.signalFd = -1,
|
.signalFd = -1,
|
||||||
.listenFd = -1,
|
.listenFd = -1,
|
||||||
|
@ -45,9 +45,8 @@ struct client_state_t {
|
|||||||
uint32_t clientAddr, serverAddr, srcAddr, routerAddr;
|
uint32_t clientAddr, serverAddr, srcAddr, routerAddr;
|
||||||
uint32_t lease, xid;
|
uint32_t lease, xid;
|
||||||
uint8_t routerArp[6], serverArp[6];
|
uint8_t routerArp[6], serverArp[6];
|
||||||
uint8_t using_dhcp_bpf, init, got_router_arp, got_server_arp,
|
bool using_dhcp_bpf, got_router_arp, got_server_arp, arp_is_defense,
|
||||||
check_fingerprint;
|
check_fingerprint, init;
|
||||||
bool arp_is_defense;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct client_config_t {
|
struct client_config_t {
|
||||||
|
@ -78,8 +78,8 @@ static void reinit_shared_deconfig(struct client_state_t cs[static 1])
|
|||||||
arp_close_fd(cs);
|
arp_close_fd(cs);
|
||||||
cs->clientAddr = 0;
|
cs->clientAddr = 0;
|
||||||
cs->num_dhcp_requests = 0;
|
cs->num_dhcp_requests = 0;
|
||||||
cs->got_router_arp = 0;
|
cs->got_router_arp = false;
|
||||||
cs->got_server_arp = 0;
|
cs->got_server_arp = false;
|
||||||
memset(&cs->routerArp, 0, sizeof cs->routerArp);
|
memset(&cs->routerArp, 0, sizeof cs->routerArp);
|
||||||
memset(&cs->serverArp, 0, sizeof cs->serverArp);
|
memset(&cs->serverArp, 0, sizeof cs->serverArp);
|
||||||
arp_reset_send_stats();
|
arp_reset_send_stats();
|
||||||
@ -344,7 +344,7 @@ static int selecting_timeout(struct client_state_t cs[static 1],
|
|||||||
if (client_config.background_if_no_lease) {
|
if (client_config.background_if_no_lease) {
|
||||||
log_line("%s: No lease; going to background.",
|
log_line("%s: No lease; going to background.",
|
||||||
client_config.interface);
|
client_config.interface);
|
||||||
cs->init = 0;
|
cs->init = false;
|
||||||
background();
|
background();
|
||||||
} else if (client_config.abort_if_no_lease)
|
} else if (client_config.abort_if_no_lease)
|
||||||
suicide("%s: No lease; failing.", client_config.interface);
|
suicide("%s: No lease; failing.", client_config.interface);
|
||||||
|
Loading…
Reference in New Issue
Block a user