path: root/include
diff options
authorPablo Neira Ayuso <>2009-05-23 11:52:20 +0200
committerPablo Neira Ayuso <>2009-05-23 11:52:20 +0200
commit20ed81b10714dfe78e31e9721e2d4f42b4beabb2 (patch)
treecc2482605cfff21244cb090f9d2e76bfb95514aa /include
parent975ae9979ec73e8acb2c215ee9a84fded2f4357a (diff)
api: add new callback interface while keeping backward compatibility
This patch adds nfct_callback_register2() and nfct_callback_unregister2() that allows to register a callback function with a new callback interface that includes the Netlink message. This fixes an early design error. This is not nice but it is the only way to resolve this problem without breaking backward (I don't like function versioning, it is messy). Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'include')
2 files changed, 21 insertions, 0 deletions
diff --git a/include/internal/object.h b/include/internal/object.h
index fe1506c..378ba74 100644
--- a/include/internal/object.h
+++ b/include/internal/object.h
@@ -22,6 +22,15 @@ struct nfct_handle {
struct nf_conntrack *ct,
void *data);
+ /* This is the second version of the callback that includes
+ * the Netlink header. This is the result of an early design
+ * error, hiding Netlink details is evil. You end needing some
+ * internal information at some point like the Netlink PortID. */
+ int (*cb2)(const struct nlmsghdr *nlh,
+ enum nf_conntrack_msg_type type,
+ struct nf_conntrack *ct,
+ void *data);
int (*expect_cb)(enum nf_conntrack_msg_type type,
struct nf_expect *exp,
void *data);
diff --git a/include/libnetfilter_conntrack/libnetfilter_conntrack.h b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
index 1e23b0b..ec85066 100644
--- a/include/libnetfilter_conntrack/libnetfilter_conntrack.h
+++ b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
@@ -233,6 +233,18 @@ extern int nfct_callback_register(struct nfct_handle *h,
extern void nfct_callback_unregister(struct nfct_handle *h);
+/* register / unregister callback: extended version including netlink header */
+extern int nfct_callback_register2(struct nfct_handle *h,
+ enum nf_conntrack_msg_type type,
+ int (*cb)(const struct nlmsghdr *nlh,
+ enum nf_conntrack_msg_type type,
+ struct nf_conntrack *ct,
+ void *data),
+ void *data);
+extern void nfct_callback_unregister2(struct nfct_handle *h);
/* callback verdict */
enum {
NFCT_CB_FAILURE = -1, /* failure */