Skip to content

Commit ecd455b

Browse files
Cristib05henrikbrixandersen
authored andcommitted
modules: openthread: mdns_socket: Add IPv4 addresses to localhost
This commit aims to add IPv4 addresses to mDNS localhost. Signed-off-by: Cristian Bulacu <[email protected]>
1 parent 186bb57 commit ecd455b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

modules/openthread/platform/mdns_socket.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,23 @@ void mdns_plat_monitor_interface(struct net_if *ail_iface)
403403
otPlatMdnsHandleHostAddressEvent(ot_instance_ptr, &ip6_addr, true,
404404
ail_iface_index);
405405
}
406+
407+
#if defined(CONFIG_NET_IPV4) && defined(CONFIG_NET_IPV4_MAPPING_TO_IPV6)
408+
struct net_if_ipv4 *ipv4 = NULL;
409+
otIp4Address ip4_addr = {0};
410+
411+
ipv4 = ail_iface->config.ip.ipv4;
412+
ARRAY_FOR_EACH(ipv4->unicast, idx) {
413+
unicast = &ipv4->unicast[idx].ipv4;
414+
415+
if (!unicast->is_used) {
416+
continue;
417+
}
418+
memcpy(&ip4_addr.mFields.m32, &unicast->address.in_addr.s4_addr32,
419+
sizeof(otIp4Address));
420+
otIp4ToIp4MappedIp6Address(&ip4_addr, &ip6_addr);
421+
otPlatMdnsHandleHostAddressEvent(ot_instance_ptr, &ip6_addr, true,
422+
ail_iface_index);
423+
}
424+
#endif /* CONFIG_NET_IPV4 && CONFIG_NET_IPV4_MAPPING_TO_IPV6 */
406425
}

0 commit comments

Comments
 (0)