]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
geoip: minor cleanups in help, opts and logic
authorJan Engelhardt <jengelh@computergmbh.de>
Fri, 21 Mar 2008 05:11:22 +0000 (06:11 +0100)
committerJan Engelhardt <jengelh@computergmbh.de>
Sat, 22 Mar 2008 02:59:58 +0000 (03:59 +0100)
extensions/libxt_geoip.c
extensions/xt_geoip.h

index c1aeb0c95ae1e8d643a9778f07c8bbc5a3c8a98f..1783a852fbc2b912d157f37dc1686ac0b74a8cdd 100644 (file)
 static void geoip_help(void)
 {
        printf (
-       "GeoIP v%s options:\n"
-       "        [!]   --src-cc, --source-country country[,country,country,...]\n"
-       "                                                     Match packet coming from (one of)\n"
-       "                                                     the specified country(ies)\n"
+       "geoip match options:\n"
+       "[!] --src-cc, --source-country country[,country...]\n"
+       "       Match packet coming from (one of) the specified country(ies)\n"
+       "[!] --dst-cc, --destination-country country[,country...]\n"
+       "       Match packet going to (one of) the specified country(ies)\n"
        "\n"
-       "        [!]   --dst-cc, --destination-country country[,country,country,...]\n"
-       "                                                     Match packet going to (one of)\n"
-       "                                                     the specified country(ies)\n"
+       "NOTE: The country is inputed by its ISO3166 code.\n"
        "\n"
-       "           NOTE: The country is inputed by its ISO3166 code.\n"
-       "\n"
-       "\n", XTABLES_VERSION
        );
 }
 
 static struct option geoip_opts[] = {
-       {  "dst-cc",  1, 0, '2'  }, /* Alias for --destination-country */
-       {  "destination-country",   1, 0, '2'  },
-       {  "src-cc",  1, 0, '1'  }, /* Alias for --source-country */
-       {  "source-country",  1, 0, '1'  },
-       {  0  },
+       {.name = "dst-cc",              .has_arg = true, .val = '2'},
+       {.name = "destination-country", .has_arg = true, .val = '2'},
+       {.name = "src-cc",              .has_arg = true, .val = '1'},
+       {.name = "source-country",      .has_arg = true, .val = '1'},
+       {NULL},
 };
 
 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
         *                       match will need to be rewritten, anyway.
         *                                                                                       - SJ  */
-       cc_int16 = (cc[0]<<8) + cc[1];
+       cc_int16 = (cc[0] << 8) | cc[1];
 
        // Check for presence of value in cc_used
        for (i = 0; i < count; i++)
index 4188a719f5a3fb7bbf211ff3bbb6dc97ed676b57..291c1087d0e2d392fa703b5e9a224bb492a7943a 100644 (file)
 #ifndef _LINUX_NETFILTER_XT_GEOIP_H
 #define _LINUX_NETFILTER_XT_GEOIP_H 1
 
-#define XT_GEOIP_SRC         0x01     /* Perform check on Source IP */
-#define XT_GEOIP_DST         0x02     /* Perform check on Destination IP */
-#define XT_GEOIP_INV         0x04     /* Negate the condition */
+enum {
+       XT_GEOIP_SRC = 1 << 0,  /* Perform check on Source IP */
+       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 */
 struct geoip_subnet {