00001
00002
00003
00004
00005
00006
00007
00008 #include "internal/internal.h"
00009
00010 static void get_attr_grp_orig_ipv4(const struct nf_conntrack *ct, void *data)
00011 {
00012 struct nfct_attr_grp_ipv4 *this = data;
00013 this->src = ct->tuple[__DIR_ORIG].src.v4;
00014 this->dst = ct->tuple[__DIR_ORIG].dst.v4;
00015 }
00016
00017 static void get_attr_grp_repl_ipv4(const struct nf_conntrack *ct, void *data)
00018 {
00019 struct nfct_attr_grp_ipv4 *this = data;
00020 this->src = ct->tuple[__DIR_REPL].src.v4;
00021 this->dst = ct->tuple[__DIR_REPL].dst.v4;
00022 }
00023
00024 static void get_attr_grp_orig_ipv6(const struct nf_conntrack *ct, void *data)
00025 {
00026 struct nfct_attr_grp_ipv6 *this = data;
00027 memcpy(this->src, &ct->tuple[__DIR_ORIG].src.v6, sizeof(u_int32_t)*4);
00028 memcpy(this->dst, &ct->tuple[__DIR_ORIG].dst.v6, sizeof(u_int32_t)*4);
00029 }
00030
00031 static void get_attr_grp_repl_ipv6(const struct nf_conntrack *ct, void *data)
00032 {
00033 struct nfct_attr_grp_ipv6 *this = data;
00034 memcpy(this->src, &ct->tuple[__DIR_REPL].src.v6, sizeof(u_int32_t)*4);
00035 memcpy(this->dst, &ct->tuple[__DIR_REPL].dst.v6, sizeof(u_int32_t)*4);
00036 }
00037
00038 static void get_attr_grp_orig_port(const struct nf_conntrack *ct, void *data)
00039 {
00040 struct nfct_attr_grp_port *this = data;
00041 this->sport = ct->tuple[__DIR_ORIG].l4src.all;
00042 this->dport = ct->tuple[__DIR_ORIG].l4dst.all;
00043 }
00044
00045 static void get_attr_grp_repl_port(const struct nf_conntrack *ct, void *data)
00046 {
00047 struct nfct_attr_grp_port *this = data;
00048 this->sport = ct->tuple[__DIR_REPL].l4src.all;
00049 this->dport = ct->tuple[__DIR_REPL].l4dst.all;
00050 }
00051
00052 static void get_attr_grp_icmp(const struct nf_conntrack *ct, void *data)
00053 {
00054 struct nfct_attr_grp_icmp *this = data;
00055 this->type = ct->tuple[__DIR_ORIG].l4dst.icmp.type;
00056 this->code = ct->tuple[__DIR_ORIG].l4dst.icmp.code;
00057 this->id = ct->tuple[__DIR_ORIG].l4src.icmp.id;
00058 }
00059
00060 static void get_attr_grp_master_ipv4(const struct nf_conntrack *ct, void *data)
00061 {
00062 struct nfct_attr_grp_ipv4 *this = data;
00063 this->src = ct->tuple[__DIR_MASTER].src.v4;
00064 this->dst = ct->tuple[__DIR_MASTER].dst.v4;
00065 }
00066
00067 static void get_attr_grp_master_ipv6(const struct nf_conntrack *ct, void *data)
00068 {
00069 struct nfct_attr_grp_ipv6 *this = data;
00070 memcpy(this->src, &ct->tuple[__DIR_MASTER].src.v6, sizeof(u_int32_t)*4);
00071 memcpy(this->dst, &ct->tuple[__DIR_MASTER].dst.v6, sizeof(u_int32_t)*4);
00072 }
00073
00074 static void get_attr_grp_master_port(const struct nf_conntrack *ct, void *data)
00075 {
00076 struct nfct_attr_grp_port *this = data;
00077 this->sport = ct->tuple[__DIR_MASTER].l4src.all;
00078 this->dport = ct->tuple[__DIR_MASTER].l4dst.all;
00079 }
00080
00081 static void get_attr_grp_orig_ctrs(const struct nf_conntrack *ct, void *data)
00082 {
00083 struct nfct_attr_grp_ctrs *this = data;
00084 this->packets = ct->counters[__DIR_ORIG].packets;
00085 this->bytes = ct->counters[__DIR_ORIG].bytes;
00086 }
00087
00088 static void get_attr_grp_repl_ctrs(const struct nf_conntrack *ct, void *data)
00089 {
00090 struct nfct_attr_grp_ctrs *this = data;
00091 this->packets = ct->counters[__DIR_REPL].packets;
00092 this->bytes = ct->counters[__DIR_REPL].bytes;
00093 }
00094
00095 const get_attr_grp get_attr_grp_array[ATTR_GRP_MAX] = {
00096 [ATTR_GRP_ORIG_IPV4] = get_attr_grp_orig_ipv4,
00097 [ATTR_GRP_REPL_IPV4] = get_attr_grp_repl_ipv4,
00098 [ATTR_GRP_ORIG_IPV6] = get_attr_grp_orig_ipv6,
00099 [ATTR_GRP_REPL_IPV6] = get_attr_grp_repl_ipv6,
00100 [ATTR_GRP_ORIG_PORT] = get_attr_grp_orig_port,
00101 [ATTR_GRP_REPL_PORT] = get_attr_grp_repl_port,
00102 [ATTR_GRP_ICMP] = get_attr_grp_icmp,
00103 [ATTR_GRP_MASTER_IPV4] = get_attr_grp_master_ipv4,
00104 [ATTR_GRP_MASTER_IPV6] = get_attr_grp_master_ipv6,
00105 [ATTR_GRP_MASTER_PORT] = get_attr_grp_master_port,
00106 [ATTR_GRP_ORIG_COUNTERS] = get_attr_grp_orig_ctrs,
00107 [ATTR_GRP_REPL_COUNTERS] = get_attr_grp_repl_ctrs
00108 };