10 #include <libnfnetlink/libnfnetlink.h>
11 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
13 #include "internal/internal.h"
15 struct nfct_handle *nfct_open_nfnl(
struct nfnl_handle *nfnlh,
17 unsigned int subscriptions)
19 struct nfct_handle *cth;
21 cth = malloc(
sizeof(
struct nfct_handle));
25 memset(cth, 0,
sizeof(*cth));
28 if (subsys_id == 0 || subsys_id == NFNL_SUBSYS_CTNETLINK) {
29 cth->nfnlssh_ct = nfnl_subsys_open(cth->nfnlh,
30 NFNL_SUBSYS_CTNETLINK,
37 if (subsys_id == 0 || subsys_id == NFNL_SUBSYS_CTNETLINK_EXP) {
38 cth->nfnlssh_exp = nfnl_subsys_open(cth->nfnlh,
39 NFNL_SUBSYS_CTNETLINK_EXP,
42 if (!cth->nfnlssh_exp)
49 if (cth->nfnlssh_exp) {
50 nfnl_subsys_close(cth->nfnlssh_exp);
51 cth->nfnlssh_exp = NULL;
53 if (cth->nfnlssh_ct) {
54 nfnl_subsys_close(cth->nfnlssh_ct);
55 cth->nfnlssh_ct = NULL;
84 struct nfct_handle *
nfct_open(uint8_t subsys_id,
unsigned subscriptions)
86 struct nfnl_handle *nfnlh = nfnl_open();
87 struct nfct_handle *nfcth;
92 nfcth = nfct_open_nfnl(nfnlh, subsys_id, subscriptions);
109 if (cth->nfnlssh_exp) {
110 nfnl_subsys_close(cth->nfnlssh_exp);
111 cth->nfnlssh_exp = NULL;
113 if (cth->nfnlssh_ct) {
114 nfnl_subsys_close(cth->nfnlssh_ct);
115 cth->nfnlssh_ct = NULL;
121 cth->expect_cb = NULL;
122 cth->expect_cb2 = NULL;
123 free(cth->nfnl_cb_ct.data);
124 free(cth->nfnl_cb_exp.data);
126 cth->nfnl_cb_ct.call = NULL;
127 cth->nfnl_cb_ct.data = NULL;
128 cth->nfnl_cb_ct.attr_count = 0;
130 cth->nfnl_cb_exp.call = NULL;
131 cth->nfnl_cb_exp.data = NULL;
132 cth->nfnl_cb_exp.attr_count = 0;
134 err = nfnl_close(cth->nfnlh);
146 return nfnl_fd(cth->nfnlh);
149 const struct nfnl_handle *nfct_nfnlh(
struct nfct_handle *cth)
int nfct_close(struct nfct_handle *cth)
int nfct_fd(struct nfct_handle *cth)
struct nfct_handle * nfct_open(uint8_t subsys_id, unsigned subscriptions)