• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * (C) 2005-2011 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 
get_attr_orig_ipv4_src(const struct nf_conntrack * ct)12 static const void *get_attr_orig_ipv4_src(const struct nf_conntrack *ct)
13 {
14 	return &ct->head.orig.src.v4;
15 }
16 
get_attr_orig_ipv4_dst(const struct nf_conntrack * ct)17 static const void *get_attr_orig_ipv4_dst(const struct nf_conntrack *ct)
18 {
19 	return &ct->head.orig.dst.v4;
20 }
21 
get_attr_repl_ipv4_src(const struct nf_conntrack * ct)22 static const void *get_attr_repl_ipv4_src(const struct nf_conntrack *ct)
23 {
24 	return &ct->repl.src.v4;
25 }
26 
get_attr_repl_ipv4_dst(const struct nf_conntrack * ct)27 static const void *get_attr_repl_ipv4_dst(const struct nf_conntrack *ct)
28 {
29 	return &ct->repl.dst.v4;
30 }
31 
get_attr_orig_ipv6_src(const struct nf_conntrack * ct)32 static const void *get_attr_orig_ipv6_src(const struct nf_conntrack *ct)
33 {
34 	return &ct->head.orig.src.v6;
35 }
36 
get_attr_orig_ipv6_dst(const struct nf_conntrack * ct)37 static const void *get_attr_orig_ipv6_dst(const struct nf_conntrack *ct)
38 {
39 	return &ct->head.orig.dst.v6;
40 }
41 
get_attr_repl_ipv6_src(const struct nf_conntrack * ct)42 static const void *get_attr_repl_ipv6_src(const struct nf_conntrack *ct)
43 {
44 	return &ct->repl.src.v6;
45 }
46 
get_attr_repl_ipv6_dst(const struct nf_conntrack * ct)47 static const void *get_attr_repl_ipv6_dst(const struct nf_conntrack *ct)
48 {
49 	return &ct->repl.dst.v6;
50 }
51 
get_attr_orig_port_src(const struct nf_conntrack * ct)52 static const void *get_attr_orig_port_src(const struct nf_conntrack *ct)
53 {
54 	return &ct->head.orig.l4src.all;
55 }
56 
get_attr_orig_port_dst(const struct nf_conntrack * ct)57 static const void *get_attr_orig_port_dst(const struct nf_conntrack *ct)
58 {
59 	return &ct->head.orig.l4dst.all;
60 }
61 
get_attr_repl_port_src(const struct nf_conntrack * ct)62 static const void *get_attr_repl_port_src(const struct nf_conntrack *ct)
63 {
64 	return &ct->repl.l4src.all;
65 }
66 
get_attr_repl_port_dst(const struct nf_conntrack * ct)67 static const void *get_attr_repl_port_dst(const struct nf_conntrack *ct)
68 {
69 	return &ct->repl.l4dst.all;
70 }
71 
get_attr_orig_zone(const struct nf_conntrack * ct)72 static const void *get_attr_orig_zone(const struct nf_conntrack *ct)
73 {
74 	return &ct->head.orig.zone;
75 }
76 
get_attr_repl_zone(const struct nf_conntrack * ct)77 static const void *get_attr_repl_zone(const struct nf_conntrack *ct)
78 {
79 	return &ct->repl.zone;
80 }
81 
get_attr_icmp_type(const struct nf_conntrack * ct)82 static const void *get_attr_icmp_type(const struct nf_conntrack *ct)
83 {
84 	return &ct->head.orig.l4dst.icmp.type;
85 }
86 
get_attr_icmp_code(const struct nf_conntrack * ct)87 static const void *get_attr_icmp_code(const struct nf_conntrack *ct)
88 {
89 	return &ct->head.orig.l4dst.icmp.code;
90 }
91 
get_attr_icmp_id(const struct nf_conntrack * ct)92 static const void *get_attr_icmp_id(const struct nf_conntrack *ct)
93 {
94 	return &ct->head.orig.l4src.icmp.id;
95 }
96 
get_attr_orig_l3proto(const struct nf_conntrack * ct)97 static const void *get_attr_orig_l3proto(const struct nf_conntrack *ct)
98 {
99 	return &ct->head.orig.l3protonum;
100 }
101 
get_attr_repl_l3proto(const struct nf_conntrack * ct)102 static const void *get_attr_repl_l3proto(const struct nf_conntrack *ct)
103 {
104 	return &ct->repl.l3protonum;
105 }
106 
get_attr_orig_l4proto(const struct nf_conntrack * ct)107 static const void *get_attr_orig_l4proto(const struct nf_conntrack *ct)
108 {
109 	return &ct->head.orig.protonum;
110 }
111 
get_attr_repl_l4proto(const struct nf_conntrack * ct)112 static const void *get_attr_repl_l4proto(const struct nf_conntrack *ct)
113 {
114 	return &ct->repl.protonum;
115 }
116 
get_attr_master_ipv4_src(const struct nf_conntrack * ct)117 static const void *get_attr_master_ipv4_src(const struct nf_conntrack *ct)
118 {
119 	return &ct->master.src.v4;
120 }
121 
get_attr_master_ipv4_dst(const struct nf_conntrack * ct)122 static const void *get_attr_master_ipv4_dst(const struct nf_conntrack *ct)
123 {
124 	return &ct->master.dst.v4;
125 }
126 
get_attr_master_ipv6_src(const struct nf_conntrack * ct)127 static const void *get_attr_master_ipv6_src(const struct nf_conntrack *ct)
128 {
129 	return &ct->master.src.v6;
130 }
131 
get_attr_master_ipv6_dst(const struct nf_conntrack * ct)132 static const void *get_attr_master_ipv6_dst(const struct nf_conntrack *ct)
133 {
134 	return &ct->master.dst.v6;
135 }
136 
get_attr_master_port_src(const struct nf_conntrack * ct)137 static const void *get_attr_master_port_src(const struct nf_conntrack *ct)
138 {
139 	return &ct->master.l4src.all;
140 }
141 
get_attr_master_port_dst(const struct nf_conntrack * ct)142 static const void *get_attr_master_port_dst(const struct nf_conntrack *ct)
143 {
144 	return &ct->master.l4dst.all;
145 }
146 
get_attr_master_l3proto(const struct nf_conntrack * ct)147 static const void *get_attr_master_l3proto(const struct nf_conntrack *ct)
148 {
149 	return &ct->master.l3protonum;
150 }
151 
get_attr_master_l4proto(const struct nf_conntrack * ct)152 static const void *get_attr_master_l4proto(const struct nf_conntrack *ct)
153 {
154 	return &ct->master.protonum;
155 }
156 
get_attr_tcp_state(const struct nf_conntrack * ct)157 static const void *get_attr_tcp_state(const struct nf_conntrack *ct)
158 {
159 	return &ct->protoinfo.tcp.state;
160 }
161 
get_attr_tcp_flags_orig(const struct nf_conntrack * ct)162 static const void *get_attr_tcp_flags_orig(const struct nf_conntrack *ct)
163 {
164 	return &ct->protoinfo.tcp.flags[__DIR_ORIG].value;
165 }
166 
get_attr_tcp_mask_orig(const struct nf_conntrack * ct)167 static const void *get_attr_tcp_mask_orig(const struct nf_conntrack *ct)
168 {
169 	return &ct->protoinfo.tcp.flags[__DIR_ORIG].mask;
170 }
171 
get_attr_tcp_flags_repl(const struct nf_conntrack * ct)172 static const void *get_attr_tcp_flags_repl(const struct nf_conntrack *ct)
173 {
174 	return &ct->protoinfo.tcp.flags[__DIR_REPL].value;
175 }
176 
get_attr_tcp_mask_repl(const struct nf_conntrack * ct)177 static const void *get_attr_tcp_mask_repl(const struct nf_conntrack *ct)
178 {
179 	return &ct->protoinfo.tcp.flags[__DIR_REPL].mask;
180 }
181 
get_attr_tcp_wscale_orig(const struct nf_conntrack * ct)182 static const void *get_attr_tcp_wscale_orig(const struct nf_conntrack *ct)
183 {
184 	return &ct->protoinfo.tcp.wscale[__DIR_ORIG];
185 }
186 
get_attr_tcp_wscale_repl(const struct nf_conntrack * ct)187 static const void *get_attr_tcp_wscale_repl(const struct nf_conntrack *ct)
188 {
189 	return &ct->protoinfo.tcp.wscale[__DIR_REPL];
190 }
191 
get_attr_sctp_state(const struct nf_conntrack * ct)192 static const void *get_attr_sctp_state(const struct nf_conntrack *ct)
193 {
194 	return &ct->protoinfo.sctp.state;
195 }
196 
get_attr_sctp_vtag_orig(const struct nf_conntrack * ct)197 static const void *get_attr_sctp_vtag_orig(const struct nf_conntrack *ct)
198 {
199 	return &ct->protoinfo.sctp.vtag[__DIR_ORIG];
200 }
201 
get_attr_sctp_vtag_repl(const struct nf_conntrack * ct)202 static const void *get_attr_sctp_vtag_repl(const struct nf_conntrack *ct)
203 {
204 	return &ct->protoinfo.sctp.vtag[__DIR_REPL];
205 }
206 
get_attr_snat_ipv4(const struct nf_conntrack * ct)207 static const void *get_attr_snat_ipv4(const struct nf_conntrack *ct)
208 {
209 	return &ct->snat.min_ip.v4;
210 }
211 
get_attr_dnat_ipv4(const struct nf_conntrack * ct)212 static const void *get_attr_dnat_ipv4(const struct nf_conntrack *ct)
213 {
214 	return &ct->dnat.min_ip.v4;
215 }
216 
get_attr_snat_ipv6(const struct nf_conntrack * ct)217 static const void *get_attr_snat_ipv6(const struct nf_conntrack *ct)
218 {
219 	return &ct->snat.min_ip.v6;
220 }
221 
get_attr_dnat_ipv6(const struct nf_conntrack * ct)222 static const void *get_attr_dnat_ipv6(const struct nf_conntrack *ct)
223 {
224 	return &ct->dnat.min_ip.v6;
225 }
226 
get_attr_snat_port(const struct nf_conntrack * ct)227 static const void *get_attr_snat_port(const struct nf_conntrack *ct)
228 {
229 	return &ct->snat.l4min.all;
230 }
231 
get_attr_dnat_port(const struct nf_conntrack * ct)232 static const void *get_attr_dnat_port(const struct nf_conntrack *ct)
233 {
234 	return &ct->dnat.l4min.all;
235 }
236 
get_attr_timeout(const struct nf_conntrack * ct)237 static const void *get_attr_timeout(const struct nf_conntrack *ct)
238 {
239 	return &ct->timeout;
240 }
241 
get_attr_mark(const struct nf_conntrack * ct)242 static const void *get_attr_mark(const struct nf_conntrack *ct)
243 {
244 	return &ct->mark;
245 }
246 
get_attr_secmark(const struct nf_conntrack * ct)247 static const void *get_attr_secmark(const struct nf_conntrack *ct)
248 {
249 	return &ct->secmark;
250 }
251 
get_attr_orig_counter_packets(const struct nf_conntrack * ct)252 static const void *get_attr_orig_counter_packets(const struct nf_conntrack *ct)
253 {
254 	return &ct->counters[__DIR_ORIG].packets;
255 }
256 
get_attr_orig_counter_bytes(const struct nf_conntrack * ct)257 static const void *get_attr_orig_counter_bytes(const struct nf_conntrack *ct)
258 {
259 	return &ct->counters[__DIR_ORIG].bytes;
260 }
261 
get_attr_repl_counter_packets(const struct nf_conntrack * ct)262 static const void *get_attr_repl_counter_packets(const struct nf_conntrack *ct)
263 {
264 	return &ct->counters[__DIR_REPL].packets;
265 }
266 
get_attr_repl_counter_bytes(const struct nf_conntrack * ct)267 static const void *get_attr_repl_counter_bytes(const struct nf_conntrack *ct)
268 {
269 	return &ct->counters[__DIR_REPL].bytes;
270 }
271 
get_attr_status(const struct nf_conntrack * ct)272 static const void *get_attr_status(const struct nf_conntrack *ct)
273 {
274 	return &ct->status;
275 }
276 
get_attr_use(const struct nf_conntrack * ct)277 static const void *get_attr_use(const struct nf_conntrack *ct)
278 {
279 	return &ct->use;
280 }
281 
get_attr_id(const struct nf_conntrack * ct)282 static const void *get_attr_id(const struct nf_conntrack *ct)
283 {
284 	return &ct->id;
285 }
286 
get_attr_orig_cor_pos(const struct nf_conntrack * ct)287 static const void *get_attr_orig_cor_pos(const struct nf_conntrack *ct)
288 {
289 	return &ct->natseq[__DIR_ORIG].correction_pos;
290 }
291 
get_attr_orig_off_bfr(const struct nf_conntrack * ct)292 static const void *get_attr_orig_off_bfr(const struct nf_conntrack *ct)
293 {
294 	return &ct->natseq[__DIR_ORIG].offset_before;
295 }
296 
get_attr_orig_off_aft(const struct nf_conntrack * ct)297 static const void *get_attr_orig_off_aft(const struct nf_conntrack *ct)
298 {
299 	return &ct->natseq[__DIR_ORIG].offset_after;
300 }
301 
get_attr_repl_cor_pos(const struct nf_conntrack * ct)302 static const void *get_attr_repl_cor_pos(const struct nf_conntrack *ct)
303 {
304 	return &ct->natseq[__DIR_REPL].correction_pos;
305 }
306 
get_attr_repl_off_bfr(const struct nf_conntrack * ct)307 static const void *get_attr_repl_off_bfr(const struct nf_conntrack *ct)
308 {
309 	return &ct->natseq[__DIR_REPL].offset_before;
310 }
311 
get_attr_repl_off_aft(const struct nf_conntrack * ct)312 static const void *get_attr_repl_off_aft(const struct nf_conntrack *ct)
313 {
314 	return &ct->natseq[__DIR_REPL].offset_after;
315 }
316 
get_attr_helper_name(const struct nf_conntrack * ct)317 static const void *get_attr_helper_name(const struct nf_conntrack *ct)
318 {
319 	return ct->helper_name;
320 }
321 
get_attr_dccp_state(const struct nf_conntrack * ct)322 static const void *get_attr_dccp_state(const struct nf_conntrack *ct)
323 {
324 	return &ct->protoinfo.dccp.state;
325 }
326 
get_attr_dccp_role(const struct nf_conntrack * ct)327 static const void *get_attr_dccp_role(const struct nf_conntrack *ct)
328 {
329 	return &ct->protoinfo.dccp.role;
330 }
331 
get_attr_dccp_handshake_seq(const struct nf_conntrack * ct)332 static const void *get_attr_dccp_handshake_seq(const struct nf_conntrack *ct)
333 {
334 	return &ct->protoinfo.dccp.handshake_seq;
335 }
336 
get_attr_zone(const struct nf_conntrack * ct)337 static const void *get_attr_zone(const struct nf_conntrack *ct)
338 {
339 	return &ct->zone;
340 }
341 
get_attr_secctx(const struct nf_conntrack * ct)342 static const void *get_attr_secctx(const struct nf_conntrack *ct)
343 {
344 	return ct->secctx;
345 }
346 
get_attr_timestamp_start(const struct nf_conntrack * ct)347 static const void *get_attr_timestamp_start(const struct nf_conntrack *ct)
348 {
349 	return &ct->timestamp.start;
350 }
351 
get_attr_timestamp_stop(const struct nf_conntrack * ct)352 static const void *get_attr_timestamp_stop(const struct nf_conntrack *ct)
353 {
354 	return &ct->timestamp.stop;
355 }
356 
get_attr_helper_info(const struct nf_conntrack * ct)357 static const void *get_attr_helper_info(const struct nf_conntrack *ct)
358 {
359 	return ct->helper_info;
360 }
361 
get_attr_connlabels(const struct nf_conntrack * ct)362 static const void *get_attr_connlabels(const struct nf_conntrack *ct)
363 {
364 	return ct->connlabels;
365 }
366 
get_attr_connlabels_mask(const struct nf_conntrack * ct)367 static const void *get_attr_connlabels_mask(const struct nf_conntrack *ct)
368 {
369 	return ct->connlabels_mask;
370 }
371 
372 const get_attr get_attr_array[ATTR_MAX] = {
373 	[ATTR_ORIG_IPV4_SRC]		= get_attr_orig_ipv4_src,
374 	[ATTR_ORIG_IPV4_DST] 		= get_attr_orig_ipv4_dst,
375 	[ATTR_REPL_IPV4_SRC]		= get_attr_repl_ipv4_src,
376 	[ATTR_REPL_IPV4_DST]		= get_attr_repl_ipv4_dst,
377 	[ATTR_ORIG_IPV6_SRC]		= get_attr_orig_ipv6_src,
378 	[ATTR_ORIG_IPV6_DST]		= get_attr_orig_ipv6_dst,
379 	[ATTR_REPL_IPV6_SRC]		= get_attr_repl_ipv6_src,
380 	[ATTR_REPL_IPV6_DST]		= get_attr_repl_ipv6_dst,
381 	[ATTR_ORIG_PORT_SRC]		= get_attr_orig_port_src,
382 	[ATTR_ORIG_PORT_DST]		= get_attr_orig_port_dst,
383 	[ATTR_REPL_PORT_SRC]		= get_attr_repl_port_src,
384 	[ATTR_REPL_PORT_DST]		= get_attr_repl_port_dst,
385 	[ATTR_ICMP_TYPE]		= get_attr_icmp_type,
386 	[ATTR_ICMP_CODE]		= get_attr_icmp_code,
387 	[ATTR_ICMP_ID]			= get_attr_icmp_id,
388 	[ATTR_ORIG_L3PROTO]		= get_attr_orig_l3proto,
389 	[ATTR_REPL_L3PROTO]		= get_attr_repl_l3proto,
390 	[ATTR_ORIG_L4PROTO]		= get_attr_orig_l4proto,
391 	[ATTR_REPL_L4PROTO]		= get_attr_repl_l4proto,
392 	[ATTR_TCP_STATE]		= get_attr_tcp_state,
393 	[ATTR_SNAT_IPV4]		= get_attr_snat_ipv4,
394 	[ATTR_DNAT_IPV4]		= get_attr_dnat_ipv4,
395 	[ATTR_SNAT_PORT]		= get_attr_snat_port,
396 	[ATTR_DNAT_PORT]		= get_attr_dnat_port,
397 	[ATTR_TIMEOUT]			= get_attr_timeout,
398 	[ATTR_MARK]			= get_attr_mark,
399 	[ATTR_ORIG_COUNTER_PACKETS] 	= get_attr_orig_counter_packets,
400 	[ATTR_ORIG_COUNTER_BYTES]	= get_attr_orig_counter_bytes,
401 	[ATTR_REPL_COUNTER_PACKETS]	= get_attr_repl_counter_packets,
402 	[ATTR_REPL_COUNTER_BYTES]	= get_attr_repl_counter_bytes,
403 	[ATTR_USE]			= get_attr_use,
404 	[ATTR_ID]			= get_attr_id,
405 	[ATTR_STATUS]			= get_attr_status,
406 	[ATTR_TCP_FLAGS_ORIG]		= get_attr_tcp_flags_orig,
407 	[ATTR_TCP_FLAGS_REPL]		= get_attr_tcp_flags_repl,
408 	[ATTR_TCP_MASK_ORIG]		= get_attr_tcp_mask_orig,
409 	[ATTR_TCP_MASK_REPL]		= get_attr_tcp_mask_repl,
410 	[ATTR_MASTER_IPV4_SRC]		= get_attr_master_ipv4_src,
411 	[ATTR_MASTER_IPV4_DST] 		= get_attr_master_ipv4_dst,
412 	[ATTR_MASTER_IPV6_SRC]		= get_attr_master_ipv6_src,
413 	[ATTR_MASTER_IPV6_DST]		= get_attr_master_ipv6_dst,
414 	[ATTR_MASTER_PORT_SRC]		= get_attr_master_port_src,
415 	[ATTR_MASTER_PORT_DST]		= get_attr_master_port_dst,
416 	[ATTR_MASTER_L3PROTO]		= get_attr_master_l3proto,
417 	[ATTR_MASTER_L4PROTO]		= get_attr_master_l4proto,
418 	[ATTR_SECMARK]			= get_attr_secmark,
419 	[ATTR_ORIG_NAT_SEQ_CORRECTION_POS]	= get_attr_orig_cor_pos,
420 	[ATTR_ORIG_NAT_SEQ_OFFSET_BEFORE]	= get_attr_orig_off_bfr,
421 	[ATTR_ORIG_NAT_SEQ_OFFSET_AFTER]	= get_attr_orig_off_aft,
422 	[ATTR_REPL_NAT_SEQ_CORRECTION_POS]	= get_attr_repl_cor_pos,
423 	[ATTR_REPL_NAT_SEQ_OFFSET_BEFORE]	= get_attr_repl_off_bfr,
424 	[ATTR_REPL_NAT_SEQ_OFFSET_AFTER]	= get_attr_repl_off_aft,
425 	[ATTR_SCTP_STATE]		= get_attr_sctp_state,
426 	[ATTR_SCTP_VTAG_ORIG]		= get_attr_sctp_vtag_orig,
427 	[ATTR_SCTP_VTAG_REPL]		= get_attr_sctp_vtag_repl,
428 	[ATTR_HELPER_NAME]		= get_attr_helper_name,
429 	[ATTR_DCCP_STATE]		= get_attr_dccp_state,
430 	[ATTR_DCCP_ROLE]		= get_attr_dccp_role,
431 	[ATTR_DCCP_HANDSHAKE_SEQ]	= get_attr_dccp_handshake_seq,
432 	[ATTR_TCP_WSCALE_ORIG]		= get_attr_tcp_wscale_orig,
433 	[ATTR_TCP_WSCALE_REPL]		= get_attr_tcp_wscale_repl,
434 	[ATTR_ZONE]			= get_attr_zone,
435 	[ATTR_ORIG_ZONE]		= get_attr_orig_zone,
436 	[ATTR_REPL_ZONE]		= get_attr_repl_zone,
437 	[ATTR_SECCTX]			= get_attr_secctx,
438 	[ATTR_TIMESTAMP_START]		= get_attr_timestamp_start,
439 	[ATTR_TIMESTAMP_STOP]		= get_attr_timestamp_stop,
440 	[ATTR_HELPER_INFO]		= get_attr_helper_info,
441 	[ATTR_CONNLABELS]		= get_attr_connlabels,
442 	[ATTR_CONNLABELS_MASK]		= get_attr_connlabels_mask,
443 	[ATTR_SNAT_IPV6]		= get_attr_snat_ipv6,
444 	[ATTR_DNAT_IPV6]		= get_attr_dnat_ipv6,
445 };
446