10 #include "internal/internal.h"
12 static int __parse_message(
const struct nlmsghdr *nlh)
14 uint16_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
15 uint16_t flags = nlh->nlmsg_flags;
16 int ret = NFCT_T_UNKNOWN;
19 case IPCTNL_MSG_CT_NEW:
20 if (flags & (NLM_F_CREATE|NLM_F_EXCL))
25 case IPCTNL_MSG_CT_DELETE:
32 int __callback(
struct nlmsghdr *nlh,
struct nfattr *nfa[],
void *data)
34 int ret = NFNL_CB_STOP;
36 struct nf_conntrack *ct = NULL;
37 struct nf_expect *exp = NULL;
38 struct __data_container *container = data;
39 uint8_t subsys = NFNL_SUBSYS_ID(nlh->nlmsg_type);
41 if (nlh->nlmsg_len < NLMSG_LENGTH(
sizeof(
struct nfgenmsg))) {
43 return NFNL_CB_FAILURE;
45 type = __parse_message(nlh);
46 if (!(type & container->type))
47 return NFNL_CB_CONTINUE;
50 case NFNL_SUBSYS_CTNETLINK:
53 return NFNL_CB_FAILURE;
55 __parse_conntrack(nlh, nfa, ct);
57 if (container->h->cb) {
58 ret = container->h->cb(type, ct, container->data);
59 }
else if (container->h->cb2) {
60 ret = container->h->cb2(nlh, type, ct,
64 case NFNL_SUBSYS_CTNETLINK_EXP:
67 return NFNL_CB_FAILURE;
69 __parse_expect(nlh, nfa, exp);
71 if (container->h->expect_cb) {
72 ret = container->h->expect_cb(type, exp,
74 }
else if (container->h->expect_cb2) {
75 ret = container->h->expect_cb2(nlh, type, exp,
81 ret = NFNL_CB_FAILURE;
85 if (ret == NFCT_CB_STOLEN)
86 return NFNL_CB_CONTINUE;
void nfct_destroy(struct nf_conntrack *ct)
struct nf_expect * nfexp_new(void)
struct nf_conntrack * nfct_new(void)
void nfexp_destroy(struct nf_expect *exp)