10 #include "internal/internal.h"
12 static void filter_attr_l4proto(
struct nfct_filter *filter,
const void *value)
14 if (filter->l4proto_len >= __FILTER_L4PROTO_MAX)
17 set_bit(*((
int *) value), filter->l4proto_map);
18 filter->l4proto_len++;
22 filter_attr_l4proto_state(
struct nfct_filter *filter,
const void *value)
26 set_bit_u16(this->state, &filter->l4proto_state[this->proto].map);
27 filter->l4proto_state[this->proto].len++;
30 static void filter_attr_src_ipv4(
struct nfct_filter *filter,
const void *value)
34 if (filter->l3proto_elems[0] >= __FILTER_ADDR_MAX)
37 filter->l3proto[0][filter->l3proto_elems[0]].addr = this->addr;
38 filter->l3proto[0][filter->l3proto_elems[0]].mask = this->mask;
39 filter->l3proto_elems[0]++;
42 static void filter_attr_dst_ipv4(
struct nfct_filter *filter,
const void *value)
46 if (filter->l3proto_elems[1] >= __FILTER_ADDR_MAX)
49 filter->l3proto[1][filter->l3proto_elems[1]].addr = this->addr;
50 filter->l3proto[1][filter->l3proto_elems[1]].mask = this->mask;
51 filter->l3proto_elems[1]++;
54 static void filter_attr_src_ipv6(
struct nfct_filter *filter,
const void *value)
58 if (filter->l3proto_elems_ipv6[0] >= __FILTER_IPV6_MAX)
61 memcpy(filter->l3proto_ipv6[0][filter->l3proto_elems_ipv6[0]].addr,
62 this->addr,
sizeof(uint32_t)*4);
63 memcpy(filter->l3proto_ipv6[0][filter->l3proto_elems_ipv6[0]].mask,
64 this->mask,
sizeof(uint32_t)*4);
65 filter->l3proto_elems_ipv6[0]++;
68 static void filter_attr_dst_ipv6(
struct nfct_filter *filter,
const void *value)
72 if (filter->l3proto_elems_ipv6[1] >= __FILTER_IPV6_MAX)
75 memcpy(filter->l3proto_ipv6[1][filter->l3proto_elems_ipv6[1]].addr,
76 this->addr,
sizeof(uint32_t)*4);
77 memcpy(filter->l3proto_ipv6[1][filter->l3proto_elems_ipv6[1]].mask,
78 this->mask,
sizeof(uint32_t)*4);
79 filter->l3proto_elems_ipv6[1]++;
82 static void filter_attr_mark(
struct nfct_filter *filter,
const void *value)
86 if (filter->mark_elems >= __FILTER_MARK_MAX)
89 filter->mark[filter->mark_elems].val = this->val;
90 filter->mark[filter->mark_elems].mask = this->mask;
94 const filter_attr filter_attr_array[NFCT_FILTER_MAX] = {
95 [NFCT_FILTER_L4PROTO] = filter_attr_l4proto,
96 [NFCT_FILTER_L4PROTO_STATE] = filter_attr_l4proto_state,
97 [NFCT_FILTER_SRC_IPV4] = filter_attr_src_ipv4,
98 [NFCT_FILTER_DST_IPV4] = filter_attr_dst_ipv4,
99 [NFCT_FILTER_SRC_IPV6] = filter_attr_src_ipv6,
100 [NFCT_FILTER_DST_IPV6] = filter_attr_dst_ipv6,
101 [NFCT_FILTER_MARK] = filter_attr_mark,