]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libiptc: use a family-invariant xtc_ops struct for code reduction
authorJan Engelhardt <jengelh@medozas.de>
Sat, 27 Aug 2011 10:50:32 +0000 (12:50 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Sun, 11 Sep 2011 15:31:35 +0000 (17:31 +0200)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
include/libiptc/libip6tc.h
include/libiptc/libiptc.h
include/libiptc/xtcshared.h
libiptc/Makefile.am
libiptc/libip4tc.c
libiptc/libip6tc.c
libiptc/libiptc.c

index 61c1e7f53baedc0fb09d4f662016bdc59e0996a7..c656bc432afcce2abc4fb132f1accaf3f8c3ef9a 100644 (file)
@@ -159,4 +159,6 @@ int ipv6_prefix_length(const struct in6_addr *a);
 
 extern void dump_entries6(struct xtc_handle *const);
 
+extern const struct xtc_ops ip6tc_ops;
+
 #endif /* _LIBIP6TC_H */
index 6f64f5a90745970b0bc9c5a39dffb040ef9b3631..24cdbdb79fddc6fe2dc1b5c78db6e15b6cd48e7f 100644 (file)
@@ -162,6 +162,8 @@ const char *iptc_strerror(int err);
 
 extern void dump_entries(struct xtc_handle *const);
 
+extern const struct xtc_ops iptc_ops;
+
 #ifdef __cplusplus
 }
 #endif
index 89a51511a8dbbba35891bacc8c04b0000354e6ff..773ebc4c77e2c8152d19c9d4dac08f2737868909 100644 (file)
@@ -3,5 +3,18 @@
 
 typedef char xt_chainlabel[32];
 struct xtc_handle;
+struct xt_counters;
+
+struct xtc_ops {
+       int (*commit)(struct xtc_handle *);
+       void (*free)(struct xtc_handle *);
+       int (*builtin)(const char *, struct xtc_handle *const);
+       int (*is_chain)(const char *, struct xtc_handle *const);
+       int (*flush_entries)(const xt_chainlabel, struct xtc_handle *);
+       int (*create_chain)(const xt_chainlabel, struct xtc_handle *);
+       int (*set_policy)(const xt_chainlabel, const xt_chainlabel,
+                         struct xt_counters *, struct xtc_handle *);
+       const char *(*strerror)(int);
+};
 
 #endif /* _LIBXTC_SHARED_H */
index 22c920f6605f677139a6f7894785b4acf9dafe01..0b59007d3163f79da1b9c08e5320f320236050e7 100644 (file)
@@ -10,6 +10,6 @@ libiptc_la_SOURCES  =
 libiptc_la_LIBADD   = libip4tc.la libip6tc.la
 libiptc_la_LDFLAGS  = -version-info 0:0:0 ${libiptc_LDFLAGS2}
 libip4tc_la_SOURCES = libip4tc.c
-libip4tc_la_LDFLAGS = -version-info 0:0:0
+libip4tc_la_LDFLAGS = -version-info 1:0:1
 libip6tc_la_SOURCES = libip6tc.c
-libip6tc_la_LDFLAGS = -version-info 0:0:0 ${libiptc_LDFLAGS2}
+libip6tc_la_LDFLAGS = -version-info 1:0:1 ${libiptc_LDFLAGS2}
index c55cbc7d5e390157d65dff2754eeed3a0998b51e..dd599516cd7843a9db4df0b7b89da4435fed5f79 100644 (file)
@@ -90,6 +90,7 @@ typedef unsigned int socklen_t;
 #define TC_STRERROR            iptc_strerror
 #define TC_NUM_RULES           iptc_num_rules
 #define TC_GET_RULE            iptc_get_rule
+#define TC_OPS                 iptc_ops
 
 #define TC_AF                  AF_INET
 #define TC_IPPROTO             IPPROTO_IP
index 9febee303e3feb03e33bf2354575b6f67e3b2ffe..7128e1cf623937e2b00919e4a3bf033660bc6f5e 100644 (file)
@@ -88,6 +88,7 @@ typedef unsigned int socklen_t;
 #define TC_STRERROR            ip6tc_strerror
 #define TC_NUM_RULES           ip6tc_num_rules
 #define TC_GET_RULE            ip6tc_get_rule
+#define TC_OPS                 ip6tc_ops
 
 #define TC_AF                  AF_INET6
 #define TC_IPPROTO             IPPROTO_IPV6
index 593c5de8ca039897094824c31f5a9fee426fb5e5..63fcfc2afc1c21931a775619852ac7ed10820db8 100644 (file)
@@ -33,6 +33,7 @@
 #include <sys/socket.h>
 #include <stdbool.h>
 #include <xtables.h>
+#include <libiptc/xtcshared.h>
 
 #include "linux_list.h"
 
@@ -2731,3 +2732,14 @@ TC_STRERROR(int err)
 
        return strerror(err);
 }
+
+const struct xtc_ops TC_OPS = {
+       .commit        = TC_COMMIT,
+       .free          = TC_FREE,
+       .builtin       = TC_BUILTIN,
+       .is_chain      = TC_IS_CHAIN,
+       .flush_entries = TC_FLUSH_ENTRIES,
+       .create_chain  = TC_CREATE_CHAIN,
+       .set_policy    = TC_SET_POLICY,
+       .strerror      = TC_STRERROR,
+};