]> granicus.if.org Git - ipset/commitdiff
Set types moved into libipset library
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Thu, 5 Jan 2012 20:30:20 +0000 (21:30 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Thu, 5 Jan 2012 20:30:20 +0000 (21:30 +0100)
The libipset library is complete by this step, and "ipset" just
a CLI interface based on the lib.

18 files changed:
Make_global.am
include/libipset/types.h
lib/Makefile.am
lib/ipset_bitmap_ip.c [moved from src/ipset_bitmap_ip.c with 100% similarity]
lib/ipset_bitmap_ipmac.c [moved from src/ipset_bitmap_ipmac.c with 100% similarity]
lib/ipset_bitmap_port.c [moved from src/ipset_bitmap_port.c with 100% similarity]
lib/ipset_hash_ip.c [moved from src/ipset_hash_ip.c with 100% similarity]
lib/ipset_hash_ipport.c [moved from src/ipset_hash_ipport.c with 100% similarity]
lib/ipset_hash_ipportip.c [moved from src/ipset_hash_ipportip.c with 100% similarity]
lib/ipset_hash_ipportnet.c [moved from src/ipset_hash_ipportnet.c with 100% similarity]
lib/ipset_hash_net.c [moved from src/ipset_hash_net.c with 100% similarity]
lib/ipset_hash_netiface.c [moved from src/ipset_hash_netiface.c with 100% similarity]
lib/ipset_hash_netport.c [moved from src/ipset_hash_netport.c with 100% similarity]
lib/ipset_list_set.c [moved from src/ipset_list_set.c with 100% similarity]
lib/libipset.map
lib/types.c
src/Makefile.am
src/ipset.c

index 6275a107570f176493d796a5e8b937bef9d70f24..0e81226e21e55275469a551d18107e2b78d4ea1f 100644 (file)
@@ -68,7 +68,7 @@
 # as -version-info 2:0:0. This release has a new, but backwards incompatible
 # interface. 
 
-LIBVERSION = 1:0:0
+LIBVERSION = 2:0:0
 
 AM_CPPFLAGS = $(kinclude_CFLAGS) $(all_includes) -I$(top_srcdir)/include \
        -I/usr/local/include
index cacce269d35ae3da6e9e2fafc969243b1cc8ce93..950988fccdf28465e4448117285d15889dce140b 100644 (file)
@@ -105,5 +105,6 @@ extern const struct ipset_type *ipset_types(void);
 extern const char *ipset_typename_resolve(const char *str);
 extern bool ipset_match_typename(const char *str,
                                 const struct ipset_type *t);
+extern void ipset_load_types(void);
 
 #endif /* LIBIPSET_TYPES_H */
index d4ea6d6d432d4f32cc2dc2e4f6d75b0a82f8c2c5..3d4352333503b6cb7ff8b1fa6bd99af3128ddc3a 100644 (file)
@@ -15,7 +15,18 @@ libipset_la_SOURCES = \
        parse.c \
        print.c \
        session.c \
-       types.c
+       types.c \
+       ipset_bitmap_ip.c \
+       ipset_bitmap_ipmac.c \
+       ipset_bitmap_port.c \
+       ipset_hash_ip.c \
+       ipset_hash_ipport.c \
+       ipset_hash_ipportip.c \
+       ipset_hash_ipportnet.c \
+       ipset_hash_net.c \
+       ipset_hash_netport.c \
+       ipset_hash_netiface.c \
+       ipset_list_set.c
 
 #%.o: %.c
 #      ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} ${CFLAGS} -o $@ -c $<
similarity index 100%
rename from src/ipset_bitmap_ip.c
rename to lib/ipset_bitmap_ip.c
similarity index 100%
rename from src/ipset_hash_ip.c
rename to lib/ipset_hash_ip.c
similarity index 100%
rename from src/ipset_hash_net.c
rename to lib/ipset_hash_net.c
similarity index 100%
rename from src/ipset_list_set.c
rename to lib/ipset_list_set.c
index a9f6f41d428a003c11e61cd649088675b777d872..677c0552a42132e6be05e0904f6536a0c61aff1a 100644 (file)
@@ -110,3 +110,8 @@ global:
   
 local: *;
 };
+
+LIBIPSET_2.0 {
+global:
+  ipset_load_types;
+} LIBIPSET_1.0;
index e93b4bdb144484407be7258026ec4bef7d39edc5..0b5826e572fecd75f8d1d32c9f373b18e9649ed7 100644 (file)
 #include <libipset/utils.h>                    /* STREQ */
 #include <libipset/types.h>                    /* prototypes */
 
