summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-02-22 22:59:18 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-02-22 22:59:18 +0000
commitea5ae395bef0188a0f3d85444e9ae7abb611e051 (patch)
treea470a02a019a7f3f5a887e7e5a9726a280abf957
parent7f9112dc9b40a7cb952d2d5927cae12cbb35960a (diff)
- fix broken 'deprecated backward compatibility'svn_t_libnetfilter_conntrack-0.0.89origin
- fix glibc 2.7.20 compilation (based on patch from Paul P. Konkoff)
-rw-r--r--include/internal.h9
-rw-r--r--src/Makefile.am1
-rw-r--r--src/conntrack/snprintf_default.c4
-rw-r--r--src/conntrack/snprintf_xml.c2
-rw-r--r--src/deprecated.c43
-rw-r--r--src/deprecated/extensions/libnetfilter_conntrack_icmp.c9
-rw-r--r--src/deprecated/extensions/libnetfilter_conntrack_sctp.c9
-rw-r--r--src/deprecated/extensions/libnetfilter_conntrack_tcp.c9
-rw-r--r--src/deprecated/extensions/libnetfilter_conntrack_udp.c9
-rw-r--r--src/deprecated/l3extensions/libnetfilter_conntrack_ipv4.c9
-rw-r--r--src/deprecated/l3extensions/libnetfilter_conntrack_ipv6.c13
-rw-r--r--src/main.c2
12 files changed, 39 insertions, 80 deletions
diff --git a/include/internal.h b/include/internal.h
index b51450f..0c369aa 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -214,4 +214,13 @@ int __expect_callback(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data);
int __snprintf_expect(char *buf, unsigned int len, const struct nf_expect *exp, unsigned int type, unsigned int msg_output, unsigned int flags);
int __snprintf_expect_default(char *buf, unsigned int len, const struct nf_expect *exp, unsigned int msg_type, unsigned int flags);
+/* backward compatibility of the deprecated API */
+extern struct nfct_l3proto ipv4;
+extern struct nfct_l3proto ipv6;
+
+extern struct nfct_proto tcp;
+extern struct nfct_proto udp;
+extern struct nfct_proto sctp;
+extern struct nfct_proto icmp;
+
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index e7d1e38..22ba2bc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,6 @@ lib_LTLIBRARIES = libnetfilter_conntrack.la
libnetfilter_conntrack_la_LIBADD = conntrack/libnfconntrack.la \
expect/libnfexpect.la \
- # deprecated extensions: scheduled to be removed
deprecated/l3extensions/libnfct_l3proto_ipv4.la \
deprecated/l3extensions/libnfct_l3proto_ipv6.la \
deprecated/extensions/libnfct_proto_tcp.la \
diff --git a/src/conntrack/snprintf_default.c b/src/conntrack/snprintf_default.c
index e129218..675be7a 100644
--- a/src/conntrack/snprintf_default.c
+++ b/src/conntrack/snprintf_default.c
@@ -93,8 +93,8 @@ int __snprintf_address_ipv6(char *buf,
struct in6_addr dst;
char tmp[INET6_ADDRSTRLEN];
- memcpy(&src.in6_u, &tuple->src.v6, sizeof(struct in6_addr));
- memcpy(&dst.in6_u, &tuple->dst.v6, sizeof(struct in6_addr));
+ memcpy(&src, &tuple->src.v6, sizeof(struct in6_addr));
+ memcpy(&dst, &tuple->dst.v6, sizeof(struct in6_addr));
if (!inet_ntop(AF_INET6, &src, tmp, sizeof(tmp)))
return -1;
diff --git a/src/conntrack/snprintf_xml.c b/src/conntrack/snprintf_xml.c
index 9f7f388..0bd4443 100644
--- a/src/conntrack/snprintf_xml.c
+++ b/src/conntrack/snprintf_xml.c
@@ -100,7 +100,7 @@ static int __snprintf_ipv6_xml(char *buf,
static char tmp[INET6_ADDRSTRLEN];
const void *p = (type == __ADDR_SRC) ? &tuple->src.v6 : &tuple->dst.v6;
- memcpy(&addr.in6_u, p, sizeof(struct in6_addr));
+ memcpy(&addr, p, sizeof(struct in6_addr));
if (!inet_ntop(AF_INET6, &addr, tmp, sizeof(tmp)))
return -1;
diff --git a/src/deprecated.c b/src/deprecated.c
index 6555062..63a5699 100644
--- a/src/deprecated.c
+++ b/src/deprecated.c
@@ -43,6 +43,17 @@ static char *l3proto2str[AF_MAX] = {
static struct nfct_proto *findproto(char *name);
static struct nfct_l3proto *findl3proto(char *name);
+void deprecated_backward_support()
+{
+ nfct_register_l3proto(&ipv4);
+ nfct_register_l3proto(&ipv6);
+
+ nfct_register_proto(&tcp);
+ nfct_register_proto(&udp);
+ nfct_register_proto(&icmp);
+ nfct_register_proto(&sctp);
+}
+
/* handler used for nfnl_listen */
static int callback_handler(struct sockaddr_nl *nladdr,
struct nlmsghdr *n, void *arg)
@@ -207,10 +218,6 @@ static struct nfct_proto *findproto(char *name)
if (!name)
return handler;
- lib_dir = getenv("LIBNETFILTER_CONNTRACK_DIR");
- if (!lib_dir)
- lib_dir = LIBNETFILTER_CONNTRACK_DIR;
-
list_for_each(i, &proto_list) {
cur = (struct nfct_proto *) i;
if (strcmp(cur->name, name) == 0) {
@@ -219,15 +226,9 @@ static struct nfct_proto *findproto(char *name)
}
}
- if (!handler) {
- char path[sizeof("nfct_proto_.so") + strlen(VERSION)
- + strlen(name) + strlen(lib_dir)];
- sprintf(path, "%s/nfct_proto_%s-%s.so", lib_dir, name, VERSION);
- if (dlopen(path, RTLD_NOW))
- handler = findproto(name);
- else
- fprintf(stderr, "%s\n", dlerror());
- }
+ if (!handler)
+ fprintf(stderr, "libnetfilter_conntrack: "
+ "cannot find %s handler\n", name);
return handler;
}
@@ -240,10 +241,6 @@ static struct nfct_l3proto *findl3proto(char *name)
if (!name)
return handler;
- lib_dir = getenv("LIBNETFILTER_CONNTRACK_DIR");
- if (!lib_dir)
- lib_dir = LIBNETFILTER_CONNTRACK_DIR;
-
list_for_each(i, &l3proto_list) {
cur = (struct nfct_l3proto *) i;
if (strcmp(cur->name, name) == 0) {
@@ -252,15 +249,9 @@ static struct nfct_l3proto *findl3proto(char *name)
}
}
- if (!handler) {
- char path[sizeof("nfct_l3proto_.so") + strlen(VERSION)
- + strlen(name) + strlen(lib_dir)];
- sprintf(path, "%s/nfct_l3proto_%s-%s.so",lib_dir,name,VERSION);
- if (dlopen(path, RTLD_NOW))
- handler = findl3proto(name);
- else
- fprintf(stderr, "%s\n", dlerror());
- }
+ if (!handler)
+ fprintf(stderr, "libnetfilter_conntrack: "
+ "cannot find %s handler\n", name);
return handler;
}
diff --git a/src/deprecated/extensions/libnetfilter_conntrack_icmp.c b/src/deprecated/extensions/libnetfilter_conntrack_icmp.c
index 72a7eb0..ae8470a 100644
--- a/src/deprecated/extensions/libnetfilter_conntrack_icmp.c
+++ b/src/deprecated/extensions/libnetfilter_conntrack_icmp.c
@@ -72,7 +72,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_proto icmp = {
+struct nfct_proto icmp = {
.name = "icmp",
.protonum = IPPROTO_ICMP,
.parse_proto = parse_proto,
@@ -81,10 +81,3 @@ static struct nfct_proto icmp = {
.compare = compare,
.version = VERSION
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_proto(&icmp);
-}
diff --git a/src/deprecated/extensions/libnetfilter_conntrack_sctp.c b/src/deprecated/extensions/libnetfilter_conntrack_sctp.c
index 3785c2e..6225ca1 100644
--- a/src/deprecated/extensions/libnetfilter_conntrack_sctp.c
+++ b/src/deprecated/extensions/libnetfilter_conntrack_sctp.c
@@ -80,7 +80,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_proto sctp = {
+struct nfct_proto sctp = {
.name = "sctp",
.protonum = IPPROTO_SCTP,
.parse_proto = parse_proto,
@@ -91,10 +91,3 @@ static struct nfct_proto sctp = {
.compare = compare,
.version = VERSION
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_proto(&sctp);
-}
diff --git a/src/deprecated/extensions/libnetfilter_conntrack_tcp.c b/src/deprecated/extensions/libnetfilter_conntrack_tcp.c
index 9efdbb7..a7ce2ce 100644
--- a/src/deprecated/extensions/libnetfilter_conntrack_tcp.c
+++ b/src/deprecated/extensions/libnetfilter_conntrack_tcp.c
@@ -121,7 +121,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_proto tcp = {
+struct nfct_proto tcp = {
.name = "tcp",
.protonum = IPPROTO_TCP,
.parse_protoinfo = parse_protoinfo,
@@ -133,10 +133,3 @@ static struct nfct_proto tcp = {
.compare = compare,
.version = VERSION
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_proto(&tcp);
-}
diff --git a/src/deprecated/extensions/libnetfilter_conntrack_udp.c b/src/deprecated/extensions/libnetfilter_conntrack_udp.c
index c1d20c3..b20ba04 100644
--- a/src/deprecated/extensions/libnetfilter_conntrack_udp.c
+++ b/src/deprecated/extensions/libnetfilter_conntrack_udp.c
@@ -66,7 +66,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_proto udp = {
+struct nfct_proto udp = {
.name = "udp",
.protonum = IPPROTO_UDP,
.build_tuple_proto = build_tuple_proto,
@@ -75,10 +75,3 @@ static struct nfct_proto udp = {
.compare = compare,
.version = VERSION,
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_proto(&udp);
-}
diff --git a/src/deprecated/l3extensions/libnetfilter_conntrack_ipv4.c b/src/deprecated/l3extensions/libnetfilter_conntrack_ipv4.c
index 727ea01..8e8c681 100644
--- a/src/deprecated/l3extensions/libnetfilter_conntrack_ipv4.c
+++ b/src/deprecated/l3extensions/libnetfilter_conntrack_ipv4.c
@@ -76,7 +76,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_l3proto ipv4 = {
+struct nfct_l3proto ipv4 = {
.name = "ipv4",
.protonum = AF_INET,
.parse_proto = parse_proto,
@@ -85,10 +85,3 @@ static struct nfct_l3proto ipv4 = {
.compare = compare,
.version = VERSION
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_l3proto(&ipv4);
-}
diff --git a/src/deprecated/l3extensions/libnetfilter_conntrack_ipv6.c b/src/deprecated/l3extensions/libnetfilter_conntrack_ipv6.c
index b0c7a3f..1b6b909 100644
--- a/src/deprecated/l3extensions/libnetfilter_conntrack_ipv6.c
+++ b/src/deprecated/l3extensions/libnetfilter_conntrack_ipv6.c
@@ -48,8 +48,8 @@ static int print_proto(char *buf, struct nfct_tuple *tuple)
char tmp[INET6_ADDRSTRLEN];
int size;
- memcpy(&src.in6_u, tuple->src.v6, sizeof(struct in6_addr));
- memcpy(&dst.in6_u, tuple->dst.v6, sizeof(struct in6_addr));
+ memcpy(&src, tuple->src.v6, sizeof(struct in6_addr));
+ memcpy(&dst, tuple->dst.v6, sizeof(struct in6_addr));
if (!inet_ntop(AF_INET6, &src, tmp, sizeof(tmp)))
return 0;
@@ -97,7 +97,7 @@ static int compare(struct nfct_conntrack *ct1,
return 1;
}
-static struct nfct_l3proto ipv6 = {
+struct nfct_l3proto ipv6 = {
.name = "ipv6",
.protonum = AF_INET6,
.parse_proto = parse_proto,
@@ -106,10 +106,3 @@ static struct nfct_l3proto ipv6 = {
.compare = compare,
.version = VERSION
};
-
-static void __attribute__ ((constructor)) init(void);
-
-static void init(void)
-{
- nfct_register_l3proto(&ipv6);
-}
diff --git a/src/main.c b/src/main.c
index 9b57d24..21bcafb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,6 +18,8 @@ struct nfct_handle *nfct_open_nfnl(struct nfnl_handle *nfnlh,
{
struct nfct_handle *cth;
+ deprecated_backward_support();
+
cth = (struct nfct_handle *) malloc(sizeof(struct nfct_handle));
if (!cth)
return NULL;