10 #include "internal/internal.h"
12 int __parse_expect_message_type(
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;
18 if (type == IPCTNL_MSG_EXP_NEW) {
19 if (flags & (NLM_F_CREATE|NLM_F_EXCL))
23 }
else if (type == IPCTNL_MSG_EXP_DELETE)
29 void __parse_expect(
const struct nlmsghdr *nlh,
31 struct nf_expect *exp)
33 struct nfgenmsg *nfhdr = NLMSG_DATA(nlh);
36 exp->expected.orig.l3protonum = nfhdr->nfgen_family;
37 set_bit(ATTR_ORIG_L3PROTO, exp->expected.set);
39 exp->mask.orig.l3protonum = nfhdr->nfgen_family;
40 set_bit(ATTR_ORIG_L3PROTO, exp->mask.set);
42 exp->master.orig.l3protonum = nfhdr->nfgen_family;
43 set_bit(ATTR_ORIG_L3PROTO, exp->master.set);
45 if (cda[CTA_EXPECT_MASTER-1]) {
46 __parse_tuple(cda[CTA_EXPECT_MASTER-1],
50 set_bit(ATTR_EXP_MASTER, exp->set);
52 if (cda[CTA_EXPECT_TUPLE-1]) {
53 __parse_tuple(cda[CTA_EXPECT_TUPLE-1],
57 set_bit(ATTR_EXP_EXPECTED, exp->set);
59 if (cda[CTA_EXPECT_MASK-1]) {
60 __parse_tuple(cda[CTA_EXPECT_MASK-1],
64 set_bit(ATTR_EXP_MASK, exp->set);
66 if (cda[CTA_EXPECT_TIMEOUT-1]) {
68 ntohl(*(uint32_t *)NFA_DATA(cda[CTA_EXPECT_TIMEOUT-1]));
69 set_bit(ATTR_EXP_TIMEOUT, exp->set);
72 if (cda[CTA_EXPECT_ZONE-1]) {
74 ntohs(*(uint16_t *)NFA_DATA(cda[CTA_EXPECT_ZONE-1]));
75 set_bit(ATTR_EXP_ZONE, exp->set);
77 if (cda[CTA_EXPECT_FLAGS-1]) {
79 ntohl(*(uint32_t *)NFA_DATA(cda[CTA_EXPECT_FLAGS-1]));
80 set_bit(ATTR_EXP_FLAGS, exp->set);
82 if (cda[CTA_EXPECT_HELP_NAME-1]) {
83 strncpy(exp->helper_name, NFA_DATA(cda[CTA_EXPECT_HELP_NAME-1]),
84 NFA_PAYLOAD(cda[CTA_EXPECT_HELP_NAME-1]));
85 set_bit(ATTR_EXP_HELPER_NAME, exp->set);
87 if (cda[CTA_EXPECT_CLASS-1]) {
89 ntohl(*(uint32_t *)NFA_DATA(cda[CTA_EXPECT_CLASS-1]));
90 set_bit(ATTR_EXP_CLASS, exp->set);
92 if (cda[CTA_EXPECT_NAT-1]) {
93 struct nfattr *tb[CTA_EXPECT_NAT_MAX];
95 exp->nat.orig.l3protonum = nfhdr->nfgen_family;
96 set_bit(ATTR_ORIG_L3PROTO, exp->nat.set);
98 nfnl_parse_nested(tb, CTA_EXPECT_NAT_MAX,
99 cda[CTA_EXPECT_NAT-1]);
101 if (tb[CTA_EXPECT_NAT_TUPLE-1]) {
102 __parse_tuple(tb[CTA_EXPECT_NAT_TUPLE-1],
106 set_bit(ATTR_EXP_NAT_TUPLE, exp->set);
108 if (tb[CTA_EXPECT_NAT_DIR-1]) {
111 NFA_DATA(tb[CTA_EXPECT_NAT_DIR-1])));
112 set_bit(ATTR_EXP_NAT_DIR, exp->set);
115 if (cda[CTA_EXPECT_FN-1]) {
116 strcpy(exp->expectfn, NFA_DATA(cda[CTA_EXPECT_FN-1]));
117 exp->expectfn[__NFCT_EXPECTFN_MAX-1] =
'\0';
118 set_bit(ATTR_EXP_FN, exp->set);