ipset: fixup compile warnings

And add a few const here and there.
This commit is contained in:
Jan Engelhardt
2008-07-07 10:36:35 +02:00
parent 9d696b727a
commit 29aea5a87b
11 changed files with 157 additions and 142 deletions

View File

@@ -25,7 +25,7 @@ struct ip_set_req_ipmap {
ip_set_ip_t ip; ip_set_ip_t ip;
}; };
unsigned int static unsigned int
mask_to_bits(ip_set_ip_t mask) mask_to_bits(ip_set_ip_t mask)
{ {
unsigned int bits = 32; unsigned int bits = 32;
@@ -41,7 +41,7 @@ mask_to_bits(ip_set_ip_t mask)
return bits; 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) range_to_mask(ip_set_ip_t from, ip_set_ip_t to, unsigned int *bits)
{ {
ip_set_ip_t mask = 0xFFFFFFFE; ip_set_ip_t mask = 0xFFFFFFFE;

View File

@@ -35,7 +35,7 @@
char program_name[] = "ipset"; char program_name[] = "ipset";
char program_version[] = IPSET_VERSION; char program_version[] = IPSET_VERSION;
char *xtables_libdir = XTABLES_LIBDIR; const char *xtables_libdir = XTABLES_LIBDIR;
/* The list of loaded set types */ /* The list of loaded set types */
static struct settype *all_settypes = NULL; static struct settype *all_settypes = NULL;
@@ -53,7 +53,7 @@ void *restore_data = NULL;
struct ip_set_restore *restore_set = NULL; struct ip_set_restore *restore_set = NULL;
size_t restore_offset = 0; size_t restore_offset = 0;
socklen_t restore_size; socklen_t restore_size;
unsigned line = 0; unsigned int g_line = 0;
#define TEMPFILE_PATTERN "/ipsetXXXXXX" #define TEMPFILE_PATTERN "/ipsetXXXXXX"
@@ -155,7 +155,7 @@ static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] = {
/* Main parser function */ /* Main parser function */
int parse_commandline(int argc, char *argv[]); int parse_commandline(int argc, char *argv[]);
void exit_tryhelp(int status) static void exit_tryhelp(int status)
{ {
fprintf(stderr, fprintf(stderr,
"Try `%s -H' or '%s --help' for more information.\n", "Try `%s -H' or '%s --help' for more information.\n",
@@ -163,7 +163,7 @@ void exit_tryhelp(int status)
exit(status); exit(status);
} }
void exit_error(enum exittype status, char *msg, ...) void exit_error(enum exittype status, const char *msg, ...)
{ {
va_list args; va_list args;
@@ -173,8 +173,8 @@ void exit_error(enum exittype status, char *msg, ...)
vfprintf(stderr, msg, args); vfprintf(stderr, msg, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (line) if (g_line)
fprintf(stderr, "Restore failed at line %u:\n", line); fprintf(stderr, "Restore failed at line %u:\n", g_line);
if (status == PARAMETER_PROBLEM) if (status == PARAMETER_PROBLEM)
exit_tryhelp(status); exit_tryhelp(status);
if (status == VERSION_PROBLEM) if (status == VERSION_PROBLEM)
@@ -186,7 +186,7 @@ void exit_error(enum exittype status, char *msg, ...)
exit(status); exit(status);
} }
void ipset_printf(char *msg, ...) static void ipset_printf(const char *msg, ...)
{ {
va_list args; 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) 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++) { for (i = 0; i < max_sets; i++) {
if (index == IP_SET_INVALID_ID if (idx == IP_SET_INVALID_ID
&& set_list[i] == NULL) && set_list[i] == NULL)
index = i; idx = i;
if (set_list[i] != NULL if (set_list[i] != NULL
&& strncmp(set_list[i]->name, name, && strncmp(set_list[i]->name, name,
IP_SET_MAXNAMELEN) == 0) IP_SET_MAXNAMELEN) == 0)
@@ -910,13 +910,13 @@ static ip_set_id_t set_find_free_index(const char *name)
name); name);
} }
if (index == IP_SET_INVALID_ID) if (idx == IP_SET_INVALID_ID)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"Set %s cannot be restored, " "Set %s cannot be restored, "
"max number of set %u reached", "max number of set %u reached",
name, max_sets); 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 * Send MAX_SETS, LIST_SIZE and/or SAVE_SIZE orders to kernel
*/ */
static size_t load_set_list(const char name[IP_SET_MAXNAMELEN], 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) unsigned op, unsigned cmd)
{ {
void *data = NULL; void *data = NULL;
@@ -1072,7 +1072,7 @@ tryagain:
max_sets = req_max_sets.max_sets; max_sets = req_max_sets.max_sets;
set_list = ipset_malloc(max_sets * sizeof(struct set *)); set_list = ipset_malloc(max_sets * sizeof(struct set *));
memset(set_list, 0, 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) if (req_max_sets.sets == 0)
/* No sets in kernel */ /* No sets in kernel */
@@ -1083,7 +1083,7 @@ tryagain:
+ req_max_sets.sets * sizeof(struct ip_set_name_list); + req_max_sets.sets * sizeof(struct ip_set_name_list);
data = ipset_malloc(size); data = ipset_malloc(size);
((struct ip_set_req_setnames *) data)->op = op; ((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); 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; void *data = NULL;
socklen_t size, req_size = 0; socklen_t size, req_size = 0;
ip_set_id_t index; ip_set_id_t idx;
int res = 0, bindings = 0; int res = 0, bindings = 0;
time_t now = time(NULL); time_t now = time(NULL);
/* Load set_list from kernel */ /* Load set_list from kernel */
size = load_set_list(name, &index, size = load_set_list(name, &idx,
IP_SET_OP_SAVE_SIZE, CMD_SAVE); IP_SET_OP_SAVE_SIZE, CMD_SAVE);
if (size) { 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)); req_size = (size += sizeof(struct ip_set_save));
data = ipset_malloc(size); data = ipset_malloc(size);
((struct ip_set_req_list *) data)->op = IP_SET_OP_SAVE; ((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); res = kernel_getfrom_handleerrno(CMD_SAVE, data, &size);
if (res != 0 || size != req_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; int line = 0, first_pass, i, bindings = 0;
struct settype *settype = NULL; struct settype *settype = NULL;
struct ip_set_req_setnames *header; struct ip_set_req_setnames *header;
ip_set_id_t index; ip_set_id_t idx;
FILE *in; FILE *in;
int res; int res;
@@ -1368,7 +1368,7 @@ static void set_restore(char *argv0)
in = create_tempfile(); in = create_tempfile();
/* Load existing sets from kernel */ /* 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); IP_SET_OP_LIST_SIZE, CMD_RESTORE);
restore_size = sizeof(struct ip_set_req_setnames)/* header */ 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) unsigned options)
{ {
void *data = NULL; void *data = NULL;
ip_set_id_t index; ip_set_id_t idx;
socklen_t size, req_size; socklen_t size, req_size;
int res = 0; int res = 0;
DP("%s", name); DP("%s", name);
/* Load set_list from kernel */ /* 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); IP_SET_OP_LIST_SIZE, CMD_LIST);
if (size) { if (size) {
/* Get sets and print them */ /* Get sets and print them */
data = ipset_malloc(size); data = ipset_malloc(size);
((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST; ((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); res = kernel_getfrom_handleerrno(CMD_LIST, data, &size);
DP("get_lists getsockopt() res=%d errno=%d", res, errno); DP("get_lists getsockopt() res=%d errno=%d", res, errno);

View File

@@ -107,7 +107,7 @@ struct settype {
void (*create_final) (void *data, unsigned int flags); void (*create_final) (void *data, unsigned int flags);
/* Pointer to list of extra command-line options for create */ /* Pointer to list of extra command-line options for create */
struct option *create_opts; const struct option *create_opts;
/* /*
* Add/del/test IP * 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 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, extern char *binding_ip_tostring(struct set *set,
ip_set_ip_t ip, unsigned options); ip_set_ip_t ip, unsigned options);

View File

@@ -41,7 +41,7 @@
#define OPT_CREATE_NETMASK 0x08U #define OPT_CREATE_NETMASK 0x08U
/* Initialize the create. */ /* 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 *mydata =
(struct ip_set_req_iphash_create *) data; (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 */ /* 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 *mydata =
(struct ip_set_req_iphash_create *) data; (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. */ /* 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 #ifdef IPSET_DEBUG
struct ip_set_req_iphash_create *mydata = struct ip_set_req_iphash_create *mydata =
@@ -137,24 +137,24 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"hashsize", 1, 0, '1'}, {"hashsize", 1, 0, '1'},
{"probes", 1, 0, '2'}, {"probes", 1, 0, '2'},
{"resize", 1, 0, '3'}, {"resize", 1, 0, '3'},
{"netmask", 1, 0, '4'}, {"netmask", 1, 0, '4'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_iphash *) data; (struct ip_set_req_iphash *) data;
parse_ip(optarg, &mydata->ip); parse_ip(arg, &mydata->ip);
if (!mydata->ip) if (!mydata->ip)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"Zero valued IP address `%s' specified", optarg); "Zero valued IP address `%s' specified", arg);
return mydata->ip; return mydata->ip;
}; };
@@ -163,7 +163,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data)
* Print and save * 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 *header =
(struct ip_set_req_iphash_create *) data; (struct ip_set_req_iphash_create *) data;
@@ -177,7 +177,7 @@ void initheader(struct set *set, const void *data)
map->netmask = header->netmask; map->netmask = header->netmask;
} }
unsigned int static unsigned int
mask_to_bits(ip_set_ip_t mask) mask_to_bits(ip_set_ip_t mask)
{ {
unsigned int bits = 32; unsigned int bits = 32;
@@ -193,7 +193,7 @@ mask_to_bits(ip_set_ip_t mask)
return bits; 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 *mysetdata =
(struct ip_set_iphash *) set->settype->header; (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)); 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; size_t offset = 0;
ip_set_ip_t *ip; 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 *mysetdata =
(struct ip_set_iphash *) set->settype->header; (struct ip_set_iphash *) set->settype->header;
@@ -235,7 +236,8 @@ void saveheader(struct set *set, unsigned options)
} }
/* Print save for an IP */ /* 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; size_t offset = 0;
ip_set_ip_t *ip; 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 printf
("-N set iphash [--hashsize hashsize] [--probes probes ]\n" ("-N set iphash [--hashsize hashsize] [--probes probes ]\n"
@@ -290,7 +292,7 @@ static struct settype settype_iphash = {
.usage = &usage, .usage = &usage,
}; };
static __attribute__((constructor)) iphash_init(void) static __attribute__((constructor)) void iphash_init(void)
{ {
settype_register(&settype_iphash); settype_register(&settype_iphash);

View File

@@ -37,7 +37,7 @@
#define OPT_ADDDEL_IP 0x01U #define OPT_ADDDEL_IP 0x01U
/* Initialize the create. */ /* 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 *mydata =
(struct ip_set_req_ipmap_create *) data; (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 */ /* 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 *mydata =
(struct ip_set_req_ipmap_create *) data; (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 #define ERRSTRLEN 256
/* Final check; exit if not ok. */ /* 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 *mydata =
(struct ip_set_req_ipmap_create *) data; (struct ip_set_req_ipmap_create *) data;
@@ -196,23 +196,23 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"from", 1, 0, '1'}, {"from", 1, 0, '1'},
{"to", 1, 0, '2'}, {"to", 1, 0, '2'},
{"network", 1, 0, '3'}, {"network", 1, 0, '3'},
{"netmask", 1, 0, '4'}, {"netmask", 1, 0, '4'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_ipmap *) data; (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)); DP("%s", ip_tostring_numeric(mydata->ip));
return 1; return 1;
@@ -222,7 +222,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data)
* Print and save * 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 *header =
(struct ip_set_req_ipmap_create *) data; (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 ); 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 *mysetdata =
(struct ip_set_ipmap *) set->settype->header; (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)); 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 *mysetdata =
(struct ip_set_ipmap *) set->settype->header; (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)); 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 *mysetdata =
(struct ip_set_ipmap *) set->settype->header; (struct ip_set_ipmap *) set->settype->header;
@@ -296,7 +297,8 @@ void saveheader(struct set *set, unsigned options)
mask_to_bits(mysetdata->netmask)); 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 *mysetdata =
(struct ip_set_ipmap *) set->settype->header; (struct ip_set_ipmap *) set->settype->header;
@@ -312,7 +314,7 @@ void saveips(struct set *set, void *data, size_t len, unsigned options)
options)); options));
} }
void usage(void) static void usage(void)
{ {
printf printf
("-N set ipmap --from IP --to IP [--netmask CIDR-netmask]\n" ("-N set ipmap --from IP --to IP [--netmask CIDR-netmask]\n"

View File

@@ -41,7 +41,7 @@
#define OPT_CREATE_TO 0x20U #define OPT_CREATE_TO 0x20U
/* Initialize the create. */ /* 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 *mydata =
(struct ip_set_req_ipporthash_create *) data; (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 */ /* 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 *mydata =
(struct ip_set_req_ipporthash_create *) data; (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. */ /* 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 *mydata =
(struct ip_set_req_ipporthash_create *) data; (struct ip_set_req_ipporthash_create *) data;
@@ -187,25 +187,25 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"hashsize", 1, 0, '1'}, {"hashsize", 1, 0, '1'},
{"probes", 1, 0, '2'}, {"probes", 1, 0, '2'},
{"resize", 1, 0, '3'}, {"resize", 1, 0, '3'},
{"from", 1, 0, '4'}, {"from", 1, 0, '4'},
{"to", 1, 0, '5'}, {"to", 1, 0, '5'},
{"network", 1, 0, '6'}, {"network", 1, 0, '6'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_ipporthash *) data; (struct ip_set_req_ipporthash *) data;
char *saved = ipset_strdup(optarg); char *saved = ipset_strdup(arg);
char *ptr, *tmp = saved; char *ptr, *tmp = saved;
DP("ipporthash: %p %p", optarg, data); DP("ipporthash: %p %p", arg, data);
ptr = strsep(&tmp, ":%"); ptr = strsep(&tmp, ":%");
parse_ip(ptr, &mydata->ip); 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 * 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 *header =
(struct ip_set_req_ipporthash_create *) data; (struct ip_set_req_ipporthash_create *) data;
@@ -238,7 +238,7 @@ void initheader(struct set *set, const void *data)
map->last_ip = header->to; 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 *mysetdata =
(struct ip_set_ipporthash *) set->settype->header; (struct ip_set_ipporthash *) set->settype->header;
@@ -250,7 +250,8 @@ void printheader(struct set *set, unsigned options)
printf(" resize: %u\n", mysetdata->resize); 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 *mysetdata =
(struct ip_set_ipporthash *) set->settype->header; (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 *mysetdata =
(struct ip_set_ipporthash *) set->settype->header; (struct ip_set_ipporthash *) set->settype->header;
@@ -286,7 +287,8 @@ void saveheader(struct set *set, unsigned options)
} }
/* Print save for an IP */ /* 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 *mysetdata =
(struct ip_set_ipporthash *) set->settype->header; (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; return buffer;
} }
void usage(void) static void usage(void)
{ {
printf printf
("-N set ipporthash --from IP --to IP\n" ("-N set ipporthash --from IP --to IP\n"

View File

@@ -31,7 +31,7 @@
#define OPT_CREATE_TIMEOUT 0x01U #define OPT_CREATE_TIMEOUT 0x01U
/* Initialize the create. */ /* 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 *mydata =
(struct ip_set_req_iptree_create *) data; (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 */ /* 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 *mydata =
(struct ip_set_req_iptree_create *) data; (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. */ /* 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 */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"timeout", 1, 0, '1'}, {"timeout", 1, 0, '1'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_iptree *) data; (struct ip_set_req_iptree *) data;
char *saved = ipset_strdup(optarg); char *saved = ipset_strdup(arg);
char *ptr, *tmp = saved; char *ptr, *tmp = saved;
DP("iptree: %p %p", optarg, data); DP("iptree: %p %p", arg, data);
ptr = strsep(&tmp, ":%"); ptr = strsep(&tmp, ":%");
parse_ip(ptr, &mydata->ip); 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 * 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 *header =
(struct ip_set_req_iptree_create *) data; (struct ip_set_req_iptree_create *) data;
@@ -111,7 +111,7 @@ void initheader(struct set *set, const void *data)
map->timeout = header->timeout; 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 *mysetdata =
(struct ip_set_iptree *) set->settype->header; (struct ip_set_iptree *) set->settype->header;
@@ -121,7 +121,8 @@ void printheader(struct set *set, unsigned options)
printf("\n"); 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 *mysetdata =
(struct ip_set_iptree *) set->settype->header; (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 *mysetdata =
(struct ip_set_iptree *) set->settype->header; (struct ip_set_iptree *) set->settype->header;
@@ -153,7 +154,8 @@ void saveheader(struct set *set, unsigned options)
set->name, set->settype->typename); 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 *mysetdata =
(struct ip_set_iptree *) set->settype->header; (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 printf
("-N set iptree [--timeout value]\n" ("-N set iptree [--timeout value]\n"

View File

@@ -28,7 +28,7 @@
#define OPT_CREATE_GC 0x1 #define OPT_CREATE_GC 0x1
void static void
create_init(void *data) create_init(void *data)
{ {
struct ip_set_req_iptreemap_create *mydata = data; struct ip_set_req_iptreemap_create *mydata = data;
@@ -36,7 +36,7 @@ create_init(void *data)
mydata->gc_interval = 0; mydata->gc_interval = 0;
} }
int static int
create_parse(int c, char *argv[], void *data, unsigned int *flags) create_parse(int c, char *argv[], void *data, unsigned int *flags)
{ {
struct ip_set_req_iptreemap_create *mydata = data; 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; return 1;
} }
void static void
create_final(void *data, unsigned int flags) create_final(void *data, unsigned int flags)
{ {
} }
static struct option create_opts[] = { static const struct option create_opts[] = {
{"gc", 1, 0, 'g'}, {"gc", 1, 0, 'g'},
{0} {NULL},
}; };
ip_set_ip_t static ip_set_ip_t
adt_parser(unsigned int cmd, const char *optarg, void *data) adt_parser(unsigned int cmd, const char *arg, void *data)
{ {
struct ip_set_req_iptreemap *mydata = data; struct ip_set_req_iptreemap *mydata = data;
ip_set_ip_t mask; ip_set_ip_t mask;
char *saved = ipset_strdup(optarg); char *saved = ipset_strdup(arg);
char *ptr, *tmp = saved; char *ptr, *tmp = saved;
if (strchr(tmp, '/')) { if (strchr(tmp, '/')) {
@@ -91,7 +91,7 @@ adt_parser(unsigned int cmd, const char *optarg, void *data)
return 1; return 1;
} }
void static void
initheader(struct set *set, const void *data) initheader(struct set *set, const void *data)
{ {
const struct ip_set_req_iptreemap_create *header = 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; map->gc_interval = header->gc_interval;
} }
void static void
printheader(struct set *set, unsigned int options) printheader(struct set *set, unsigned int options)
{ {
struct ip_set_iptreemap *mysetdata = set->settype->header; struct ip_set_iptreemap *mysetdata = set->settype->header;
@@ -111,7 +111,7 @@ printheader(struct set *set, unsigned int options)
printf("\n"); printf("\n");
} }
void static void
printips_sorted(struct set *set, void *data, size_t len, unsigned int options) printips_sorted(struct set *set, void *data, size_t len, unsigned int options)
{ {
struct ip_set_req_iptreemap *req; 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) saveheader(struct set *set, unsigned int options)
{ {
struct ip_set_iptreemap *mysetdata = set->settype->header; struct ip_set_iptreemap *mysetdata = set->settype->header;
@@ -142,7 +142,7 @@ saveheader(struct set *set, unsigned int options)
printf("\n"); printf("\n");
} }
void static void
saveips(struct set *set, void *data, size_t len, unsigned int options) saveips(struct set *set, void *data, size_t len, unsigned int options)
{ {
struct ip_set_req_iptreemap *req; 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) usage(void)
{ {
printf( printf(

View File

@@ -40,14 +40,14 @@
#define OPT_ADDDEL_MAC 0x02U #define OPT_ADDDEL_MAC 0x02U
/* Initialize the create. */ /* Initialize the create. */
void create_init(void *data) static void create_init(void *data)
{ {
DP("create INIT"); DP("create INIT");
/* Nothing */ /* Nothing */
} }
/* Function which parses command options; returns true if it ate an option */ /* 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 *mydata =
(struct ip_set_req_macipmap_create *) data; (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. */ /* 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 *mydata =
(struct ip_set_req_macipmap_create *) data; (struct ip_set_req_macipmap_create *) data;
@@ -145,12 +145,12 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"from", 1, 0, '1'}, {"from", 1, 0, '1'},
{"to", 1, 0, '2'}, {"to", 1, 0, '2'},
{"network", 1, 0, '3'}, {"network", 1, 0, '3'},
{"matchunset", 0, 0, '4'}, {"matchunset", 0, 0, '4'},
{0} {NULL},
}; };
static void parse_mac(const char *mac, unsigned char *ethernet) 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 */ /* 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 *mydata =
(struct ip_set_req_macipmap *) data; (struct ip_set_req_macipmap *) data;
char *saved = ipset_strdup(optarg); char *saved = ipset_strdup(arg);
char *ptr, *tmp = saved; char *ptr, *tmp = saved;
DP("macipmap: %p %p", optarg, data); DP("macipmap: %p %p", arg, data);
ptr = strsep(&tmp, ":%"); ptr = strsep(&tmp, ":%");
parse_ip(ptr, &mydata->ip); 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 * 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 *header =
(struct ip_set_req_macipmap_create *) data; (struct ip_set_req_macipmap_create *) data;
@@ -213,7 +213,7 @@ void initheader(struct set *set, const void *data)
map->flags = header->flags; 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 *mysetdata =
(struct ip_set_macipmap *) set->settype->header; (struct ip_set_macipmap *) set->settype->header;
@@ -235,7 +235,8 @@ static void print_mac(unsigned char macaddress[ETH_ALEN])
printf(":%02X", macaddress[i]); 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 *mysetdata =
(struct ip_set_macipmap *) set->settype->header; (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 *mysetdata =
(struct ip_set_macipmap *) set->settype->header; (struct ip_set_macipmap *) set->settype->header;
@@ -270,7 +271,8 @@ void saveheader(struct set *set, unsigned options)
printf("\n"); 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 *mysetdata =
(struct ip_set_macipmap *) set->settype->header; (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 printf
("-N set macipmap --from IP --to IP [--matchunset]\n" ("-N set macipmap --from IP --to IP [--matchunset]\n"

View File

@@ -40,7 +40,7 @@
#define OPT_CREATE_RESIZE 0x04U #define OPT_CREATE_RESIZE 0x04U
/* Initialize the create. */ /* 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 *mydata =
(struct ip_set_req_nethash_create *) data; (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 */ /* 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 *mydata =
(struct ip_set_req_nethash_create *) data; (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. */ /* 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 #ifdef IPSET_DEBUG
struct ip_set_req_nethash_create *mydata = struct ip_set_req_nethash_create *mydata =
@@ -118,19 +118,19 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"hashsize", 1, 0, '1'}, {"hashsize", 1, 0, '1'},
{"probes", 1, 0, '2'}, {"probes", 1, 0, '2'},
{"resize", 1, 0, '3'}, {"resize", 1, 0, '3'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_nethash *) data; (struct ip_set_req_nethash *) data;
char *saved = ipset_strdup(optarg); char *saved = ipset_strdup(arg);
char *ptr, *tmp = saved; char *ptr, *tmp = saved;
ip_set_ip_t cidr; ip_set_ip_t cidr;
@@ -141,11 +141,11 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data)
cidr = 32; cidr = 32;
else else
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"Missing cidr from `%s'", optarg); "Missing cidr from `%s'", arg);
} else } else
if (string_to_number(tmp, 1, 31, &cidr)) if (string_to_number(tmp, 1, 31, &cidr))
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"Out of range cidr `%s' specified", optarg); "Out of range cidr `%s' specified", arg);
mydata->cidr = cidr; mydata->cidr = cidr;
parse_ip(ptr, &mydata->ip); 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 * 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 *header =
(struct ip_set_req_nethash_create *) data; (struct ip_set_req_nethash_create *) data;
@@ -174,7 +174,7 @@ void initheader(struct set *set, const void *data)
map->resize = header->resize; 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 *mysetdata =
(struct ip_set_nethash *) set->settype->header; (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; 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; size_t offset = 0;
ip_set_ip_t *ip; 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 *mysetdata =
(struct ip_set_nethash *) set->settype->header; (struct ip_set_nethash *) set->settype->header;
@@ -261,7 +262,8 @@ void saveheader(struct set *set, unsigned options)
} }
/* Print save for an IP */ /* 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; size_t offset = 0;
ip_set_ip_t *ip; 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); *ip = pack(*ip, cidr);
} }
void usage(void) static void usage(void)
{ {
printf printf
("-N set nethash [--hashsize hashsize] [--probes probes ]\n" ("-N set nethash [--hashsize hashsize] [--probes probes ]\n"

View File

@@ -34,14 +34,14 @@
#define OPT_ADDDEL_PORT 0x01U #define OPT_ADDDEL_PORT 0x01U
/* Initialize the create. */ /* Initialize the create. */
void create_init(void *data) static void create_init(void *data)
{ {
DP("create INIT"); DP("create INIT");
/* Nothing */ /* Nothing */
} }
/* Function which parses command options; returns true if it ate an option */ /* 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 *mydata =
(struct ip_set_req_portmap_create *) data; (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. */ /* 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 *mydata =
(struct ip_set_req_portmap_create *) data; (struct ip_set_req_portmap_create *) data;
@@ -107,19 +107,19 @@ void create_final(void *data, unsigned int flags)
} }
/* Create commandline options */ /* Create commandline options */
static struct option create_opts[] = { static const struct option create_opts[] = {
{"from", 1, 0, '1'}, {"from", 1, 0, '1'},
{"to", 1, 0, '2'}, {"to", 1, 0, '2'},
{0} {NULL},
}; };
/* Add, del, test parser */ /* 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 *mydata =
(struct ip_set_req_portmap *) data; (struct ip_set_req_portmap *) data;
parse_port(optarg, &mydata->port); parse_port(arg, &mydata->port);
DP("%s", port_tostring(mydata->port, 0)); DP("%s", port_tostring(mydata->port, 0));
return 1; return 1;
@@ -129,7 +129,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data)
* Print and save * 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 *header =
(struct ip_set_req_portmap_create *) data; (struct ip_set_req_portmap_create *) data;
@@ -141,7 +141,7 @@ void initheader(struct set *set, const void *data)
map->last_port = header->to; 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 *mysetdata =
(struct ip_set_portmap *) set->settype->header; (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)); 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 *mysetdata =
(struct ip_set_portmap *) set->settype->header; (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); 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 *mysetdata =
(struct ip_set_portmap *) set->settype->header; (struct ip_set_portmap *) set->settype->header;
@@ -182,7 +184,8 @@ void saveheader(struct set *set, unsigned options)
port_tostring(mysetdata->last_port, 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 *mysetdata =
(struct ip_set_portmap *) set->settype->header; (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 printf
("-N set portmap --from PORT --to PORT\n" ("-N set portmap --from PORT --to PORT\n"