]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: prefix/order - modprobe and xtables.ko loading
authorJan Engelhardt <jengelh@medozas.de>
Tue, 27 Jan 2009 14:10:05 +0000 (15:10 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 27 Jan 2009 22:14:29 +0000 (23:14 +0100)
This change affects:
load_xtables_ko -> xtables_load_ko
modprobe_program -> xtables_modprobe_program
Now uses bool for the "quiet" flag.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
include/xtables.h.in
include/xtables/internal.h
ip6tables-restore.c
ip6tables.c
iptables-restore.c
iptables.c
xtables.c

index e63d171e40a07dbed24e49a00143573e24957d6b..2512d79f8ea54c8eb8c11f805869c2384449ab75 100644 (file)
@@ -140,9 +140,14 @@ struct xtables_target
 #endif
 };
 
+extern const char *xtables_modprobe_program;
+
 extern void *xtables_calloc(size_t, size_t);
 extern void *xtables_malloc(size_t);
 
+extern int xtables_insmod(const char *, const char *, bool);
+extern int xtables_load_ko(const char *, bool);
+
 /* Your shared library should call one of these. */
 extern void xtables_register_match(struct xtables_match *me);
 extern void xtables_register_target(struct xtables_target *me);
index 6b78d3a8405881f32abeefe43a82101819d3bfc1..62fe2edb3e081977aeb0020d1c28b61e8fadbb02 100644 (file)
@@ -43,10 +43,6 @@ struct xtables_rule_match {
 
 extern char *lib_dir;
 
-extern const char *modprobe_program;
-extern int xtables_insmod(const char *modname, const char *modprobe, int quiet);
-extern int load_xtables_ko(const char *modprobe, int quiet);
-
 /* This is decleared in ip[6]tables.c */
 extern struct afinfo afinfo;
 
index a84c2e3e36b6887f16dd1b1b95a0aa6244555637..097711f3557ae67550a53ae8498d374dea001d61 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <getopt.h>
 #include <sys/errno.h>
+#include <stdbool.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -64,7 +65,7 @@ static struct ip6tc_handle *create_handle(const char *tablename)
 
        if (!handle) {
                /* try to insmod the module if iptc_init failed */
-               load_xtables_ko(modprobe_program, 0);
+               xtables_load_ko(xtables_modprobe_program, false);
                handle = ip6tc_init(tablename);
        }
 
@@ -165,7 +166,7 @@ int main(int argc, char *argv[])
                                noflush = 1;
                                break;
                        case 'M':
-                               modprobe_program = optarg;
+                               xtables_modprobe_program = optarg;
                                break;
                }
        }
index a3b84bdd23bb50e6ebf3e0e29edb091f26119985..ea8d80d13565f7279d0bc41910f65a0623165272 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <limits.h>
 #include <ip6tables.h>
 #include <xtables.h>
@@ -1769,7 +1770,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                        break;
 
                case 'M':
-                       modprobe_program = optarg;
+                       xtables_modprobe_program = optarg;
                        break;
 
                case 'c':
@@ -1967,7 +1968,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                *handle = ip6tc_init(*table);
 
        /* try to insmod the module if iptc_init failed */
-       if (!*handle && load_xtables_ko(modprobe_program, 0) != -1)
+       if (!*handle && xtables_load_ko(xtables_modprobe_program, false) != -1)
                *handle = ip6tc_init(*table);
 
        if (!*handle)
index 7cc6d6dcb8fbdba4f613bbd63a2e356b7e3c1523..3fbc90870f440422034a4143da0d747ff850cf2c 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <getopt.h>
 #include <sys/errno.h>
+#include <stdbool.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -63,7 +64,7 @@ static struct iptc_handle *create_handle(const char *tablename)
 
        if (!handle) {
                /* try to insmod the module if iptc_init failed */
-               load_xtables_ko(modprobe_program, 0);
+               xtables_load_ko(xtables_modprobe_program, false);
                handle = iptc_init(tablename);
        }
 
@@ -167,7 +168,7 @@ main(int argc, char *argv[])
                                noflush = 1;
                                break;
                        case 'M':
-                               modprobe_program = optarg;
+                               xtables_modprobe_program = optarg;
                                break;
                        case 'T':
                                tablename = optarg;
index 8068cc80772abafe52408a4e1d994428bb1585e1..75fe583171c9197929796a16c72b06576f866aad 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <netdb.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -1786,7 +1787,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
                        break;
 
                case 'M':
-                       modprobe_program = optarg;
+                       xtables_modprobe_program = optarg;
                        break;
 
                case 'c':
@@ -1996,7 +1997,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
                *handle = iptc_init(*table);
 
        /* try to insmod the module if iptc_init failed */
-       if (!*handle && load_xtables_ko(modprobe_program, 0) != -1)
+       if (!*handle && xtables_load_ko(xtables_modprobe_program, false) != -1)
                *handle = iptc_init(*table);
 
        if (!*handle)
index 564b27e9b39bdeef5ff7ec5427a673c526e6294e..c9721b63f493bf339196f550ecb1ce6c47a07dbb 100644 (file)
--- a/xtables.c
+++ b/xtables.c
@@ -47,7 +47,7 @@
 char *lib_dir;
 
 /* the path to command to load kernel module */
-const char *modprobe_program = NULL;
+const char *xtables_modprobe_program;
 
 /* Keeping track of external matches and targets: linked lists.  */
 struct xtables_match *xtables_matches;
@@ -108,7 +108,7 @@ static char *get_modprobe(void)
        return NULL;
 }
 
-int xtables_insmod(const char *modname, const char *modprobe, int quiet)
+int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
 {
        char *buf = NULL;
        char *argv[4];
@@ -150,9 +150,9 @@ int xtables_insmod(const char *modname, const char *modprobe, int quiet)
        return -1;
 }
 
-int load_xtables_ko(const char *modprobe, int quiet)
+int xtables_load_ko(const char *modprobe, bool quiet)
 {
-       static int loaded = 0;
+       static bool loaded = false;
        static int ret = -1;
 
        if (!loaded) {
@@ -502,7 +502,7 @@ static int compatible_revision(const char *name, u_int8_t revision, int opt)
                exit(1);
        }
 
-       load_xtables_ko(modprobe_program, 1);
+       xtables_load_ko(xtables_modprobe_program, true);
 
        strcpy(rev.name, name);
        rev.revision = revision;