1 /*
2  * (C) 2005-2012 by Pablo Neira Ayuso <pablo@netfilter.org>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  */
9 
10 #include "internal/internal.h"
11 
12 const struct attr_grp_bitmask attr_grp_bitmask[ATTR_GRP_MAX]= {
13 	[ATTR_GRP_ORIG_IPV4] = {
14 		.bitmask[0] = (1 << ATTR_ORIG_IPV4_SRC) |
15 			      (1 << ATTR_ORIG_IPV4_DST) |
16 			      (1 << ATTR_ORIG_L3PROTO),
17 		.type = NFCT_BITMASK_AND,
18 	},
19 	[ATTR_GRP_REPL_IPV4] = {
20 		.bitmask[0] = (1 << ATTR_REPL_IPV4_SRC) |
21 			      (1 << ATTR_REPL_IPV4_DST) |
22 			      (1 << ATTR_REPL_L3PROTO),
23 		.type = NFCT_BITMASK_AND,
24 	},
25 	[ATTR_GRP_ORIG_IPV6] = {
26 		.bitmask[0] = (1 << ATTR_ORIG_IPV6_SRC) |
27 			      (1 << ATTR_ORIG_IPV6_DST) |
28 			      (1 << ATTR_ORIG_L3PROTO),
29 		.type = NFCT_BITMASK_AND,
30 	},
31 	[ATTR_GRP_REPL_IPV6] = {
32 		.bitmask[0] = (1 << ATTR_REPL_IPV6_SRC) |
33 			      (1 << ATTR_REPL_IPV6_DST) |
34 			      (1 << ATTR_REPL_L3PROTO),
35 		.type = NFCT_BITMASK_AND,
36 	},
37 	[ATTR_GRP_ORIG_PORT] = {
38 		.bitmask[0] = (1 << ATTR_ORIG_PORT_SRC) |
39 			      (1 << ATTR_ORIG_PORT_DST) |
40 			      (1 << ATTR_ORIG_L4PROTO),
41 		.type = NFCT_BITMASK_AND,
42 	},
43 	[ATTR_GRP_REPL_PORT] = {
44 		.bitmask[0] = (1 << ATTR_REPL_PORT_SRC) |
45 			      (1 << ATTR_REPL_PORT_DST) |
46 			      (1 << ATTR_REPL_L4PROTO),
47 		.type = NFCT_BITMASK_AND,
48 	},
49 	[ATTR_GRP_ICMP] = {
50 		.bitmask[0] = (1 << ATTR_ICMP_CODE) |
51 			      (1 << ATTR_ICMP_TYPE) |
52 			      (1 << ATTR_ICMP_ID),
53 		.type = NFCT_BITMASK_AND,
54 	},
55 	[ATTR_GRP_MASTER_IPV4] = {
56 		.bitmask[1] = (1 << (ATTR_MASTER_IPV4_SRC - 32)) |
57 			      (1 << (ATTR_MASTER_IPV4_DST - 32)) |
58 			      (1 << (ATTR_MASTER_L3PROTO - 32)),
59 		.type = NFCT_BITMASK_AND,
60 	},
61 	[ATTR_GRP_MASTER_IPV6] = {
62 		.bitmask[1] = (1 << (ATTR_MASTER_IPV6_SRC - 32)) |
63 			      (1 << (ATTR_MASTER_IPV6_DST - 32)) |
64 			      (1 << (ATTR_MASTER_L3PROTO - 32)),
65 		.type = NFCT_BITMASK_AND,
66 	},
67 	[ATTR_GRP_MASTER_PORT] = {
68 		.bitmask[1] = (1 << (ATTR_MASTER_PORT_SRC - 32)) |
69 			      (1 << (ATTR_MASTER_PORT_DST - 32)) |
70 			      (1 << (ATTR_MASTER_L4PROTO - 32)),
71 		.type = NFCT_BITMASK_AND,
72 	},
73 	[ATTR_GRP_ORIG_COUNTERS] = {
74 		.bitmask[0] = (1 << (ATTR_ORIG_COUNTER_PACKETS)) |
75 			      (1 << (ATTR_ORIG_COUNTER_BYTES)),
76 		.type = NFCT_BITMASK_AND,
77 	},
78 	[ATTR_GRP_REPL_COUNTERS] = {
79 		.bitmask[0] = (1 << (ATTR_REPL_COUNTER_PACKETS)) |
80 			      (1 << (ATTR_REPL_COUNTER_BYTES)),
81 		.type = NFCT_BITMASK_AND,
82 	},
83 	[ATTR_GRP_ORIG_ADDR_SRC] = {
84 		.bitmask[0] = (1 << ATTR_ORIG_IPV4_SRC) |
85 			      (1 << ATTR_ORIG_IPV6_SRC),
86 		.type = NFCT_BITMASK_OR,
87 	},
88 	[ATTR_GRP_ORIG_ADDR_DST] = {
89 		.bitmask[0] = (1 << ATTR_ORIG_IPV4_DST) |
90 			      (1 << ATTR_ORIG_IPV6_DST),
91 		.type = NFCT_BITMASK_OR,
92 
93 	},
94 	[ATTR_GRP_REPL_ADDR_SRC] = {
95 		.bitmask[0] = (1 << ATTR_REPL_IPV4_SRC) |
96 			      (1 << ATTR_REPL_IPV6_SRC),
97 		.type = NFCT_BITMASK_OR,
98 	},
99 	[ATTR_GRP_REPL_ADDR_DST] = {
100 		.bitmask[0] = (1 << ATTR_REPL_IPV4_DST) |
101 			      (1 << ATTR_REPL_IPV6_DST),
102 		.type = NFCT_BITMASK_OR,
103 	},
104 };
105