diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-01-04 17:16:39 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-01-04 17:16:39 +0100 |
commit | 8e63e483240687ee4c4325073d84926e39416bc9 (patch) | |
tree | 54848f691373638fc54c84c5f87938e18977f6b1 /src/expect/api.c | |
parent | 849342adcb7099d23b39192a4369908bb0259eee (diff) |
expect: add nfexp_cmp
This patch adds nfexp_cmp that allows you to compare two expectation
objects.
This includes the extension of test_api for this new function.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expect/api.c')
-rw-r--r-- | src/expect/api.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/expect/api.c b/src/expect/api.c index cf45091..4da44a0 100644 --- a/src/expect/api.c +++ b/src/expect/api.c @@ -99,6 +99,40 @@ struct nf_expect *nfexp_clone(const struct nf_expect *exp) } /** + * nfexp_cmp - compare two expectation objects + * \param exp1 pointer to a valid expectation object + * \param exp2 pointer to a valid expectation object + * \param flags flags + * + * This function only compare attribute set in both objects, by default + * the comparison is not strict, ie. if a certain attribute is not set in one + * of the objects, then such attribute is not used in the comparison. + * If you want more strict comparisons, you can use the appropriate flags + * to modify this behaviour (see NFCT_CMP_STRICT and NFCT_CMP_MASK). + * + * The available flags are: + * - NFCT_CMP_STRICT: the compared objects must have the same attributes + * and the same values, otherwise it returns that the objects are + * different. + * - NFCT_CMP_MASK: the first object is used as mask, this means that + * if an attribute is present in exp1 but not in exp2, this function + * returns that the objects are different. + * + * Other existing flags that are used by nfct_cmp() are ignored. + * + * If both conntrack object are equal, this function returns 1, otherwise + * 0 is returned. + */ +int nfexp_cmp(const struct nf_expect *exp1, const struct nf_expect *exp2, + unsigned int flags) +{ + assert(exp1 != NULL); + assert(exp2 != NULL); + + return __cmp_expect(exp1, exp2, flags); +} + +/** * @} */ |