summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
-rw-r--r--extensions/libip6t_ah.c85
-rw-r--r--extensions/libip6t_dst.c72
-rw-r--r--extensions/libip6t_esp.c46
-rw-r--r--extensions/libip6t_fuzzy.c46
4 files changed, 117 insertions, 132 deletions
diff --git a/extensions/libip6t_ah.c b/extensions/libip6t_ah.c
index aced51bb..794e02eb 100644
--- a/extensions/libip6t_ah.c
+++ b/extensions/libip6t_ah.c
@@ -21,10 +21,10 @@ IPTABLES_VERSION);
}
static struct option opts[] = {
- { "ahspi", 1, 0, '1' },
- { "ahlen", 1, 0, '2' },
- { "ahres", 0, 0, '3' },
- {0}
+ { .name = "ahspi", .has_arg = 1, .flag = 0, .val = '1' },
+ { .name = "ahlen", .has_arg = 1, .flag = 0, .val = '2' },
+ { .name = "ahres", .has_arg = 0, .flag = 0, .val = '3' },
+ { .name = 0 }
};
static u_int32_t
@@ -33,21 +33,21 @@ parse_ah_spi(const char *spistr, const char *typestr)
unsigned long int spi;
char* ep;
- spi = strtoul(spistr,&ep,0) ;
+ spi = strtoul(spistr, &ep, 0);
- if ( spistr == ep ) {
+ if ( spistr == ep )
exit_error(PARAMETER_PROBLEM,
"AH no valid digits in %s `%s'", typestr, spistr);
- }
- if ( spi == ULONG_MAX && errno == ERANGE ) {
+
+ if ( spi == ULONG_MAX && errno == ERANGE )
exit_error(PARAMETER_PROBLEM,
"%s `%s' specified too big: would overflow",
typestr, spistr);
- }
- if ( *spistr != '\0' && *ep != '\0' ) {
+
+ if ( *spistr != '\0' && *ep != '\0' )
exit_error(PARAMETER_PROBLEM,
"AH error parsing %s `%s'", typestr, spistr);
- }
+
return (u_int32_t) spi;
}
@@ -59,13 +59,13 @@ parse_ah_spis(const char *spistring, u_int32_t *spis)
buffer = strdup(spistring);
if ((cp = strchr(buffer, ':')) == NULL)
- spis[0] = spis[1] = parse_ah_spi(buffer,"spi");
+ spis[0] = spis[1] = parse_ah_spi(buffer, "spi");
else {
*cp = '\0';
cp++;
- spis[0] = buffer[0] ? parse_ah_spi(buffer,"spi") : 0;
- spis[1] = cp[0] ? parse_ah_spi(cp,"spi") : 0xFFFFFFFF;
+ spis[0] = buffer[0] ? parse_ah_spi(buffer, "spi") : 0;
+ spis[1] = cp[0] ? parse_ah_spi(cp, "spi") : 0xFFFFFFFF;
}
free(buffer);
}
@@ -139,17 +139,10 @@ print_spis(const char *name, u_int32_t min, u_int32_t max,
const char *inv = invert ? "!" : "";
if (min != 0 || max != 0xFFFFFFFF || invert) {
- printf("%s", name);
- if (min == max) {
- printf(":%s", inv);
- printf("%u", min);
- } else {
- printf("s:%s", inv);
- printf("%u",min);
- printf(":");
- printf("%u",max);
- }
- printf(" ");
+ if (min == max)
+ printf("%s:%s%u ", name, inv, min);
+ else
+ printf("%ss:%s%u:%u ", name, inv, min, max);
}
}
@@ -158,12 +151,8 @@ print_len(const char *name, u_int32_t len, int invert)
{
const char *inv = invert ? "!" : "";
- if (len != 0 || invert) {
- printf("%s", name);
- printf(":%s", inv);
- printf("%u", len);
- printf(" ");
- }
+ if (len != 0 || invert)
+ printf("%s:%s%u ", name, inv, len);
}
/* Prints out the union ip6t_matchinfo. */
@@ -178,7 +167,10 @@ print(const struct ip6t_ip6 *ip,
ah->invflags & IP6T_AH_INV_SPI);
print_len("length", ah->hdrlen,
ah->invflags & IP6T_AH_INV_LEN);
- if (ah->hdrres) printf("reserved ");
+
+ if (ah->hdrres)
+ printf("reserved ");
+
if (ah->invflags & ~IP6T_AH_INV_MASK)
printf("Unknown invflags: 0x%X ",
ah->invflags & ~IP6T_AH_INV_MASK);
@@ -209,26 +201,23 @@ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match
ahinfo->hdrlen);
}
- if (ahinfo->hdrres != 0 ) {
+ if (ahinfo->hdrres != 0 )
printf("--ahres ");
- }
-
}
static
-struct ip6tables_match ah
-= { NULL,
- "ah",
- IPTABLES_VERSION,
- IP6T_ALIGN(sizeof(struct ip6t_ah)),
- IP6T_ALIGN(sizeof(struct ip6t_ah)),
- &help,
- &init,
- &parse,
- &final_check,
- &print,
- &save,
- opts
+struct ip6tables_match ah = {
+ .name = "ah",
+ .version = IPTABLES_VERSION,
+ .size = IP6T_ALIGN(sizeof(struct ip6t_ah)),
+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_ah)),
+ .help = &help,
+ .init = &init,
+ .parse = &parse,
+ .final_check = &final_check,
+ .print = &print,
+ .save = &save,
+ .extra_opts = opts
};
void
diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c
index b1327014..7eb64cd7 100644
--- a/extensions/libip6t_dst.c
+++ b/extensions/libip6t_dst.c
@@ -31,17 +31,17 @@ UNAME , IPTABLES_VERSION, LNAME, LNAME, IP6T_OPTS_OPTSNR);
#if HOPBYHOP
static struct option opts[] = {
- { "hbh-len", 1, 0, '1' },
- { "hbh-opts", 1, 0, '2' },
- { "hbh-not-strict", 1, 0, '3' },
- {0}
+ { .name = "hbh-len", .has_arg = 1, .flag = 0, .val = '1' },
+ { .name = "hbh-opts", .has_arg = 1, .flag = 0, .val = '2' },
+ { .name = "hbh-not-strict", .has_arg = 1, .flag = 0, .val = '3' },
+ { .name = 0 }
};
#else
static struct option opts[] = {
- { "dst-len", 1, 0, '1' },
- { "dst-opts", 1, 0, '2' },
- { "dst-not-strict", 1, 0, '3' },
- {0}
+ { .name = "dst-len", .has_arg = 1, .flag = 0, .val = '1' },
+ { .name = "dst-opts", .has_arg = 1, .flag = 0, .val = '2' },
+ { .name = "dst-not-strict", .has_arg = 1, .flag = 0, .val = '3' },
+ { .name = 0 }
};
#endif
@@ -51,7 +51,7 @@ parse_opts_num(const char *idstr, const char *typestr)
unsigned long int id;
char* ep;
- id = strtoul(idstr,&ep,0) ;
+ id = strtoul(idstr, &ep, 0);
if ( idstr == ep ) {
exit_error(PARAMETER_PROBLEM,
@@ -206,15 +206,19 @@ print(const struct ip6t_ip6 *ip,
const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data;
printf("%s ", LNAME);
- if (optinfo->flags & IP6T_OPTS_LEN) {
- printf("length");
- printf(":%s", optinfo->invflags & IP6T_OPTS_INV_LEN ? "!" : "");
- printf("%u", optinfo->hdrlen);
- printf(" ");
- }
- if (optinfo->flags & IP6T_OPTS_OPTS) printf("opts ");
+ if (optinfo->flags & IP6T_OPTS_LEN)
+ printf("length:%s%u ",
+ optinfo->invflags & IP6T_OPTS_INV_LEN ? "!" : "",
+ optinfo->hdrlen);
+
+ if (optinfo->flags & IP6T_OPTS_OPTS)
+ printf("opts ");
+
print_options(optinfo->optsnr, (u_int16_t *)optinfo->opts);
- if (optinfo->flags & IP6T_OPTS_NSTRICT) printf("not-strict ");
+
+ if (optinfo->flags & IP6T_OPTS_NSTRICT)
+ printf("not-strict ");
+
if (optinfo->invflags & ~IP6T_OPTS_INV_MASK)
printf("Unknown invflags: 0x%X ",
optinfo->invflags & ~IP6T_OPTS_INV_MASK);
@@ -231,30 +235,32 @@ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match
optinfo->hdrlen);
}
- if (optinfo->flags & IP6T_OPTS_OPTS) printf("--%s-opts ", LNAME);
+ if (optinfo->flags & IP6T_OPTS_OPTS)
+ printf("--%s-opts ", LNAME);
+
print_options(optinfo->optsnr, (u_int16_t *)optinfo->opts);
- if (optinfo->flags & IP6T_OPTS_NSTRICT) printf("--%s-not-strict ", LNAME);
+ if (optinfo->flags & IP6T_OPTS_NSTRICT)
+ printf("--%s-not-strict ", LNAME);
}
static
-struct ip6tables_match optstruct
-= { NULL,
+struct ip6tables_match optstruct = {
#if HOPBYHOP
- "hbh",
+ .name = "hbh",
#else
- "dst",
+ .name = "dst",
#endif
- IPTABLES_VERSION,
- IP6T_ALIGN(sizeof(struct ip6t_opts)),
- IP6T_ALIGN(sizeof(struct ip6t_opts)),
- &help,
- &init,
- &parse,
- &final_check,
- &print,
- &save,
- opts
+ .version = IPTABLES_VERSION,
+ .size = IP6T_ALIGN(sizeof(struct ip6t_opts)),
+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_opts)),
+ .help = &help,
+ .init = &init,
+ .parse = &parse,
+ .final = &final_check,
+ .print = &print,
+ .save = &save,
+ .extra_opts = opts
};
void
diff --git a/extensions/libip6t_esp.c b/extensions/libip6t_esp.c
index 3b471026..29e865d4 100644
--- a/extensions/libip6t_esp.c
+++ b/extensions/libip6t_esp.c
@@ -19,8 +19,8 @@ IPTABLES_VERSION);
}
static struct option opts[] = {
- { "espspi", 1, 0, '1' },
- {0}
+ { .name = "espspi", .has_arg = 1, .flag = 0, .val = '1' },
+ { .name = 0 }
};
static u_int32_t
@@ -29,7 +29,7 @@ parse_esp_spi(const char *spistr)
unsigned long int spi;
char* ep;
- spi = strtoul(spistr,&ep,0) ;
+ spi = strtoul(spistr, &ep, 0);
if ( spistr == ep ) {
exit_error(PARAMETER_PROBLEM,
@@ -117,17 +117,10 @@ print_spis(const char *name, u_int32_t min, u_int32_t max,
const char *inv = invert ? "!" : "";
if (min != 0 || max != 0xFFFFFFFF || invert) {
- printf("%s", name);
- if (min == max) {
- printf(":%s", inv);
- printf("%u", min);
- } else {
- printf("s:%s", inv);
- printf("%u",min);
- printf(":");
- printf("%u",max);
- }
- printf(" ");
+ if (min == max)
+ printf("%s:%s%u ", name, inv, min);
+ else
+ printf("%ss:%s%u:%u ", name, inv, min, max);
}
}
@@ -168,19 +161,18 @@ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match
}
static
-struct ip6tables_match esp
-= { NULL,
- "esp",
- IPTABLES_VERSION,
- IP6T_ALIGN(sizeof(struct ip6t_esp)),
- IP6T_ALIGN(sizeof(struct ip6t_esp)),
- &help,
- &init,
- &parse,
- &final_check,
- &print,
- &save,
- opts
+struct ip6tables_match esp = {
+ .name = "esp",
+ .version = IPTABLES_VERSION,
+ .size = IP6T_ALIGN(sizeof(struct ip6t_esp)),
+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_esp)),
+ .help = &help,
+ .init = &init,
+ .parse = &parse,
+ .final_check = &final_check,
+ .print = &print,
+ .save = &save,
+ .extra_opts = opts
};
void
diff --git a/extensions/libip6t_fuzzy.c b/extensions/libip6t_fuzzy.c
index 95a59cb3..65c2acfd 100644
--- a/extensions/libip6t_fuzzy.c
+++ b/extensions/libip6t_fuzzy.c
@@ -34,9 +34,9 @@ help(void)
};
static struct option opts[] = {
- { "lower-limit", 1 , 0 , '1' } ,
- { "upper-limit", 1 , 0 , '2' } ,
- { 0 }
+ { .name = "lower-limit", .has_arg = 1, .flag = 0, .val = '1' },
+ { .name = "upper-limit", .has_arg = 1, .flag = 0, .val = '2' },
+ { .name = 0 }
};
/* Initialize data structures */
@@ -64,8 +64,8 @@ parse(int c, char **argv, int invert, unsigned int *flags,
unsigned int *nfcache,
struct ip6t_entry_match **match)
{
-
-struct ip6t_fuzzy_info *fuzzyinfo = (struct ip6t_fuzzy_info *)(*match)->data;
+ struct ip6t_fuzzy_info *fuzzyinfo =
+ (struct ip6t_fuzzy_info *)(*match)->data;
u_int32_t num;
@@ -99,7 +99,7 @@ struct ip6t_fuzzy_info *fuzzyinfo = (struct ip6t_fuzzy_info *)(*match)->data;
if (string_to_number(optarg,1,MAXFUZZYRATE,&num) == -1 || num < 1)
exit_error(PARAMETER_PROBLEM,"BAD --upper-limit");
- fuzzyinfo->maximum_rate = num ;
+ fuzzyinfo->maximum_rate = num;
*flags |= IP6T_FUZZY_OPT_MAXIMUM;
@@ -123,8 +123,8 @@ print(const struct ip6t_ip6 *ipv6,
const struct ip6t_fuzzy_info *fuzzyinfo
= (const struct ip6t_fuzzy_info *)match->data;
- printf(" fuzzy: lower limit = %u pps - upper limit = %u pps ",fuzzyinfo->minimum_rate,fuzzyinfo->maximum_rate);
-
+ printf(" fuzzy: lower limit = %u pps - upper limit = %u pps ",
+ fuzzyinfo->minimum_rate, fuzzyinfo->maximum_rate);
}
/* Saves the union ip6t_targinfo in parsable form to stdout. */
@@ -134,24 +134,22 @@ save(const struct ip6t_ip6 *ipv6, const struct ip6t_entry_match *match)
const struct ip6t_fuzzy_info *fuzzyinfo
= (const struct ip6t_fuzzy_info *)match->data;
- printf("--lower-limit %u ",fuzzyinfo->minimum_rate);
- printf("--upper-limit %u ",fuzzyinfo->maximum_rate);
-
+ printf("--lower-limit %u --upper-limit %u ",
+ fuzzyinfo->minimum_rate, fuzzyinfo->maximum_rate);
}
-struct ip6tables_match fuzzy_match
-= { NULL,
- "fuzzy",
- IPTABLES_VERSION,
- IP6T_ALIGN(sizeof(struct ip6t_fuzzy_info)),
- IP6T_ALIGN(sizeof(struct ip6t_fuzzy_info)),
- &help,
- &init,
- &parse,
- &final_check,
- &print,
- &save,
- opts
+struct ip6tables_match fuzzy_match = {
+ .name = "fuzzy",
+ .version = IPTABLES_VERSION,
+ .size = IP6T_ALIGN(sizeof(struct ip6t_fuzzy_info)),
+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_fuzzy_info)),
+ .help = &help,
+ .init = &init,
+ .parse = &parse,
+ .final_check = &final_check,
+ .print = &print,
+ .save = &save,
+ .extra_opts = opts
};
void _init(void)