dhclient: raise WARNS to 4
Mostly const-correctness fixes. There were also some variable-shadowing, unused variable, and a couple of sockaddr type-correctness changes. I also had trouble with cast-align warnings. I was able to prove that one of them was a false positive. But ultimately I had to disable the warning program-wide to deal with the others. Reviewed by: cem MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D14460
This commit is contained in:
parent
ce0d4434ae
commit
79a1d19516
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329754
@ -50,7 +50,8 @@ LIBADD+= cap_syslog
|
|||||||
CFLAGS+=-DWITH_CASPER
|
CFLAGS+=-DWITH_CASPER
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
WARNS?= 3
|
WARNS?= 4
|
||||||
|
NO_WCAST_ALIGN= yes
|
||||||
|
|
||||||
HAS_TESTS=
|
HAS_TESTS=
|
||||||
SUBDIR.${MK_TESTS}+= tests
|
SUBDIR.${MK_TESTS}+= tests
|
||||||
|
@ -687,7 +687,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
|
|||||||
u_int8_t hunkbuf[1024];
|
u_int8_t hunkbuf[1024];
|
||||||
unsigned hunkix = 0;
|
unsigned hunkix = 0;
|
||||||
char *vendor;
|
char *vendor;
|
||||||
char *fmt;
|
const char *fmt;
|
||||||
struct universe *universe;
|
struct universe *universe;
|
||||||
struct option *option;
|
struct option *option;
|
||||||
struct iaddr ip_addr;
|
struct iaddr ip_addr;
|
||||||
|
@ -55,7 +55,7 @@ int lexchar;
|
|||||||
char *token_line;
|
char *token_line;
|
||||||
char *prev_line;
|
char *prev_line;
|
||||||
char *cur_line;
|
char *cur_line;
|
||||||
char *tlname;
|
const char *tlname;
|
||||||
int eol_token;
|
int eol_token;
|
||||||
|
|
||||||
static char line1[81];
|
static char line1[81];
|
||||||
@ -78,7 +78,7 @@ static int read_num_or_name(int, FILE *);
|
|||||||
static int intern(char *, int);
|
static int intern(char *, int);
|
||||||
|
|
||||||
void
|
void
|
||||||
new_parse(char *name)
|
new_parse(const char *name)
|
||||||
{
|
{
|
||||||
tlname = name;
|
tlname = name;
|
||||||
lpos = line = 1;
|
lpos = line = 1;
|
||||||
@ -264,7 +264,7 @@ read_string(FILE *cfile)
|
|||||||
static int
|
static int
|
||||||
read_number(int c, FILE *cfile)
|
read_number(int c, FILE *cfile)
|
||||||
{
|
{
|
||||||
int seenx = 0, token = NUMBER;
|
int seenx = 0, _token = NUMBER;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
tokbuf[i++] = c;
|
tokbuf[i++] = c;
|
||||||
@ -286,7 +286,7 @@ read_number(int c, FILE *cfile)
|
|||||||
tokbuf[i] = 0;
|
tokbuf[i] = 0;
|
||||||
tval = tokbuf;
|
tval = tokbuf;
|
||||||
|
|
||||||
return (token);
|
return (_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -91,7 +91,7 @@ cap_channel_t *capsyslog;
|
|||||||
time_t cur_time;
|
time_t cur_time;
|
||||||
time_t default_lease_time = 43200; /* 12 hours... */
|
time_t default_lease_time = 43200; /* 12 hours... */
|
||||||
|
|
||||||
char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
|
const char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
|
||||||
char *path_dhclient_db = NULL;
|
char *path_dhclient_db = NULL;
|
||||||
|
|
||||||
int log_perror = 1;
|
int log_perror = 1;
|
||||||
@ -131,10 +131,10 @@ void routehandler(struct protocol *);
|
|||||||
void usage(void);
|
void usage(void);
|
||||||
int check_option(struct client_lease *l, int option);
|
int check_option(struct client_lease *l, int option);
|
||||||
int check_classless_option(unsigned char *data, int len);
|
int check_classless_option(unsigned char *data, int len);
|
||||||
int ipv4addrs(char * buf);
|
int ipv4addrs(const char * buf);
|
||||||
int res_hnok(const char *dn);
|
int res_hnok(const char *dn);
|
||||||
int check_search(const char *srch);
|
int check_search(const char *srch);
|
||||||
char *option_as_string(unsigned int code, unsigned char *data, int len);
|
const char *option_as_string(unsigned int code, unsigned char *data, int len);
|
||||||
int fork_privchld(int, int);
|
int fork_privchld(int, int);
|
||||||
|
|
||||||
#define ROUNDUP(a) \
|
#define ROUNDUP(a) \
|
||||||
@ -201,26 +201,25 @@ uint8_t curbssid[6];
|
|||||||
static void
|
static void
|
||||||
disassoc(void *arg)
|
disassoc(void *arg)
|
||||||
{
|
{
|
||||||
struct interface_info *ifi = arg;
|
struct interface_info *_ifi = arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear existing state.
|
* Clear existing state.
|
||||||
*/
|
*/
|
||||||
if (ifi->client->active != NULL) {
|
if (_ifi->client->active != NULL) {
|
||||||
script_init("EXPIRE", NULL);
|
script_init("EXPIRE", NULL);
|
||||||
script_write_params("old_",
|
script_write_params("old_",
|
||||||
ifi->client->active);
|
_ifi->client->active);
|
||||||
if (ifi->client->alias)
|
if (_ifi->client->alias)
|
||||||
script_write_params("alias_",
|
script_write_params("alias_",
|
||||||
ifi->client->alias);
|
_ifi->client->alias);
|
||||||
script_go();
|
script_go();
|
||||||
}
|
}
|
||||||
ifi->client->state = S_INIT;
|
_ifi->client->state = S_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
|
||||||
void
|
void
|
||||||
routehandler(struct protocol *p)
|
routehandler(struct protocol *p __unused)
|
||||||
{
|
{
|
||||||
char msg[2048], *addr;
|
char msg[2048], *addr;
|
||||||
struct rt_msghdr *rtm;
|
struct rt_msghdr *rtm;
|
||||||
@ -230,7 +229,7 @@ routehandler(struct protocol *p)
|
|||||||
struct ieee80211_join_event *jev;
|
struct ieee80211_join_event *jev;
|
||||||
struct client_lease *l;
|
struct client_lease *l;
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct sockaddr *sa;
|
struct sockaddr_in *sa;
|
||||||
struct iaddr a;
|
struct iaddr a;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
int linkstat;
|
int linkstat;
|
||||||
@ -254,13 +253,13 @@ routehandler(struct protocol *p)
|
|||||||
if (scripttime == 0 || t < scripttime + 10)
|
if (scripttime == 0 || t < scripttime + 10)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sa = get_ifa((char *)(ifam + 1), ifam->ifam_addrs);
|
sa = (struct sockaddr_in*)get_ifa((char *)(ifam + 1), ifam->ifam_addrs);
|
||||||
if (sa == NULL)
|
if (sa == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((a.len = sizeof(struct in_addr)) > sizeof(a.iabuf))
|
if ((a.len = sizeof(struct in_addr)) > sizeof(a.iabuf))
|
||||||
error("king bula sez: len mismatch");
|
error("king bula sez: len mismatch");
|
||||||
memcpy(a.iabuf, &((struct sockaddr_in *)sa)->sin_addr, a.len);
|
memcpy(a.iabuf, &sa->sin_addr, a.len);
|
||||||
if (addr_eq(a, defaddr))
|
if (addr_eq(a, defaddr))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -271,7 +270,7 @@ routehandler(struct protocol *p)
|
|||||||
if (l == NULL) /* added/deleted addr is not the one we set */
|
if (l == NULL) /* added/deleted addr is not the one we set */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
addr = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
|
addr = inet_ntoa(sa->sin_addr);
|
||||||
if (rtm->rtm_type == RTM_NEWADDR) {
|
if (rtm->rtm_type == RTM_NEWADDR) {
|
||||||
/*
|
/*
|
||||||
* XXX: If someone other than us adds our address,
|
* XXX: If someone other than us adds our address,
|
||||||
@ -946,7 +945,7 @@ dhcp(struct packet *packet)
|
|||||||
{
|
{
|
||||||
struct iaddrlist *ap;
|
struct iaddrlist *ap;
|
||||||
void (*handler)(struct packet *);
|
void (*handler)(struct packet *);
|
||||||
char *type;
|
const char *type;
|
||||||
|
|
||||||
switch (packet->packet_type) {
|
switch (packet->packet_type) {
|
||||||
case DHCPOFFER:
|
case DHCPOFFER:
|
||||||
@ -984,7 +983,7 @@ dhcpoffer(struct packet *packet)
|
|||||||
struct client_lease *lease, *lp;
|
struct client_lease *lease, *lp;
|
||||||
int i;
|
int i;
|
||||||
int arp_timeout_needed, stop_selecting;
|
int arp_timeout_needed, stop_selecting;
|
||||||
char *name = packet->options[DHO_DHCP_MESSAGE_TYPE].len ?
|
const char *name = packet->options[DHO_DHCP_MESSAGE_TYPE].len ?
|
||||||
"DHCPOFFER" : "BOOTREPLY";
|
"DHCPOFFER" : "BOOTREPLY";
|
||||||
|
|
||||||
/* If we're not receptive to an offer right now, or if the offer
|
/* If we're not receptive to an offer right now, or if the offer
|
||||||
@ -1993,7 +1992,7 @@ write_client_lease(struct interface_info *ip, struct client_lease *lease,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
script_init(char *reason, struct string_list *medium)
|
script_init(const char *reason, struct string_list *medium)
|
||||||
{
|
{
|
||||||
size_t len, mediumlen = 0;
|
size_t len, mediumlen = 0;
|
||||||
struct imsg_hdr hdr;
|
struct imsg_hdr hdr;
|
||||||
@ -2028,7 +2027,7 @@ script_init(char *reason, struct string_list *medium)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
priv_script_init(char *reason, char *medium)
|
priv_script_init(const char *reason, char *medium)
|
||||||
{
|
{
|
||||||
struct interface_info *ip = ifi;
|
struct interface_info *ip = ifi;
|
||||||
|
|
||||||
@ -2056,7 +2055,7 @@ priv_script_init(char *reason, char *medium)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
priv_script_write_params(char *prefix, struct client_lease *lease)
|
priv_script_write_params(const char *prefix, struct client_lease *lease)
|
||||||
{
|
{
|
||||||
struct interface_info *ip = ifi;
|
struct interface_info *ip = ifi;
|
||||||
u_int8_t dbuf[1500], *dp = NULL;
|
u_int8_t dbuf[1500], *dp = NULL;
|
||||||
@ -2196,7 +2195,7 @@ priv_script_write_params(char *prefix, struct client_lease *lease)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
script_write_params(char *prefix, struct client_lease *lease)
|
script_write_params(const char *prefix, struct client_lease *lease)
|
||||||
{
|
{
|
||||||
size_t fn_len = 0, sn_len = 0, pr_len = 0;
|
size_t fn_len = 0, sn_len = 0, pr_len = 0;
|
||||||
struct imsg_hdr hdr;
|
struct imsg_hdr hdr;
|
||||||
@ -2460,8 +2459,8 @@ go_daemon(void)
|
|||||||
int
|
int
|
||||||
check_option(struct client_lease *l, int option)
|
check_option(struct client_lease *l, int option)
|
||||||
{
|
{
|
||||||
char *opbuf;
|
const char *opbuf;
|
||||||
char *sbuf;
|
const char *sbuf;
|
||||||
|
|
||||||
/* we use this, since this is what gets passed to dhclient-script */
|
/* we use this, since this is what gets passed to dhclient-script */
|
||||||
|
|
||||||
@ -2721,7 +2720,7 @@ check_search(const char *srch)
|
|||||||
* otherwise, return 0
|
* otherwise, return 0
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ipv4addrs(char * buf)
|
ipv4addrs(const char * buf)
|
||||||
{
|
{
|
||||||
struct in_addr jnk;
|
struct in_addr jnk;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -2739,7 +2738,7 @@ ipv4addrs(char * buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
option_as_string(unsigned int code, unsigned char *data, int len)
|
option_as_string(unsigned int code, unsigned char *data, int len)
|
||||||
{
|
{
|
||||||
static char optbuf[32768]; /* XXX */
|
static char optbuf[32768]; /* XXX */
|
||||||
|
@ -235,7 +235,7 @@ struct protocol {
|
|||||||
|
|
||||||
struct hash_bucket {
|
struct hash_bucket {
|
||||||
struct hash_bucket *next;
|
struct hash_bucket *next;
|
||||||
unsigned char *name;
|
const unsigned char *name;
|
||||||
int len;
|
int len;
|
||||||
unsigned char *value;
|
unsigned char *value;
|
||||||
};
|
};
|
||||||
@ -258,26 +258,27 @@ struct hash_table {
|
|||||||
/* options.c */
|
/* options.c */
|
||||||
int cons_options(struct packet *, struct dhcp_packet *, int,
|
int cons_options(struct packet *, struct dhcp_packet *, int,
|
||||||
struct tree_cache **, int, int, int, u_int8_t *, int);
|
struct tree_cache **, int, int, int, u_int8_t *, int);
|
||||||
char *pretty_print_option(unsigned int,
|
const char *pretty_print_option(unsigned int,
|
||||||
unsigned char *, int, int, int);
|
unsigned char *, int, int, int);
|
||||||
void do_packet(struct interface_info *, struct dhcp_packet *,
|
void do_packet(struct interface_info *, struct dhcp_packet *,
|
||||||
int, unsigned int, struct iaddr, struct hardware *);
|
int, unsigned int, struct iaddr, struct hardware *);
|
||||||
|
|
||||||
/* errwarn.c */
|
/* errwarn.c */
|
||||||
extern int warnings_occurred;
|
extern int warnings_occurred;
|
||||||
void error(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
void error(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
int warning(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
int warning(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
int note(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
int note(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
int debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
int debug(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
int parse_warn(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
int parse_warn(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
|
|
||||||
/* conflex.c */
|
/* conflex.c */
|
||||||
extern int lexline, lexchar;
|
extern int lexline, lexchar;
|
||||||
extern char *token_line, *tlname;
|
extern char *token_line;
|
||||||
|
extern const char *tlname;
|
||||||
extern char comments[4096];
|
extern char comments[4096];
|
||||||
extern int comment_index;
|
extern int comment_index;
|
||||||
extern int eol_token;
|
extern int eol_token;
|
||||||
void new_parse(char *);
|
void new_parse(const char *);
|
||||||
int next_token(char **, FILE *);
|
int next_token(char **, FILE *);
|
||||||
int peek_token(char **, FILE *);
|
int peek_token(char **, FILE *);
|
||||||
|
|
||||||
@ -321,7 +322,7 @@ void dispatch(void);
|
|||||||
void got_one(struct protocol *);
|
void got_one(struct protocol *);
|
||||||
void add_timeout(time_t, void (*)(void *), void *);
|
void add_timeout(time_t, void (*)(void *), void *);
|
||||||
void cancel_timeout(void (*)(void *), void *);
|
void cancel_timeout(void (*)(void *), void *);
|
||||||
void add_protocol(char *, int, void (*)(struct protocol *), void *);
|
void add_protocol(const char *, int, void (*)(struct protocol *), void *);
|
||||||
void remove_protocol(struct protocol *);
|
void remove_protocol(struct protocol *);
|
||||||
int interface_link_status(char *);
|
int interface_link_status(char *);
|
||||||
void interface_set_mtu_unpriv(int, u_int16_t);
|
void interface_set_mtu_unpriv(int, u_int16_t);
|
||||||
@ -329,8 +330,8 @@ void interface_set_mtu_priv(char *, u_int16_t);
|
|||||||
|
|
||||||
/* hash.c */
|
/* hash.c */
|
||||||
struct hash_table *new_hash(void);
|
struct hash_table *new_hash(void);
|
||||||
void add_hash(struct hash_table *, unsigned char *, int, unsigned char *);
|
void add_hash(struct hash_table *, const unsigned char *, int, unsigned char *);
|
||||||
unsigned char *hash_lookup(struct hash_table *, unsigned char *, int);
|
void *hash_lookup(struct hash_table *, unsigned char *, int);
|
||||||
|
|
||||||
/* tables.c */
|
/* tables.c */
|
||||||
extern struct option dhcp_options[256];
|
extern struct option dhcp_options[256];
|
||||||
@ -358,7 +359,7 @@ char *piaddr(struct iaddr);
|
|||||||
|
|
||||||
/* dhclient.c */
|
/* dhclient.c */
|
||||||
extern cap_channel_t *capsyslog;
|
extern cap_channel_t *capsyslog;
|
||||||
extern char *path_dhclient_conf;
|
extern const char *path_dhclient_conf;
|
||||||
extern char *path_dhclient_db;
|
extern char *path_dhclient_db;
|
||||||
extern time_t cur_time;
|
extern time_t cur_time;
|
||||||
extern int log_priority;
|
extern int log_priority;
|
||||||
@ -393,12 +394,12 @@ void free_client_lease(struct client_lease *);
|
|||||||
void rewrite_client_leases(void);
|
void rewrite_client_leases(void);
|
||||||
void write_client_lease(struct interface_info *, struct client_lease *, int);
|
void write_client_lease(struct interface_info *, struct client_lease *, int);
|
||||||
|
|
||||||
void priv_script_init(char *, char *);
|
void priv_script_init(const char *, char *);
|
||||||
void priv_script_write_params(char *, struct client_lease *);
|
void priv_script_write_params(const char *, struct client_lease *);
|
||||||
int priv_script_go(void);
|
int priv_script_go(void);
|
||||||
|
|
||||||
void script_init(char *, struct string_list *);
|
void script_init(const char *, struct string_list *);
|
||||||
void script_write_params(char *, struct client_lease *);
|
void script_write_params(const char *, struct client_lease *);
|
||||||
int script_go(void);
|
int script_go(void);
|
||||||
void client_envadd(struct client_state *,
|
void client_envadd(struct client_state *,
|
||||||
const char *, const char *, const char *, ...);
|
const char *, const char *, const char *, ...);
|
||||||
@ -442,7 +443,7 @@ void parse_reject_statement(FILE *, struct client_config *);
|
|||||||
|
|
||||||
/* privsep.c */
|
/* privsep.c */
|
||||||
struct buf *buf_open(size_t);
|
struct buf *buf_open(size_t);
|
||||||
int buf_add(struct buf *, void *, size_t);
|
int buf_add(struct buf *, const void *, size_t);
|
||||||
int buf_close(int, struct buf *);
|
int buf_close(int, struct buf *);
|
||||||
ssize_t buf_read(int, void *, size_t);
|
ssize_t buf_read(int, void *, size_t);
|
||||||
void dispatch_imsg(struct interface_info *, int);
|
void dispatch_imsg(struct interface_info *, int);
|
||||||
|
@ -49,10 +49,14 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
|
/* Assert that pointer p is aligned to at least align bytes */
|
||||||
|
#define assert_aligned(p, align) assert((((uintptr_t)p) & ((align) - 1)) == 0)
|
||||||
|
|
||||||
struct protocol *protocols;
|
struct protocol *protocols;
|
||||||
struct timeout *timeouts;
|
struct timeout *timeouts;
|
||||||
static struct timeout *free_timeouts;
|
static struct timeout *free_timeouts;
|
||||||
@ -73,7 +77,6 @@ void
|
|||||||
discover_interfaces(struct interface_info *iface)
|
discover_interfaces(struct interface_info *iface)
|
||||||
{
|
{
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
struct sockaddr_in foo;
|
|
||||||
struct ifreq *tif;
|
struct ifreq *tif;
|
||||||
|
|
||||||
if (getifaddrs(&ifap) != 0)
|
if (getifaddrs(&ifap) != 0)
|
||||||
@ -93,8 +96,22 @@ discover_interfaces(struct interface_info *iface)
|
|||||||
* and record it in a linked list.
|
* and record it in a linked list.
|
||||||
*/
|
*/
|
||||||
if (ifa->ifa_addr->sa_family == AF_LINK) {
|
if (ifa->ifa_addr->sa_family == AF_LINK) {
|
||||||
struct sockaddr_dl *foo =
|
struct sockaddr_dl *foo;
|
||||||
(struct sockaddr_dl *)ifa->ifa_addr;
|
|
||||||
|
/*
|
||||||
|
* The implementation of getifaddrs should guarantee
|
||||||
|
* this alignment
|
||||||
|
*/
|
||||||
|
assert_aligned(ifa->ifa_addr,
|
||||||
|
_Alignof(struct sockaddr_dl));
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcast-align"
|
||||||
|
#endif
|
||||||
|
foo = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
iface->index = foo->sdl_index;
|
iface->index = foo->sdl_index;
|
||||||
iface->hw_address.hlen = foo->sdl_alen;
|
iface->hw_address.hlen = foo->sdl_alen;
|
||||||
@ -102,6 +119,7 @@ discover_interfaces(struct interface_info *iface)
|
|||||||
memcpy(iface->hw_address.haddr,
|
memcpy(iface->hw_address.haddr,
|
||||||
LLADDR(foo), foo->sdl_alen);
|
LLADDR(foo), foo->sdl_alen);
|
||||||
} else if (ifa->ifa_addr->sa_family == AF_INET) {
|
} else if (ifa->ifa_addr->sa_family == AF_INET) {
|
||||||
|
struct sockaddr_in foo;
|
||||||
struct iaddr addr;
|
struct iaddr addr;
|
||||||
|
|
||||||
memcpy(&foo, ifa->ifa_addr, sizeof(foo));
|
memcpy(&foo, ifa->ifa_addr, sizeof(foo));
|
||||||
@ -437,7 +455,7 @@ cancel_timeout(void (*where)(void *), void *what)
|
|||||||
|
|
||||||
/* Add a protocol to the list of protocols... */
|
/* Add a protocol to the list of protocols... */
|
||||||
void
|
void
|
||||||
add_protocol(char *name, int fd, void (*handler)(struct protocol *),
|
add_protocol(const char *name, int fd, void (*handler)(struct protocol *),
|
||||||
void *local)
|
void *local)
|
||||||
{
|
{
|
||||||
struct protocol *p;
|
struct protocol *p;
|
||||||
|
@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
|
|
||||||
static void do_percentm(char *obuf, size_t size, char *ibuf);
|
static void do_percentm(char *obuf, size_t size, const char *ibuf);
|
||||||
|
|
||||||
static char mbuf[1024];
|
static char mbuf[1024];
|
||||||
static char fbuf[1024];
|
static char fbuf[1024];
|
||||||
@ -60,7 +60,7 @@ int warnings_occurred;
|
|||||||
* Log an error message, then exit.
|
* Log an error message, then exit.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
error(char *fmt, ...)
|
error(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ error(char *fmt, ...)
|
|||||||
* Log a warning message...
|
* Log a warning message...
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
warning(char *fmt, ...)
|
warning(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ warning(char *fmt, ...)
|
|||||||
* Log a note...
|
* Log a note...
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
note(char *fmt, ...)
|
note(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ note(char *fmt, ...)
|
|||||||
* Log a debug message...
|
* Log a debug message...
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
debug(char *fmt, ...)
|
debug(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
@ -172,10 +172,10 @@ debug(char *fmt, ...)
|
|||||||
* Find %m in the input string and substitute an error message string.
|
* Find %m in the input string and substitute an error message string.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
do_percentm(char *obuf, size_t size, char *ibuf)
|
do_percentm(char *obuf, size_t size, const char *ibuf)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
char *s = ibuf;
|
const char *s = ibuf;
|
||||||
char *t = obuf;
|
char *t = obuf;
|
||||||
size_t prlen;
|
size_t prlen;
|
||||||
size_t fmt_left;
|
size_t fmt_left;
|
||||||
@ -205,7 +205,7 @@ do_percentm(char *obuf, size_t size, char *ibuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
parse_warn(char *fmt, ...)
|
parse_warn(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
static char spaces[] =
|
static char spaces[] =
|
||||||
|
@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
|
|
||||||
static int do_hash(unsigned char *, int, int);
|
static int do_hash(const unsigned char *, int, int);
|
||||||
|
|
||||||
struct hash_table *
|
struct hash_table *
|
||||||
new_hash(void)
|
new_hash(void)
|
||||||
@ -62,9 +62,9 @@ new_hash(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_hash(unsigned char *name, int len, int size)
|
do_hash(const unsigned char *name, int len, int size)
|
||||||
{
|
{
|
||||||
unsigned char *s = name;
|
const unsigned char *s = name;
|
||||||
int accum = 0, i = len;
|
int accum = 0, i = len;
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
@ -77,7 +77,7 @@ do_hash(unsigned char *name, int len, int size)
|
|||||||
return (accum % size);
|
return (accum % size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_hash(struct hash_table *table, unsigned char *name, int len,
|
void add_hash(struct hash_table *table, const unsigned char *name, int len,
|
||||||
unsigned char *pointer)
|
unsigned char *pointer)
|
||||||
{
|
{
|
||||||
struct hash_bucket *bp;
|
struct hash_bucket *bp;
|
||||||
@ -86,7 +86,7 @@ void add_hash(struct hash_table *table, unsigned char *name, int len,
|
|||||||
if (!table)
|
if (!table)
|
||||||
return;
|
return;
|
||||||
if (!len)
|
if (!len)
|
||||||
len = strlen((char *)name);
|
len = strlen((const char *)name);
|
||||||
|
|
||||||
hashno = do_hash(name, len, table->hash_count);
|
hashno = do_hash(name, len, table->hash_count);
|
||||||
bp = new_hash_bucket();
|
bp = new_hash_bucket();
|
||||||
@ -102,7 +102,7 @@ void add_hash(struct hash_table *table, unsigned char *name, int len,
|
|||||||
table->buckets[hashno] = bp;
|
table->buckets[hashno] = bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *
|
void *
|
||||||
hash_lookup(struct hash_table *table, unsigned char *name, int len)
|
hash_lookup(struct hash_table *table, unsigned char *name, int len)
|
||||||
{
|
{
|
||||||
struct hash_bucket *bp;
|
struct hash_bucket *bp;
|
||||||
|
@ -628,7 +628,7 @@ store_options(unsigned char *buffer, int buflen, struct tree_cache **options,
|
|||||||
/*
|
/*
|
||||||
* Format the specified option so that a human can easily read it.
|
* Format the specified option so that a human can easily read it.
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
pretty_print_option(unsigned int code, unsigned char *data, int len,
|
pretty_print_option(unsigned int code, unsigned char *data, int len,
|
||||||
int emit_commas, int emit_quotes)
|
int emit_commas, int emit_quotes)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ buf_open(size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
buf_add(struct buf *buf, void *data, size_t len)
|
buf_add(struct buf *buf, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
if (buf->wpos + len > buf->size)
|
if (buf->wpos + len > buf->size)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -46,6 +46,6 @@ struct imsg_hdr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct buf *buf_open(size_t);
|
struct buf *buf_open(size_t);
|
||||||
int buf_add(struct buf *, void *, size_t);
|
int buf_add(struct buf *, const void *, size_t);
|
||||||
int buf_close(int, struct buf *);
|
int buf_close(int, struct buf *);
|
||||||
ssize_t buf_read(int sock, void *, size_t);
|
ssize_t buf_read(int sock, void *, size_t);
|
||||||
|
@ -440,11 +440,11 @@ initialize_universes(void)
|
|||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
dhcp_universe.options[i] = &dhcp_options[i];
|
dhcp_universe.options[i] = &dhcp_options[i];
|
||||||
add_hash(dhcp_universe.hash,
|
add_hash(dhcp_universe.hash,
|
||||||
(unsigned char *)dhcp_options[i].name, 0,
|
(const unsigned char *)dhcp_options[i].name, 0,
|
||||||
(unsigned char *)&dhcp_options[i]);
|
(unsigned char *)&dhcp_options[i]);
|
||||||
}
|
}
|
||||||
universe_hash.hash_count = DEFAULT_HASH_SIZE;
|
universe_hash.hash_count = DEFAULT_HASH_SIZE;
|
||||||
add_hash(&universe_hash,
|
add_hash(&universe_hash,
|
||||||
(unsigned char *)dhcp_universe.name, 0,
|
(const unsigned char *)dhcp_universe.name, 0,
|
||||||
(unsigned char *)&dhcp_universe);
|
(unsigned char *)&dhcp_universe);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
extern jmp_buf env;
|
extern jmp_buf env;
|
||||||
|
|
||||||
void
|
void
|
||||||
error(char *fmt, ...)
|
error(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ error(char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
warning(char *fmt, ...)
|
warning(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ warning(char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
note(char *fmt, ...)
|
note(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -57,14 +57,14 @@ struct tree_cache {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct universe {
|
struct universe {
|
||||||
char *name;
|
const char *name;
|
||||||
struct hash_table *hash;
|
struct hash_table *hash;
|
||||||
struct option *options[256];
|
struct option *options[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct option {
|
struct option {
|
||||||
char *name;
|
const char *name;
|
||||||
char *format;
|
const char *format;
|
||||||
struct universe *universe;
|
struct universe *universe;
|
||||||
unsigned char code;
|
unsigned char code;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user