10 #include "internal/internal.h"
12 static void __build_timeout(
struct nfnlhdr *req,
14 const struct nf_expect *exp)
16 nfnl_addattr32(&req->nlh, size, CTA_EXPECT_TIMEOUT,htonl(exp->timeout));
19 static void __build_zone(
struct nfnlhdr *req,
size_t size,
20 const struct nf_expect *exp)
22 nfnl_addattr16(&req->nlh, size, CTA_EXPECT_ZONE, htons(exp->zone));
25 static void __build_flags(
struct nfnlhdr *req,
26 size_t size,
const struct nf_expect *exp)
28 nfnl_addattr32(&req->nlh, size, CTA_EXPECT_FLAGS,htonl(exp->flags));
31 static void __build_class(
struct nfnlhdr *req,
33 const struct nf_expect *exp)
35 nfnl_addattr32(&req->nlh, size, CTA_EXPECT_CLASS, htonl(exp->class));
38 static void __build_helper_name(
struct nfnlhdr *req,
size_t size,
39 const struct nf_expect *exp)
41 nfnl_addattr_l(&req->nlh, size, CTA_EXPECT_HELP_NAME,
42 exp->helper_name, strlen(exp->helper_name)+1);
45 static void __build_expectfn(
struct nfnlhdr *req,
46 size_t size,
const struct nf_expect *exp)
48 nfnl_addattr_l(&req->nlh, size, CTA_EXPECT_FN,
49 exp->expectfn, strlen(exp->expectfn)+1);
52 int __build_expect(
struct nfnl_subsys_handle *ssh,
57 const struct nf_expect *exp)
61 if (test_bit(ATTR_ORIG_L3PROTO, exp->master.set))
62 l3num = exp->master.orig.l3protonum;
63 else if (test_bit(ATTR_ORIG_L3PROTO, exp->expected.set))
64 l3num = exp->expected.orig.l3protonum;
70 nfnl_fill_hdr(ssh, &req->nlh, 0, l3num, 0, type, flags);
72 if (test_bit(ATTR_EXP_EXPECTED, exp->set)) {
73 __build_tuple(req, size, &exp->expected.orig, CTA_EXPECT_TUPLE);
76 if (test_bit(ATTR_EXP_MASTER, exp->set)) {
77 __build_tuple(req, size, &exp->master.orig, CTA_EXPECT_MASTER);
80 if (test_bit(ATTR_EXP_MASK, exp->set)) {
81 __build_tuple(req, size, &exp->mask.orig, CTA_EXPECT_MASK);
84 if (test_bit(ATTR_EXP_NAT_TUPLE, exp->set) &&
85 test_bit(ATTR_EXP_NAT_DIR, exp->set)) {
88 nest = nfnl_nest(&req->nlh, size, CTA_EXPECT_NAT);
89 __build_tuple(req, size, &exp->nat.orig, CTA_EXPECT_NAT_TUPLE);
90 nfnl_addattr32(&req->nlh, size, CTA_EXPECT_NAT_DIR,
92 nfnl_nest_end(&req->nlh, nest);
95 if (test_bit(ATTR_EXP_TIMEOUT, exp->set))
96 __build_timeout(req, size, exp);
97 if (test_bit(ATTR_EXP_FLAGS, exp->set))
98 __build_flags(req, size, exp);
99 if (test_bit(ATTR_EXP_ZONE, exp->set))
100 __build_zone(req, size, exp);
101 if (test_bit(ATTR_EXP_CLASS, exp->set))
102 __build_class(req, size, exp);
103 if (test_bit(ATTR_EXP_HELPER_NAME, exp->set))
104 __build_helper_name(req, size, exp);
105 if (test_bit(ATTR_EXP_FN, exp->set))
106 __build_expectfn(req, size, exp);