geoip: minor cleanups in help, opts and logic

This commit is contained in:
Jan Engelhardt
2008-03-21 06:11:22 +01:00
parent 5d431b45f1
commit cd7c8fc4fa
2 changed files with 18 additions and 20 deletions

View File

@@ -31,27 +31,23 @@
static void geoip_help(void) static void geoip_help(void)
{ {
printf ( printf (
"GeoIP v%s options:\n" "geoip match options:\n"
" [!] --src-cc, --source-country country[,country,country,...]\n" "[!] --src-cc, --source-country country[,country...]\n"
" Match packet coming from (one of)\n" " Match packet coming from (one of) the specified country(ies)\n"
" the specified country(ies)\n" "[!] --dst-cc, --destination-country country[,country...]\n"
" Match packet going to (one of) the specified country(ies)\n"
"\n" "\n"
" [!] --dst-cc, --destination-country country[,country,country,...]\n" "NOTE: The country is inputed by its ISO3166 code.\n"
" Match packet going to (one of)\n"
" the specified country(ies)\n"
"\n" "\n"
" NOTE: The country is inputed by its ISO3166 code.\n"
"\n"
"\n", XTABLES_VERSION
); );
} }
static struct option geoip_opts[] = { static struct option geoip_opts[] = {
{ "dst-cc", 1, 0, '2' }, /* Alias for --destination-country */ {.name = "dst-cc", .has_arg = true, .val = '2'},
{ "destination-country", 1, 0, '2' }, {.name = "destination-country", .has_arg = true, .val = '2'},
{ "src-cc", 1, 0, '1' }, /* Alias for --source-country */ {.name = "src-cc", .has_arg = true, .val = '1'},
{ "source-country", 1, 0, '1' }, {.name = "source-country", .has_arg = true, .val = '1'},
{ 0 }, {NULL},
}; };
static struct geoip_subnet *geoip_get_subnets(const char *code, uint32_t *count) static struct geoip_subnet *geoip_get_subnets(const char *code, uint32_t *count)
@@ -127,7 +123,7 @@ check_geoip_cc(char *cc, u_int16_t cc_used[], u_int8_t count)
* going to change someday, this whole * going to change someday, this whole
* match will need to be rewritten, anyway. * match will need to be rewritten, anyway.
* - SJ */ * - SJ */
cc_int16 = (cc[0]<<8) + cc[1]; cc_int16 = (cc[0] << 8) | cc[1];
// Check for presence of value in cc_used // Check for presence of value in cc_used
for (i = 0; i < count; i++) for (i = 0; i < count; i++)

View File

@@ -13,11 +13,13 @@
#ifndef _LINUX_NETFILTER_XT_GEOIP_H #ifndef _LINUX_NETFILTER_XT_GEOIP_H
#define _LINUX_NETFILTER_XT_GEOIP_H 1 #define _LINUX_NETFILTER_XT_GEOIP_H 1
#define XT_GEOIP_SRC 0x01 /* Perform check on Source IP */ enum {
#define XT_GEOIP_DST 0x02 /* Perform check on Destination IP */ XT_GEOIP_SRC = 1 << 0, /* Perform check on Source IP */
#define XT_GEOIP_INV 0x04 /* Negate the condition */ XT_GEOIP_DST = 1 << 1, /* Perform check on Destination IP */
XT_GEOIP_INV = 1 << 2, /* Negate the condition */
#define XT_GEOIP_MAX 15 /* Maximum of countries */ XT_GEOIP_MAX = 15, /* Maximum of countries */
};
/* Yup, an address range will be passed in with host-order */ /* Yup, an address range will be passed in with host-order */
struct geoip_subnet { struct geoip_subnet {