1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*/
#include "internal/internal.h"
int __parse_expect_message_type(const struct nlmsghdr *nlh)
{
u_int16_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
u_int16_t flags = nlh->nlmsg_flags;
int ret = NFCT_T_UNKNOWN;
if (type == IPCTNL_MSG_EXP_NEW) {
if (flags & (NLM_F_CREATE|NLM_F_EXCL))
ret = NFCT_T_NEW;
else
ret = NFCT_T_UPDATE;
} else if (type == IPCTNL_MSG_EXP_DELETE)
ret = NFCT_T_DESTROY;
return ret;
}
void __parse_expect(const struct nlmsghdr *nlh,
const struct nfattr *cda[],
struct nf_expect *exp)
{
struct nfgenmsg *nfhdr = NLMSG_DATA(nlh);
/* XXX: this is ugly, clean it up, please */
exp->expected.tuple[__DIR_ORIG].l3protonum = nfhdr->nfgen_family;
set_bit(ATTR_ORIG_L3PROTO, exp->expected.set);
exp->mask.tuple[__DIR_REPL].l3protonum = nfhdr->nfgen_family;
set_bit(ATTR_ORIG_L3PROTO, exp->mask.set);
if (cda[CTA_EXPECT_TUPLE-1])
__parse_tuple(cda[CTA_EXPECT_TUPLE-1],
&exp->expected.tuple[__DIR_ORIG],
__DIR_ORIG,
exp->set);
if (cda[CTA_EXPECT_MASK-1])
__parse_tuple(cda[CTA_EXPECT_MASK-1],
&exp->mask.tuple[__DIR_ORIG],
__DIR_ORIG,
exp->set);
if (cda[CTA_EXPECT_TIMEOUT-1]) {
exp->timeout =
ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_TIMEOUT-1]));
set_bit(ATTR_EXP_TIMEOUT, exp->set);
}
}
|