9 #include "internal/internal.h"
11 static int __cmp(
int attr,
12 const struct nf_expect *exp1,
13 const struct nf_expect *exp2,
15 int (*cmp)(
const struct nf_expect *exp1,
16 const struct nf_expect *exp2,
19 if (test_bit(attr, exp1->set) && test_bit(attr, exp2->set)) {
20 return cmp(ct1, ct2, flags);
21 }
else if (flags & NFCT_CMP_MASK &&
22 test_bit(attr, exp1->set)) {
24 }
else if (flags & NFCT_CMP_STRICT) {
32 cmp_timeout(
const struct nf_expect *exp1,
33 const struct nf_expect *exp2,
38 #define __NFCT_CMP_TIMEOUT (NFCT_CMP_TIMEOUT_LE | NFCT_CMP_TIMEOUT_GT)
40 if (!(flags & __NFCT_CMP_TIMEOUT) &&
41 exp1->timeout != exp2->timeout)
44 if (flags & NFCT_CMP_TIMEOUT_GT &&
45 exp1->timeout > exp2->timeout)
47 else if (flags & NFCT_CMP_TIMEOUT_LT &&
48 exp1->timeout < exp2->timeout)
50 else if (flags & NFCT_CMP_TIMEOUT_EQ &&
51 exp1->timeout == exp2->timeout)
61 cmp_status(
const struct nf_conntrack *ct1,
62 const struct nf_conntrack *ct2,
65 return ((ct1->status & ct2->status) == ct1->status);
69 cmp_zone(
const struct nf_conntrack *ct1,
70 const struct nf_conntrack *ct2,
73 return (ct1->zone == ct2->zone);
76 static int cmp_meta(
const struct nf_expect *exp1,
77 const struct nf_expect *exp2,
80 if (!__cmp(ATTR_EXP_TIMEOUT, exp1, exp2, flags, cmp_timeout))
82 if (!__cmp(ATTR_EXP_FLAGS, exp1, exp2, flags, cmp_status))
84 if (!__cmp(ATTR_EXP_ZONE, exp1, exp2, flags, cmp_zone))
90 int cmp_exp(
const struct nf_expect *exp1,
const struct nf_expect *exp2,
93 const struct nf_conntrack *ct1, *ct2;
98 if (!
nfct_cmp(ct1, ct2, NFCT_CMP_ORIG|NFCT_CMP_REPL))
104 if (!
nfct_cmp(ct1, ct2, NFCT_CMP_ORIG))
110 if (!
nfct_cmp(ct1, ct2, NFCT_CMP_ORIG))
113 if (flags & NFCT_CMP_META) {
int nfct_cmp(const struct nf_conntrack *ct1, const struct nf_conntrack *ct2, unsigned int flags)
const void * nfexp_get_attr(const struct nf_expect *exp, const enum nf_expect_attr type)