]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
authorJamal Hadi Salim <hadi@cyberus.ca>
Wed, 11 Feb 2009 12:03:34 +0000 (13:03 +0100)
committerPatrick McHardy <kaber@trash.net>
Wed, 11 Feb 2009 12:03:34 +0000 (13:03 +0100)
convert ip6tables, iptables and iptables-xml to use
xtables_globals/xtables_set_params()

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Makefile.am
ip6tables.c
iptables-xml.c
iptables.c

index 0ffb978509c6591d600370f7e8a265137974cf6b..96de1b2eed65f241b62042b1b198c0e2c93aeebb 100644 (file)
@@ -21,6 +21,7 @@ iptables_SOURCES          = iptables-standalone.c iptables.c
 iptables_LDFLAGS          = -rdynamic
 iptables_LDADD            = -ldl -lm libiptc/libiptc.a extensions/libext4.a libxtables.la
 
+iptables_xml_LDADD        = -ldl libxtables.la
 iptables_multi_SOURCES    = iptables-multi.c iptables-save.c \
                             iptables-restore.c iptables-xml.c \
                             iptables-standalone.c iptables.c
index 233974f2539138af3e66259930b718ccbdeb4fdc..7561353f8288e3b26fed548df3ec588761b01e95 100644 (file)
@@ -145,6 +145,13 @@ int line = -1;
 
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
+struct xtables_globals ip6tables_globals = {
+       .option_offset = 0,
+       .program_version = IPTABLES_VERSION,
+       .program_name = "ip6tables",
+       .opts = original_opts,
+       .exit_error = exit_error,
+};
 
 /* Table of legal combinations of commands and options.  If any of the
  * given commands make an option legal, that option is legal (applies to
@@ -1371,6 +1378,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
            demand-load a protocol. */
        opterr = 0;
 
+       xtables_set_params(&ip6tables_globals);
        while ((c = getopt_long(argc, argv,
           "-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:",
                                           opts, NULL)) != -1) {
index 307845c5b553d0cc0f02f32477b3a462107043b1..329c5983cf2cdb0b733fbcec4c2e352d1bf0b335 100644 (file)
@@ -17,6 +17,7 @@
 #include "iptables.h"
 #include "libiptc/libiptc.h"
 #include "iptables-multi.h"
+#include <xtables.h>
 
 #ifdef DEBUG
 #define DEBUGP(x, args...) fprintf(stderr, x, ## args)
@@ -629,6 +630,12 @@ do_rule(char *pcnt, char *bcnt, int argc, char *argv[], int argvattr[])
        do_rule_part(NULL, NULL, 1, argc, argv, argvattr);
 }
 
+struct xtables_globals iptables_xml_globals = {
+       .option_offset = 0,
+       .program_version = IPTABLES_VERSION,
+       .program_name = "iptables-xml",
+       .exit_error = exit_error,
+};
 
 #ifdef IPTABLES_MULTI
 int
@@ -646,6 +653,7 @@ main(int argc, char *argv[])
        program_version = IPTABLES_VERSION;
        line = 0;
 
+       xtables_set_params(&iptables_xml_globals);
        while ((c = getopt_long(argc, argv, "cvh", options, NULL)) != -1) {
                switch (c) {
                case 'c':
index f1a5d33edfd361f8901ed352d79b8deb486219f5..e8bed8779c4f2c61de5704509fe43dd853ac97c6 100644 (file)
@@ -145,6 +145,14 @@ int line = -1;
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 
+struct xtables_globals iptables_globals = {
+       .option_offset = 0,
+       .program_version = IPTABLES_VERSION,
+       .program_name = "iptables",
+       .opts = original_opts,
+       .exit_error = exit_error,
+};
+
 /* Table of legal combinations of commands and options.  If any of the
  * given commands make an option legal, that option is legal (applies to
  * CMD_LIST and CMD_ZERO only).
@@ -1393,6 +1401,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
            demand-load a protocol. */
        opterr = 0;
 
+       xtables_set_params(&iptables_globals);
        while ((c = getopt_long(argc, argv,
           "-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
                                           opts, NULL)) != -1) {