libxt_geoip: reorder option parsing code

This commit is contained in:
Jan Engelhardt
2008-08-24 12:34:31 -04:00
parent 006147a21e
commit 4f25eab39d

View File

@@ -175,33 +175,35 @@ static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '1': case '1':
// Ensure that XT_GEOIP_SRC *OR* XT_GEOIP_DST haven't been used yet.
if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST)) if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"geoip: only use --source-country *OR* --destination-country once!"); "geoip: Only exactly one of --source-country "
"or --destination-country must be specified!");
*flags |= XT_GEOIP_SRC; *flags |= XT_GEOIP_SRC;
break;
case '2':
// Ensure that XT_GEOIP_SRC *OR* XT_GEOIP_DST haven't been used yet.
if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
exit_error(PARAMETER_PROBLEM,
"geoip: only use --source-country *OR* --destination-country once!");
*flags |= XT_GEOIP_DST;
break;
default:
return 0;
}
if (invert) if (invert)
*flags |= XT_GEOIP_INV; *flags |= XT_GEOIP_INV;
info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem); info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem);
info->flags = *flags; info->flags = *flags;
return 1; return true;
case '2':
if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
exit_error(PARAMETER_PROBLEM,
"geoip: Only exactly one of --source-country "
"or --destination-country must be specified!");
*flags |= XT_GEOIP_DST;
if (invert)
*flags |= XT_GEOIP_INV;
info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem);
info->flags = *flags;
return true;
}
return false;
} }
static void static void