Replace mostly obsolete -[static 1] with reliable old *-.

This notation originally had the sole advantage of implying
that the pointer was non-NULL, but it has seen little use and
now clang presents warnings about it in certain contexts.
This commit is contained in:
Nicholas J. Kain 2022-01-11 22:35:19 -05:00
parent 6047f04a12
commit 6ec0a5c731
27 changed files with 191 additions and 207 deletions

View File

@ -79,7 +79,7 @@ static struct arp_data garp = {
void set_arp_relentless_def(bool v) { garp.relentless_def = v; }
static void arp_min_close_fd(struct client_state_t cs[static 1])
static void arp_min_close_fd(struct client_state_t *cs)
{
if (cs->arpFd < 0)
return;
@ -88,14 +88,14 @@ static void arp_min_close_fd(struct client_state_t cs[static 1])
cs->arp_is_defense = false;
}
static void arp_close_fd(struct client_state_t cs[static 1])
static void arp_close_fd(struct client_state_t *cs)
{
arp_min_close_fd(cs);
for (int i = 0; i < AS_MAX; ++i)
garp.wake_ts[i] = -1;
}
void arp_reset_state(struct client_state_t cs[static 1])
void arp_reset_state(struct client_state_t *cs)
{
arp_close_fd(cs);
memset(&garp.reply, 0, sizeof garp.reply);
@ -112,7 +112,7 @@ void arp_reset_state(struct client_state_t cs[static 1])
}
}
static int get_arp_basic_socket(struct client_state_t cs[static 1])
static int get_arp_basic_socket(struct client_state_t *cs)
{
char resp;
int fd = request_sockd_fd("a", 1, &resp);
@ -126,7 +126,7 @@ static int get_arp_basic_socket(struct client_state_t cs[static 1])
return fd;
}
static int get_arp_defense_socket(struct client_state_t cs[static 1])
static int get_arp_defense_socket(struct client_state_t *cs)
{
char buf[32];
size_t buflen = 0;
@ -148,7 +148,7 @@ static int get_arp_defense_socket(struct client_state_t cs[static 1])
return fd;
}
static int arp_open_fd(struct client_state_t cs[static 1], bool defense)
static int arp_open_fd(struct client_state_t *cs, bool defense)
{
if (cs->arpFd >= 0 && defense == cs->arp_is_defense)
return 0;
@ -163,8 +163,8 @@ static int arp_open_fd(struct client_state_t cs[static 1], bool defense)
return 0;
}
static int arp_send(struct client_state_t cs[static 1],
struct arpMsg arp[static 1])
static int arp_send(struct client_state_t *cs,
struct arpMsg *arp)
{
int ret = -1;
struct sockaddr_ll addr = {
@ -214,7 +214,7 @@ carrier_down:
memcpy(arp.smac, client_config.arp, 6)
// Returns 0 on success, -1 on failure.
static int arp_ping(struct client_state_t cs[static 1], uint32_t test_ip)
static int arp_ping(struct client_state_t *cs, uint32_t test_ip)
{
BASE_ARPMSG();
memcpy(arp.sip4, &cs->clientAddr, sizeof cs->clientAddr);
@ -228,7 +228,7 @@ static int arp_ping(struct client_state_t cs[static 1], uint32_t test_ip)
}
// Returns 0 on success, -1 on failure.
static int arp_ip_anon_ping(struct client_state_t cs[static 1],
static int arp_ip_anon_ping(struct client_state_t *cs,
uint32_t test_ip)
{
BASE_ARPMSG();
@ -243,7 +243,7 @@ static int arp_ip_anon_ping(struct client_state_t cs[static 1],
return 0;
}
static int arp_announcement(struct client_state_t cs[static 1])
static int arp_announcement(struct client_state_t *cs)
{
BASE_ARPMSG();
memcpy(arp.sip4, &cs->clientAddr, 4);
@ -258,8 +258,8 @@ static int arp_announcement(struct client_state_t cs[static 1])
#undef BASE_ARPMSG
// Checks to see if there is another host that has our assigned IP.
int arp_check(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1])
int arp_check(struct client_state_t *cs,
struct dhcpmsg *packet)
{
memcpy(&garp.dhcp_packet, packet, sizeof (struct dhcpmsg));
if (arp_open_fd(cs, false) < 0)
@ -274,7 +274,7 @@ int arp_check(struct client_state_t cs[static 1],
}
// Confirms that we're still on the fingerprinted network.
int arp_gw_check(struct client_state_t cs[static 1])
int arp_gw_check(struct client_state_t *cs)
{
if (arp_open_fd(cs, false) < 0)
return -1;
@ -296,7 +296,7 @@ int arp_gw_check(struct client_state_t cs[static 1])
}
// Gathers the fingerprinting info for the associated network.
static int arp_get_gw_hwaddr(struct client_state_t cs[static 1])
static int arp_get_gw_hwaddr(struct client_state_t *cs)
{
if (arp_open_fd(cs, false) < 0)
return -1;
@ -321,12 +321,12 @@ static int arp_get_gw_hwaddr(struct client_state_t cs[static 1])
return 0;
}
int arp_set_defense_mode(struct client_state_t cs[static 1])
int arp_set_defense_mode(struct client_state_t *cs)
{
return arp_open_fd(cs, true);
}
static int arp_gw_success(struct client_state_t cs[static 1])
static int arp_gw_success(struct client_state_t *cs)
{
log_line("%s: arp: Network seems unchanged. Resuming normal operation.",
client_config.interface);
@ -372,8 +372,8 @@ static int arp_validate_bpf(struct arpMsg *am)
// ARP validation functions that will be performed by the BPF if it is
// installed.
static int arp_validate_bpf_defense(struct client_state_t cs[static 1],
struct arpMsg am[static 1])
static int arp_validate_bpf_defense(struct client_state_t *cs,
struct arpMsg *am)
{
if (memcmp(am->sip4, &cs->clientAddr, 4))
return 0;
@ -382,7 +382,7 @@ static int arp_validate_bpf_defense(struct client_state_t cs[static 1],
return 1;
}
static int arp_is_query_reply(struct arpMsg am[static 1])
static int arp_is_query_reply(struct arpMsg *am)
{
if (am->operation != htons(ARPOP_REPLY))
return 0;
@ -393,7 +393,7 @@ static int arp_is_query_reply(struct arpMsg am[static 1])
return 1;
}
static int arp_gen_probe_wait(struct client_state_t cs[static 1])
static int arp_gen_probe_wait(struct client_state_t *cs)
{
int range = arp_probe_max - arp_probe_min;
if (range < 1000) range = 1000;
@ -401,7 +401,7 @@ static int arp_gen_probe_wait(struct client_state_t cs[static 1])
return arp_probe_min + (int)(nk_random_u32(&cs->rnd_state) % (unsigned)range);
}
int arp_defense_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_defense_timeout(struct client_state_t *cs, long long nowts)
{
(void)nowts; // Suppress warning; parameter necessary but unused.
int ret = 0;
@ -413,7 +413,7 @@ int arp_defense_timeout(struct client_state_t cs[static 1], long long nowts)
return ret;
}
int arp_gw_check_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_gw_check_timeout(struct client_state_t *cs, long long nowts)
{
if (garp.send_stats[ASEND_GW_PING].count >= garp.gw_check_initpings + 6) {
if (garp.router_replied && !garp.server_replied)
@ -456,7 +456,7 @@ int arp_gw_check_timeout(struct client_state_t cs[static 1], long long nowts)
return ARPR_OK;
}
int arp_gw_query_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_gw_query_timeout(struct client_state_t *cs, long long nowts)
{
long long rtts = garp.send_stats[ASEND_GW_PING].ts + ARP_RETRANS_DELAY;
if (nowts < rtts) {
@ -500,7 +500,7 @@ int arp_gw_query_timeout(struct client_state_t cs[static 1], long long nowts)
return ARPR_OK;
}
int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_collision_timeout(struct client_state_t *cs, long long nowts)
{
if (nowts >= garp.arp_check_start_ts + ANNOUNCE_WAIT ||
garp.send_stats[ASEND_COLLISION_CHECK].count >= arp_probe_num)
@ -540,7 +540,7 @@ int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts)
return ARPR_OK;
}
int arp_query_gateway(struct client_state_t cs[static 1])
int arp_query_gateway(struct client_state_t *cs)
{
if (cs->sent_gw_query) {
garp.wake_ts[AS_QUERY_GW_SEND] = -1;
@ -560,7 +560,7 @@ int arp_query_gateway(struct client_state_t cs[static 1])
}
// 1 == not yet time, 0 == timed out, success, -1 == timed out, failure
int arp_query_gateway_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_query_gateway_timeout(struct client_state_t *cs, long long nowts)
{
long long rtts = garp.wake_ts[AS_QUERY_GW_SEND];
if (rtts == -1) return 0;
@ -568,7 +568,7 @@ int arp_query_gateway_timeout(struct client_state_t cs[static 1], long long nowt
return arp_query_gateway(cs) == ARPR_OK ? 0 : -1;
}
int arp_announce(struct client_state_t cs[static 1])
int arp_announce(struct client_state_t *cs)
{
if (cs->sent_first_announce && cs->sent_second_announce) {
garp.wake_ts[AS_ANNOUNCE] = -1;
@ -592,7 +592,7 @@ int arp_announce(struct client_state_t cs[static 1])
}
// 1 == not yet time, 0 == timed out, success, -1 == timed out, failure
int arp_announce_timeout(struct client_state_t cs[static 1], long long nowts)
int arp_announce_timeout(struct client_state_t *cs, long long nowts)
{
long long rtts = garp.wake_ts[AS_ANNOUNCE];
if (rtts == -1) return 0;
@ -600,7 +600,7 @@ int arp_announce_timeout(struct client_state_t cs[static 1], long long nowts)
return arp_announce(cs) == ARPR_OK ? 0 : -1;
}
int arp_do_defense(struct client_state_t cs[static 1])
int arp_do_defense(struct client_state_t *cs)
{
// Even though the BPF will usually catch this case, sometimes there are
// packets still in the socket buffer that arrived before the defense
@ -630,7 +630,7 @@ int arp_do_defense(struct client_state_t cs[static 1])
return ARPR_OK;
}
int arp_do_gw_query(struct client_state_t cs[static 1])
int arp_do_gw_query(struct client_state_t *cs)
{
if (!arp_is_query_reply(&garp.reply))
return ARPR_OK;
@ -670,7 +670,7 @@ server_is_router:
return ARPR_OK;
}
int arp_do_collision_check(struct client_state_t cs[static 1])
int arp_do_collision_check(struct client_state_t *cs)
{
if (!arp_is_query_reply(&garp.reply))
return ARPR_OK;
@ -695,7 +695,7 @@ int arp_do_collision_check(struct client_state_t cs[static 1])
return ARPR_OK;
}
int arp_do_gw_check(struct client_state_t cs[static 1])
int arp_do_gw_check(struct client_state_t *cs)
{
if (!arp_is_query_reply(&garp.reply))
return ARPR_OK;
@ -731,7 +731,7 @@ server_is_router:
return ARPR_OK;
}
bool arp_packet_get(struct client_state_t cs[static 1])
bool arp_packet_get(struct client_state_t *cs)
{
if (cs->arpFd < 0)
return false;

View File

@ -103,32 +103,32 @@ struct arp_data {
bool server_replied:1;
};
void arp_reset_state(struct client_state_t cs[static 1]);
void arp_reset_state(struct client_state_t *cs);
bool arp_packet_get(struct client_state_t cs[static 1]);
bool arp_packet_get(struct client_state_t *cs);
void set_arp_relentless_def(bool v);
int arp_check(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1]);
int arp_gw_check(struct client_state_t cs[static 1]);
int arp_set_defense_mode(struct client_state_t cs[static 1]);
int arp_gw_failed(struct client_state_t cs[static 1]);
int arp_check(struct client_state_t *cs,
struct dhcpmsg *packet);
int arp_gw_check(struct client_state_t *cs);
int arp_set_defense_mode(struct client_state_t *cs);
int arp_gw_failed(struct client_state_t *cs);
int arp_do_collision_check(struct client_state_t cs[static 1]);
int arp_collision_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_do_collision_check(struct client_state_t *cs);
int arp_collision_timeout(struct client_state_t *cs, long long nowts);
int arp_query_gateway(struct client_state_t cs[static 1]);
int arp_query_gateway_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_query_gateway(struct client_state_t *cs);
int arp_query_gateway_timeout(struct client_state_t *cs, long long nowts);
int arp_announce(struct client_state_t cs[static 1]);
int arp_announce_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_announce(struct client_state_t *cs);
int arp_announce_timeout(struct client_state_t *cs, long long nowts);
int arp_do_defense(struct client_state_t cs[static 1]);
int arp_defense_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_do_gw_query(struct client_state_t cs[static 1]);
int arp_gw_query_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_do_gw_check(struct client_state_t cs[static 1]);
int arp_gw_check_timeout(struct client_state_t cs[static 1], long long nowts);
int arp_do_defense(struct client_state_t *cs);
int arp_defense_timeout(struct client_state_t *cs, long long nowts);
int arp_do_gw_query(struct client_state_t *cs);
int arp_gw_query_timeout(struct client_state_t *cs, long long nowts);
int arp_do_gw_check(struct client_state_t *cs);
int arp_gw_check_timeout(struct client_state_t *cs, long long nowts);
// No action needs to be taken.
#define ARPR_OK 0

View File

@ -200,7 +200,7 @@ struct cfgparse {
%% write data;
static void parse_cfgfile(const char fname[static 1])
static void parse_cfgfile(const char *fname)
{
bool reached_eof = false;
struct cfgparse ccfg;

View File

@ -50,7 +50,7 @@
#include "options.h"
#include "sockd.h"
static int get_udp_unicast_socket(struct client_state_t cs[static 1])
static int get_udp_unicast_socket(struct client_state_t *cs)
{
char buf[32];
buf[0] = 'u';
@ -63,7 +63,7 @@ static int get_raw_broadcast_socket(void)
return request_sockd_fd("s", 1, (char *)0);
}
static int get_raw_listen_socket(struct client_state_t cs[static 1])
static int get_raw_listen_socket(struct client_state_t *cs)
{
char resp;
int fd = request_sockd_fd("L", 1, &resp);
@ -77,8 +77,8 @@ static int get_raw_listen_socket(struct client_state_t cs[static 1])
}
// Unicast a DHCP message using a UDP socket.
static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1],
struct dhcpmsg payload[static 1])
static ssize_t send_dhcp_unicast(struct client_state_t *cs,
struct dhcpmsg *payload)
{
ssize_t ret = -1;
int fd = get_udp_unicast_socket(cs);
@ -131,13 +131,13 @@ static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1],
}
// Returns 1 if IP checksum is correct, otherwise 0.
static int ip_checksum(struct ip_udp_dhcp_packet packet[static 1])
static int ip_checksum(struct ip_udp_dhcp_packet *packet)
{
return net_checksum16(&packet->ip, sizeof packet->ip) == 0;
}
// Returns 1 if UDP checksum is correct, otherwise 0.
static int udp_checksum(struct ip_udp_dhcp_packet packet[static 1])
static int udp_checksum(struct ip_udp_dhcp_packet *packet)
{
struct iphdr ph = {
.saddr = packet->ip.saddr,
@ -154,7 +154,7 @@ static int udp_checksum(struct ip_udp_dhcp_packet packet[static 1])
return cs == 0;
}
static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet packet[static 1])
static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet *packet)
{
if (packet->ip.version != IPVERSION) {
log_line("%s: IP version is not IPv4.", client_config.interface);
@ -186,8 +186,8 @@ static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet packet[static 1
// Read a packet from a raw socket. Returns -1 on fatal error, -2 on
// transient error.
static ssize_t get_raw_packet(struct client_state_t cs[static 1],
struct dhcpmsg payload[static 1],
static ssize_t get_raw_packet(struct client_state_t *cs,
struct dhcpmsg *payload,
uint32_t *srcaddr)
{
struct ip_udp_dhcp_packet packet;
@ -235,7 +235,7 @@ static ssize_t get_raw_packet(struct client_state_t cs[static 1],
}
// Broadcast a DHCP message using a raw socket.
static ssize_t send_dhcp_raw(struct dhcpmsg payload[static 1])
static ssize_t send_dhcp_raw(struct dhcpmsg *payload)
{
ssize_t ret = -1;
int fd = get_raw_broadcast_socket();
@ -320,7 +320,7 @@ carrier_down:
return ret;
}
void start_dhcp_listen(struct client_state_t cs[static 1])
void start_dhcp_listen(struct client_state_t *cs)
{
if (cs->listenFd >= 0)
return;
@ -330,7 +330,7 @@ void start_dhcp_listen(struct client_state_t cs[static 1])
client_config.interface, strerror(errno));
}
void stop_dhcp_listen(struct client_state_t cs[static 1])
void stop_dhcp_listen(struct client_state_t *cs)
{
if (cs->listenFd < 0)
return;
@ -338,9 +338,9 @@ void stop_dhcp_listen(struct client_state_t cs[static 1])
cs->listenFd = -1;
}
static int validate_dhcp_packet(struct client_state_t cs[static 1],
size_t len, struct dhcpmsg packet[static 1],
uint8_t msgtype[static 1])
static int validate_dhcp_packet(struct client_state_t *cs,
size_t len, struct dhcpmsg *packet,
uint8_t *msgtype)
{
if (len < offsetof(struct dhcpmsg, options)) {
log_line("%s: Packet is too short to contain magic cookie. Ignoring.",
@ -391,10 +391,8 @@ static int validate_dhcp_packet(struct client_state_t cs[static 1],
return 1;
}
bool dhcp_packet_get(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1],
uint8_t msgtype[static 1],
uint32_t srcaddr[static 1])
bool dhcp_packet_get(struct client_state_t *cs, struct dhcpmsg *packet,
uint8_t *msgtype, uint32_t *srcaddr)
{
if (cs->listenFd < 0)
return false;
@ -414,7 +412,7 @@ bool dhcp_packet_get(struct client_state_t cs[static 1],
return true;
}
static void add_options_vendor_hostname(struct dhcpmsg packet[static 1])
static void add_options_vendor_hostname(struct dhcpmsg *packet)
{
size_t vlen = strlen(client_config.vendor);
size_t hlen = strlen(client_config.hostname);
@ -426,7 +424,7 @@ static void add_options_vendor_hostname(struct dhcpmsg packet[static 1])
}
// Initialize a DHCP client packet that will be sent to a server
static void init_packet(struct dhcpmsg packet[static 1], uint8_t type)
static void init_packet(struct dhcpmsg *packet, uint8_t type)
{
packet->op = 1; // BOOTREQUEST (client)
packet->htype = 1; // ETH_10MB
@ -439,7 +437,7 @@ static void init_packet(struct dhcpmsg packet[static 1], uint8_t type)
client_config.clientid_len);
}
ssize_t send_discover(struct client_state_t cs[static 1])
ssize_t send_discover(struct client_state_t *cs)
{
struct dhcpmsg packet = {.xid = cs->xid};
init_packet(&packet, DHCPDISCOVER);
@ -452,7 +450,7 @@ ssize_t send_discover(struct client_state_t cs[static 1])
return send_dhcp_raw(&packet);
}
ssize_t send_selecting(struct client_state_t cs[static 1])
ssize_t send_selecting(struct client_state_t *cs)
{
char clibuf[INET_ADDRSTRLEN];
struct dhcpmsg packet = {.xid = cs->xid};
@ -469,7 +467,7 @@ ssize_t send_selecting(struct client_state_t cs[static 1])
return send_dhcp_raw(&packet);
}
ssize_t send_renew_or_rebind(struct client_state_t cs[static 1], bool is_renew)
ssize_t send_renew_or_rebind(struct client_state_t *cs, bool is_renew)
{
struct dhcpmsg packet = {.xid = cs->xid};
init_packet(&packet, DHCPREQUEST);
@ -482,7 +480,7 @@ ssize_t send_renew_or_rebind(struct client_state_t cs[static 1], bool is_renew)
return is_renew? send_dhcp_unicast(cs, &packet) : send_dhcp_raw(&packet);
}
ssize_t send_decline(struct client_state_t cs[static 1], uint32_t server)
ssize_t send_decline(struct client_state_t *cs, uint32_t server)
{
struct dhcpmsg packet = {.xid = cs->xid};
init_packet(&packet, DHCPDECLINE);
@ -492,7 +490,7 @@ ssize_t send_decline(struct client_state_t cs[static 1], uint32_t server)
return send_dhcp_raw(&packet);
}
ssize_t send_release(struct client_state_t cs[static 1])
ssize_t send_release(struct client_state_t *cs)
{
struct dhcpmsg packet = {.xid = nk_random_u32(&cs->rnd_state)};
init_packet(&packet, DHCPRELEASE);

View File

@ -81,24 +81,22 @@ struct udp_dhcp_packet {
struct dhcpmsg data;
};
void start_dhcp_listen(struct client_state_t cs[static 1]);
void stop_dhcp_listen(struct client_state_t cs[static 1]);
bool dhcp_packet_get(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1],
uint8_t msgtype[static 1],
uint32_t srcaddr[static 1]);
ssize_t send_discover(struct client_state_t cs[static 1]);
ssize_t send_selecting(struct client_state_t cs[static 1]);
ssize_t send_renew_or_rebind(struct client_state_t cs[static 1], bool is_renew);
static inline ssize_t send_renew(struct client_state_t cs[static 1])
void start_dhcp_listen(struct client_state_t *cs);
void stop_dhcp_listen(struct client_state_t *cs);
bool dhcp_packet_get(struct client_state_t *cs, struct dhcpmsg *packet,
uint8_t *msgtype, uint32_t *srcaddr);
ssize_t send_discover(struct client_state_t *cs);
ssize_t send_selecting(struct client_state_t *cs);
ssize_t send_renew_or_rebind(struct client_state_t *cs, bool is_renew);
static inline ssize_t send_renew(struct client_state_t *cs)
{
return send_renew_or_rebind(cs, true);
}
static inline ssize_t send_rebind(struct client_state_t cs[static 1])
static inline ssize_t send_rebind(struct client_state_t *cs)
{
return send_renew_or_rebind(cs, false);
}
ssize_t send_decline(struct client_state_t cs[static 1], uint32_t server);
ssize_t send_release(struct client_state_t cs[static 1]);
ssize_t send_decline(struct client_state_t *cs, uint32_t server);
ssize_t send_release(struct client_state_t *cs);
#endif

View File

@ -41,7 +41,7 @@
#include "duiaid.h"
#include "ndhc.h"
static void get_duid_path(char duidfile[static 1], size_t dlen)
static void get_duid_path(char *duidfile, size_t dlen)
{
int splen = snprintf(duidfile, dlen, "%s/DUID", state_dir);
if (splen < 0)
@ -51,7 +51,7 @@ static void get_duid_path(char duidfile[static 1], size_t dlen)
__func__, splen, sizeof dlen);
}
static void get_iaid_path(char iaidfile[static 1], size_t ilen,
static void get_iaid_path(char *iaidfile, size_t ilen,
const uint8_t hwaddr[static 6], size_t hwaddrlen)
{
if (hwaddrlen != 6)
@ -121,8 +121,8 @@ static int open_iaidfile_write(const uint8_t hwaddr[static 6],
// RFC6355 specifies a RFC4122 UUID, but I simply use a 128-byte random
// value, as the complexity of RFC4122 UUID generation is completely
// unwarranted for DHCPv4.
static size_t generate_duid(struct nk_random_state s[static 1],
char dest[static 1], size_t dlen)
static size_t generate_duid(struct nk_random_state *s,
char *dest, size_t dlen)
{
const size_t tlen = sizeof(uint16_t) + 4 * sizeof(uint32_t);
if (dlen < tlen)
@ -143,8 +143,8 @@ static size_t generate_duid(struct nk_random_state s[static 1],
// RFC6355 specifies the IAID as a 32-bit value that uniquely identifies
// a hardware link for a given host.
static size_t generate_iaid(struct nk_random_state s[static 1],
char dest[static 1], size_t dlen)
static size_t generate_iaid(struct nk_random_state *s,
char *dest, size_t dlen)
{
if (dlen < sizeof(uint32_t))
suicide("%s: dlen < %zu", __func__, sizeof(uint32_t));
@ -157,8 +157,8 @@ static size_t generate_iaid(struct nk_random_state s[static 1],
}
// Failures are all fatal.
void get_clientid(struct client_state_t cs[static 1],
struct client_config_t cc[static 1])
void get_clientid(struct client_state_t *cs,
struct client_config_t *cc)
{
if (cc->clientid_len > 0)
return;

View File

@ -30,7 +30,6 @@
#include "ndhc.h"
void get_clientid(struct client_state_t cs[static 1],
struct client_config_t cc[static 1]);
void get_clientid(struct client_state_t *cs, struct client_config_t *cc);
#endif /* NJK_NDHC_DUIAID_H_ */

View File

@ -47,8 +47,7 @@
static struct dhcpmsg cfg_packet; // Copy of the current configuration packet.
static int ifcmd_raw(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_raw(char *buf, size_t buflen, const char *optname,
char *optdata, size_t optlen)
{
if (!optdata) {
@ -78,15 +77,13 @@ static int ifcmd_raw(char buf[static 1], size_t buflen,
return olen;
}
static int ifcmd_bytes(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_bytes(char *buf, size_t buflen, const char *optname,
uint8_t *optdata, size_t optlen)
{
return ifcmd_raw(buf, buflen, optname, (char *)optdata, optlen);
}
static int ifcmd_u8(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_u8(char *buf, size_t buflen, const char *optname,
uint8_t *optdata, size_t optlen)
{
if (!optdata || optlen < 1)
@ -99,8 +96,7 @@ static int ifcmd_u8(char buf[static 1], size_t buflen,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
}
static int ifcmd_u16(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_u16(char *buf, size_t buflen, const char *optname,
uint8_t *optdata, size_t optlen)
{
if (!optdata || optlen < 2)
@ -115,8 +111,7 @@ static int ifcmd_u16(char buf[static 1], size_t buflen,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
}
static int ifcmd_s32(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_s32(char *buf, size_t buflen, const char *optname,
uint8_t *optdata, size_t optlen)
{
if (!optdata || optlen < 4)
@ -131,8 +126,7 @@ static int ifcmd_s32(char buf[static 1], size_t buflen,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
}
static int ifcmd_ip(char buf[static 1], size_t buflen,
const char optname[static 1],
static int ifcmd_ip(char *buf, size_t buflen, const char *optname,
uint8_t *optdata, size_t optlen)
{
if (!optdata || optlen < 4)
@ -142,8 +136,7 @@ static int ifcmd_ip(char buf[static 1], size_t buflen,
return ifcmd_raw(buf, buflen, optname, ipbuf, strlen(ipbuf));
}
static int ifcmd_iplist(char out[static 1], size_t outlen,
const char optname[static 1],
static int ifcmd_iplist(char *out, size_t outlen, const char *optname,
uint8_t *optdata, size_t optlen)
{
char buf[2048];
@ -171,7 +164,7 @@ static int ifcmd_iplist(char out[static 1], size_t outlen,
return ifcmd_raw(out, outlen, optname, buf, strlen(buf));
}
static int ifchd_cmd(char b[static 1], size_t bl, uint8_t *od,
static int ifchd_cmd(char *b, size_t bl, uint8_t *od,
size_t ol, uint8_t code)
{
switch (code) {
@ -192,7 +185,7 @@ static int ifchd_cmd(char b[static 1], size_t bl, uint8_t *od,
return -1;
}
static int ifchwrite(const char buf[static 1], size_t count)
static int ifchwrite(const char *buf, size_t count)
{
ssize_t r = safe_write(ifchSock[0], buf, count);
if (r < 0 || (size_t)r != count) {
@ -231,7 +224,7 @@ bool ifchange_carrier_isup(void)
return ifchwrite(buf, strlen(buf)) == 0;
}
int ifchange_deconfig(struct client_state_t cs[static 1])
int ifchange_deconfig(struct client_state_t *cs)
{
char buf[256];
int ret = -1;
@ -250,8 +243,8 @@ int ifchange_deconfig(struct client_state_t cs[static 1])
return ret;
}
static size_t send_client_ip(char out[static 1], size_t olen,
struct dhcpmsg packet[static 1])
static size_t send_client_ip(char *out, size_t olen,
struct dhcpmsg *packet)
{
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
char ip[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN], bc[INET_ADDRSTRLEN];
@ -312,8 +305,8 @@ static size_t send_client_ip(char out[static 1], size_t olen,
return (size_t)snlen;
}
static size_t send_cmd(char out[static 1], size_t olen,
struct dhcpmsg packet[static 1], uint8_t code)
static size_t send_cmd(char *out, size_t olen,
struct dhcpmsg *packet, uint8_t code)
{
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
size_t optlen, oldlen;
@ -328,8 +321,7 @@ static size_t send_cmd(char out[static 1], size_t olen,
return r > 0 ? (size_t)r : 0;
}
int ifchange_bind(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1])
int ifchange_bind(struct client_state_t *cs, struct dhcpmsg *packet)
{
char buf[2048];
size_t bo;

View File

@ -32,8 +32,7 @@
#include <stdbool.h>
bool ifchange_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]);
int ifchange_bind(struct client_state_t *cs, struct dhcpmsg *packet);
int ifchange_deconfig(struct client_state_t *cs);
#endif

View File

@ -29,6 +29,6 @@
#ifndef _NJK_NDHC_IFCHD_PARSE_H_
#define _NJK_NDHC_IFCHD_PARSE_H_
int execute_buffer(const char newbuf[static 1]);
int execute_buffer(const char *newbuf);
#endif /* _NJK_NDHC_IFCHD_PARSE_H_ */

View File

@ -76,7 +76,7 @@
%% write data;
static int perform_ip4set(const char buf[static 1], size_t len)
static int perform_ip4set(const char *buf, size_t len)
{
char ip4_addr[INET_ADDRSTRLEN];
char ip4_subnet[INET_ADDRSTRLEN];
@ -191,7 +191,7 @@ static int perform_ip4set(const char buf[static 1], size_t len)
* Returns -1 if one of the commands failed.
* Returns 0 on success.
*/
int execute_buffer(const char newbuf[static 1])
int execute_buffer(const char *newbuf)
{
char buf[MAX_BUF * 2];
char tb[MAX_BUF];

View File

@ -63,7 +63,7 @@ int allow_hostname = 0;
uid_t ifch_uid = 0;
gid_t ifch_gid = 0;
static void writeordie(int fd, const char buf[static 1], size_t len)
static void writeordie(int fd, const char *buf, size_t len)
{
ssize_t r = safe_write(fd, buf, len);
if (r < 0 || (size_t)r != len)
@ -71,7 +71,7 @@ static void writeordie(int fd, const char buf[static 1], size_t len)
__func__, r);
}
static int write_append_fd(int to_fd, int from_fd, const char descr[static 1])
static int write_append_fd(int to_fd, int from_fd, const char *descr)
{
if (from_fd < 0) return 0;
if (to_fd < 0) return -1;
@ -199,7 +199,7 @@ static int write_resolve_conf(void)
}
/* XXX: addme */
int perform_timezone(const char str[static 1], size_t len)
int perform_timezone(const char *str, size_t len)
{
(void)len;
log_line("Timezone setting NYI: '%s'", str);
@ -207,7 +207,7 @@ int perform_timezone(const char str[static 1], size_t len)
}
/* Add a dns server to the /etc/resolv.conf -- we already have a fd. */
int perform_dns(const char str[static 1], size_t len)
int perform_dns(const char *str, size_t len)
{
if (resolv_conf_fd < 0)
return 0;
@ -228,7 +228,7 @@ int perform_dns(const char str[static 1], size_t len)
}
/* Updates for print daemons are too non-standard to be useful. */
int perform_lprsvr(const char str[static 1], size_t len)
int perform_lprsvr(const char *str, size_t len)
{
(void)len;
log_line("Line printer server setting NYI: '%s'", str);
@ -236,7 +236,7 @@ int perform_lprsvr(const char str[static 1], size_t len)
}
/* Sets machine hostname. */
int perform_hostname(const char str[static 1], size_t len)
int perform_hostname(const char *str, size_t len)
{
if (!allow_hostname)
return 0;
@ -249,7 +249,7 @@ int perform_hostname(const char str[static 1], size_t len)
}
/* update "domain" and "search" in /etc/resolv.conf */
int perform_domain(const char str[static 1], size_t len)
int perform_domain(const char *str, size_t len)
{
if (resolv_conf_fd < 0)
return 0;
@ -271,7 +271,7 @@ int perform_domain(const char str[static 1], size_t len)
/* I don't think this can be done without a netfilter extension
* that isn't in the mainline kernels. */
int perform_ipttl(const char str[static 1], size_t len)
int perform_ipttl(const char *str, size_t len)
{
(void)len;
log_line("TTL setting NYI: '%s'", str);
@ -279,7 +279,7 @@ int perform_ipttl(const char str[static 1], size_t len)
}
/* XXX: addme */
int perform_ntpsrv(const char str[static 1], size_t len)
int perform_ntpsrv(const char *str, size_t len)
{
(void)len;
log_line("NTP server setting NYI: '%s'", str);
@ -287,7 +287,7 @@ int perform_ntpsrv(const char str[static 1], size_t len)
}
/* Maybe Samba cares about this feature? I don't know. */
int perform_wins(const char str[static 1], size_t len)
int perform_wins(const char *str, size_t len)
{
(void)str;
(void)len;

View File

@ -37,14 +37,14 @@ extern int allow_hostname;
extern uid_t ifch_uid;
extern gid_t ifch_gid;
int perform_timezone(const char str[static 1], size_t len);
int perform_dns(const char str[static 1], size_t len);
int perform_lprsvr(const char str[static 1], size_t len);
int perform_hostname(const char str[static 1], size_t len);
int perform_domain(const char str[static 1], size_t len);
int perform_ipttl(const char str[static 1], size_t len);
int perform_ntpsrv(const char str[static 1], size_t len);
int perform_wins(const char str[static 1], size_t len);
int perform_timezone(const char *str, size_t len);
int perform_dns(const char *str, size_t len);
int perform_lprsvr(const char *str, size_t len);
int perform_hostname(const char *str, size_t len);
int perform_domain(const char *str, size_t len);
int perform_ipttl(const char *str, size_t len);
int perform_ntpsrv(const char *str, size_t len);
int perform_wins(const char *str, size_t len);
void ifch_main(void);

View File

@ -304,7 +304,7 @@ static void link_flags_get_do(const struct nlmsghdr *nlh, void *data)
}
}
static int link_flags_get(int fd, uint32_t flags[static 1])
static int link_flags_get(int fd, uint32_t *flags)
{
char nlbuf[8192];
struct link_flag_data ipx = { .fd = fd, .flags = 0, .got_flags = false };
@ -519,8 +519,8 @@ int perform_ifup(void)
}
// str_bcast is optional.
int perform_ip_subnet_bcast(const char str_ipaddr[static 1],
const char str_subnet[static 1],
int perform_ip_subnet_bcast(const char *str_ipaddr,
const char *str_subnet,
const char *str_bcast)
{
struct in_addr ipaddr, subnet, bcast;
@ -601,7 +601,7 @@ fail:
}
int perform_router(const char str_router[static 1], size_t len)
int perform_router(const char *str_router, size_t len)
{
int ret = -99;
if (len < 7)
@ -634,7 +634,7 @@ fail:
return ret;
}
int perform_mtu(const char str[static 1], size_t len)
int perform_mtu(const char *str, size_t len)
{
unsigned int mtu;
int fd, ret = -99;

View File

@ -30,10 +30,10 @@
#define NJK_IFSET_H_
int perform_carrier(void);
int perform_ifup(void);
int perform_ip_subnet_bcast(const char str_ipaddr[static 1],
const char str_subnet[static 1],
int perform_ip_subnet_bcast(const char *str_ipaddr,
const char *str_subnet,
const char *str_bcast);
int perform_router(const char str[static 1], size_t len);
int perform_router(const char *str, size_t len);
int perform_mtu(const char *str, size_t len);
#endif

View File

@ -56,7 +56,7 @@ void nk_set_chroot(const char *chroot_dir)
}
#ifdef NK_USE_CAPABILITY
static size_t nk_get_capability_vinfo(uint32_t version[static 1])
static size_t nk_get_capability_vinfo(uint32_t *version)
{
struct __user_cap_header_struct hdr;
memset(&hdr, 0, sizeof hdr);
@ -80,7 +80,7 @@ static size_t nk_get_capability_vinfo(uint32_t version[static 1])
}
static size_t nk_set_capability_prologue(const unsigned char *caps,
size_t caplen,
uint32_t cversion[static 1])
uint32_t *cversion)
{
if (!caps || !caplen)
return 0;
@ -120,7 +120,7 @@ static void nk_set_capability_epilogue(const unsigned char *caps,
#else
static size_t nk_set_capability_prologue(const unsigned char *caps,
size_t caplen,
uint32_t cversion[static 1])
uint32_t *cversion)
{ (void)caps; (void)caplen; (void)cversion; return 0; }
static void nk_set_capability_epilogue(const unsigned char *caps,
size_t caplen, uint32_t cversion,

View File

@ -112,7 +112,7 @@ int signals_flagged(void)
bool carrier_isup(void) { return cs.carrier_up; }
void set_client_addr(const char v[static 1]) { cs.clientAddr = inet_addr(v); }
void set_client_addr(const char *v) { cs.clientAddr = inet_addr(v); }
void print_version(void)
{
@ -223,7 +223,7 @@ static void setup_signals_ndhc(void)
suicide("sigaction failed");
}
static int is_string_hwaddr(const char str[static 1], size_t slen)
static int is_string_hwaddr(const char *str, size_t slen)
{
if (slen == 17 && str[2] == ':' && str[5] == ':' && str[8] == ':' &&
str[11] == ':' && str[14] == ':' &&
@ -236,7 +236,7 @@ static int is_string_hwaddr(const char str[static 1], size_t slen)
return 0;
}
int get_clientid_string(const char str[static 1], size_t slen)
int get_clientid_string(const char *str, size_t slen)
{
if (!slen)
return -1;

View File

@ -100,10 +100,10 @@ extern gid_t ndhc_gid;
int signals_flagged(void);
bool carrier_isup(void);
void set_client_addr(const char v[static 1]);
void set_client_addr(const char *v);
void show_usage(void);
void signal_exit(int status);
int get_clientid_string(const char str[static 1], size_t slen);
int get_clientid_string(const char *str, size_t slen);
void print_version(void);
#endif /* NJK_NDHC_NDHC_H_ */

View File

@ -89,7 +89,7 @@ static void nl_process_msgs(const struct nlmsghdr *nlh, void *data)
nl_process_msgs_return = IFS_REMOVED;
}
int nl_event_get(struct client_state_t cs[static 1])
int nl_event_get(struct client_state_t *cs)
{
char nlbuf[8192];
ssize_t ret;

View File

@ -42,7 +42,7 @@ enum {
};
bool nl_event_carrier_wentup(int state);
int nl_event_get(struct client_state_t cs[static 1]);
int nl_event_get(struct client_state_t *cs);
int nl_getifdata(void);
#endif /* NK_NETLINK_H_ */

View File

@ -81,7 +81,7 @@ void nl_rtattr_parse(const struct nlmsghdr *nlh, size_t offset,
}
}
ssize_t nl_recv_buf(int fd, char buf[static 1], size_t blen)
ssize_t nl_recv_buf(int fd, char *buf, size_t blen)
{
struct sockaddr_nl addr;
struct iovec iov = {
@ -114,7 +114,7 @@ ssize_t nl_recv_buf(int fd, char buf[static 1], size_t blen)
return ret;
}
int nl_foreach_nlmsg(char buf[static 1], size_t blen, uint32_t seq, uint32_t portid,
int nl_foreach_nlmsg(char *buf, size_t blen, uint32_t seq, uint32_t portid,
nlmsg_foreach_fn pfn, void *fnarg)
{
const struct nlmsghdr *nlh = (const struct nlmsghdr *)buf;

View File

@ -37,7 +37,7 @@
#include "ndhc.h"
#include "rfkill.h"
int rfkill_open(bool enable_rfkill[static 1])
int rfkill_open(bool *enable_rfkill)
{
if (!*enable_rfkill)
return -1;
@ -52,8 +52,7 @@ int rfkill_open(bool enable_rfkill[static 1])
// check_idx: Does rfkidx have any meaning?
// rfkidx: Pay attention only to this radio kill switch number.
int rfkill_get(struct client_state_t cs[static 1],
int check_idx, uint32_t rfkidx)
int rfkill_get(struct client_state_t *cs, int check_idx, uint32_t rfkidx)
{
struct rfkill_event event;
ssize_t len = safe_read(cs->rfkillFd, (char *)&event, sizeof event);

View File

@ -35,9 +35,8 @@ enum {
RFK_DISABLED,
};
int rfkill_open(bool enable_rfkill[static 1]);
int rfkill_get(struct client_state_t cs[static 1],
int check_idx, uint32_t rfkidx);
int rfkill_open(bool *enable_rfkill);
int rfkill_get(struct client_state_t *cs, int check_idx, uint32_t rfkidx);
#endif

View File

@ -62,7 +62,7 @@ uid_t sockd_uid = 0;
gid_t sockd_gid = 0;
// Interface to make requests of sockd. Called from ndhc process.
int request_sockd_fd(char buf[static 1], size_t buflen, char *response)
int request_sockd_fd(char *buf, size_t buflen, char *response)
{
if (!buflen)
return -1;
@ -472,7 +472,7 @@ static void xfer_fd(int fd, char cmd)
close(fd);
}
static size_t execute_sockd(char buf[static 1], size_t buflen)
static size_t execute_sockd(char *buf, size_t buflen)
{
if (!buflen)
return 0;

View File

@ -3,7 +3,7 @@
extern uid_t sockd_uid;
extern gid_t sockd_gid;
int request_sockd_fd(char buf[static 1], size_t buflen, char *response);
int request_sockd_fd(char *buf, size_t buflen, char *response);
void sockd_main(void);
#endif /* NDHC_SOCKD_H_ */

View File

@ -65,7 +65,7 @@
#define IFUP_NEWLEASE 1
#define IFUP_FAIL -1
static int delay_timeout(struct client_state_t cs[static 1], size_t numpackets)
static int delay_timeout(struct client_state_t *cs, size_t numpackets)
{
int to = 64;
char tot[] = { 4, 8, 16, 32, 64 };
@ -75,7 +75,7 @@ static int delay_timeout(struct client_state_t cs[static 1], size_t numpackets)
return to * 1000 + (int)(nk_random_u32(&cs->rnd_state) % 1000);
}
static void reinit_shared_deconfig(struct client_state_t cs[static 1])
static void reinit_shared_deconfig(struct client_state_t *cs)
{
cs->xid = nk_random_u32(&cs->rnd_state);
cs->clientAddr = 0;
@ -96,7 +96,7 @@ static void reinit_shared_deconfig(struct client_state_t cs[static 1])
arp_reset_state(cs);
}
static void reinit_selecting(struct client_state_t cs[static 1], int timeout)
static void reinit_selecting(struct client_state_t *cs, int timeout)
{
reinit_shared_deconfig(cs);
cs->dhcp_wake_ts = curms() + timeout;
@ -107,7 +107,7 @@ static void reinit_selecting(struct client_state_t cs[static 1], int timeout)
// been received within the response wait time. If we've not exceeded the
// maximum number of request retransmits, then send another packet and wait
// again. Otherwise, return to the DHCP initialization state.
static int requesting_timeout(struct client_state_t cs[static 1],
static int requesting_timeout(struct client_state_t *cs,
long long nowts)
{
if (cs->num_dhcp_requests >= 5) {
@ -126,7 +126,7 @@ static int requesting_timeout(struct client_state_t cs[static 1],
// Called by renewing_timeout() to try to renew the lease. If all
// timeouts expire, then expire the lease and notify the caller.
static int rebinding_timeout(struct client_state_t cs[static 1],
static int rebinding_timeout(struct client_state_t *cs,
long long nowts)
{
long long elt = cs->leaseStartTime + cs->lease * 1000;
@ -149,7 +149,7 @@ static int rebinding_timeout(struct client_state_t cs[static 1],
}
// Called by bound_timeout() to try to renew the lease.
static int renewing_timeout(struct client_state_t cs[static 1],
static int renewing_timeout(struct client_state_t *cs,
long long nowts)
{
long long rbt = cs->leaseStartTime + cs->rebindTime * 1000;
@ -170,7 +170,7 @@ static int renewing_timeout(struct client_state_t cs[static 1],
// Called to handle dhcp state timeouts, such as when RENEW or REBIND
// DHCPREQUESTs must be sent. Can return BTO_(WAIT|EXPIRED|HARDFAIL).
static int bound_timeout(struct client_state_t cs[static 1], long long nowts)
static int bound_timeout(struct client_state_t *cs, long long nowts)
{
long long rnt = cs->leaseStartTime + cs->renewTime * 1000;
if (nowts < rnt) {
@ -180,8 +180,8 @@ static int bound_timeout(struct client_state_t cs[static 1], long long nowts)
return renewing_timeout(cs, nowts);
}
static void get_leasetime(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1])
static void get_leasetime(struct client_state_t *cs,
struct dhcpmsg *packet)
{
cs->lease = get_option_leasetime(packet);
cs->leaseStartTime = curms();
@ -203,9 +203,9 @@ static void get_leasetime(struct client_state_t cs[static 1],
cs->dhcp_wake_ts = cs->leaseStartTime + cs->renewTime * 1000;
}
static bool validate_acknak(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1],
const char typemsg[static 1],
static bool validate_acknak(struct client_state_t *cs,
struct dhcpmsg *packet,
const char *typemsg,
uint32_t srcaddr)
{
// Don't validate the server id. Instead validate that the
@ -229,8 +229,8 @@ static bool validate_acknak(struct client_state_t cs[static 1],
return true;
}
static int extend_packet(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1], uint8_t msgtype,
static int extend_packet(struct client_state_t *cs,
struct dhcpmsg *packet, uint8_t msgtype,
uint32_t srcaddr)
{
(void)srcaddr;
@ -271,8 +271,8 @@ static int extend_packet(struct client_state_t cs[static 1],
return ANP_IGNORE;
}
static int selecting_packet(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1], uint8_t msgtype,
static int selecting_packet(struct client_state_t *cs,
struct dhcpmsg *packet, uint8_t msgtype,
uint32_t srcaddr, bool is_requesting)
{
char clibuf[INET_ADDRSTRLEN];
@ -323,7 +323,7 @@ static int selecting_packet(struct client_state_t cs[static 1],
// been received within the response wait time. If we've not exceeded the
// maximum number of discover retransmits, then send another packet and wait
// again. Otherwise fail.
static int selecting_timeout(struct client_state_t cs[static 1],
static int selecting_timeout(struct client_state_t *cs,
long long nowts)
{
if (cs->program_init && cs->num_dhcp_requests >= 2) {
@ -341,7 +341,7 @@ static int selecting_timeout(struct client_state_t cs[static 1],
}
// Called for a release signal during SELECTING or REQUESTING.
static void print_release(struct client_state_t cs[static 1])
static void print_release(struct client_state_t *cs)
{
log_line("%s: ndhc going to sleep. Wake it by sending a SIGUSR1.",
client_config.interface);
@ -351,7 +351,7 @@ static void print_release(struct client_state_t cs[static 1])
}
// Called for a release signal during BOUND, RENEWING, or REBINDING.
static int xmit_release(struct client_state_t cs[static 1])
static int xmit_release(struct client_state_t *cs)
{
char clibuf[INET_ADDRSTRLEN];
char svrbuf[INET_ADDRSTRLEN];
@ -371,7 +371,7 @@ static int xmit_release(struct client_state_t cs[static 1])
}
// Called for a renewing signal during BOUND or RELEASED
static int frenew(struct client_state_t cs[static 1], bool is_bound)
static int frenew(struct client_state_t *cs, bool is_bound)
{
if (is_bound) {
log_line("%s: Forcing a DHCP renew...", client_config.interface);
@ -389,7 +389,7 @@ static int frenew(struct client_state_t cs[static 1], bool is_bound)
// If we have a lease, check to see if our gateway is still valid via ARP.
// If it fails, state -> SELECTING.
static int ifup_action(struct client_state_t cs[static 1])
static int ifup_action(struct client_state_t *cs)
{
if (cs->routerAddr && cs->serverAddr) {
const bool fp_server = cs->server_arp_state == ARP_FOUND;
@ -420,7 +420,7 @@ no_fingerprint:
// ret == 1: ret = COR_ERROR; scrReturn(ret); continue
// ret == 2: goto skip_to_released
// ret == 3: break
static int signal_check_nolease(struct client_state_t cs[static 1])
static int signal_check_nolease(struct client_state_t *cs)
{
for (;;) {
int s = signals_flagged();
@ -433,7 +433,7 @@ static int signal_check_nolease(struct client_state_t cs[static 1])
}
return 0;
}
static int signal_check_havelease(struct client_state_t cs[static 1])
static int signal_check_havelease(struct client_state_t *cs)
{
for (;;) {
int s = signals_flagged();
@ -451,7 +451,7 @@ static int signal_check_havelease(struct client_state_t cs[static 1])
}
return 0;
}
static int signal_check_released(struct client_state_t cs[static 1])
static int signal_check_released(struct client_state_t *cs)
{
(void)cs;
for (;;) {
@ -477,8 +477,8 @@ static int signal_check_released(struct client_state_t cs[static 1])
#define BAD_STATE() suicide("%s(%d): bad state", __func__, __LINE__)
// XXX: Should be re-entrant so as to handle multiple servers.
int dhcp_handle(struct client_state_t cs[static 1], long long nowts,
bool sev_dhcp, struct dhcpmsg dhcp_packet[static 1],
int dhcp_handle(struct client_state_t *cs, long long nowts,
bool sev_dhcp, struct dhcpmsg *dhcp_packet,
uint8_t dhcp_msgtype, uint32_t dhcp_srcaddr, bool sev_arp,
bool force_fingerprint, bool dhcp_timeout, bool arp_timeout)
{

View File

@ -34,8 +34,8 @@
#define COR_SUCCESS 0
#define COR_ERROR -1
int dhcp_handle(struct client_state_t cs[static 1], long long nowts,
bool sev_dhcp, struct dhcpmsg dhcp_packet[static 1],
int dhcp_handle(struct client_state_t *cs, long long nowts,
bool sev_dhcp, struct dhcpmsg *dhcp_packet,
uint8_t dhcp_msgtype, uint32_t dhcp_srcaddr, bool sev_arp,
bool force_fingerprint, bool dhcp_timeout, bool arp_timeout);