Skip to content

Commit 6af8ed7

Browse files
committed
use net_addr_ntop for ipv6
1 parent f5b3024 commit 6af8ed7

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

zephyr/subsys/bacnet_datalink/bip6-init.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,11 @@ static char ipv6_addr_str[] = "";
5151
static char *inet6_ntoa(struct in6_addr *a)
5252
{
5353
#if CONFIG_BACNETSTACK_LOG_LEVEL
54-
uint8_t x = 0;
55-
uint8_t d = 0;
56-
uint8_t non_zero_count = 0;
57-
5854
/* Avoid overwhelming the logging system */
5955
while (log_buffered_cnt()) {
6056
k_sleep(K_MSEC(1));
6157
}
62-
63-
for (x = 0; x < IP6_ADDRESS_MAX; x += 2) {
64-
if (a->s6_addr[x] | a->s6_addr[x + 1]) {
65-
non_zero_count++;
66-
d += snprintf(
67-
&ipv6_addr_str[d], sizeof(ipv6_addr_str), "%02X%02X",
68-
a->s6_addr[x], a->s6_addr[x + 1]);
69-
}
70-
71-
if (x < 14) {
72-
d += snprintf(&ipv6_addr_str[d], sizeof(ipv6_addr_str), ":");
73-
}
74-
}
75-
76-
if (!non_zero_count) {
77-
snprintf(&ipv6_addr_str[0], sizeof(ipv6_addr_str), "undefined");
78-
}
58+
net_addr_ntop(AF_INET6, a, &ipv6_addr_str[0], sizeof(ipv6_addr_str));
7959
#endif
8060
return &ipv6_addr_str[0];
8161
}

0 commit comments

Comments
 (0)