-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Improve Zephyr version detection * Support the new Zephyr multicast API * Reuse ifa variable
- Loading branch information
1 parent
37397bf
commit 87e21ad
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,9 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#if defined(ZENOH_PIO) | ||
#include <version.h> | ||
|
||
#if KERNEL_VERSION_MAJOR == 2 | ||
#include <drivers/uart.h> | ||
#else | ||
#include <zephyr/drivers/uart.h> | ||
|
@@ -404,14 +406,22 @@ int8_t _z_listen_udp_multicast(_z_sys_net_socket_t *sock, const _z_sys_net_endpo | |
if (!mcast) { | ||
ret = _Z_ERR_GENERIC; | ||
} | ||
#if KERNEL_VERSION_MAJOR == 3 && KERNEL_VERSION_MINOR > 3 | ||
net_if_ipv4_maddr_join(ifa, mcast); | ||
#else | ||
net_if_ipv4_maddr_join(mcast); | ||
#endif | ||
} else if (rep._iptcp->ai_family == AF_INET6) { | ||
struct net_if_mcast_addr *mcast = NULL; | ||
mcast = net_if_ipv6_maddr_add(ifa, &((struct sockaddr_in6 *)rep._iptcp->ai_addr)->sin6_addr); | ||
if (!mcast) { | ||
ret = _Z_ERR_GENERIC; | ||
} | ||
#if KERNEL_VERSION_MAJOR == 3 && KERNEL_VERSION_MINOR > 3 | ||
net_if_ipv6_maddr_join(ifa, mcast); | ||
#else | ||
net_if_ipv6_maddr_join(mcast); | ||
#endif | ||
} else { | ||
ret = _Z_ERR_GENERIC; | ||
} | ||
|
@@ -439,15 +449,23 @@ void _z_close_udp_multicast(_z_sys_net_socket_t *sockrecv, _z_sys_net_socket_t * | |
if (rep._iptcp->ai_family == AF_INET) { | ||
mcast = net_if_ipv4_maddr_add(ifa, &((struct sockaddr_in *)rep._iptcp->ai_addr)->sin_addr); | ||
if (mcast != NULL) { | ||
#if KERNEL_VERSION_MAJOR == 3 && KERNEL_VERSION_MINOR > 3 | ||
net_if_ipv4_maddr_leave(ifa, mcast); | ||
#else | ||
net_if_ipv4_maddr_leave(mcast); | ||
#endif | ||
net_if_ipv4_maddr_rm(ifa, &((struct sockaddr_in *)rep._iptcp->ai_addr)->sin_addr); | ||
} else { | ||
// Do nothing. The socket will be closed in any case. | ||
} | ||
} else if (rep._iptcp->ai_family == AF_INET6) { | ||
mcast = net_if_ipv6_maddr_add(ifa, &((struct sockaddr_in6 *)rep._iptcp->ai_addr)->sin6_addr); | ||
if (mcast != NULL) { | ||
#if KERNEL_VERSION_MAJOR == 3 && KERNEL_VERSION_MINOR > 3 | ||
net_if_ipv6_maddr_leave(ifa, mcast); | ||
#else | ||
net_if_ipv6_maddr_leave(mcast); | ||
#endif | ||
net_if_ipv6_maddr_rm(ifa, &((struct sockaddr_in6 *)rep._iptcp->ai_addr)->sin6_addr); | ||
} else { | ||
// Do nothing. The socket will be closed in any case. | ||
|
@@ -531,7 +549,7 @@ size_t _z_send_udp_multicast(const _z_sys_net_socket_t sock, const uint8_t *ptr, | |
_z_sys_net_endpoint_t rep) { | ||
return sendto(sock._fd, ptr, len, 0, rep._iptcp->ai_addr, rep._iptcp->ai_addrlen); | ||
} | ||
#endif | ||
#endif // Z_LINK_UDP_MULTICAST == 1 | ||
|
||
#if Z_LINK_SERIAL == 1 | ||
int8_t _z_open_serial_from_pins(_z_sys_net_socket_t *sock, uint32_t txpin, uint32_t rxpin, uint32_t baudrate) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,11 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#if defined(ZENOH_PIO) | ||
#include <kernel.h> | ||
#include <version.h> | ||
|
||
#if KERNEL_VERSION_MAJOR == 2 | ||
#include <random/rand32.h> | ||
#else | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/random/rand32.h> | ||
#endif | ||
|
||
|