10 #include "internal/internal.h"
12 static void get_attr_grp_orig_ipv4(
const struct nf_conntrack *ct,
void *data)
15 this->src = ct->head.orig.src.v4;
16 this->dst = ct->head.orig.dst.v4;
19 static void get_attr_grp_repl_ipv4(
const struct nf_conntrack *ct,
void *data)
22 this->src = ct->repl.src.v4;
23 this->dst = ct->repl.dst.v4;
26 static void get_attr_grp_orig_ipv6(
const struct nf_conntrack *ct,
void *data)
29 memcpy(this->src, &ct->head.orig.src.v6,
sizeof(uint32_t)*4);
30 memcpy(this->dst, &ct->head.orig.dst.v6,
sizeof(uint32_t)*4);
33 static void get_attr_grp_repl_ipv6(
const struct nf_conntrack *ct,
void *data)
36 memcpy(this->src, &ct->repl.src.v6,
sizeof(uint32_t)*4);
37 memcpy(this->dst, &ct->repl.dst.v6,
sizeof(uint32_t)*4);
40 static void get_attr_grp_orig_port(
const struct nf_conntrack *ct,
void *data)
43 this->sport = ct->head.orig.l4src.all;
44 this->dport = ct->head.orig.l4dst.all;
47 static void get_attr_grp_repl_port(
const struct nf_conntrack *ct,
void *data)
50 this->sport = ct->repl.l4src.all;
51 this->dport = ct->repl.l4dst.all;
54 static void get_attr_grp_icmp(
const struct nf_conntrack *ct,
void *data)
57 this->type = ct->head.orig.l4dst.icmp.type;
58 this->code = ct->head.orig.l4dst.icmp.code;
59 this->
id = ct->head.orig.l4src.icmp.id;
62 static void get_attr_grp_master_ipv4(
const struct nf_conntrack *ct,
void *data)
65 this->src = ct->master.src.v4;
66 this->dst = ct->master.dst.v4;
69 static void get_attr_grp_master_ipv6(
const struct nf_conntrack *ct,
void *data)
72 memcpy(this->src, &ct->master.src.v6,
sizeof(uint32_t)*4);
73 memcpy(this->dst, &ct->master.dst.v6,
sizeof(uint32_t)*4);
76 static void get_attr_grp_master_port(
const struct nf_conntrack *ct,
void *data)
79 this->sport = ct->master.l4src.all;
80 this->dport = ct->master.l4dst.all;
83 static void get_attr_grp_orig_ctrs(
const struct nf_conntrack *ct,
void *data)
86 this->packets = ct->counters[__DIR_ORIG].packets;
87 this->bytes = ct->counters[__DIR_ORIG].bytes;
90 static void get_attr_grp_repl_ctrs(
const struct nf_conntrack *ct,
void *data)
93 this->packets = ct->counters[__DIR_REPL].packets;
94 this->bytes = ct->counters[__DIR_REPL].bytes;
98 get_attr_grp_orig_addr_src(
const struct nf_conntrack *ct,
void *data)
101 memcpy(&this->addr, &ct->head.orig.src,
sizeof(ct->head.orig.src));
105 get_attr_grp_orig_addr_dst(
const struct nf_conntrack *ct,
void *data)
108 memcpy(&this->addr, &ct->head.orig.dst,
sizeof(ct->head.orig.dst));
112 get_attr_grp_repl_addr_src(
const struct nf_conntrack *ct,
void *data)
115 memcpy(&this->addr, &ct->repl.src,
sizeof(ct->repl.src));
119 get_attr_grp_repl_addr_dst(
const struct nf_conntrack *ct,
void *data)
122 memcpy(&this->addr, &ct->repl.dst,
sizeof(ct->repl.dst));
125 const get_attr_grp get_attr_grp_array[ATTR_GRP_MAX] = {
126 [ATTR_GRP_ORIG_IPV4] = get_attr_grp_orig_ipv4,
127 [ATTR_GRP_REPL_IPV4] = get_attr_grp_repl_ipv4,
128 [ATTR_GRP_ORIG_IPV6] = get_attr_grp_orig_ipv6,
129 [ATTR_GRP_REPL_IPV6] = get_attr_grp_repl_ipv6,
130 [ATTR_GRP_ORIG_PORT] = get_attr_grp_orig_port,
131 [ATTR_GRP_REPL_PORT] = get_attr_grp_repl_port,
132 [ATTR_GRP_ICMP] = get_attr_grp_icmp,
133 [ATTR_GRP_MASTER_IPV4] = get_attr_grp_master_ipv4,
134 [ATTR_GRP_MASTER_IPV6] = get_attr_grp_master_ipv6,
135 [ATTR_GRP_MASTER_PORT] = get_attr_grp_master_port,
136 [ATTR_GRP_ORIG_COUNTERS] = get_attr_grp_orig_ctrs,
137 [ATTR_GRP_REPL_COUNTERS] = get_attr_grp_repl_ctrs,
138 [ATTR_GRP_ORIG_ADDR_SRC] = get_attr_grp_orig_addr_src,
139 [ATTR_GRP_ORIG_ADDR_DST] = get_attr_grp_orig_addr_dst,
140 [ATTR_GRP_REPL_ADDR_SRC] = get_attr_grp_repl_addr_src,
141 [ATTR_GRP_REPL_ADDR_DST] = get_attr_grp_repl_addr_dst,