From eb6e65e1ccfb52457d461b72cf5abe4e9f7187c6 Mon Sep 17 00:00:00 2001 From: Yasuyuki KOZAKAI Date: Tue, 24 Jul 2007 06:45:03 +0000 Subject: Use unified API in multiport match --- extensions/libipt_multiport.c | 96 ++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 46 deletions(-) (limited to 'extensions') diff --git a/extensions/libipt_multiport.c b/extensions/libipt_multiport.c index 6de25c3b..b6d2dffc 100644 --- a/extensions/libipt_multiport.c +++ b/extensions/libipt_multiport.c @@ -4,9 +4,11 @@ #include #include #include -#include + +#include +#include /* To ensure that iptables compiles with an old kernel */ -#include "../include/linux/netfilter_ipv4/ipt_multiport.h" +#include "../include/linux/netfilter/xt_multiport.h" /* Function which prints out usage message. */ static void @@ -79,7 +81,7 @@ parse_multi_ports(const char *portstring, u_int16_t *ports, const char *proto) buffer = strdup(portstring); if (!buffer) exit_error(OTHER_PROBLEM, "strdup failed"); - for (cp=buffer, i=0; cp && ipflags[i] = 0; - for (cp=buffer, i=0; cp && iip.invflags & IPT_INV_PROTO) + if (entry->ip.invflags & XT_INV_PROTO) exit_error(PARAMETER_PROBLEM, "multiport only works with TCP, UDP, UDPLITE, SCTP and DCCP"); @@ -167,8 +169,8 @@ parse(int c, char **argv, int invert, unsigned int *flags, { const struct ipt_entry *entry = e; const char *proto; - struct ipt_multiport *multiinfo - = (struct ipt_multiport *)(*match)->data; + struct xt_multiport *multiinfo + = (struct xt_multiport *)(*match)->data; switch (c) { case '1': @@ -176,7 +178,7 @@ parse(int c, char **argv, int invert, unsigned int *flags, proto = check_proto(entry); multiinfo->count = parse_multi_ports(argv[optind-1], multiinfo->ports, proto); - multiinfo->flags = IPT_MULTIPORT_SOURCE; + multiinfo->flags = XT_MULTIPORT_SOURCE; break; case '2': @@ -184,7 +186,7 @@ parse(int c, char **argv, int invert, unsigned int *flags, proto = check_proto(entry); multiinfo->count = parse_multi_ports(argv[optind-1], multiinfo->ports, proto); - multiinfo->flags = IPT_MULTIPORT_DESTINATION; + multiinfo->flags = XT_MULTIPORT_DESTINATION; break; case '3': @@ -192,7 +194,7 @@ parse(int c, char **argv, int invert, unsigned int *flags, proto = check_proto(entry); multiinfo->count = parse_multi_ports(argv[optind-1], multiinfo->ports, proto); - multiinfo->flags = IPT_MULTIPORT_EITHER; + multiinfo->flags = XT_MULTIPORT_EITHER; break; default: @@ -218,29 +220,29 @@ parse_v1(int c, char **argv, int invert, unsigned int *flags, { const struct ipt_entry *entry = e; const char *proto; - struct ipt_multiport_v1 *multiinfo - = (struct ipt_multiport_v1 *)(*match)->data; + struct xt_multiport_v1 *multiinfo + = (struct xt_multiport_v1 *)(*match)->data; switch (c) { case '1': check_inverse(argv[optind-1], &invert, &optind, 0); proto = check_proto(entry); parse_multi_ports_v1(argv[optind-1], multiinfo, proto); - multiinfo->flags = IPT_MULTIPORT_SOURCE; + multiinfo->flags = XT_MULTIPORT_SOURCE; break; case '2': check_inverse(argv[optind-1], &invert, &optind, 0); proto = check_proto(entry); parse_multi_ports_v1(argv[optind-1], multiinfo, proto); - multiinfo->flags = IPT_MULTIPORT_DESTINATION; + multiinfo->flags = XT_MULTIPORT_DESTINATION; break; case '3': check_inverse(argv[optind-1], &invert, &optind, 0); proto = check_proto(entry); parse_multi_ports_v1(argv[optind-1], multiinfo, proto); - multiinfo->flags = IPT_MULTIPORT_EITHER; + multiinfo->flags = XT_MULTIPORT_EITHER; break; default: @@ -294,22 +296,22 @@ print(const void *ip_void, int numeric) { const struct ipt_ip *ip = ip_void; - const struct ipt_multiport *multiinfo - = (const struct ipt_multiport *)match->data; + const struct xt_multiport *multiinfo + = (const struct xt_multiport *)match->data; unsigned int i; printf("multiport "); switch (multiinfo->flags) { - case IPT_MULTIPORT_SOURCE: + case XT_MULTIPORT_SOURCE: printf("sports "); break; - case IPT_MULTIPORT_DESTINATION: + case XT_MULTIPORT_DESTINATION: printf("dports "); break; - case IPT_MULTIPORT_EITHER: + case XT_MULTIPORT_EITHER: printf("ports "); break; @@ -331,22 +333,22 @@ print_v1(const void *ip_void, int numeric) { const struct ipt_ip *ip = ip_void; - const struct ipt_multiport_v1 *multiinfo - = (const struct ipt_multiport_v1 *)match->data; + const struct xt_multiport_v1 *multiinfo + = (const struct xt_multiport_v1 *)match->data; unsigned int i; printf("multiport "); switch (multiinfo->flags) { - case IPT_MULTIPORT_SOURCE: + case XT_MULTIPORT_SOURCE: printf("sports "); break; - case IPT_MULTIPORT_DESTINATION: + case XT_MULTIPORT_DESTINATION: printf("dports "); break; - case IPT_MULTIPORT_EITHER: + case XT_MULTIPORT_EITHER: printf("ports "); break; @@ -373,20 +375,20 @@ print_v1(const void *ip_void, static void save(const void *ip_void, const struct xt_entry_match *match) { const struct ipt_ip *ip = ip_void; - const struct ipt_multiport *multiinfo - = (const struct ipt_multiport *)match->data; + const struct xt_multiport *multiinfo + = (const struct xt_multiport *)match->data; unsigned int i; switch (multiinfo->flags) { - case IPT_MULTIPORT_SOURCE: + case XT_MULTIPORT_SOURCE: printf("--sports "); break; - case IPT_MULTIPORT_DESTINATION: + case XT_MULTIPORT_DESTINATION: printf("--dports "); break; - case IPT_MULTIPORT_EITHER: + case XT_MULTIPORT_EITHER: printf("--ports "); break; } @@ -402,20 +404,20 @@ static void save_v1(const void *ip_void, const struct xt_entry_match *match) { const struct ipt_ip *ip = ip_void; - const struct ipt_multiport_v1 *multiinfo - = (const struct ipt_multiport_v1 *)match->data; + const struct xt_multiport_v1 *multiinfo + = (const struct xt_multiport_v1 *)match->data; unsigned int i; switch (multiinfo->flags) { - case IPT_MULTIPORT_SOURCE: + case XT_MULTIPORT_SOURCE: printf("--sports "); break; - case IPT_MULTIPORT_DESTINATION: + case XT_MULTIPORT_DESTINATION: printf("--dports "); break; - case IPT_MULTIPORT_EITHER: + case XT_MULTIPORT_EITHER: printf("--ports "); break; } @@ -434,13 +436,14 @@ static void save_v1(const void *ip_void, printf(" "); } -static struct iptables_match multiport = { +static struct xtables_match multiport = { .next = NULL, + .family = AF_INET, .name = "multiport", .revision = 0, .version = IPTABLES_VERSION, - .size = IPT_ALIGN(sizeof(struct ipt_multiport)), - .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport)), + .size = XT_ALIGN(sizeof(struct xt_multiport)), + .userspacesize = XT_ALIGN(sizeof(struct xt_multiport)), .help = &help, .init = &init, .parse = &parse, @@ -450,13 +453,14 @@ static struct iptables_match multiport = { .extra_opts = opts }; -static struct iptables_match multiport_v1 = { +static struct xtables_match multiport_v1 = { .next = NULL, + .family = AF_INET, .name = "multiport", .version = IPTABLES_VERSION, .revision = 1, - .size = IPT_ALIGN(sizeof(struct ipt_multiport_v1)), - .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport_v1)), + .size = XT_ALIGN(sizeof(struct xt_multiport_v1)), + .userspacesize = XT_ALIGN(sizeof(struct xt_multiport_v1)), .help = &help_v1, .init = &init, .parse = &parse_v1, @@ -469,6 +473,6 @@ static struct iptables_match multiport_v1 = { void _init(void) { - register_match(&multiport); - register_match(&multiport_v1); + xtables_register_match(&multiport); + xtables_register_match(&multiport_v1); } -- cgit v1.2.3