Skip to content

Commit 33ff683

Browse files
committed
modules: openthread: platform: mdns_socket: Update AIL address monitor
This commit improves AIL address monitoring; Associated function will be called after OpenThread mDNS module starts platform code by 'otPlatMdnsSetListeningEnabled`. A new flag, `mdns_socket_is_enabled` has been added to support this new logic. Signed-off-by: Cristian Bulacu <[email protected]>
1 parent e57676a commit 33ff683

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/openthread/platform/mdns_socket.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static int mdns_sock_v4 = -1;
3535
#endif /* CONFIG_NET_IPV4 */
3636
static struct otInstance *ot_instance_ptr;
3737
static uint32_t ail_iface_index;
38+
static bool mdns_socket_is_enabled;
3839

3940
static otError mdns_socket_init_v6(uint32_t ail_iface_idx);
4041
#if defined(CONFIG_NET_IPV4)
@@ -87,10 +88,13 @@ static otError set_listening_enable(otInstance *instance, bool enable, uint32_t
8788
#if defined(CONFIG_NET_IPV4)
8889
SuccessOrExit(error = mdns_socket_init_v4(ail_iface_idx));
8990
#endif /* CONFIG_NET_IPV4 */
91+
mdns_socket_is_enabled = true;
92+
mdns_plat_monitor_interface(net_if_get_by_index(ail_iface_idx));
9093
ExitNow();
9194
}
9295

9396
SuccessOrExit(error = mdns_socket_deinit());
97+
mdns_socket_is_enabled = false;
9498
exit:
9599
return error;
96100

@@ -389,6 +393,10 @@ void mdns_plat_monitor_interface(struct net_if *ail_iface)
389393
otIp6Address ip6_addr = {0};
390394
struct net_if_addr *unicast = NULL;
391395

396+
VerifyOrExit(mdns_socket_is_enabled);
397+
398+
net_if_lock(ail_iface);
399+
392400
otPlatMdnsHandleHostAddressRemoveAll(ot_instance_ptr, ail_iface_index);
393401

394402
ipv6 = ail_iface->config.ip.ipv6;
@@ -422,4 +430,8 @@ void mdns_plat_monitor_interface(struct net_if *ail_iface)
422430
ail_iface_index);
423431
}
424432
#endif /* CONFIG_NET_IPV4 && CONFIG_NET_IPV4_MAPPING_TO_IPV6 */
433+
434+
net_if_unlock(ail_iface);
435+
exit:
436+
return;
425437
}

0 commit comments

Comments
 (0)