rename xxx_tostring() -> xxx_to_str()

This commit is contained in:
luwenpeng
2024-03-08 13:43:03 +08:00
parent 31c9303a93
commit d7370e0e19
15 changed files with 188 additions and 188 deletions

View File

@@ -25,22 +25,22 @@ TEST(TUPLE, TUPLE2)
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);
// tostring
// to_str
memset(buf, 0, sizeof(buf));
tuple2_tostring(&tuple_a, buf, sizeof(buf));
tuple2_to_str(&tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.2 -> 192.168.1.3");
memset(buf, 0, sizeof(buf));
tuple2_tostring(&tuple_b, buf, sizeof(buf));
tuple2_to_str(&tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:8329 -> 2001:db8::ff00:42:832a");
// reverse
tuple2_reverse(&tuple_a, &reversed_tuple_a);
tuple2_reverse(&tuple_b, &reversed_tuple_b);
memset(buf, 0, sizeof(buf));
tuple2_tostring(&reversed_tuple_a, buf, sizeof(buf));
tuple2_to_str(&reversed_tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.3 -> 192.168.1.2");
memset(buf, 0, sizeof(buf));
tuple2_tostring(&reversed_tuple_b, buf, sizeof(buf));
tuple2_to_str(&reversed_tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:832a -> 2001:db8::ff00:42:8329");
// hash
@@ -88,22 +88,22 @@ TEST(TUPLE, TUPLE4)
tuple_b.src_port = htons(1234);
tuple_b.dst_port = htons(5678);
// tostring
// to_str
memset(buf, 0, sizeof(buf));
tuple4_tostring(&tuple_a, buf, sizeof(buf));
tuple4_to_str(&tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.2:1234 -> 192.168.1.3:5678");
memset(buf, 0, sizeof(buf));
tuple4_tostring(&tuple_b, buf, sizeof(buf));
tuple4_to_str(&tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:8329:1234 -> 2001:db8::ff00:42:832a:5678");
// reverse
tuple4_reverse(&tuple_a, &reversed_tuple_a);
tuple4_reverse(&tuple_b, &reversed_tuple_b);
memset(buf, 0, sizeof(buf));
tuple4_tostring(&reversed_tuple_a, buf, sizeof(buf));
tuple4_to_str(&reversed_tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.3:5678 -> 192.168.1.2:1234");
memset(buf, 0, sizeof(buf));
tuple4_tostring(&reversed_tuple_b, buf, sizeof(buf));
tuple4_to_str(&reversed_tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:832a:5678 -> 2001:db8::ff00:42:8329:1234");
// hash
@@ -153,22 +153,22 @@ TEST(TUPLE, TUPLE5)
tuple_b.dst_port = htons(5678);
tuple_b.ip_proto = IPPROTO_UDP;
// tostring
// to_str
memset(buf, 0, sizeof(buf));
tuple5_tostring(&tuple_a, buf, sizeof(buf));
tuple5_to_str(&tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.2:1234 -> 192.168.1.3:5678, proto: 6");
memset(buf, 0, sizeof(buf));
tuple5_tostring(&tuple_b, buf, sizeof(buf));
tuple5_to_str(&tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:8329:1234 -> 2001:db8::ff00:42:832a:5678, proto: 17");
// reverse
tuple5_reverse(&tuple_a, &reversed_tuple_a);
tuple5_reverse(&tuple_b, &reversed_tuple_b);
memset(buf, 0, sizeof(buf));
tuple5_tostring(&reversed_tuple_a, buf, sizeof(buf));
tuple5_to_str(&reversed_tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.3:5678 -> 192.168.1.2:1234, proto: 6");
memset(buf, 0, sizeof(buf));
tuple5_tostring(&reversed_tuple_b, buf, sizeof(buf));
tuple5_to_str(&reversed_tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:832a:5678 -> 2001:db8::ff00:42:8329:1234, proto: 17");
// hash
@@ -220,22 +220,22 @@ TEST(TUPLE, TUPLE6)
tuple_b.ip_proto = IPPROTO_UDP;
tuple_b.domain = 0;
// tostring
// to_str
memset(buf, 0, sizeof(buf));
tuple6_tostring(&tuple_a, buf, sizeof(buf));
tuple6_to_str(&tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.2:1234 -> 192.168.1.3:5678, proto: 6, domain: 0");
memset(buf, 0, sizeof(buf));
tuple6_tostring(&tuple_b, buf, sizeof(buf));
tuple6_to_str(&tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:8329:1234 -> 2001:db8::ff00:42:832a:5678, proto: 17, domain: 0");
// reverse
tuple6_reverse(&tuple_a, &reversed_tuple_a);
tuple6_reverse(&tuple_b, &reversed_tuple_b);
memset(buf, 0, sizeof(buf));
tuple6_tostring(&reversed_tuple_a, buf, sizeof(buf));
tuple6_to_str(&reversed_tuple_a, buf, sizeof(buf));
EXPECT_STREQ(buf, "192.168.1.3:5678 -> 192.168.1.2:1234, proto: 6, domain: 0");
memset(buf, 0, sizeof(buf));
tuple6_tostring(&reversed_tuple_b, buf, sizeof(buf));
tuple6_to_str(&reversed_tuple_b, buf, sizeof(buf));
EXPECT_STREQ(buf, "2001:db8::ff00:42:832a:5678 -> 2001:db8::ff00:42:8329:1234, proto: 17, domain: 0");
// hash

View File

@@ -367,7 +367,7 @@ void tuple6_reverse(const struct tuple6 *in, struct tuple6 *out)
}
}
void tuple2_tostring(const struct tuple2 *tuple, char *buf, uint32_t size)
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};
@@ -386,7 +386,7 @@ void tuple2_tostring(const struct tuple2 *tuple, char *buf, uint32_t size)
snprintf(buf, size, "%s -> %s", src_addr, dst_addr);
}
void tuple4_tostring(const struct tuple4 *tuple, char *buf, uint32_t size)
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};
@@ -407,7 +407,7 @@ void tuple4_tostring(const struct tuple4 *tuple, char *buf, uint32_t size)
dst_addr, ntohs(tuple->dst_port));
}
void tuple5_tostring(const struct tuple5 *tuple, char *buf, uint32_t size)
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};
@@ -429,7 +429,7 @@ void tuple5_tostring(const struct tuple5 *tuple, char *buf, uint32_t size)
tuple->ip_proto);
}
void tuple6_tostring(const struct tuple6 *tuple, char *buf, uint32_t size)
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};

View File

@@ -77,10 +77,10 @@ void tuple4_reverse(const struct tuple4 *in, struct tuple4 *out);
void tuple5_reverse(const struct tuple5 *in, struct tuple5 *out);
void tuple6_reverse(const struct tuple6 *in, struct tuple6 *out);
void tuple2_tostring(const struct tuple2 *tuple, char *buf, uint32_t size);
void tuple4_tostring(const struct tuple4 *tuple, char *buf, uint32_t size);
void tuple5_tostring(const struct tuple5 *tuple, char *buf, uint32_t size);
void tuple6_tostring(const struct tuple6 *tuple, char *buf, uint32_t size);
void tuple2_to_str(const struct tuple2 *tuple, char *buf, uint32_t size);
void tuple4_to_str(const struct tuple4 *tuple, char *buf, uint32_t size);
void tuple5_to_str(const struct tuple5 *tuple, char *buf, uint32_t size);
void tuple6_to_str(const struct tuple6 *tuple, char *buf, uint32_t size);
#ifdef __cpluscplus
}