Mark pointer arguments that cannot ever be null as [static 1].

Also constify some cases, too.
This commit is contained in:
Nicholas J. Kain 2015-02-13 23:14:08 -05:00
parent cc806acc0b
commit 702d8b0c5b
20 changed files with 169 additions and 137 deletions

View File

@ -209,7 +209,8 @@ static void arp_min_close_fd(struct client_state_t cs[static 1])
garp.state = AS_NONE; garp.state = AS_NONE;
} }
static void arp_switch_state(struct client_state_t cs[static 1], arp_state_t state) static void arp_switch_state(struct client_state_t cs[static 1],
arp_state_t state)
{ {
if (garp.state == state || garp.state >= AS_MAX) if (garp.state == state || garp.state >= AS_MAX)
return; return;
@ -242,7 +243,8 @@ static void arp_reopen_fd(struct client_state_t cs[static 1])
arp_switch_state(cs, prev_state); arp_switch_state(cs, prev_state);
} }
static int arp_send(struct client_state_t cs[static 1], struct arpMsg *arp) static int arp_send(struct client_state_t cs[static 1],
struct arpMsg arp[static 1])
{ {
struct sockaddr_ll addr = { struct sockaddr_ll addr = {
.sll_family = AF_PACKET, .sll_family = AF_PACKET,
@ -305,7 +307,8 @@ static int arp_ping(struct client_state_t cs[static 1], uint32_t test_ip)
} }
// Returns 0 on success, -1 on failure. // Returns 0 on success, -1 on failure.
static int arp_ip_anon_ping(struct client_state_t cs[static 1], uint32_t test_ip) static int arp_ip_anon_ping(struct client_state_t cs[static 1],
uint32_t test_ip)
{ {
BASE_ARPMSG(); BASE_ARPMSG();
memcpy(arp.dip4, &test_ip, sizeof test_ip); memcpy(arp.dip4, &test_ip, sizeof test_ip);
@ -332,7 +335,8 @@ static int arp_announcement(struct client_state_t cs[static 1])
#undef BASE_ARPMSG #undef BASE_ARPMSG
// Callable from DS_REQUESTING, DS_RENEWING, or DS_REBINDING via an_packet() // Callable from DS_REQUESTING, DS_RENEWING, or DS_REBINDING via an_packet()
int arp_check(struct client_state_t cs[static 1], struct dhcpmsg *packet) int arp_check(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1])
{ {
memcpy(&garp.dhcp_packet, packet, sizeof (struct dhcpmsg)); memcpy(&garp.dhcp_packet, packet, sizeof (struct dhcpmsg));
arp_switch_state(cs, AS_COLLISION_CHECK); arp_switch_state(cs, AS_COLLISION_CHECK);
@ -509,7 +513,7 @@ static int arp_validate_bpf(struct arpMsg *am)
// ARP validation functions that will be performed by the BPF if it is // ARP validation functions that will be performed by the BPF if it is
// installed. // installed.
static int arp_validate_bpf_defense(struct client_state_t cs[static 1], static int arp_validate_bpf_defense(struct client_state_t cs[static 1],
struct arpMsg *am) struct arpMsg am[static 1])
{ {
if (memcmp(am->sip4, &cs->clientAddr, 4)) if (memcmp(am->sip4, &cs->clientAddr, 4))
return 0; return 0;
@ -518,7 +522,7 @@ static int arp_validate_bpf_defense(struct client_state_t cs[static 1],
return 1; return 1;
} }
static int arp_is_query_reply(struct arpMsg *am) static int arp_is_query_reply(struct arpMsg am[static 1])
{ {
if (am->operation != htons(ARPOP_REPLY)) if (am->operation != htons(ARPOP_REPLY))
return 0; return 0;
@ -536,7 +540,8 @@ static int arp_gen_probe_wait(struct client_state_t cs[static 1])
% (arp_probe_max - arp_probe_min); % (arp_probe_max - arp_probe_min);
} }
static void arp_defense_timeout(struct client_state_t cs[static 1], long long nowts) static void arp_defense_timeout(struct client_state_t cs[static 1],
long long nowts)
{ {
(void)nowts; // Suppress warning; parameter necessary but unused. (void)nowts; // Suppress warning; parameter necessary but unused.
if (garp.wake_ts[AS_DEFENSE] != -1) { if (garp.wake_ts[AS_DEFENSE] != -1) {
@ -546,7 +551,8 @@ static void arp_defense_timeout(struct client_state_t cs[static 1], long long no
} }
} }
static void arp_gw_check_timeout(struct client_state_t cs[static 1], long long nowts) static void arp_gw_check_timeout(struct client_state_t cs[static 1],
long long nowts)
{ {
arp_defense_timeout(cs, nowts); arp_defense_timeout(cs, nowts);
@ -582,7 +588,8 @@ static void arp_do_gw_query_done(struct client_state_t cs[static 1])
arp_announcement(cs); // Do a second announcement. arp_announcement(cs); // Do a second announcement.
} }
static void arp_gw_query_timeout(struct client_state_t cs[static 1], long long nowts) static void arp_gw_query_timeout(struct client_state_t cs[static 1],
long long nowts)
{ {
arp_defense_timeout(cs, nowts); arp_defense_timeout(cs, nowts);
@ -609,7 +616,8 @@ static void arp_gw_query_timeout(struct client_state_t cs[static 1], long long n
garp.send_stats[ASEND_GW_PING].ts + ARP_RETRANS_DELAY; garp.send_stats[ASEND_GW_PING].ts + ARP_RETRANS_DELAY;
} }
static void arp_collision_timeout(struct client_state_t cs[static 1], long long nowts) static void arp_collision_timeout(struct client_state_t cs[static 1],
long long nowts)
{ {
arp_defense_timeout(cs, nowts); arp_defense_timeout(cs, nowts);

View File

@ -61,7 +61,8 @@ extern int arp_probe_max;
void set_arp_relentless_def(bool v); void set_arp_relentless_def(bool v);
void arp_reset_send_stats(void); void arp_reset_send_stats(void);
void arp_close_fd(struct client_state_t cs[static 1]); void arp_close_fd(struct client_state_t cs[static 1]);
int arp_check(struct client_state_t cs[static 1], struct dhcpmsg *packet); 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_gw_check(struct client_state_t cs[static 1]);
void arp_set_defense_mode(struct client_state_t cs[static 1]); void arp_set_defense_mode(struct client_state_t cs[static 1]);
void arp_success(struct client_state_t cs[static 1]); void arp_success(struct client_state_t cs[static 1]);

View File

@ -224,7 +224,7 @@ struct cfgparse {
%% write data; %% write data;
static void parse_cfgfile(const char *fname) static void parse_cfgfile(const char fname[static 1])
{ {
struct cfgparse ccfg; struct cfgparse ccfg;
memset(&ccfg, 0, sizeof ccfg); memset(&ccfg, 0, sizeof ccfg);

View File

@ -78,7 +78,7 @@ static int get_raw_listen_socket(struct client_state_t cs[static 1])
// Unicast a DHCP message using a UDP socket. // Unicast a DHCP message using a UDP socket.
static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1], static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1],
struct dhcpmsg *payload) struct dhcpmsg payload[static 1])
{ {
ssize_t ret = -1; ssize_t ret = -1;
int fd = get_udp_unicast_socket(cs); int fd = get_udp_unicast_socket(cs);
@ -124,13 +124,13 @@ static ssize_t send_dhcp_unicast(struct client_state_t cs[static 1],
} }
// Returns 1 if IP checksum is correct, otherwise 0. // Returns 1 if IP checksum is correct, otherwise 0.
static int ip_checksum(struct ip_udp_dhcp_packet *packet) static int ip_checksum(struct ip_udp_dhcp_packet packet[static 1])
{ {
return net_checksum161c(&packet->ip, sizeof packet->ip) == 0; return net_checksum161c(&packet->ip, sizeof packet->ip) == 0;
} }
// Returns 1 if UDP checksum is correct, otherwise 0. // Returns 1 if UDP checksum is correct, otherwise 0.
static int udp_checksum(struct ip_udp_dhcp_packet *packet) static int udp_checksum(struct ip_udp_dhcp_packet packet[static 1])
{ {
struct iphdr ph = { struct iphdr ph = {
.saddr = packet->ip.saddr, .saddr = packet->ip.saddr,
@ -147,7 +147,7 @@ static int udp_checksum(struct ip_udp_dhcp_packet *packet)
return cs == 0; return cs == 0;
} }
static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet *packet) static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet packet[static 1])
{ {
if (packet->ip.version != IPVERSION) { if (packet->ip.version != IPVERSION) {
log_warning("%s: IP version is not IPv4.", client_config.interface); log_warning("%s: IP version is not IPv4.", client_config.interface);
@ -180,7 +180,7 @@ static int get_raw_packet_validate_bpf(struct ip_udp_dhcp_packet *packet)
// Read a packet from a raw socket. Returns -1 on fatal error, -2 on // Read a packet from a raw socket. Returns -1 on fatal error, -2 on
// transient error. // transient error.
static ssize_t get_raw_packet(struct client_state_t cs[static 1], static ssize_t get_raw_packet(struct client_state_t cs[static 1],
struct dhcpmsg *payload, struct dhcpmsg payload[static 1],
uint32_t *srcaddr) uint32_t *srcaddr)
{ {
struct ip_udp_dhcp_packet packet; struct ip_udp_dhcp_packet packet;
@ -244,7 +244,7 @@ int check_carrier(int fd)
} }
// Broadcast a DHCP message using a raw socket. // Broadcast a DHCP message using a raw socket.
static ssize_t send_dhcp_raw(struct dhcpmsg *payload) static ssize_t send_dhcp_raw(struct dhcpmsg payload[static 1])
{ {
ssize_t ret = -1; ssize_t ret = -1;
int fd = get_raw_broadcast_socket(); int fd = get_raw_broadcast_socket();
@ -341,8 +341,9 @@ void stop_dhcp_listen(struct client_state_t cs[static 1])
cs->listenFd = -1; cs->listenFd = -1;
} }
static int validate_dhcp_packet(struct client_state_t cs[static 1], size_t len, static int validate_dhcp_packet(struct client_state_t cs[static 1],
struct dhcpmsg *packet, uint8_t *msgtype) size_t len, struct dhcpmsg packet[static 1],
uint8_t *msgtype)
{ {
if (len < offsetof(struct dhcpmsg, options)) { if (len < offsetof(struct dhcpmsg, options)) {
log_warning("%s: Packet is too short to contain magic cookie. Ignoring.", log_warning("%s: Packet is too short to contain magic cookie. Ignoring.",

View File

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

View File

@ -30,6 +30,7 @@
#include "ndhc.h" #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[static 1],
struct client_config_t cc[static 1]);
#endif /* NJK_NDHC_DUIAID_H_ */ #endif /* NJK_NDHC_DUIAID_H_ */

View File

@ -47,7 +47,8 @@
static struct dhcpmsg cfg_packet; // Copy of the current configuration packet. static struct dhcpmsg cfg_packet; // Copy of the current configuration packet.
static int ifcmd_raw(char buf[static 1], size_t buflen, char *optname, static int ifcmd_raw(char buf[static 1], size_t buflen,
const char optname[static 1],
char *optdata, ssize_t optlen) char *optdata, ssize_t optlen)
{ {
if (!optdata) { if (!optdata) {
@ -77,13 +78,15 @@ static int ifcmd_raw(char buf[static 1], size_t buflen, char *optname,
return olen; return olen;
} }
static int ifcmd_bytes(char buf[static 1], size_t buflen, char *optname, static int ifcmd_bytes(char buf[static 1], size_t buflen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
return ifcmd_raw(buf, buflen, optname, (char *)optdata, optlen); return ifcmd_raw(buf, buflen, optname, (char *)optdata, optlen);
} }
static int ifcmd_u8(char buf[static 1], size_t buflen, char *optname, static int ifcmd_u8(char buf[static 1], size_t buflen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
if (!optdata || optlen < 1) if (!optdata || optlen < 1)
@ -96,7 +99,8 @@ static int ifcmd_u8(char buf[static 1], size_t buflen, char *optname,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf)); return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
} }
static int ifcmd_u16(char buf[static 1], size_t buflen, char *optname, static int ifcmd_u16(char buf[static 1], size_t buflen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
if (!optdata || optlen < 2) if (!optdata || optlen < 2)
@ -111,7 +115,8 @@ static int ifcmd_u16(char buf[static 1], size_t buflen, char *optname,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf)); return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
} }
static int ifcmd_s32(char buf[static 1], size_t buflen, char *optname, static int ifcmd_s32(char buf[static 1], size_t buflen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
if (!optdata || optlen < 4) if (!optdata || optlen < 4)
@ -126,7 +131,8 @@ static int ifcmd_s32(char buf[static 1], size_t buflen, char *optname,
return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf)); return ifcmd_raw(buf, buflen, optname, numbuf, strlen(numbuf));
} }
static int ifcmd_ip(char buf[static 1], size_t buflen, char *optname, static int ifcmd_ip(char buf[static 1], size_t buflen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
if (!optdata || optlen < 4) if (!optdata || optlen < 4)
@ -136,7 +142,8 @@ static int ifcmd_ip(char buf[static 1], size_t buflen, char *optname,
return ifcmd_raw(buf, buflen, optname, ipbuf, strlen(ipbuf)); return ifcmd_raw(buf, buflen, optname, ipbuf, strlen(ipbuf));
} }
static int ifcmd_iplist(char *out, size_t outlen, char *optname, static int ifcmd_iplist(char out[static 1], size_t outlen,
const char optname[static 1],
uint8_t *optdata, ssize_t optlen) uint8_t *optdata, ssize_t optlen)
{ {
char buf[2048]; char buf[2048];
@ -164,7 +171,8 @@ static int ifcmd_iplist(char *out, size_t outlen, char *optname,
return ifcmd_raw(out, outlen, optname, buf, strlen(buf)); return ifcmd_raw(out, outlen, optname, buf, strlen(buf));
} }
static int ifchd_cmd(char *b, size_t bl, uint8_t *od, ssize_t ol, uint8_t code) static int ifchd_cmd(char b[static 1], size_t bl, uint8_t *od,
ssize_t ol, uint8_t code)
{ {
switch (code) { switch (code) {
case DCODE_ROUTER: return ifcmd_ip(b, bl, "routr", od, ol); case DCODE_ROUTER: return ifcmd_ip(b, bl, "routr", od, ol);
@ -184,7 +192,8 @@ static int ifchd_cmd(char *b, size_t bl, uint8_t *od, ssize_t ol, uint8_t code)
return -1; return -1;
} }
static void ifchwrite(struct client_state_t cs[static 1], const char buf[static 1], size_t count) static void ifchwrite(struct client_state_t cs[static 1],
const char buf[static 1], size_t count)
{ {
cs->ifchWorking = 1; cs->ifchWorking = 1;
ssize_t r = safe_write(ifchSock[0], buf, count); ssize_t r = safe_write(ifchSock[0], buf, count);
@ -210,7 +219,8 @@ void ifchange_deconfig(struct client_state_t cs[static 1])
memset(&cfg_packet, 0, sizeof cfg_packet); memset(&cfg_packet, 0, sizeof cfg_packet);
} }
static size_t send_client_ip(char *out, size_t olen, struct dhcpmsg *packet) static size_t send_client_ip(char out[static 1], size_t olen,
struct dhcpmsg packet[static 1])
{ {
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE]; uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
char ip[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN], bc[INET_ADDRSTRLEN]; char ip[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN], bc[INET_ADDRSTRLEN];
@ -271,8 +281,8 @@ static size_t send_client_ip(char *out, size_t olen, struct dhcpmsg *packet)
return snlen; return snlen;
} }
static size_t send_cmd(char *out, size_t olen, struct dhcpmsg *packet, static size_t send_cmd(char out[static 1], size_t olen,
uint8_t code) struct dhcpmsg packet[static 1], uint8_t code)
{ {
uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE]; uint8_t optdata[MAX_DOPT_SIZE], olddata[MAX_DOPT_SIZE];
ssize_t optlen, oldlen; ssize_t optlen, oldlen;
@ -290,7 +300,8 @@ static size_t send_cmd(char *out, size_t olen, struct dhcpmsg *packet,
return r > 0 ? r : 0; return r > 0 ? r : 0;
} }
void ifchange_bind(struct client_state_t cs[static 1], struct dhcpmsg *packet) void ifchange_bind(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1])
{ {
char buf[2048]; char buf[2048];
size_t bo; size_t bo;

View File

@ -29,7 +29,8 @@
#ifndef IFCHANGE_H_ #ifndef IFCHANGE_H_
#define IFCHANGE_H_ #define IFCHANGE_H_
void ifchange_bind(struct client_state_t cs[static 1], struct dhcpmsg *packet); void ifchange_bind(struct client_state_t cs[static 1],
struct dhcpmsg packet[static 1]);
void ifchange_deconfig(struct client_state_t cs[static 1]); void ifchange_deconfig(struct client_state_t cs[static 1]);
#endif #endif

View File

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

View File

@ -180,7 +180,7 @@ static void perform_ip4set(const char buf[static 1], size_t len)
/* /*
* Returns -1 on fatal error; that leads to peer connection being closed. * Returns -1 on fatal error; that leads to peer connection being closed.
*/ */
int execute_buffer(char *newbuf) int execute_buffer(const char newbuf[static 1])
{ {
char buf[MAX_BUF * 2]; char buf[MAX_BUF * 2];
char tb[MAX_BUF]; char tb[MAX_BUF];

View File

@ -172,16 +172,16 @@ static void write_resolve_conf(void)
} }
/* XXX: addme */ /* XXX: addme */
void perform_timezone(const char *str, size_t len) void perform_timezone(const char str[static 1], size_t len)
{ {
(void)len; (void)len;
log_line("Timezone setting NYI: '%s'", str); log_line("Timezone setting NYI: '%s'", str);
} }
/* Add a dns server to the /etc/resolv.conf -- we already have a fd. */ /* Add a dns server to the /etc/resolv.conf -- we already have a fd. */
void perform_dns(const char *str, size_t len) void perform_dns(const char str[static 1], size_t len)
{ {
if (!str || resolv_conf_fd < 0) if (resolv_conf_fd < 0)
return; return;
if (len > sizeof cl.namesvrs) { if (len > sizeof cl.namesvrs) {
log_line("DNS server list is too long: %zu > %zu", len, cl.namesvrs); log_line("DNS server list is too long: %zu > %zu", len, cl.namesvrs);
@ -197,16 +197,16 @@ void perform_dns(const char *str, size_t len)
} }
/* Updates for print daemons are too non-standard to be useful. */ /* Updates for print daemons are too non-standard to be useful. */
void perform_lprsvr(const char *str, size_t len) void perform_lprsvr(const char str[static 1], size_t len)
{ {
(void)len; (void)len;
log_line("Line printer server setting NYI: '%s'", str); log_line("Line printer server setting NYI: '%s'", str);
} }
/* Sets machine hostname. */ /* Sets machine hostname. */
void perform_hostname(const char *str, size_t len) void perform_hostname(const char str[static 1], size_t len)
{ {
if (!allow_hostname || !str) if (!allow_hostname)
return; return;
if (sethostname(str, len) < 0) if (sethostname(str, len) < 0)
log_line("sethostname returned %s", strerror(errno)); log_line("sethostname returned %s", strerror(errno));
@ -215,9 +215,9 @@ void perform_hostname(const char *str, size_t len)
} }
/* update "domain" and "search" in /etc/resolv.conf */ /* update "domain" and "search" in /etc/resolv.conf */
void perform_domain(const char *str, size_t len) void perform_domain(const char str[static 1], size_t len)
{ {
if (!str || resolv_conf_fd < 0) if (resolv_conf_fd < 0)
return; return;
if (len > sizeof cl.domains) { if (len > sizeof cl.domains) {
log_line("DNS domain list is too long: %zu > %zu", len, cl.namesvrs); log_line("DNS domain list is too long: %zu > %zu", len, cl.namesvrs);
@ -234,21 +234,21 @@ void perform_domain(const char *str, size_t len)
/* I don't think this can be done without a netfilter extension /* I don't think this can be done without a netfilter extension
* that isn't in the mainline kernels. */ * that isn't in the mainline kernels. */
void perform_ipttl(const char *str, size_t len) void perform_ipttl(const char str[static 1], size_t len)
{ {
(void)len; (void)len;
log_line("TTL setting NYI: '%s'", str); log_line("TTL setting NYI: '%s'", str);
} }
/* XXX: addme */ /* XXX: addme */
void perform_ntpsrv(const char *str, size_t len) void perform_ntpsrv(const char str[static 1], size_t len)
{ {
(void)len; (void)len;
log_line("NTP server setting NYI: '%s'", str); log_line("NTP server setting NYI: '%s'", str);
} }
/* Maybe Samba cares about this feature? I don't know. */ /* Maybe Samba cares about this feature? I don't know. */
void perform_wins(const char *str, size_t len) void perform_wins(const char str[static 1], size_t len)
{ {
(void)str; (void)str;
(void)len; (void)len;

View File

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

View File

@ -96,7 +96,7 @@ struct client_config_t client_config = {
.foreground = 1, .foreground = 1,
}; };
void set_client_addr(const char *v) { cs.clientAddr = inet_addr(v); } void set_client_addr(const char v[static 1]) { cs.clientAddr = inet_addr(v); }
void print_version(void) void print_version(void)
{ {
@ -212,7 +212,7 @@ static void signal_dispatch(void)
} }
} }
static int is_string_hwaddr(char *str, size_t slen) static int is_string_hwaddr(const char str[static 1], size_t slen)
{ {
if (slen == 17 && str[2] == ':' && str[5] == ':' && str[8] == ':' && if (slen == 17 && str[2] == ':' && str[5] == ':' && str[8] == ':' &&
str[11] == ':' && str[14] == ':' && str[11] == ':' && str[14] == ':' &&
@ -225,7 +225,7 @@ static int is_string_hwaddr(char *str, size_t slen)
return 0; return 0;
} }
int get_clientid_string(char *str, size_t slen) int get_clientid_string(const char str[static 1], size_t slen)
{ {
if (!slen) if (!slen)
return -1; return -1;

View File

@ -80,9 +80,9 @@ extern char pidfile[PATH_MAX];
extern uid_t ndhc_uid; extern uid_t ndhc_uid;
extern gid_t ndhc_gid; extern gid_t ndhc_gid;
void set_client_addr(const char *v); void set_client_addr(const char v[static 1]);
void show_usage(void); void show_usage(void);
int get_clientid_string(char *str, size_t slen); int get_clientid_string(const char str[static 1], size_t slen);
void background(void); void background(void);
void print_version(void); void print_version(void);

View File

@ -34,7 +34,8 @@
#include "options.h" #include "options.h"
static int do_overload_value(const uint8_t buf[static 1], ssize_t blen, int overload) static int do_overload_value(const uint8_t buf[static 1], ssize_t blen,
int overload)
{ {
ssize_t i = 0; ssize_t i = 0;
while (i < blen) { while (i < blen) {
@ -58,7 +59,7 @@ static int do_overload_value(const uint8_t buf[static 1], ssize_t blen, int over
return overload; return overload;
} }
static int overload_value(const struct dhcpmsg *packet) static int overload_value(const struct dhcpmsg packet[static 1])
{ {
int ol = do_overload_value(packet->options, sizeof packet->options, 0); int ol = do_overload_value(packet->options, sizeof packet->options, 0);
if (ol & 1 && ol & 2) if (ol & 1 && ol & 2)
@ -100,8 +101,8 @@ static void do_get_dhcp_opt(const uint8_t *sbuf, ssize_t slen, uint8_t code,
} }
} }
ssize_t get_dhcp_opt(const struct dhcpmsg *packet, uint8_t code, uint8_t *dbuf, ssize_t get_dhcp_opt(const struct dhcpmsg packet[static 1], uint8_t code,
ssize_t dlen) uint8_t *dbuf, ssize_t dlen)
{ {
int ol = overload_value(packet); int ol = overload_value(packet);
ssize_t didx = 0; ssize_t didx = 0;
@ -117,7 +118,7 @@ ssize_t get_dhcp_opt(const struct dhcpmsg *packet, uint8_t code, uint8_t *dbuf,
} }
// return the position of the 'end' option // return the position of the 'end' option
ssize_t get_end_option_idx(const struct dhcpmsg *packet) ssize_t get_end_option_idx(const struct dhcpmsg packet[static 1])
{ {
for (size_t i = 0; i < sizeof packet->options; ++i) { for (size_t i = 0; i < sizeof packet->options; ++i) {
if (packet->options[i] == DCODE_END) if (packet->options[i] == DCODE_END)
@ -142,8 +143,8 @@ static inline size_t sizeof_option_str(uint8_t code, size_t datalen)
// Add a raw data string to the options. It will take a binary string suitable // Add a raw data string to the options. It will take a binary string suitable
// for use with eg memcpy() and will append it to the options[] field of // for use with eg memcpy() and will append it to the options[] field of
// a dhcp packet with the requested option code and proper length specifier. // a dhcp packet with the requested option code and proper length specifier.
size_t add_option_string(struct dhcpmsg *packet, uint8_t code, const char *str, size_t add_option_string(struct dhcpmsg packet[static 1], uint8_t code,
size_t slen) const char str[static 1], size_t slen)
{ {
size_t len = sizeof_option_str(code, slen); size_t len = sizeof_option_str(code, slen);
if (slen > 255 || len != slen + 2) { if (slen > 255 || len != slen + 2) {
@ -167,7 +168,7 @@ size_t add_option_string(struct dhcpmsg *packet, uint8_t code, const char *str,
return len; return len;
} }
static ssize_t add_option_check(struct dhcpmsg *packet, uint8_t code, static ssize_t add_option_check(struct dhcpmsg packet[static 1], uint8_t code,
uint8_t rlen) uint8_t rlen)
{ {
ssize_t end = get_end_option_idx(packet); ssize_t end = get_end_option_idx(packet);
@ -183,7 +184,8 @@ static ssize_t add_option_check(struct dhcpmsg *packet, uint8_t code,
return end; return end;
} }
static size_t add_u8_option(struct dhcpmsg *packet, uint8_t code, uint8_t data) static size_t add_u8_option(struct dhcpmsg packet[static 1], uint8_t code,
uint8_t data)
{ {
ssize_t end = add_option_check(packet, code, 1); ssize_t end = add_option_check(packet, code, 1);
if (end < 0) if (end < 0)
@ -197,7 +199,7 @@ static size_t add_u8_option(struct dhcpmsg *packet, uint8_t code, uint8_t data)
#ifndef NDHS_BUILD #ifndef NDHS_BUILD
// Data should be in network byte order. // Data should be in network byte order.
static size_t add_u16_option(struct dhcpmsg *packet, uint8_t code, static size_t add_u16_option(struct dhcpmsg packet[static 1], uint8_t code,
uint16_t data) uint16_t data)
{ {
ssize_t end = add_option_check(packet, code, 2); ssize_t end = add_option_check(packet, code, 2);
@ -214,7 +216,8 @@ static size_t add_u16_option(struct dhcpmsg *packet, uint8_t code,
#endif #endif
// Data should be in network byte order. // Data should be in network byte order.
size_t add_u32_option(struct dhcpmsg *packet, uint8_t code, uint32_t data) size_t add_u32_option(struct dhcpmsg packet[static 1], uint8_t code,
uint32_t data)
{ {
ssize_t end = add_option_check(packet, code, 4); ssize_t end = add_option_check(packet, code, 4);
if (end < 0) if (end < 0)
@ -231,7 +234,7 @@ size_t add_u32_option(struct dhcpmsg *packet, uint8_t code, uint32_t data)
} }
// Add a parameter request list for stubborn DHCP servers // Add a parameter request list for stubborn DHCP servers
size_t add_option_request_list(struct dhcpmsg *packet) size_t add_option_request_list(struct dhcpmsg packet[static 1])
{ {
static const uint8_t reqdata[] = { static const uint8_t reqdata[] = {
DCODE_SUBNET, DCODE_ROUTER, DCODE_DNS, DCODE_HOSTNAME, DCODE_DOMAIN, DCODE_SUBNET, DCODE_ROUTER, DCODE_DNS, DCODE_HOSTNAME, DCODE_DOMAIN,
@ -242,52 +245,53 @@ size_t add_option_request_list(struct dhcpmsg *packet)
} }
#ifdef NDHS_BUILD #ifdef NDHS_BUILD
size_t add_option_domain_name(struct dhcpmsg *packet, const char *dom, size_t add_option_domain_name(struct dhcpmsg packet[static 1],
size_t domlen) const char dom[static 1], size_t domlen)
{ {
return add_option_string(packet, DCODE_DOMAIN, dom, domlen); return add_option_string(packet, DCODE_DOMAIN, dom, domlen);
} }
void add_option_subnet_mask(struct dhcpmsg *packet, uint32_t subnet) void add_option_subnet_mask(struct dhcpmsg packet[static 1], uint32_t subnet)
{ {
add_u32_option(packet, DCODE_SUBNET, subnet); add_u32_option(packet, DCODE_SUBNET, subnet);
} }
void add_option_broadcast(struct dhcpmsg *packet, uint32_t bc) void add_option_broadcast(struct dhcpmsg packet[static 1], uint32_t bc)
{ {
add_u32_option(packet, DCODE_BROADCAST, bc); add_u32_option(packet, DCODE_BROADCAST, bc);
} }
#endif #endif
void add_option_msgtype(struct dhcpmsg *packet, uint8_t type) void add_option_msgtype(struct dhcpmsg packet[static 1], uint8_t type)
{ {
add_u8_option(packet, DCODE_MSGTYPE, type); add_u8_option(packet, DCODE_MSGTYPE, type);
} }
void add_option_reqip(struct dhcpmsg *packet, uint32_t ip) void add_option_reqip(struct dhcpmsg packet[static 1], uint32_t ip)
{ {
add_u32_option(packet, DCODE_REQIP, ip); add_u32_option(packet, DCODE_REQIP, ip);
} }
void add_option_serverid(struct dhcpmsg *packet, uint32_t sid) void add_option_serverid(struct dhcpmsg packet[static 1], uint32_t sid)
{ {
add_u32_option(packet, DCODE_SERVER_ID, sid); add_u32_option(packet, DCODE_SERVER_ID, sid);
} }
void add_option_clientid(struct dhcpmsg *packet, const char *clientid, void add_option_clientid(struct dhcpmsg packet[static 1],
const char clientid[static 1],
size_t clen) size_t clen)
{ {
add_option_string(packet, DCODE_CLIENT_ID, clientid, clen); add_option_string(packet, DCODE_CLIENT_ID, clientid, clen);
} }
#ifndef NDHS_BUILD #ifndef NDHS_BUILD
void add_option_maxsize(struct dhcpmsg *packet) void add_option_maxsize(struct dhcpmsg packet[static 1])
{ {
add_u16_option(packet, DCODE_MAX_SIZE, add_u16_option(packet, DCODE_MAX_SIZE,
htons(sizeof(struct ip_udp_dhcp_packet))); htons(sizeof(struct ip_udp_dhcp_packet)));
} }
void add_option_vendor(struct dhcpmsg *packet) void add_option_vendor(struct dhcpmsg packet[static 1])
{ {
size_t len = strlen(client_config.vendor); size_t len = strlen(client_config.vendor);
if (len) if (len)
@ -296,7 +300,7 @@ void add_option_vendor(struct dhcpmsg *packet)
add_option_string(packet, DCODE_VENDOR, "ndhc", sizeof "ndhc" - 1); add_option_string(packet, DCODE_VENDOR, "ndhc", sizeof "ndhc" - 1);
} }
void add_option_hostname(struct dhcpmsg *packet) void add_option_hostname(struct dhcpmsg packet[static 1])
{ {
size_t len = strlen(client_config.hostname); size_t len = strlen(client_config.hostname);
if (len) if (len)
@ -304,7 +308,7 @@ void add_option_hostname(struct dhcpmsg *packet)
} }
#endif #endif
uint32_t get_option_router(const struct dhcpmsg *packet) uint32_t get_option_router(const struct dhcpmsg packet[static 1])
{ {
ssize_t ol; ssize_t ol;
uint32_t ret = 0; uint32_t ret = 0;
@ -315,7 +319,7 @@ uint32_t get_option_router(const struct dhcpmsg *packet)
return ret; return ret;
} }
uint8_t get_option_msgtype(const struct dhcpmsg *packet) uint8_t get_option_msgtype(const struct dhcpmsg packet[static 1])
{ {
ssize_t ol; ssize_t ol;
uint8_t ret = 0; uint8_t ret = 0;
@ -326,7 +330,7 @@ uint8_t get_option_msgtype(const struct dhcpmsg *packet)
return ret; return ret;
} }
uint32_t get_option_serverid(const struct dhcpmsg *packet, int *found) uint32_t get_option_serverid(const struct dhcpmsg packet[static 1], int *found)
{ {
ssize_t ol; ssize_t ol;
uint32_t ret = 0; uint32_t ret = 0;
@ -340,7 +344,7 @@ uint32_t get_option_serverid(const struct dhcpmsg *packet, int *found)
return ret; return ret;
} }
uint32_t get_option_leasetime(const struct dhcpmsg *packet) uint32_t get_option_leasetime(const struct dhcpmsg packet[static 1])
{ {
ssize_t ol; ssize_t ol;
uint32_t ret = 0; uint32_t ret = 0;
@ -354,8 +358,8 @@ uint32_t get_option_leasetime(const struct dhcpmsg *packet)
} }
// Returned buffer is not nul-terminated. // Returned buffer is not nul-terminated.
size_t get_option_clientid(const struct dhcpmsg *packet, const char *cbuf, size_t get_option_clientid(const struct dhcpmsg packet[static 1],
size_t clen) char cbuf[static 1], size_t clen)
{ {
if (clen < 1) if (clen < 1)
return 0; return 0;

View File

@ -56,36 +56,37 @@
#define MAX_DOPT_SIZE 500 #define MAX_DOPT_SIZE 500
ssize_t get_dhcp_opt(const struct dhcpmsg *packet, uint8_t code, uint8_t *dbuf, ssize_t get_dhcp_opt(const struct dhcpmsg packet[static 1], uint8_t code,
ssize_t dlen); uint8_t *dbuf, ssize_t dlen);
ssize_t get_end_option_idx(const struct dhcpmsg *packet); ssize_t get_end_option_idx(const struct dhcpmsg packet[static 1]);
size_t add_option_string(struct dhcpmsg *packet, uint8_t code, const char *str, size_t add_option_string(struct dhcpmsg packet[static 1], uint8_t code,
size_t slen); const char str[static 1], size_t slen);
size_t add_u32_option(struct dhcpmsg *packet, uint8_t code, uint32_t data); size_t add_u32_option(struct dhcpmsg packet[static 1], uint8_t code,
uint32_t data);
size_t add_option_request_list(struct dhcpmsg *packet); size_t add_option_request_list(struct dhcpmsg packet[static 1]);
#ifdef NDHS_BUILD #ifdef NDHS_BUILD
size_t add_option_domain_name(struct dhcpmsg *packet, const char *dom, size_t add_option_domain_name(struct dhcpmsg packet[static 1],
size_t domlen); const char dom[static 1], size_t domlen);
void add_option_subnet_mask(struct dhcpmsg *packet, uint32_t subnet); void add_option_subnet_mask(struct dhcpmsg packet[static 1], uint32_t subnet);
void add_option_broadcast(struct dhcpmsg *packet, uint32_t bc); void add_option_broadcast(struct dhcpmsg packet[static 1], uint32_t bc);
#endif #endif
void add_option_msgtype(struct dhcpmsg *packet, uint8_t type); void add_option_msgtype(struct dhcpmsg packet[static 1], uint8_t type);
void add_option_reqip(struct dhcpmsg *packet, uint32_t ip); void add_option_reqip(struct dhcpmsg packet[static 1], uint32_t ip);
void add_option_serverid(struct dhcpmsg *packet, uint32_t sid); void add_option_serverid(struct dhcpmsg packet[static 1], uint32_t sid);
void add_option_clientid(struct dhcpmsg *packet, const char *clientid, void add_option_clientid(struct dhcpmsg packet[static 1],
size_t clen); const char clientid[static 1], size_t clen);
#ifndef NDHS_BUILD #ifndef NDHS_BUILD
void add_option_maxsize(struct dhcpmsg *packet); void add_option_maxsize(struct dhcpmsg packet[static 1]);
void add_option_vendor(struct dhcpmsg *packet); void add_option_vendor(struct dhcpmsg packet[static 1]);
void add_option_hostname(struct dhcpmsg *packet); void add_option_hostname(struct dhcpmsg packet[static 1]);
#endif #endif
uint32_t get_option_router(const struct dhcpmsg *packet); uint32_t get_option_router(const struct dhcpmsg packet[static 1]);
uint8_t get_option_msgtype(const struct dhcpmsg *packet); uint8_t get_option_msgtype(const struct dhcpmsg packet[static 1]);
uint32_t get_option_serverid(const struct dhcpmsg *packet, int *found); uint32_t get_option_serverid(const struct dhcpmsg packet[static 1], int *found);
uint32_t get_option_leasetime(const struct dhcpmsg *packet); uint32_t get_option_leasetime(const struct dhcpmsg packet[static 1]);
size_t get_option_clientid(const struct dhcpmsg *packet, const char *cbuf, size_t get_option_clientid(const struct dhcpmsg packet[static 1],
size_t clen); char cbuf[static 1], size_t clen);
#endif #endif

View File

@ -41,9 +41,9 @@
#include "ndhc.h" #include "ndhc.h"
#include "sys.h" #include "sys.h"
static void selecting_packet(struct client_state_t cs[static 1], struct dhcpmsg *packet, static void selecting_packet(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
uint8_t msgtype, uint32_t srcaddr); uint8_t msgtype, uint32_t srcaddr);
static void an_packet(struct client_state_t cs[static 1], struct dhcpmsg *packet, static void an_packet(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
uint8_t msgtype, uint32_t srcaddr); uint8_t msgtype, uint32_t srcaddr);
static void selecting_timeout(struct client_state_t cs[static 1], long long nowts); static void selecting_timeout(struct client_state_t cs[static 1], long long nowts);
static void requesting_timeout(struct client_state_t cs[static 1], long long nowts); static void requesting_timeout(struct client_state_t cs[static 1], long long nowts);
@ -56,7 +56,7 @@ static void print_release(struct client_state_t cs[static 1]);
static void frenew(struct client_state_t cs[static 1]); static void frenew(struct client_state_t cs[static 1]);
typedef struct { typedef struct {
void (*packet_fn)(struct client_state_t cs[static 1], struct dhcpmsg *packet, void (*packet_fn)(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
uint8_t msgtype, uint32_t srcaddr); uint8_t msgtype, uint32_t srcaddr);
void (*timeout_fn)(struct client_state_t cs[static 1], long long nowts); void (*timeout_fn)(struct client_state_t cs[static 1], long long nowts);
void (*force_renew_fn)(struct client_state_t cs[static 1]); void (*force_renew_fn)(struct client_state_t cs[static 1]);
@ -201,7 +201,7 @@ static void released_timeout(struct client_state_t cs[static 1], long long nowts
dhcp_wake_ts = -1; dhcp_wake_ts = -1;
} }
static int validate_serverid(struct client_state_t cs[static 1], struct dhcpmsg *packet, static int validate_serverid(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
char *typemsg) char *typemsg)
{ {
int found; int found;
@ -223,7 +223,7 @@ static int validate_serverid(struct client_state_t cs[static 1], struct dhcpmsg
} }
// Can transition to DS_BOUND or DS_SELECTING. // Can transition to DS_BOUND or DS_SELECTING.
static void an_packet(struct client_state_t cs[static 1], struct dhcpmsg *packet, static void an_packet(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
uint8_t msgtype, uint32_t srcaddr) uint8_t msgtype, uint32_t srcaddr)
{ {
(void)srcaddr; (void)srcaddr;
@ -280,7 +280,7 @@ static void an_packet(struct client_state_t cs[static 1], struct dhcpmsg *packet
} }
} }
static void selecting_packet(struct client_state_t cs[static 1], struct dhcpmsg *packet, static void selecting_packet(struct client_state_t cs[static 1], struct dhcpmsg packet[static 1],
uint8_t msgtype, uint32_t srcaddr) uint8_t msgtype, uint32_t srcaddr)
{ {
if (msgtype == DHCPOFFER) { if (msgtype == DHCPOFFER) {
@ -405,8 +405,9 @@ void ifnocarrier_action(struct client_state_t cs[static 1])
log_line("%s: Carrier down.", client_config.interface); log_line("%s: Carrier down.", client_config.interface);
} }
void packet_action(struct client_state_t cs[static 1], struct dhcpmsg *packet, void packet_action(struct client_state_t cs[static 1],
uint8_t msgtype, uint32_t srcaddr) struct dhcpmsg packet[static 1], uint8_t msgtype,
uint32_t srcaddr)
{ {
if (dhcp_states[cs->dhcpState].packet_fn) if (dhcp_states[cs->dhcpState].packet_fn)
dhcp_states[cs->dhcpState].packet_fn(cs, packet, msgtype, srcaddr); dhcp_states[cs->dhcpState].packet_fn(cs, packet, msgtype, srcaddr);

View File

@ -45,8 +45,9 @@ typedef enum {
void reinit_selecting(struct client_state_t cs[static 1], int timeout); void reinit_selecting(struct client_state_t cs[static 1], int timeout);
void packet_action(struct client_state_t cs[static 1], struct dhcpmsg *packet, void packet_action(struct client_state_t cs[static 1],
uint8_t msgtype, uint32_t srcaddr); struct dhcpmsg packet[static 1], uint8_t msgtype,
uint32_t srcaddr);
void timeout_action(struct client_state_t cs[static 1], long long nowts); void timeout_action(struct client_state_t cs[static 1], long long nowts);
void force_renew_action(struct client_state_t cs[static 1]); void force_renew_action(struct client_state_t cs[static 1]);
void force_release_action(struct client_state_t cs[static 1]); void force_release_action(struct client_state_t cs[static 1]);

View File

@ -75,7 +75,7 @@ int setup_signals_subprocess(void)
return sfd; return sfd;
} }
void signal_dispatch_subprocess(int sfd, const char *pname) void signal_dispatch_subprocess(int sfd, const char pname[static 1])
{ {
struct signalfd_siginfo si = {0}; struct signalfd_siginfo si = {0};
ssize_t r = safe_read(sfd, (char *)&si, sizeof si); ssize_t r = safe_read(sfd, (char *)&si, sizeof si);

View File

@ -47,7 +47,7 @@ void epoll_add(int epfd, int fd);
void epoll_del(int epfd, int fd); void epoll_del(int epfd, int fd);
int setup_signals_subprocess(void); int setup_signals_subprocess(void);
void signal_dispatch_subprocess(int sfd, const char *pname); void signal_dispatch_subprocess(int sfd, const char pname[static 1]);
#endif /* SYS_H_ */ #endif /* SYS_H_ */