From 7b0ff352fa289f4b8ec398c36c07e01acc7cc413 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=kadlec/emailAddress=kadlec@netfilter.org" Date: Thu, 24 Nov 2005 09:31:53 +0000 Subject: Several fixes by Jones Desougi: missing or confusing error message fixes for ipporthash minor correction in debugging in nethash unified memory allocations in ipset --- ipset_ipporthash.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'ipset_ipporthash.c') diff --git a/ipset_ipporthash.c b/ipset_ipporthash.c index e615cea..1ebbc50 100644 --- a/ipset_ipporthash.c +++ b/ipset_ipporthash.c @@ -38,7 +38,7 @@ #define OPT_CREATE_RESIZE 0x04U #define OPT_CREATE_NETWORK 0x08U #define OPT_CREATE_FROM 0x10U -#define OPT_CREATE_TO 0x10U +#define OPT_CREATE_TO 0x20U /* Initialize the create. */ void create_init(void *data) @@ -156,21 +156,20 @@ void create_final(void *data, unsigned int flags) mydata->hashsize, mydata->probes, mydata->resize); #endif - if (flags == 0) - exit_error(PARAMETER_PROBLEM, - "Need to specify --from and --to, or --network\n"); - if (flags & OPT_CREATE_NETWORK) { /* --network */ if ((flags & OPT_CREATE_FROM) || (flags & OPT_CREATE_TO)) exit_error(PARAMETER_PROBLEM, "Can't specify --from or --to with --network\n"); - } else { + } else if (flags & (OPT_CREATE_FROM | OPT_CREATE_TO)) { /* --from --to */ - if ((flags & OPT_CREATE_FROM) == 0 - || (flags & OPT_CREATE_TO) == 0) + if (!(flags & OPT_CREATE_FROM) || !(flags & OPT_CREATE_TO)) exit_error(PARAMETER_PROBLEM, "Need to specify both --from and --to\n"); + } else { + exit_error(PARAMETER_PROBLEM, + "Need to specify --from and --to, or --network\n"); + } DP("from : %x to: %x diff: %x", @@ -179,7 +178,7 @@ void create_final(void *data, unsigned int flags) if (mydata->from > mydata->to) exit_error(PARAMETER_PROBLEM, - "From can't be lower than to.\n"); + "From can't be higher than to.\n"); if (mydata->to - mydata->from > MAX_RANGE) exit_error(PARAMETER_PROBLEM, @@ -203,7 +202,7 @@ ip_set_ip_t adt_parser(unsigned cmd, const char *optarg, void *data) { struct ip_set_req_ipporthash *mydata = (struct ip_set_req_ipporthash *) data; - char *saved = strdup(optarg); + char *saved = ipset_strdup(optarg); char *ptr, *tmp = saved; DP("ipporthash: %p %p", optarg, data); @@ -331,9 +330,9 @@ void usage(void) " [--hashsize hashsize] [--probes probes ] [--resize resize]\n" "-N set ipporthash --network IP/mask\n" " [--hashsize hashsize] [--probes probes ] [--resize resize]\n" - "-A set IP\n" - "-D set IP\n" - "-T set IP\n"); + "-A set IP%%port\n" + "-D set IP%%port\n" + "-T set IP%%port\n"); } static struct settype settype_ipporthash = { -- cgit v1.2.3