Add packet_build.cpp support imitate_tcp_packet() / imitate_udp_packet()

This commit is contained in:
luwenpeng
2024-04-24 11:40:00 +08:00
parent ffead24e45
commit d8963af5f8
16 changed files with 444 additions and 441 deletions

View File

@@ -1487,10 +1487,7 @@ const struct raw_layer *packet_get_outermost_raw_layer(const struct packet *pkt,
return NULL;
}
// TODO
// direction 1: E2I
// direction 0: I2E
uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int direction)
uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, enum packet_direction direction)
{
uint64_t temp = 0;
uint64_t hash_value = 1;
@@ -1549,7 +1546,7 @@ uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int
switch (method)
{
case LDBC_METHOD_HASH_INT_IP:
if (direction)
if (direction == PACKET_DIRECTION_INCOMING)
{
// direction 1: E2I
HASH_VALUE(outer_dst_addr, outer_addr_len, hash_value);
@@ -1561,7 +1558,7 @@ uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int
}
break;
case LDBC_METHOD_HASH_EXT_IP:
if (direction)
if (direction == PACKET_DIRECTION_INCOMING)
{
// direction 1: E2I
HASH_VALUE(outer_src_addr, outer_addr_len, hash_value);
@@ -1578,7 +1575,7 @@ uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int
hash_value = hash_value ^ temp;
break;
case LDBC_METHOD_HASH_INNERMOST_INT_IP:
if (direction)
if (direction == PACKET_DIRECTION_INCOMING)
{
// direction 1: E2I
HASH_VALUE(inner_dst_addr, inner_addr_len, hash_value);
@@ -1590,7 +1587,7 @@ uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int
}
break;
case LDBC_METHOD_HASH_INNERMOST_EXT_IP:
if (direction)
if (direction == PACKET_DIRECTION_INCOMING)
{
// direction 1: E2I
HASH_VALUE(inner_src_addr, inner_addr_len, hash_value);