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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* ulogd_filter_MARK.c, Version $Revision: 1500 $
*
* ulogd interpreter plugin for internal IP storage format to string conversion
*
* (C) 2008 by Eric Leblond <eric@inl.fr>
*
* Based on ulogd_filter_IFINDEX.c Harald Welte <laforge@gnumonks.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: ulogd_filter_IFINDEX.c 1500 2005-10-03 16:54:02Z laforge $
*/
#include <stdio.h>
#include <ulogd/ulogd.h>
enum mark_kset {
MARK_MARK,
MARK_MASK,
};
static struct config_keyset libulog_kset = {
.num_ces = 2,
.ces = {
[MARK_MARK] = {
.key = "mark",
.type = CONFIG_TYPE_INT,
.options = CONFIG_OPT_NONE,
.u.value = 0,
},
[MARK_MASK] = {
.key = "mask",
.type = CONFIG_TYPE_INT,
.options = CONFIG_OPT_NONE,
.u.value = 0xffffffff,
},
}
};
enum input_keys {
KEY_CT_MARK,
KEY_OOB_MARK,
MAX_KEY = KEY_OOB_MARK,
};
static struct ulogd_key mark_inp[] = {
[KEY_CT_MARK] = {
.type = ULOGD_RET_UINT32,
.flags = ULOGD_RETF_NONE|ULOGD_KEYF_OPTIONAL,
.name = "ct.mark",
},
[KEY_OOB_MARK] = {
.type = ULOGD_RET_UINT32,
.flags = ULOGD_RETF_NONE|ULOGD_KEYF_OPTIONAL,
.name = "oob.mark",
},
};
static int interp_mark(struct ulogd_pluginstance *pi)
{
struct ulogd_key *inp = pi->input.keys;
if (pp_is_valid(inp, KEY_CT_MARK)) {
if ((ikey_get_u32(&inp[KEY_CT_MARK]) &
pi->config_kset->ces[MARK_MASK].u.value) !=
(u_int32_t) pi->config_kset->ces[MARK_MARK].u.value
) {
return ULOGD_IRET_STOP;
}
} else if (pp_is_valid(inp, KEY_OOB_MARK)) {
if ((ikey_get_u32(&inp[KEY_OOB_MARK]) &
pi->config_kset->ces[MARK_MASK].u.value) !=
(u_int32_t) pi->config_kset->ces[MARK_MARK].u.value
) {
return ULOGD_IRET_STOP;
}
}
return ULOGD_IRET_OK;
}
static int configure(struct ulogd_pluginstance *upi,
struct ulogd_pluginstance_stack *stack)
{
ulogd_log(ULOGD_DEBUG, "parsing config file section `%s', "
"plugin `%s'\n", upi->id, upi->plugin->name);
config_parse_file(upi->id, upi->config_kset);
return 0;
}
static struct ulogd_plugin mark_pluging = {
.name = "MARK",
.input = {
.keys = mark_inp,
.num_keys = ARRAY_SIZE(mark_inp),
.type = ULOGD_DTYPE_PACKET | ULOGD_DTYPE_FLOW,
},
.output = {
.type = ULOGD_DTYPE_PACKET | ULOGD_DTYPE_FLOW,
},
.interp = &interp_mark,
.config_kset = &libulog_kset,
.configure = &configure,
.version = ULOGD_VERSION,
};
void __attribute__ ((constructor)) init(void);
void init(void)
{
ulogd_register_plugin(&mark_pluging);
}
|