mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
There is some ambiguity with the DHCPv4 handling in the dns_resolve sample. On one hand, the sample uses net_config library, which does initiate the DHCPv4 on the interface (if enabled) and may block the initialization until the address is assigned (in case there is no other statically assigned IPv4 addresses.) On the other hand, the sample registers for NET_EVENT_IPV4_ADDR_ADD in case DHCPv4 is in use, delaying the DNS queries until address is assigned. In case net_config delayed the initialization however, this will not work, as the event handler will be registered only after DHCPv4 address is assigned, so the callback will not get executed. Fix this, by checking if DHCPv4 assigned address already exists on an interface - if so, schedule DNS queries immediately. Otherwise (for example in case when net_config was not configured to wait for address) register an event callback, and schedule queries from there. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>