Rename check_carrier() to carrier_isup() and use bool return.

This commit is contained in:
Nicholas J. Kain 2017-01-12 05:25:15 -05:00
parent 1fc7bd3144
commit c47630ffca
4 changed files with 8 additions and 7 deletions

View File

@ -180,7 +180,7 @@ static int arp_send(struct client_state_t cs[static 1],
return ret;
}
if (check_carrier()) {
if (!carrier_isup()) {
log_error("%s: (%s) carrier down; sendto would fail",
client_config.interface, __func__);
ret = -99;

View File

@ -108,7 +108,7 @@ static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1],
}
size_t payload_len =
sizeof *payload - (sizeof payload->options - 1 - endloc);
if (check_carrier()) {
if (!carrier_isup()) {
log_error("%s: (%s) carrier down; write would fail",
client_config.interface, __func__);
ret = -99;
@ -286,7 +286,7 @@ static ssize_t send_dhcp_raw(struct dhcpmsg payload[static 1])
.sll_halen = 6,
};
memcpy(da.sll_addr, "\xff\xff\xff\xff\xff\xff", 6);
if (check_carrier()) {
if (!carrier_isup()) {
log_error("%s: (%s) carrier down; sendto would fail",
client_config.interface, __func__);
ret = -99;

View File

@ -224,12 +224,11 @@ static int ifchwrite(const char buf[static 1], size_t count)
return -1;
}
// Returns 0 if there is a carrier, -1 if not.
int check_carrier(void)
bool carrier_isup(void)
{
char buf[256];
snprintf(buf, sizeof buf, "carrier:;");
return ifchwrite(buf, strlen(buf));
return ifchwrite(buf, strlen(buf)) == 0;
}
int ifchange_deconfig(struct client_state_t cs[static 1])

View File

@ -29,7 +29,9 @@
#ifndef IFCHANGE_H_
#define IFCHANGE_H_
int check_carrier(void);
#include <stdbool.h>
bool carrier_isup(void);
int ifchange_bind(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1]);
int ifchange_deconfig(struct client_state_t cs[static 1]);