From 29aea5a87b3556bdedb694f518a73c0af0f8091c Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 7 Jul 2008 10:36:35 +0200 Subject: [PATCH] ipset: fixup compile warnings And add a few const here and there. --- extensions/ipset/ip_set_ipmap.h | 4 +-- extensions/ipset/ipset.c | 46 ++++++++++++++--------------- extensions/ipset/ipset.h | 4 +-- extensions/ipset/ipset_iphash.c | 34 +++++++++++---------- extensions/ipset/ipset_ipmap.c | 30 ++++++++++--------- extensions/ipset/ipset_ipporthash.c | 30 ++++++++++--------- extensions/ipset/ipset_iptree.c | 30 ++++++++++--------- extensions/ipset/ipset_iptreemap.c | 28 +++++++++--------- extensions/ipset/ipset_macipmap.c | 30 ++++++++++--------- extensions/ipset/ipset_nethash.c | 32 ++++++++++---------- extensions/ipset/ipset_portmap.c | 31 ++++++++++--------- 11 files changed, 157 insertions(+), 142 deletions(-) diff --git a/extensions/ipset/ip_set_ipmap.h b/extensions/ipset/ip_set_ipmap.h index eecc2be..ebe67fc 100644 --- a/extensions/ipset/ip_set_ipmap.h +++ b/extensions/ipset/ip_set_ipmap.h @@ -25,7 +25,7 @@ struct ip_set_req_ipmap { ip_set_ip_t ip; }; -unsigned int +static unsigned int mask_to_bits(ip_set_ip_t mask) { unsigned int bits = 32; @@ -41,7 +41,7 @@ mask_to_bits(ip_set_ip_t mask) return bits; } -ip_set_ip_t +static ip_set_ip_t range_to_mask(ip_set_ip_t from, ip_set_ip_t to, unsigned int *bits) { ip_set_ip_t mask = 0xFFFFFFFE; diff --git a/extensions/ipset/ipset.c b/extensions/ipset/ipset.c index 5228623..2180493 100644 --- a/extensions/ipset/ipset.c +++ b/extensions/ipset/ipset.c @@ -35,7 +35,7 @@ char program_name[] = "ipset"; char program_version[] = IPSET_VERSION; -char *xtables_libdir = XTABLES_LIBDIR; +const char *xtables_libdir = XTABLES_LIBDIR; /* The list of loaded set types */ static struct settype *all_settypes = NULL; @@ -53,7 +53,7 @@ void *restore_data = NULL; struct ip_set_restore *restore_set = NULL; size_t restore_offset = 0; socklen_t restore_size; -unsigned line = 0; +unsigned int g_line = 0; #define TEMPFILE_PATTERN "/ipsetXXXXXX" @@ -155,7 +155,7 @@ static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] = { /* Main parser function */ int parse_commandline(int argc, char *argv[]); -void exit_tryhelp(int status) +static void exit_tryhelp(int status) { fprintf(stderr, "Try `%s -H' or '%s --help' for more information.\n", @@ -163,7 +163,7 @@ void exit_tryhelp(int status) exit(status); } -void exit_error(enum exittype status, char *msg, ...) +void exit_error(enum exittype status, const char *msg, ...) { va_list args; @@ -173,8 +173,8 @@ void exit_error(enum exittype status, char *msg, ...) vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, "\n"); - if (line) - fprintf(stderr, "Restore failed at line %u:\n", line); + if (g_line) + fprintf(stderr, "Restore failed at line %u:\n", g_line); if (status == PARAMETER_PROBLEM) exit_tryhelp(status); if (status == VERSION_PROBLEM) @@ -186,7 +186,7 @@ void exit_error(enum exittype status, char *msg, ...) exit(status); } -void ipset_printf(char *msg, ...) +static void ipset_printf(const char *msg, ...) { va_list args; @@ -896,12 +896,12 @@ static struct set *set_find_byname(const char *name) static ip_set_id_t set_find_free_index(const char *name) { - ip_set_id_t i, index = IP_SET_INVALID_ID; + ip_set_id_t i, idx = IP_SET_INVALID_ID; for (i = 0; i < max_sets; i++) { - if (index == IP_SET_INVALID_ID + if (idx == IP_SET_INVALID_ID && set_list[i] == NULL) - index = i; + idx = i; if (set_list[i] != NULL && strncmp(set_list[i]->name, name, IP_SET_MAXNAMELEN) == 0) @@ -910,13 +910,13 @@ static ip_set_id_t set_find_free_index(const char *name) name); } - if (index == IP_SET_INVALID_ID) + if (idx == IP_SET_INVALID_ID) exit_error(PARAMETER_PROBLEM, "Set %s cannot be restored, " "max number of set %u reached", name, max_sets); - return index; + return idx; } /* @@ -1035,7 +1035,7 @@ static void set_rename(const char *name, const char *newname, * Send MAX_SETS, LIST_SIZE and/or SAVE_SIZE orders to kernel */ static size_t load_set_list(const char name[IP_SET_MAXNAMELEN], - ip_set_id_t *index, + ip_set_id_t *idx, unsigned op, unsigned cmd) { void *data = NULL; @@ -1072,7 +1072,7 @@ tryagain: max_sets = req_max_sets.max_sets; set_list = ipset_malloc(max_sets * sizeof(struct set *)); memset(set_list, 0, max_sets * sizeof(struct set *)); - *index = req_max_sets.set.index; + *idx = req_max_sets.set.index; if (req_max_sets.sets == 0) /* No sets in kernel */ @@ -1083,7 +1083,7 @@ tryagain: + req_max_sets.sets * sizeof(struct ip_set_name_list); data = ipset_malloc(size); ((struct ip_set_req_setnames *) data)->op = op; - ((struct ip_set_req_setnames *) data)->index = *index; + ((struct ip_set_req_setnames *) data)->index = *idx; res = kernel_getfrom_handleerrno(cmd, data, &size); @@ -1222,12 +1222,12 @@ static int try_save_sets(const char name[IP_SET_MAXNAMELEN]) { void *data = NULL; socklen_t size, req_size = 0; - ip_set_id_t index; + ip_set_id_t idx; int res = 0, bindings = 0; time_t now = time(NULL); /* Load set_list from kernel */ - size = load_set_list(name, &index, + size = load_set_list(name, &idx, IP_SET_OP_SAVE_SIZE, CMD_SAVE); if (size) { @@ -1236,7 +1236,7 @@ static int try_save_sets(const char name[IP_SET_MAXNAMELEN]) req_size = (size += sizeof(struct ip_set_save)); data = ipset_malloc(size); ((struct ip_set_req_list *) data)->op = IP_SET_OP_SAVE; - ((struct ip_set_req_list *) data)->index = index; + ((struct ip_set_req_list *) data)->index = idx; res = kernel_getfrom_handleerrno(CMD_SAVE, data, &size); if (res != 0 || size != req_size) { @@ -1360,7 +1360,7 @@ static void set_restore(char *argv0) int line = 0, first_pass, i, bindings = 0; struct settype *settype = NULL; struct ip_set_req_setnames *header; - ip_set_id_t index; + ip_set_id_t idx; FILE *in; int res; @@ -1368,7 +1368,7 @@ static void set_restore(char *argv0) in = create_tempfile(); /* Load existing sets from kernel */ - load_set_list(IPSET_TOKEN_ALL, &index, + load_set_list(IPSET_TOKEN_ALL, &idx, IP_SET_OP_LIST_SIZE, CMD_RESTORE); restore_size = sizeof(struct ip_set_req_setnames)/* header */ @@ -1797,20 +1797,20 @@ static int try_list_sets(const char name[IP_SET_MAXNAMELEN], unsigned options) { void *data = NULL; - ip_set_id_t index; + ip_set_id_t idx; socklen_t size, req_size; int res = 0; DP("%s", name); /* Load set_list from kernel */ - size = req_size = load_set_list(name, &index, + size = req_size = load_set_list(name, &idx, IP_SET_OP_LIST_SIZE, CMD_LIST); if (size) { /* Get sets and print them */ data = ipset_malloc(size); ((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; - ((struct ip_set_req_list *) data)->index = index; + ((struct ip_set_req_list *) data)->index = idx; res = kernel_getfrom_handleerrno(CMD_LIST, data, &size); DP("get_lists getsockopt() res=%d errno=%d", res, errno); diff --git a/extensions/ipset/ipset.h b/extensions/ipset/ipset.h index 4e01c33..35153af 100644 --- a/extensions/ipset/ipset.h +++ b/extensions/ipset/ipset.h @@ -107,7 +107,7 @@ struct settype { void (*create_final) (void *data, unsigned int flags); /* Pointer to list of extra command-line options for create */ - struct option *create_opts; + const struct option *create_opts; /* * Add/del/test IP @@ -164,7 +164,7 @@ extern void settype_register(struct settype *settype); /* extern void unregister_settype(set_type_t *set_type); */ -extern void exit_error(enum exittype status, char *msg, ...); +extern void exit_error(enum exittype status, const char *msg, ...); extern char *binding_ip_tostring(struct set *set, ip_set_ip_t ip, unsigned options); diff --git a/extensions/ipset/ipset_iphash.c b/extensions/ipset/ipset_iphash.c index b8c54d8..9426180 100644 --- a/extensions/ipset/ipset_iphash.c +++ b/extensions/ipset/ipset_iphash.c @@ -41,7 +41,7 @@ #define OPT_CREATE_NETMASK 0x08U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { struct ip_set_req_iphash_create *mydata = (struct ip_set_req_iphash_create *) data; @@ -57,7 +57,7 @@ void create_init(void *data) } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_iphash_create *mydata = (struct ip_set_req_iphash_create *) data; @@ -125,7 +125,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { #ifdef IPSET_DEBUG struct ip_set_req_iphash_create *mydata = @@ -137,24 +137,24 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"hashsize", 1, 0, '1'}, {"probes", 1, 0, '2'}, {"resize", 1, 0, '3'}, {"netmask", 1, 0, '4'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_iphash *mydata = (struct ip_set_req_iphash *) data; - parse_ip(optarg, &mydata->ip); + parse_ip(arg, &mydata->ip); if (!mydata->ip) exit_error(PARAMETER_PROBLEM, - "Zero valued IP address `%s' specified", optarg); + "Zero valued IP address `%s' specified", arg); return mydata->ip; }; @@ -163,7 +163,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_iphash_create *header = (struct ip_set_req_iphash_create *) data; @@ -177,7 +177,7 @@ void initheader(struct set *set, const void *data) map->netmask = header->netmask; } -unsigned int +static unsigned int mask_to_bits(ip_set_ip_t mask) { unsigned int bits = 32; @@ -193,7 +193,7 @@ mask_to_bits(ip_set_ip_t mask) return bits; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_iphash *mysetdata = (struct ip_set_iphash *) set->settype->header; @@ -207,7 +207,8 @@ void printheader(struct set *set, unsigned options) printf(" netmask: %d\n", mask_to_bits(mysetdata->netmask)); } -void printips(struct set *set, void *data, size_t len, unsigned options) +static void printips(struct set *set, void *data, size_t len, + unsigned int options) { size_t offset = 0; ip_set_ip_t *ip; @@ -220,7 +221,7 @@ void printips(struct set *set, void *data, size_t len, unsigned options) } } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_iphash *mysetdata = (struct ip_set_iphash *) set->settype->header; @@ -235,7 +236,8 @@ void saveheader(struct set *set, unsigned options) } /* Print save for an IP */ -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { size_t offset = 0; ip_set_ip_t *ip; @@ -249,7 +251,7 @@ void saveips(struct set *set, void *data, size_t len, unsigned options) } } -void usage(void) +static void usage(void) { printf ("-N set iphash [--hashsize hashsize] [--probes probes ]\n" @@ -290,7 +292,7 @@ static struct settype settype_iphash = { .usage = &usage, }; -static __attribute__((constructor)) iphash_init(void) +static __attribute__((constructor)) void iphash_init(void) { settype_register(&settype_iphash); diff --git a/extensions/ipset/ipset_ipmap.c b/extensions/ipset/ipset_ipmap.c index d00e630..9a0619c 100644 --- a/extensions/ipset/ipset_ipmap.c +++ b/extensions/ipset/ipset_ipmap.c @@ -37,7 +37,7 @@ #define OPT_ADDDEL_IP 0x01U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { struct ip_set_req_ipmap_create *mydata = (struct ip_set_req_ipmap_create *) data; @@ -47,7 +47,7 @@ void create_init(void *data) } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_ipmap_create *mydata = (struct ip_set_req_ipmap_create *) data; @@ -119,7 +119,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) #define ERRSTRLEN 256 /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { struct ip_set_req_ipmap_create *mydata = (struct ip_set_req_ipmap_create *) data; @@ -196,23 +196,23 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"from", 1, 0, '1'}, {"to", 1, 0, '2'}, {"network", 1, 0, '3'}, {"netmask", 1, 0, '4'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_ipmap *mydata = (struct ip_set_req_ipmap *) data; - DP("ipmap: %p %p", optarg, data); + DP("ipmap: %p %p", arg, data); - parse_ip(optarg, &mydata->ip); + parse_ip(arg, &mydata->ip); DP("%s", ip_tostring_numeric(mydata->ip)); return 1; @@ -222,7 +222,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_ipmap_create *header = (struct ip_set_req_ipmap_create *) data; @@ -252,7 +252,7 @@ void initheader(struct set *set, const void *data) DP("%i %i", map->hosts, map->sizeid ); } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_ipmap *mysetdata = (struct ip_set_ipmap *) set->settype->header; @@ -265,7 +265,8 @@ void printheader(struct set *set, unsigned options) printf(" netmask: %d\n", mask_to_bits(mysetdata->netmask)); } -void printips_sorted(struct set *set, void *data, size_t len, unsigned options) +static void printips_sorted(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_ipmap *mysetdata = (struct ip_set_ipmap *) set->settype->header; @@ -279,7 +280,7 @@ void printips_sorted(struct set *set, void *data, size_t len, unsigned options) options)); } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_ipmap *mysetdata = (struct ip_set_ipmap *) set->settype->header; @@ -296,7 +297,8 @@ void saveheader(struct set *set, unsigned options) mask_to_bits(mysetdata->netmask)); } -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_ipmap *mysetdata = (struct ip_set_ipmap *) set->settype->header; @@ -312,7 +314,7 @@ void saveips(struct set *set, void *data, size_t len, unsigned options) options)); } -void usage(void) +static void usage(void) { printf ("-N set ipmap --from IP --to IP [--netmask CIDR-netmask]\n" diff --git a/extensions/ipset/ipset_ipporthash.c b/extensions/ipset/ipset_ipporthash.c index 77f62b5..eecacf5 100644 --- a/extensions/ipset/ipset_ipporthash.c +++ b/extensions/ipset/ipset_ipporthash.c @@ -41,7 +41,7 @@ #define OPT_CREATE_TO 0x20U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { struct ip_set_req_ipporthash_create *mydata = (struct ip_set_req_ipporthash_create *) data; @@ -55,7 +55,7 @@ void create_init(void *data) } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_ipporthash_create *mydata = (struct ip_set_req_ipporthash_create *) data; @@ -146,7 +146,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { struct ip_set_req_ipporthash_create *mydata = (struct ip_set_req_ipporthash_create *) data; @@ -187,25 +187,25 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"hashsize", 1, 0, '1'}, {"probes", 1, 0, '2'}, {"resize", 1, 0, '3'}, {"from", 1, 0, '4'}, {"to", 1, 0, '5'}, {"network", 1, 0, '6'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_ipporthash *mydata = (struct ip_set_req_ipporthash *) data; - char *saved = ipset_strdup(optarg); + char *saved = ipset_strdup(arg); char *ptr, *tmp = saved; - DP("ipporthash: %p %p", optarg, data); + DP("ipporthash: %p %p", arg, data); ptr = strsep(&tmp, ":%"); parse_ip(ptr, &mydata->ip); @@ -223,7 +223,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_ipporthash_create *header = (struct ip_set_req_ipporthash_create *) data; @@ -238,7 +238,7 @@ void initheader(struct set *set, const void *data) map->last_ip = header->to; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_ipporthash *mysetdata = (struct ip_set_ipporthash *) set->settype->header; @@ -250,7 +250,8 @@ void printheader(struct set *set, unsigned options) printf(" resize: %u\n", mysetdata->resize); } -void printips(struct set *set, void *data, size_t len, unsigned options) +static void printips(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_ipporthash *mysetdata = (struct ip_set_ipporthash *) set->settype->header; @@ -271,7 +272,7 @@ void printips(struct set *set, void *data, size_t len, unsigned options) } } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_ipporthash *mysetdata = (struct ip_set_ipporthash *) set->settype->header; @@ -286,7 +287,8 @@ void saveheader(struct set *set, unsigned options) } /* Print save for an IP */ -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_ipporthash *mysetdata = (struct ip_set_ipporthash *) set->settype->header; @@ -323,7 +325,7 @@ static char * unpack_ipport_tostring(struct set *set, ip_set_ip_t bip, unsigned return buffer; } -void usage(void) +static void usage(void) { printf ("-N set ipporthash --from IP --to IP\n" diff --git a/extensions/ipset/ipset_iptree.c b/extensions/ipset/ipset_iptree.c index aab5852..565c2c4 100644 --- a/extensions/ipset/ipset_iptree.c +++ b/extensions/ipset/ipset_iptree.c @@ -31,7 +31,7 @@ #define OPT_CREATE_TIMEOUT 0x01U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { struct ip_set_req_iptree_create *mydata = (struct ip_set_req_iptree_create *) data; @@ -41,7 +41,7 @@ void create_init(void *data) } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_iptree_create *mydata = (struct ip_set_req_iptree_create *) data; @@ -65,25 +65,25 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"timeout", 1, 0, '1'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_iptree *mydata = (struct ip_set_req_iptree *) data; - char *saved = ipset_strdup(optarg); + char *saved = ipset_strdup(arg); char *ptr, *tmp = saved; - DP("iptree: %p %p", optarg, data); + DP("iptree: %p %p", arg, data); ptr = strsep(&tmp, ":%"); parse_ip(ptr, &mydata->ip); @@ -101,7 +101,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_iptree_create *header = (struct ip_set_req_iptree_create *) data; @@ -111,7 +111,7 @@ void initheader(struct set *set, const void *data) map->timeout = header->timeout; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_iptree *mysetdata = (struct ip_set_iptree *) set->settype->header; @@ -121,7 +121,8 @@ void printheader(struct set *set, unsigned options) printf("\n"); } -void printips_sorted(struct set *set, void *data, size_t len, unsigned options) +static void printips_sorted(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_iptree *mysetdata = (struct ip_set_iptree *) set->settype->header; @@ -139,7 +140,7 @@ void printips_sorted(struct set *set, void *data, size_t len, unsigned options) } } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_iptree *mysetdata = (struct ip_set_iptree *) set->settype->header; @@ -153,7 +154,8 @@ void saveheader(struct set *set, unsigned options) set->name, set->settype->typename); } -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_iptree *mysetdata = (struct ip_set_iptree *) set->settype->header; @@ -177,7 +179,7 @@ void saveips(struct set *set, void *data, size_t len, unsigned options) } } -void usage(void) +static void usage(void) { printf ("-N set iptree [--timeout value]\n" diff --git a/extensions/ipset/ipset_iptreemap.c b/extensions/ipset/ipset_iptreemap.c index 5998431..9e3d072 100644 --- a/extensions/ipset/ipset_iptreemap.c +++ b/extensions/ipset/ipset_iptreemap.c @@ -28,7 +28,7 @@ #define OPT_CREATE_GC 0x1 -void +static void create_init(void *data) { struct ip_set_req_iptreemap_create *mydata = data; @@ -36,7 +36,7 @@ create_init(void *data) mydata->gc_interval = 0; } -int +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_iptreemap_create *mydata = data; @@ -55,23 +55,23 @@ create_parse(int c, char *argv[], void *data, unsigned int *flags) return 1; } -void +static void create_final(void *data, unsigned int flags) { } -static struct option create_opts[] = { +static const struct option create_opts[] = { {"gc", 1, 0, 'g'}, - {0} + {NULL}, }; -ip_set_ip_t -adt_parser(unsigned int cmd, const char *optarg, void *data) +static ip_set_ip_t +adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_iptreemap *mydata = data; ip_set_ip_t mask; - char *saved = ipset_strdup(optarg); + char *saved = ipset_strdup(arg); char *ptr, *tmp = saved; if (strchr(tmp, '/')) { @@ -91,7 +91,7 @@ adt_parser(unsigned int cmd, const char *optarg, void *data) return 1; } -void +static void initheader(struct set *set, const void *data) { const struct ip_set_req_iptreemap_create *header = data; @@ -100,7 +100,7 @@ initheader(struct set *set, const void *data) map->gc_interval = header->gc_interval; } -void +static void printheader(struct set *set, unsigned int options) { struct ip_set_iptreemap *mysetdata = set->settype->header; @@ -111,7 +111,7 @@ printheader(struct set *set, unsigned int options) printf("\n"); } -void +static void printips_sorted(struct set *set, void *data, size_t len, unsigned int options) { struct ip_set_req_iptreemap *req; @@ -129,7 +129,7 @@ printips_sorted(struct set *set, void *data, size_t len, unsigned int options) } } -void +static void saveheader(struct set *set, unsigned int options) { struct ip_set_iptreemap *mysetdata = set->settype->header; @@ -142,7 +142,7 @@ saveheader(struct set *set, unsigned int options) printf("\n"); } -void +static void saveips(struct set *set, void *data, size_t len, unsigned int options) { struct ip_set_req_iptreemap *req; @@ -162,7 +162,7 @@ saveips(struct set *set, void *data, size_t len, unsigned int options) } } -void +static void usage(void) { printf( diff --git a/extensions/ipset/ipset_macipmap.c b/extensions/ipset/ipset_macipmap.c index 0bd18fb..3c2f316 100644 --- a/extensions/ipset/ipset_macipmap.c +++ b/extensions/ipset/ipset_macipmap.c @@ -40,14 +40,14 @@ #define OPT_ADDDEL_MAC 0x02U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { DP("create INIT"); /* Nothing */ } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_macipmap_create *mydata = (struct ip_set_req_macipmap_create *) data; @@ -107,7 +107,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { struct ip_set_req_macipmap_create *mydata = (struct ip_set_req_macipmap_create *) data; @@ -145,12 +145,12 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"from", 1, 0, '1'}, {"to", 1, 0, '2'}, {"network", 1, 0, '3'}, {"matchunset", 0, 0, '4'}, - {0} + {NULL}, }; static void parse_mac(const char *mac, unsigned char *ethernet) @@ -175,14 +175,14 @@ static void parse_mac(const char *mac, unsigned char *ethernet) } /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_macipmap *mydata = (struct ip_set_req_macipmap *) data; - char *saved = ipset_strdup(optarg); + char *saved = ipset_strdup(arg); char *ptr, *tmp = saved; - DP("macipmap: %p %p", optarg, data); + DP("macipmap: %p %p", arg, data); ptr = strsep(&tmp, ":%"); parse_ip(ptr, &mydata->ip); @@ -200,7 +200,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_macipmap_create *header = (struct ip_set_req_macipmap_create *) data; @@ -213,7 +213,7 @@ void initheader(struct set *set, const void *data) map->flags = header->flags; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_macipmap *mysetdata = (struct ip_set_macipmap *) set->settype->header; @@ -235,7 +235,8 @@ static void print_mac(unsigned char macaddress[ETH_ALEN]) printf(":%02X", macaddress[i]); } -void printips_sorted(struct set *set, void *data, size_t len, unsigned options) +static void printips_sorted(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_macipmap *mysetdata = (struct ip_set_macipmap *) set->settype->header; @@ -255,7 +256,7 @@ void printips_sorted(struct set *set, void *data, size_t len, unsigned options) } } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_macipmap *mysetdata = (struct ip_set_macipmap *) set->settype->header; @@ -270,7 +271,8 @@ void saveheader(struct set *set, unsigned options) printf("\n"); } -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_macipmap *mysetdata = (struct ip_set_macipmap *) set->settype->header; @@ -291,7 +293,7 @@ void saveips(struct set *set, void *data, size_t len, unsigned options) } } -void usage(void) +static void usage(void) { printf ("-N set macipmap --from IP --to IP [--matchunset]\n" diff --git a/extensions/ipset/ipset_nethash.c b/extensions/ipset/ipset_nethash.c index 53ae713..efa7508 100644 --- a/extensions/ipset/ipset_nethash.c +++ b/extensions/ipset/ipset_nethash.c @@ -40,7 +40,7 @@ #define OPT_CREATE_RESIZE 0x04U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { struct ip_set_req_nethash_create *mydata = (struct ip_set_req_nethash_create *) data; @@ -54,7 +54,7 @@ void create_init(void *data) } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_nethash_create *mydata = (struct ip_set_req_nethash_create *) data; @@ -106,7 +106,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { #ifdef IPSET_DEBUG struct ip_set_req_nethash_create *mydata = @@ -118,19 +118,19 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"hashsize", 1, 0, '1'}, {"probes", 1, 0, '2'}, {"resize", 1, 0, '3'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_nethash *mydata = (struct ip_set_req_nethash *) data; - char *saved = ipset_strdup(optarg); + char *saved = ipset_strdup(arg); char *ptr, *tmp = saved; ip_set_ip_t cidr; @@ -141,11 +141,11 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) cidr = 32; else exit_error(PARAMETER_PROBLEM, - "Missing cidr from `%s'", optarg); + "Missing cidr from `%s'", arg); } else if (string_to_number(tmp, 1, 31, &cidr)) exit_error(PARAMETER_PROBLEM, - "Out of range cidr `%s' specified", optarg); + "Out of range cidr `%s' specified", arg); mydata->cidr = cidr; parse_ip(ptr, &mydata->ip); @@ -161,7 +161,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_nethash_create *header = (struct ip_set_req_nethash_create *) data; @@ -174,7 +174,7 @@ void initheader(struct set *set, const void *data) map->resize = header->resize; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_nethash *mysetdata = (struct ip_set_nethash *) set->settype->header; @@ -237,7 +237,8 @@ static char * unpack_ip_tostring(ip_set_ip_t ip, unsigned options) return buf; } -void printips(struct set *set, void *data, size_t len, unsigned options) +static void printips(struct set *set, void *data, size_t len, + unsigned int options) { size_t offset = 0; ip_set_ip_t *ip; @@ -250,7 +251,7 @@ void printips(struct set *set, void *data, size_t len, unsigned options) } } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_nethash *mysetdata = (struct ip_set_nethash *) set->settype->header; @@ -261,7 +262,8 @@ void saveheader(struct set *set, unsigned options) } /* Print save for an IP */ -void saveips(struct set *set, void *data, size_t len, unsigned options) +static void saveips(struct set *set, void *data, size_t len, + unsigned int options) { size_t offset = 0; ip_set_ip_t *ip; @@ -302,7 +304,7 @@ static void parse_net(const char *str, ip_set_ip_t *ip) *ip = pack(*ip, cidr); } -void usage(void) +static void usage(void) { printf ("-N set nethash [--hashsize hashsize] [--probes probes ]\n" diff --git a/extensions/ipset/ipset_portmap.c b/extensions/ipset/ipset_portmap.c index 3f83406..5928666 100644 --- a/extensions/ipset/ipset_portmap.c +++ b/extensions/ipset/ipset_portmap.c @@ -34,14 +34,14 @@ #define OPT_ADDDEL_PORT 0x01U /* Initialize the create. */ -void create_init(void *data) +static void create_init(void *data) { DP("create INIT"); /* Nothing */ } /* Function which parses command options; returns true if it ate an option */ -int create_parse(int c, char *argv[], void *data, unsigned *flags) +static int create_parse(int c, char *argv[], void *data, unsigned int *flags) { struct ip_set_req_portmap_create *mydata = (struct ip_set_req_portmap_create *) data; @@ -77,7 +77,7 @@ int create_parse(int c, char *argv[], void *data, unsigned *flags) } /* Final check; exit if not ok. */ -void create_final(void *data, unsigned int flags) +static void create_final(void *data, unsigned int flags) { struct ip_set_req_portmap_create *mydata = (struct ip_set_req_portmap_create *) data; @@ -107,19 +107,19 @@ void create_final(void *data, unsigned int flags) } /* Create commandline options */ -static struct option create_opts[] = { +static const struct option create_opts[] = { {"from", 1, 0, '1'}, {"to", 1, 0, '2'}, - {0} + {NULL}, }; /* Add, del, test parser */ -ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) +static ip_set_ip_t adt_parser(unsigned int cmd, const char *arg, void *data) { struct ip_set_req_portmap *mydata = (struct ip_set_req_portmap *) data; - parse_port(optarg, &mydata->port); + parse_port(arg, &mydata->port); DP("%s", port_tostring(mydata->port, 0)); return 1; @@ -129,7 +129,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) * Print and save */ -void initheader(struct set *set, const void *data) +static void initheader(struct set *set, const void *data) { struct ip_set_req_portmap_create *header = (struct ip_set_req_portmap_create *) data; @@ -141,7 +141,7 @@ void initheader(struct set *set, const void *data) map->last_port = header->to; } -void printheader(struct set *set, unsigned options) +static void printheader(struct set *set, unsigned int options) { struct ip_set_portmap *mysetdata = (struct ip_set_portmap *) set->settype->header; @@ -150,7 +150,8 @@ void printheader(struct set *set, unsigned options) printf(" to: %s\n", port_tostring(mysetdata->last_port, options)); } -void printports_sorted(struct set *set, void *data, size_t len, unsigned options) +static void printports_sorted(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_portmap *mysetdata = (struct ip_set_portmap *) set->settype->header; @@ -164,12 +165,13 @@ void printports_sorted(struct set *set, void *data, size_t len, unsigned options } } -char * binding_port_tostring(struct set *set, ip_set_ip_t ip, unsigned options) +static char *binding_port_tostring(struct set *set, ip_set_ip_t ip, + unsigned int options) { return port_tostring(ip, options); } -void saveheader(struct set *set, unsigned options) +static void saveheader(struct set *set, unsigned int options) { struct ip_set_portmap *mysetdata = (struct ip_set_portmap *) set->settype->header; @@ -182,7 +184,8 @@ void saveheader(struct set *set, unsigned options) port_tostring(mysetdata->last_port, options)); } -void saveports(struct set *set, void *data, size_t len, unsigned options) +static void saveports(struct set *set, void *data, size_t len, + unsigned int options) { struct ip_set_portmap *mysetdata = (struct ip_set_portmap *) set->settype->header; @@ -197,7 +200,7 @@ void saveports(struct set *set, void *data, size_t len, unsigned options) } } -void usage(void) +static void usage(void) { printf ("-N set portmap --from PORT --to PORT\n"