Skip to content

Commit b0fd16c

Browse files
authored
Fixed compile in BACnet/IP subsys using CONFIG_POSIX_API=y. (#47)
2 parents 7a5529f + 6af8ed7 commit b0fd16c

File tree

3 files changed

+3
-39
lines changed

3 files changed

+3
-39
lines changed

zephyr/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ config BACDL_BIP
6969
bool "BACnet BIP datalink"
7070
select NETWORKING
7171
select NET_SOCKETS
72-
select NET_SOCKETS_POSIX_NAMES
7372
select NET_UDP
7473
select NET_IPV4
7574
help
@@ -79,7 +78,6 @@ config BACDL_BIP6
7978
bool "BACnet BIP6 datalink"
8079
select NETWORKING
8180
select NET_SOCKETS
82-
select NET_SOCKETS_POSIX_NAMES
8381
select NET_UDP
8482
select NET_IPV6
8583
help

zephyr/subsys/bacnet_datalink/bip-init.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,6 @@ static char ipv4_addr_str[16] = { 0 };
5050
static char ipv4_addr_str[] = "";
5151
#endif
5252

53-
/**
54-
* @brief Return a string representation of an IPv4 address
55-
* @param a - IPv4 address
56-
* @return Pointer to global string
57-
*/
58-
char *inet_ntoa(struct in_addr *a)
59-
{
60-
if (IS_ENABLED(CONFIG_BACNETSTACK_LOG_LEVEL)) {
61-
snprintf(
62-
ipv4_addr_str, sizeof(ipv4_addr_str), "%d.%d.%d.%d", a->s4_addr[0],
63-
a->s4_addr[1], a->s4_addr[2], a->s4_addr[3]);
64-
}
65-
66-
return &ipv4_addr_str[0];
67-
}
6853

6954
/**
7055
* @brief Print the IPv4 address with debug info
@@ -78,7 +63,8 @@ static void debug_print_ipv4(
7863
const unsigned int count)
7964
{
8065
LOG_DBG(
81-
"%s %s:%hu (%u bytes)", str, inet_ntoa((struct in_addr *)&addr),
66+
"%s %s:%hu (%u bytes)", str,
67+
net_addr_ntop(AF_INET, addr, ipv4_addr_str, sizeof(ipv4_addr_str)),
8268
ntohs(port), count);
8369
}
8470

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)