From 000226ff5441112b05c1f08af290ad02009ce1d8 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Tue, 15 Oct 2019 09:56:03 +0200 Subject: [PATCH] net: lwm2m: Add config to enable DNS support Add new config option `LWM2M_DNS_SUPPORT` to the LWM2M library, instead of relying on `DNS_RESOLVER` which is only compatible with native network stack. This allows to use DNS with offloaded interfaces seamlessly. Signed-off-by: Robert Lubos --- subsys/net/lib/lwm2m/Kconfig | 4 ++++ subsys/net/lib/lwm2m/lwm2m_engine.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/subsys/net/lib/lwm2m/Kconfig b/subsys/net/lib/lwm2m/Kconfig index 3151008096e..d4906524e63 100644 --- a/subsys/net/lib/lwm2m/Kconfig +++ b/subsys/net/lib/lwm2m/Kconfig @@ -26,6 +26,10 @@ config LWM2M_DTLS_SUPPORT select NET_SOCKETS_SOCKOPT_TLS select NET_SOCKETS_ENABLE_DTLS +config LWM2M_DNS_SUPPORT + bool "Enable DNS support in the LWM2M client" + default y if DNS_RESOLVER + config LWM2M_ENGINE_STACK_SIZE int "LWM2M engine stack size" default 2560 if NET_LOG diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index 95b92551a20..75a78ce4085 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -4202,7 +4202,7 @@ int lwm2m_socket_start(struct lwm2m_ctx *client_ctx) int lwm2m_parse_peerinfo(char *url, struct sockaddr *addr, bool *use_dtls) { struct http_parser_url parser; -#if defined(CONFIG_DNS_RESOLVER) +#if defined(CONFIG_LWM2M_DNS_SUPPORT) struct addrinfo hints, *res; #endif int ret; @@ -4263,7 +4263,7 @@ int lwm2m_parse_peerinfo(char *url, struct sockaddr *addr, bool *use_dtls) } if (ret < 0) { -#if defined(CONFIG_DNS_RESOLVER) +#if defined(CONFIG_LWM2M_DNS_SUPPORT) #if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4) hints.ai_family = AF_UNSPEC; #elif defined(CONFIG_NET_IPV6) @@ -4290,7 +4290,7 @@ int lwm2m_parse_peerinfo(char *url, struct sockaddr *addr, bool *use_dtls) freeaddrinfo(res); #else goto cleanup; -#endif /* CONFIG_DNS_RESOLVER */ +#endif /* CONFIG_LWM2M_DNS_SUPPORT */ } /* set port */