Home | History | Annotate | Download | only in conntrack
      1 /*
      2  * (C) 2005-2011 by Pablo Neira Ayuso <pablo (at) 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 static const void *get_attr_orig_ipv4_src(const struct nf_conntrack *ct)
     13 {
     14 	return &ct->head.orig.src.v4;
     15 }
     16 
     17 static const void *get_attr_orig_ipv4_dst(const struct nf_conntrack *ct)
     18 {
     19 	return &ct->head.orig.dst.v4;
     20 }
     21 
     22 static const void *get_attr_repl_ipv4_src(const struct nf_conntrack *ct)
     23 {
     24 	return &ct->repl.src.v4;
     25 }
     26 
     27 static const void *get_attr_repl_ipv4_dst(const struct nf_conntrack *ct)
     28 {
     29 	return &ct->repl.dst.v4;
     30 }
     31 
     32 static const void *get_attr_orig_ipv6_src(const struct nf_conntrack *ct)
     33 {
     34 	return &ct->head.orig.src.v6;
     35 }
     36 
     37 static const void *get_attr_orig_ipv6_dst(const struct nf_conntrack *ct)
     38 {
     39 	return &ct->head.orig.dst.v6;
     40 }
     41 
     42 static const void *get_attr_repl_ipv6_src(const struct nf_conntrack *ct)
     43 {
     44 	return &ct->repl.src.v6;
     45 }
     46 
     47 static const void *get_attr_repl_ipv6_dst(const struct nf_conntrack *ct)
     48 {
     49 	return &ct->repl.dst.v6;
     50 }
     51 
     52 static const void *get_attr_orig_port_src(const struct nf_conntrack *ct)
     53 {
     54 	return &ct->head.orig.l4src.all;
     55 }
     56 
     57 static const void *get_attr_orig_port_dst(const struct nf_conntrack *ct)
     58 {
     59 	return &ct->head.orig.l4dst.all;
     60 }
     61 
     62 static const void *get_attr_repl_port_src(const struct nf_conntrack *ct)
     63 {
     64 	return &ct->repl.l4src.all;
     65 }
     66 
     67 static const void *get_attr_repl_port_dst(const struct nf_conntrack *ct)
     68 {
     69 	return &ct->repl.l4dst.all;
     70 }
     71 
     72 static const void *get_attr_orig_zone(const struct nf_conntrack *ct)
     73 {
     74 	return &ct->head.orig.zone;
     75 }
     76 
     77 static const void *get_attr_repl_zone(const struct nf_conntrack *ct)
     78 {
     79 	return &ct->repl.zone;
     80 }
     81 
     82 static const void *get_attr_icmp_type(const struct nf_conntrack *ct)
     83 {
     84 	return &ct->head.orig.l4dst.icmp.type;
     85 }
     86 
     87 static const void *get_attr_icmp_code(const struct nf_conntrack *ct)
     88 {
     89 	return &ct->head.orig.l4dst.icmp.code;
     90 }
     91 
     92 static const void *get_attr_icmp_id(const struct nf_conntrack *ct)
     93 {
     94 	return &ct->head.orig.l4src.icmp.id;
     95 }
     96 
     97 static const void *get_attr_orig_l3proto(const struct nf_conntrack *ct)
     98 {
     99 	return &ct->head.orig.l3protonum;
    100 }
    101 
    102 static const void *get_attr_repl_l3proto(const struct nf_conntrack *ct)
    103 {
    104 	return &ct->repl.l3protonum;
    105 }
    106 
    107 static const void *get_attr_orig_l4proto(const struct nf_conntrack *ct)
    108 {
    109 	return &ct->head.orig.protonum;
    110 }
    111 
    112 static const void *get_attr_repl_l4proto(const struct nf_conntrack *ct)
    113 {
    114 	return &ct->repl.protonum;
    115 }
    116 
    117 static const void *get_attr_master_ipv4_src(const struct nf_conntrack *ct)
    118 {
    119 	return &ct->master.src.v4;
    120 }
    121 
    122 static const void *get_attr_master_ipv4_dst(const struct nf_conntrack *ct)
    123 {
    124 	return &ct->master.dst.v4;
    125 }
    126 
    127 static const void *get_attr_master_ipv6_src(const struct nf_conntrack *ct)
    128 {
    129 	return &ct->master.src.v6;
    130 }
    131 
    132 static const void *get_attr_master_ipv6_dst(const struct nf_conntrack *ct)
    133 {
    134 	return &ct->master.dst.v6;
    135 }
    136 
    137 static const void *get_attr_master_port_src(const struct nf_conntrack *ct)
    138 {
    139 	return &ct->master.l4src.all;
    140 }
    141 
    142 static const void *get_attr_master_port_dst(const struct nf_conntrack *ct)
    143 {
    144 	return &ct->master.l4dst.all;
    145 }
    146 
    147 static const void *get_attr_master_l3proto(const struct nf_conntrack *ct)
    148 {
    149 	return &ct->master.l3protonum;
    150 }
    151 
    152 static const void *get_attr_master_l4proto(const struct nf_conntrack *ct)
    153 {
    154 	return &ct->master.protonum;
    155 }
    156 
    157 static const void *get_attr_tcp_state(const struct nf_conntrack *ct)
    158 {
    159 	return &ct->protoinfo.tcp.state;
    160 }
    161 
    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 
    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 
    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 
    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 
    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 
    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 
    192 static const void *get_attr_sctp_state(const struct nf_conntrack *ct)
    193 {
    194 	return &ct->protoinfo.sctp.state;
    195 }
    196 
    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 
    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 
    207 static const void *get_attr_snat_ipv4(const struct nf_conntrack *ct)
    208 {
    209 	return &ct->snat.min_ip.v4;
    210 }
    211 
    212 static const void *get_attr_dnat_ipv4(const struct nf_conntrack *ct)
    213 {
    214 	return &ct->dnat.min_ip.v4;
    215 }
    216 
    217 static const void *get_attr_snat_ipv6(const struct nf_conntrack *ct)
    218 {
    219 	return &ct->snat.min_ip.v6;
    220 }
    221 
    222 static const void *get_attr_dnat_ipv6(const struct nf_conntrack *ct)
    223 {
    224 	return &ct->dnat.min_ip.v6;
    225 }
    226 
    227 static const void *get_attr_snat_port(const struct nf_conntrack *ct)
    228 {
    229 	return &ct->snat.l4min.all;
    230 }
    231 
    232 static const void *get_attr_dnat_port(const struct nf_conntrack *ct)
    233 {
    234 	return &ct->dnat.l4min.all;
    235 }
    236 
    237 static const void *get_attr_timeout(const struct nf_conntrack *ct)
    238 {
    239 	return &ct->timeout;
    240 }
    241 
    242 static const void *get_attr_mark(const struct nf_conntrack *ct)
    243 {
    244 	return &ct->mark;
    245 }
    246 
    247 static const void *get_attr_secmark(const struct nf_conntrack *ct)
    248 {
    249 	return &ct->secmark;
    250 }
    251 
    252 static const void *get_attr_orig_counter_packets(const struct nf_conntrack *ct)
    253 {
    254 	return &ct->counters[__DIR_ORIG].packets;
    255 }
    256 
    257 static const void *get_attr_orig_counter_bytes(const struct nf_conntrack *ct)
    258 {
    259 	return &ct->counters[__DIR_ORIG].bytes;
    260 }
    261 
    262 static const void *get_attr_repl_counter_packets(const struct nf_conntrack *ct)
    263 {
    264 	return &ct->counters[__DIR_REPL].packets;
    265 }
    266 
    267 static const void *get_attr_repl_counter_bytes(const struct nf_conntrack *ct)
    268 {
    269 	return &ct->counters[__DIR_REPL].bytes;
    270 }
    271 
    272 static const void *get_attr_status(const struct nf_conntrack *ct)
    273 {
    274 	return &ct->status;
    275 }
    276 
    277 static const void *get_attr_use(const struct nf_conntrack *ct)
    278 {
    279 	return &ct->use;
    280 }
    281 
    282 static const void *get_attr_id(const struct nf_conntrack *ct)
    283 {
    284 	return &ct->id;
    285 }
    286 
    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 
    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 
    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 
    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 
    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 
    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 
    317 static const void *get_attr_helper_name(const struct nf_conntrack *ct)
    318 {
    319 	return ct->helper_name;
    320 }
    321 
    322 static const void *get_attr_dccp_state(const struct nf_conntrack *ct)
    323 {
    324 	return &ct->protoinfo.dccp.state;
    325 }
    326 
    327 static const void *get_attr_dccp_role(const struct nf_conntrack *ct)
    328 {
    329 	return &ct->protoinfo.dccp.role;
    330 }
    331 
    332 static const void *get_attr_dccp_handshake_seq(const struct nf_conntrack *ct)
    333 {
    334 	return &ct->protoinfo.dccp.handshake_seq;
    335 }
    336 
    337 static const void *get_attr_zone(const struct nf_conntrack *ct)
    338 {
    339 	return &ct->zone;
    340 }
    341 
    342 static const void *get_attr_secctx(const struct nf_conntrack *ct)
    343 {
    344 	return ct->secctx;
    345 }
    346 
    347 static const void *get_attr_timestamp_start(const struct nf_conntrack *ct)
    348 {
    349 	return &ct->timestamp.start;
    350 }
    351 
    352 static const void *get_attr_timestamp_stop(const struct nf_conntrack *ct)
    353 {
    354 	return &ct->timestamp.stop;
    355 }
    356 
    357 static const void *get_attr_helper_info(const struct nf_conntrack *ct)
    358 {
    359 	return ct->helper_info;
    360 }
    361 
    362 static const void *get_attr_connlabels(const struct nf_conntrack *ct)
    363 {
    364 	return ct->connlabels;
    365 }
    366 
    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