+/* The known set types: (typename, revision, family) is unique */
+extern struct ipset_type ipset_bitmap_ip0;
+extern struct ipset_type ipset_bitmap_ipmac0;
+extern struct ipset_type ipset_bitmap_port0;
+extern struct ipset_type ipset_hash_ip0;
+extern struct ipset_type ipset_hash_net0;
+extern struct ipset_type ipset_hash_net1;
+extern struct ipset_type ipset_hash_netport1;
+extern struct ipset_type ipset_hash_netport2;
+extern struct ipset_type ipset_hash_netiface0;
+extern struct ipset_type ipset_hash_ipport1;
+extern struct ipset_type ipset_hash_ipportip1;
+extern struct ipset_type ipset_hash_ipportnet1;
+extern struct ipset_type ipset_hash_ipportnet2;
+extern struct ipset_type ipset_list_set0;
+
 /* Userspace cache of sets which exists in the kernel */
 
 struct ipset {
@@ -554,3 +570,31 @@ ipset_cache_fini(void)
                free(set);
        }
 }
+
+/**
+ * ipset_load_types - load known set types
+ *
+ * Load in (register) all known set types for the system
+ */
+ void
+ ipset_load_types(void)
+ {
+       if (typelist != NULL)
+               return;
+
+       ipset_type_add(&ipset_bitmap_ip0);
+       ipset_type_add(&ipset_bitmap_ipmac0);
+       ipset_type_add(&ipset_bitmap_port0);
+       ipset_type_add(&ipset_hash_ip0);
+       ipset_type_add(&ipset_hash_net0);
+       ipset_type_add(&ipset_hash_net1);
+       ipset_type_add(&ipset_hash_netport1);
+       ipset_type_add(&ipset_hash_netport2);
+       ipset_type_add(&ipset_hash_netiface0);
+       ipset_type_add(&ipset_hash_ipport1);
+       ipset_type_add(&ipset_hash_ipportip1);
+       ipset_type_add(&ipset_hash_ipportnet1);
+       ipset_type_add(&ipset_hash_ipportnet2);
+       ipset_type_add(&ipset_list_set0);
+}
\ No newline at end of file
index 52960473f7335e5552e93c64ab7fc2d3baf65759..e3f65493c940c09d65eef6db62f7189b8b81c714 100644 (file)
@@ -1,19 +1,7 @@
 include $(top_srcdir)/Make_global.am
 
 sbin_PROGRAMS  = ipset
-ipset_SOURCES  = ipset.c \
-       ipset_bitmap_ip.c \
-       ipset_bitmap_ipmac.c \
-       ipset_bitmap_port.c \
-       ipset_hash_ip.c \
-       ipset_hash_ipport.c \
-       ipset_hash_ipportip.c \
-       ipset_hash_ipportnet.c \
-       ipset_hash_net.c \
-       ipset_hash_netport.c \
-       ipset_hash_netiface.c \
-       ipset_list_set.c \
-       ui.c
+ipset_SOURCES  = ipset.c ui.c
 ipset_LDADD    = ../lib/libipset.la
 AM_LDFLAGS     = -static
 
index e835f06cf59702a35421ea6e1ae6fe875ae50419..4a20ca16280ced7fedcd8bc6583633368d87f3d8 100644 (file)
@@ -33,22 +33,6 @@ static char cmdline[1024];
 static char *newargv[255];
 static int newargc;
 
-/* The known set types: (typename, revision, family) is unique */
-extern struct ipset_type ipset_bitmap_ip0;
-extern struct ipset_type ipset_bitmap_ipmac0;
-extern struct ipset_type ipset_bitmap_port0;
-extern struct ipset_type ipset_hash_ip0;
-extern struct ipset_type ipset_hash_net0;
-extern struct ipset_type ipset_hash_net1;
-extern struct ipset_type ipset_hash_netport1;
-extern struct ipset_type ipset_hash_netport2;
-extern struct ipset_type ipset_hash_netiface0;
-extern struct ipset_type ipset_hash_ipport1;
-extern struct ipset_type ipset_hash_ipportip1;
-extern struct ipset_type ipset_hash_ipportnet1;
-extern struct ipset_type ipset_hash_ipportnet2;
-extern struct ipset_type ipset_list_set0;
-
 enum exittype {
        NO_PROBLEM = 0,
        OTHER_PROBLEM,
@@ -725,21 +709,8 @@ main(int argc, char *argv[])
 {
        int ret;
 
-       /* Register types */
-       ipset_type_add(&ipset_bitmap_ip0);
-       ipset_type_add(&ipset_bitmap_ipmac0);
-       ipset_type_add(&ipset_bitmap_port0);
-       ipset_type_add(&ipset_hash_ip0);
-       ipset_type_add(&ipset_hash_net0);
-       ipset_type_add(&ipset_hash_net1);
-       ipset_type_add(&ipset_hash_netport1);
-       ipset_type_add(&ipset_hash_netport2);
-       ipset_type_add(&ipset_hash_netiface0);
-       ipset_type_add(&ipset_hash_ipport1);
-       ipset_type_add(&ipset_hash_ipportip1);
-       ipset_type_add(&ipset_hash_ipportnet1);
-       ipset_type_add(&ipset_hash_ipportnet2);
-       ipset_type_add(&ipset_list_set0);
+       /* Load set types */
+       ipset_load_types();
 
        /* Initialize session */
        session = ipset_session_init(printf);