optimizate: rename IP type to address family
This commit is contained in:
@@ -13,7 +13,7 @@ TEST(EVICTED_SESSION_FILTER, TEST)
|
||||
double error_rate = 0.00001;
|
||||
|
||||
memset(&c2s_key, 0, sizeof(c2s_key));
|
||||
c2s_key.ip_type = IP_TYPE_V4;
|
||||
c2s_key.addr_family = AF_INET;
|
||||
c2s_key.src_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
c2s_key.dst_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
c2s_key.src_port = 0x0303;
|
||||
@@ -22,7 +22,7 @@ TEST(EVICTED_SESSION_FILTER, TEST)
|
||||
c2s_key.domain = 0x0606060606060606;
|
||||
|
||||
memset(&s2c_key, 0, sizeof(s2c_key));
|
||||
s2c_key.ip_type = IP_TYPE_V4;
|
||||
s2c_key.addr_family = AF_INET;
|
||||
s2c_key.src_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
s2c_key.dst_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
s2c_key.src_port = 0x0404;
|
||||
|
||||
@@ -33,7 +33,7 @@ uint64_t packet_ldbc_hash(const struct packet *pkt, enum load_balance ldbc, enum
|
||||
return hash_value;
|
||||
}
|
||||
|
||||
if (inner_addr.ip_type == IP_TYPE_V4)
|
||||
if (inner_addr.addr_family == AF_INET)
|
||||
{
|
||||
inner_src_addr = (const char *)&inner_addr.src_addr.v4;
|
||||
inner_dst_addr = (const char *)&inner_addr.dst_addr.v4;
|
||||
@@ -46,7 +46,7 @@ uint64_t packet_ldbc_hash(const struct packet *pkt, enum load_balance ldbc, enum
|
||||
inner_addr_len = sizeof(struct in6_addr);
|
||||
}
|
||||
|
||||
if (outer_addr.ip_type == IP_TYPE_V4)
|
||||
if (outer_addr.addr_family == AF_INET)
|
||||
{
|
||||
outer_src_addr = (const char *)&outer_addr.src_addr.v4;
|
||||
outer_dst_addr = (const char *)&outer_addr.dst_addr.v4;
|
||||
|
||||
@@ -144,7 +144,7 @@ int packet_get_innermost_tuple2(const struct packet *pkt, struct tuple2 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
return 0;
|
||||
@@ -152,7 +152,7 @@ int packet_get_innermost_tuple2(const struct packet *pkt, struct tuple2 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
return 0;
|
||||
@@ -176,7 +176,7 @@ int packet_get_outermost_tuple2(const struct packet *pkt, struct tuple2 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
return 0;
|
||||
@@ -184,7 +184,7 @@ int packet_get_outermost_tuple2(const struct packet *pkt, struct tuple2 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
return 0;
|
||||
@@ -229,7 +229,7 @@ int packet_get_innermost_tuple4(const struct packet *pkt, struct tuple4 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -238,7 +238,7 @@ int packet_get_innermost_tuple4(const struct packet *pkt, struct tuple4 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -273,7 +273,7 @@ int packet_get_outermost_tuple4(const struct packet *pkt, struct tuple4 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -282,7 +282,7 @@ int packet_get_outermost_tuple4(const struct packet *pkt, struct tuple4 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -355,7 +355,7 @@ int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -364,7 +364,7 @@ int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -400,7 +400,7 @@ int packet_get_outermost_tuple6(const struct packet *pkt, struct tuple6 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV4)
|
||||
{
|
||||
const struct ip *ip4_hdr = (const struct ip *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V4;
|
||||
tuple->addr_family = AF_INET;
|
||||
tuple->src_addr.v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
|
||||
tuple->dst_addr.v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
|
||||
layer_l3 = layer;
|
||||
@@ -409,7 +409,7 @@ int packet_get_outermost_tuple6(const struct packet *pkt, struct tuple6 *tuple)
|
||||
if (layer->proto == LAYER_PROTO_IPV6)
|
||||
{
|
||||
const struct ip6_hdr *ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
|
||||
tuple->ip_type = IP_TYPE_V6;
|
||||
tuple->addr_family = AF_INET6;
|
||||
tuple->src_addr.v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
|
||||
tuple->dst_addr.v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
|
||||
layer_l3 = layer;
|
||||
|
||||
@@ -411,7 +411,7 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
|
||||
memset(&tuple, 0, sizeof(struct tuple6));
|
||||
packet_get_innermost_tuple6(pkt, &tuple);
|
||||
|
||||
if (tuple.ip_type == IP_TYPE_V4)
|
||||
if (tuple.addr_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &tuple.src_addr.v4, src_addr, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &tuple.dst_addr.v4, dst_addr, INET6_ADDRSTRLEN);
|
||||
|
||||
@@ -1057,6 +1057,7 @@ void session_manager_free_session(struct session_manager *mgr, struct session *s
|
||||
session_clear_route_ctx(sess, FLOW_DIRECTION_S2C);
|
||||
session_clear_sids(sess, FLOW_DIRECTION_C2S);
|
||||
session_clear_sids(sess, FLOW_DIRECTION_S2C);
|
||||
session_set_current_state(sess, SESSION_STATE_INIT);
|
||||
session_set_current_packet(sess, NULL);
|
||||
session_set_current_flow_direction(sess, FLOW_DIRECTION_NONE);
|
||||
session_pool_push(mgr->sess_pool, sess);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define SESSION_KEY_IPV4_TCP(name) \
|
||||
struct tuple6 name; \
|
||||
memset(&name, 0, sizeof(struct tuple6)); \
|
||||
(name).ip_type = IP_TYPE_V4; \
|
||||
(name).addr_family = AF_INET; \
|
||||
(name).src_addr.v4.s_addr = inet_addr("192.168.1.2"); \
|
||||
(name).dst_addr.v4.s_addr = inet_addr("192.168.1.3"); \
|
||||
(name).src_port = htons(1234); \
|
||||
@@ -17,7 +17,7 @@
|
||||
#define SESSION_KEY_IPV6_UDP(name) \
|
||||
struct tuple6 name; \
|
||||
memset(&name, 0, sizeof(struct tuple6)); \
|
||||
(name).ip_type = IP_TYPE_V6; \
|
||||
(name).addr_family = AF_INET6; \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:8329", &(name).src_addr.v6); \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:832a", &(name).dst_addr.v6); \
|
||||
(name).src_port = htons(1234); \
|
||||
@@ -28,7 +28,7 @@
|
||||
#define SESSION_KEY_IPV6_TCP(name) \
|
||||
struct tuple6 name; \
|
||||
memset(&name, 0, sizeof(struct tuple6)); \
|
||||
(name).ip_type = IP_TYPE_V6; \
|
||||
(name).addr_family = AF_INET6; \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:8329", &(name).src_addr.v6); \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:832a", &(name).dst_addr.v6); \
|
||||
(name).src_port = htons(1234); \
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define TUPLE6_SET_V4_TCP(t6) \
|
||||
{ \
|
||||
memset(&t6, 0, sizeof(struct tuple6)); \
|
||||
(t6).ip_type = IP_TYPE_V4; \
|
||||
(t6).addr_family = AF_INET; \
|
||||
(t6).src_addr.v4.s_addr = inet_addr("192.168.1.2"); \
|
||||
(t6).dst_addr.v4.s_addr = inet_addr("192.168.1.3"); \
|
||||
(t6).src_port = htons(1234); \
|
||||
@@ -20,7 +20,7 @@
|
||||
#define TUPLE6_SET_V6_UDP(t6) \
|
||||
{ \
|
||||
memset(&t6, 0, sizeof(struct tuple6)); \
|
||||
(t6).ip_type = IP_TYPE_V6; \
|
||||
(t6).addr_family = AF_INET6; \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:8329", &(t6).src_addr.v6); \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:832a", &(t6).dst_addr.v6); \
|
||||
(t6).src_port = htons(2345); \
|
||||
@@ -32,7 +32,7 @@
|
||||
#define TUPLE6_SET_V6_TCP(t6) \
|
||||
{ \
|
||||
memset(&t6, 0, sizeof(struct tuple6)); \
|
||||
(t6).ip_type = IP_TYPE_V6; \
|
||||
(t6).addr_family = AF_INET6; \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:8329", &(t6).src_addr.v6); \
|
||||
inet_pton(AF_INET6, "2001:db8:0:0:0:ff00:42:832a", &(t6).dst_addr.v6); \
|
||||
(t6).src_port = htons(3456); \
|
||||
@@ -44,7 +44,7 @@
|
||||
#define TUPLE6_TO_TUPLE4(t6, t4) \
|
||||
{ \
|
||||
memset(&(t4), 0, sizeof(struct tuple4)); \
|
||||
(t4).ip_type = (t6).ip_type; \
|
||||
(t4).addr_family = (t6).addr_family; \
|
||||
(t4).src_addr = (t6).src_addr; \
|
||||
(t4).dst_addr = (t6).dst_addr; \
|
||||
(t4).src_port = (t6).src_port; \
|
||||
|
||||
@@ -17,11 +17,11 @@ TEST(TUPLE, TUPLE2)
|
||||
memset(&reversed_tuple_a, 0, sizeof(struct tuple2));
|
||||
memset(&reversed_tuple_b, 0, sizeof(struct tuple2));
|
||||
|
||||
tuple_a.ip_type = IP_TYPE_V4;
|
||||
tuple_a.addr_family = AF_INET;
|
||||
tuple_a.src_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
tuple_a.dst_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
|
||||
tuple_b.ip_type = IP_TYPE_V6;
|
||||
tuple_b.addr_family = AF_INET6;
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:8329", &tuple_b.src_addr.v6);
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:832a", &tuple_b.dst_addr.v6);
|
||||
|
||||
@@ -76,13 +76,13 @@ TEST(TUPLE, TUPLE4)
|
||||
memset(&reversed_tuple_a, 0, sizeof(struct tuple4));
|
||||
memset(&reversed_tuple_b, 0, sizeof(struct tuple4));
|
||||
|
||||
tuple_a.ip_type = IP_TYPE_V4;
|
||||
tuple_a.addr_family = AF_INET;
|
||||
tuple_a.src_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
tuple_a.dst_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
tuple_a.src_port = htons(1234);
|
||||
tuple_a.dst_port = htons(5678);
|
||||
|
||||
tuple_b.ip_type = IP_TYPE_V6;
|
||||
tuple_b.addr_family = AF_INET6;
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:8329", &tuple_b.src_addr.v6);
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:832a", &tuple_b.dst_addr.v6);
|
||||
tuple_b.src_port = htons(1234);
|
||||
@@ -139,14 +139,14 @@ TEST(TUPLE, TUPLE5)
|
||||
memset(&reversed_tuple_a, 0, sizeof(struct tuple5));
|
||||
memset(&reversed_tuple_b, 0, sizeof(struct tuple5));
|
||||
|
||||
tuple_a.ip_type = IP_TYPE_V4;
|
||||
tuple_a.addr_family = AF_INET;
|
||||
tuple_a.src_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
tuple_a.dst_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
tuple_a.src_port = htons(1234);
|
||||
tuple_a.dst_port = htons(5678);
|
||||
tuple_a.ip_proto = IPPROTO_TCP;
|
||||
|
||||
tuple_b.ip_type = IP_TYPE_V6;
|
||||
tuple_b.addr_family = AF_INET6;
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:8329", &tuple_b.src_addr.v6);
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:832a", &tuple_b.dst_addr.v6);
|
||||
tuple_b.src_port = htons(1234);
|
||||
@@ -204,7 +204,7 @@ TEST(TUPLE, TUPLE6)
|
||||
memset(&reversed_tuple_a, 0, sizeof(struct tuple6));
|
||||
memset(&reversed_tuple_b, 0, sizeof(struct tuple6));
|
||||
|
||||
tuple_a.ip_type = IP_TYPE_V4;
|
||||
tuple_a.addr_family = AF_INET;
|
||||
tuple_a.src_addr.v4.s_addr = inet_addr("192.168.1.2");
|
||||
tuple_a.dst_addr.v4.s_addr = inet_addr("192.168.1.3");
|
||||
tuple_a.src_port = htons(1234);
|
||||
@@ -212,7 +212,7 @@ TEST(TUPLE, TUPLE6)
|
||||
tuple_a.ip_proto = IPPROTO_TCP;
|
||||
tuple_a.domain = 0;
|
||||
|
||||
tuple_b.ip_type = IP_TYPE_V6;
|
||||
tuple_b.addr_family = AF_INET6;
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:8329", &tuple_b.src_addr.v6);
|
||||
inet_pton(AF_INET6, "2001:db8::ff00:42:832a", &tuple_b.dst_addr.v6);
|
||||
tuple_b.src_port = htons(1234);
|
||||
|
||||
@@ -8,9 +8,9 @@ uint32_t tuple2_hash(const struct tuple2 *tuple)
|
||||
{
|
||||
uint32_t src_addr_hash = 0;
|
||||
uint32_t dst_addr_hash = 0;
|
||||
uint32_t hash = crc32_hash(&tuple->ip_type, sizeof(tuple->ip_type), 0);
|
||||
uint32_t hash = crc32_hash(&tuple->addr_family, sizeof(tuple->addr_family), 0);
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
src_addr_hash = crc32_hash(&tuple->src_addr.v4, sizeof(tuple->src_addr.v4), hash);
|
||||
dst_addr_hash = crc32_hash(&tuple->dst_addr.v4, sizeof(tuple->dst_addr.v4), hash);
|
||||
@@ -31,9 +31,9 @@ uint32_t tuple4_hash(const struct tuple4 *tuple)
|
||||
uint32_t dst_addr_hash = 0;
|
||||
uint32_t src_port_hash = 0;
|
||||
uint32_t dst_port_hash = 0;
|
||||
uint32_t hash = crc32_hash(&tuple->ip_type, sizeof(tuple->ip_type), 0);
|
||||
uint32_t hash = crc32_hash(&tuple->addr_family, sizeof(tuple->addr_family), 0);
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
src_addr_hash = crc32_hash(&tuple->src_addr.v4, sizeof(tuple->src_addr.v4), hash);
|
||||
dst_addr_hash = crc32_hash(&tuple->dst_addr.v4, sizeof(tuple->dst_addr.v4), hash);
|
||||
@@ -58,10 +58,10 @@ uint32_t tuple5_hash(const struct tuple5 *tuple)
|
||||
uint32_t dst_addr_hash = 0;
|
||||
uint32_t src_port_hash = 0;
|
||||
uint32_t dst_port_hash = 0;
|
||||
uint32_t hash = crc32_hash(&tuple->ip_type, sizeof(tuple->ip_type), 0);
|
||||
uint32_t hash = crc32_hash(&tuple->addr_family, sizeof(tuple->addr_family), 0);
|
||||
hash = crc32_hash(&tuple->ip_proto, sizeof(tuple->ip_proto), hash);
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
src_addr_hash = crc32_hash(&tuple->src_addr.v4, sizeof(tuple->src_addr.v4), hash);
|
||||
dst_addr_hash = crc32_hash(&tuple->dst_addr.v4, sizeof(tuple->dst_addr.v4), hash);
|
||||
@@ -86,11 +86,11 @@ uint32_t tuple6_hash(const struct tuple6 *tuple)
|
||||
uint32_t dst_addr_hash = 0;
|
||||
uint32_t src_port_hash = 0;
|
||||
uint32_t dst_port_hash = 0;
|
||||
uint32_t hash = crc32_hash(&tuple->ip_type, sizeof(tuple->ip_type), 0);
|
||||
uint32_t hash = crc32_hash(&tuple->addr_family, sizeof(tuple->addr_family), 0);
|
||||
hash = crc32_hash(&tuple->ip_proto, sizeof(tuple->ip_proto), hash);
|
||||
hash = crc32_hash(&tuple->domain, sizeof(tuple->domain), hash);
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
src_addr_hash = crc32_hash(&tuple->src_addr.v4, sizeof(tuple->src_addr.v4), hash);
|
||||
dst_addr_hash = crc32_hash(&tuple->dst_addr.v4, sizeof(tuple->dst_addr.v4), hash);
|
||||
@@ -111,12 +111,12 @@ uint32_t tuple6_hash(const struct tuple6 *tuple)
|
||||
|
||||
int tuple2_cmp(const struct tuple2 *tuple_a, const struct tuple2 *tuple_b)
|
||||
{
|
||||
if (tuple_a->ip_type != tuple_b->ip_type)
|
||||
if (tuple_a->addr_family != tuple_b->addr_family)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type == IP_TYPE_V4)
|
||||
if (tuple_a->addr_family == AF_INET)
|
||||
{
|
||||
if (tuple_a->src_addr.v4.s_addr != tuple_b->src_addr.v4.s_addr)
|
||||
{
|
||||
@@ -156,12 +156,12 @@ int tuple4_cmp(const struct tuple4 *tuple_a, const struct tuple4 *tuple_b)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type != tuple_b->ip_type)
|
||||
if (tuple_a->addr_family != tuple_b->addr_family)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type == IP_TYPE_V4)
|
||||
if (tuple_a->addr_family == AF_INET)
|
||||
{
|
||||
if (tuple_a->src_addr.v4.s_addr != tuple_b->src_addr.v4.s_addr)
|
||||
{
|
||||
@@ -206,12 +206,12 @@ int tuple5_cmp(const struct tuple5 *tuple_a, const struct tuple5 *tuple_b)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type != tuple_b->ip_type)
|
||||
if (tuple_a->addr_family != tuple_b->addr_family)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type == IP_TYPE_V4)
|
||||
if (tuple_a->addr_family == AF_INET)
|
||||
{
|
||||
if (tuple_a->src_addr.v4.s_addr != tuple_b->src_addr.v4.s_addr)
|
||||
{
|
||||
@@ -261,12 +261,12 @@ int tuple6_cmp(const struct tuple6 *tuple_a, const struct tuple6 *tuple_b)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type != tuple_b->ip_type)
|
||||
if (tuple_a->addr_family != tuple_b->addr_family)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tuple_a->ip_type == IP_TYPE_V4)
|
||||
if (tuple_a->addr_family == AF_INET)
|
||||
{
|
||||
if (tuple_a->src_addr.v4.s_addr != tuple_b->src_addr.v4.s_addr)
|
||||
{
|
||||
@@ -297,7 +297,7 @@ int tuple6_cmp(const struct tuple6 *tuple_a, const struct tuple6 *tuple_b)
|
||||
void tuple2_reverse(const struct tuple2 *in, struct tuple2 *out)
|
||||
{
|
||||
memset(out, 0, sizeof(struct tuple2));
|
||||
out->ip_type = in->ip_type;
|
||||
out->addr_family = in->addr_family;
|
||||
|
||||
memcpy(&out->src_addr, &in->dst_addr, sizeof(in->dst_addr));
|
||||
memcpy(&out->dst_addr, &in->src_addr, sizeof(in->src_addr));
|
||||
@@ -306,7 +306,7 @@ void tuple2_reverse(const struct tuple2 *in, struct tuple2 *out)
|
||||
void tuple4_reverse(const struct tuple4 *in, struct tuple4 *out)
|
||||
{
|
||||
memset(out, 0, sizeof(struct tuple4));
|
||||
out->ip_type = in->ip_type;
|
||||
out->addr_family = in->addr_family;
|
||||
out->src_port = in->dst_port;
|
||||
out->dst_port = in->src_port;
|
||||
|
||||
@@ -317,7 +317,7 @@ void tuple4_reverse(const struct tuple4 *in, struct tuple4 *out)
|
||||
void tuple5_reverse(const struct tuple5 *in, struct tuple5 *out)
|
||||
{
|
||||
memset(out, 0, sizeof(struct tuple5));
|
||||
out->ip_type = in->ip_type;
|
||||
out->addr_family = in->addr_family;
|
||||
out->ip_proto = in->ip_proto;
|
||||
out->src_port = in->dst_port;
|
||||
out->dst_port = in->src_port;
|
||||
@@ -329,7 +329,7 @@ void tuple5_reverse(const struct tuple5 *in, struct tuple5 *out)
|
||||
void tuple6_reverse(const struct tuple6 *in, struct tuple6 *out)
|
||||
{
|
||||
memset(out, 0, sizeof(struct tuple6));
|
||||
out->ip_type = in->ip_type;
|
||||
out->addr_family = in->addr_family;
|
||||
out->ip_proto = in->ip_proto;
|
||||
out->domain = in->domain;
|
||||
out->src_port = in->dst_port;
|
||||
@@ -344,7 +344,7 @@ void tuple2_to_str(const struct tuple2 *tuple, char *buf, uint32_t size)
|
||||
char src_addr[INET6_ADDRSTRLEN] = {0};
|
||||
char dst_addr[INET6_ADDRSTRLEN] = {0};
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &tuple->src_addr.v4, src_addr, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &tuple->dst_addr.v4, dst_addr, INET6_ADDRSTRLEN);
|
||||
@@ -363,7 +363,7 @@ void tuple4_to_str(const struct tuple4 *tuple, char *buf, uint32_t size)
|
||||
char src_addr[INET6_ADDRSTRLEN] = {0};
|
||||
char dst_addr[INET6_ADDRSTRLEN] = {0};
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &tuple->src_addr.v4, src_addr, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &tuple->dst_addr.v4, dst_addr, INET6_ADDRSTRLEN);
|
||||
@@ -384,7 +384,7 @@ void tuple5_to_str(const struct tuple5 *tuple, char *buf, uint32_t size)
|
||||
char src_addr[INET6_ADDRSTRLEN] = {0};
|
||||
char dst_addr[INET6_ADDRSTRLEN] = {0};
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &tuple->src_addr.v4, src_addr, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &tuple->dst_addr.v4, dst_addr, INET6_ADDRSTRLEN);
|
||||
@@ -406,7 +406,7 @@ void tuple6_to_str(const struct tuple6 *tuple, char *buf, uint32_t size)
|
||||
char src_addr[INET6_ADDRSTRLEN] = {0};
|
||||
char dst_addr[INET6_ADDRSTRLEN] = {0};
|
||||
|
||||
if (tuple->ip_type == IP_TYPE_V4)
|
||||
if (tuple->addr_family == AF_INET)
|
||||
{
|
||||
inet_ntop(AF_INET, &tuple->src_addr.v4, src_addr, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &tuple->dst_addr.v4, dst_addr, INET6_ADDRSTRLEN);
|
||||
|
||||
@@ -7,12 +7,6 @@ extern "C"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
enum ip_type
|
||||
{
|
||||
IP_TYPE_V4,
|
||||
IP_TYPE_V6,
|
||||
};
|
||||
|
||||
union ip_address
|
||||
{
|
||||
struct in_addr v4; /* network order */
|
||||
@@ -21,14 +15,14 @@ union ip_address
|
||||
|
||||
struct tuple2
|
||||
{
|
||||
enum ip_type ip_type;
|
||||
uint32_t addr_family;
|
||||
union ip_address src_addr; /* network order */
|
||||
union ip_address dst_addr; /* network order */
|
||||
};
|
||||
|
||||
struct tuple4
|
||||
{
|
||||
enum ip_type ip_type;
|
||||
uint32_t addr_family;
|
||||
union ip_address src_addr; /* network order */
|
||||
union ip_address dst_addr; /* network order */
|
||||
|
||||
@@ -38,7 +32,7 @@ struct tuple4
|
||||
|
||||
struct tuple5
|
||||
{
|
||||
enum ip_type ip_type;
|
||||
uint32_t addr_family;
|
||||
union ip_address src_addr; /* network order */
|
||||
union ip_address dst_addr; /* network order */
|
||||
|
||||
@@ -50,7 +44,7 @@ struct tuple5
|
||||
|
||||
struct tuple6
|
||||
{
|
||||
enum ip_type ip_type;
|
||||
uint32_t addr_family;
|
||||
union ip_address src_addr; /* network order */
|
||||
union ip_address dst_addr; /* network order */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user