Skip to content

Commit

Permalink
do not send multicast message using thread-only source addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
tiniuclx committed Feb 26, 2024
1 parent c6cb3d3 commit 7dd1367
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions port/linux/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,14 @@ oc_send_discovery_request(oc_message_t *message)
if ((message->endpoint.flags & IPV6) && iface->ifa_addr &&
iface->ifa_addr->sa_family == AF_INET6) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)iface->ifa_addr;
// check for Thread mesh local prefix
bool is_thread_mesh =
addr->sin6_addr.__in6_u.__u6_addr16[0] == 0xfdde
&& addr->sin6_addr.__in6_u.__u6_addr16[1] == 0xad00
&& addr->sin6_addr.__in6_u.__u6_addr16[2] == 0xbeef
&& addr->sin6_addr.__in6_u.__u6_addr16[3] == 0x0000;
if (is_thread_mesh)
continue;
memcpy(&message->endpoint.addr_local.ipv6.address, &addr->sin6_addr, 16);
unsigned int mif = if_nametoindex(iface->ifa_name);
if (setsockopt(dev->server_sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &mif,
Expand Down

0 comments on commit 7dd1367

Please sign in to comment.