Zephyr API Documentation 4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dns_resolve.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2017 Intel Corporation
9 * Copyright 2025 NXP
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13
14#ifndef ZEPHYR_INCLUDE_NET_DNS_RESOLVE_H_
15#define ZEPHYR_INCLUDE_NET_DNS_RESOLVE_H_
16
17#include <zephyr/kernel.h>
18#include <zephyr/net/net_ip.h>
19#include <zephyr/net/net_if.h>
21#include <zephyr/net/net_core.h>
22#include <zephyr/sys/atomic.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
36
58
59
61#define DNS_RR_TYPE_PRIVATE_START_VALUE 65280
63#define DNS_RR_TYPE_PRIVATE_END_VALUE 65534
64
71static inline bool dns_query_type_is_private(enum dns_query_type type)
72{
73 unsigned int val = (unsigned int)type;
74
75 return (val >= DNS_RR_TYPE_PRIVATE_START_VALUE &&
77}
78
96
98#if defined(CONFIG_DNS_RESOLVER_MAX_NAME_LEN)
99#define DNS_MAX_NAME_SIZE CONFIG_DNS_RESOLVER_MAX_NAME_LEN
100#else
101#define DNS_MAX_NAME_SIZE 20
102#endif /* CONFIG_DNS_RESOLVER_MAX_NAME_LEN */
103
105#if defined(CONFIG_DNS_RESOLVER_MAX_TEXT_LEN)
106#define DNS_MAX_TEXT_SIZE CONFIG_DNS_RESOLVER_MAX_TEXT_LEN
107#else
108#define DNS_MAX_TEXT_SIZE 64
109#endif /* CONFIG_DNS_RESOLVER_MAX_TEXT_LEN */
110
112#if defined(CONFIG_DNS_RESOLVER_MAX_PRIVATE_DATA_LEN)
113#define DNS_MAX_PRIVATE_DATA_SIZE CONFIG_DNS_RESOLVER_MAX_PRIVATE_DATA_LEN
114#else
115#define DNS_MAX_PRIVATE_DATA_SIZE 128
116#endif /* CONFIG_DNS_RESOLVER_MAX_PRIVATE_DATA_LEN */
117
119
120#define DNS_BUF_TIMEOUT K_MSEC(500) /* ms */
121
122/* This value is recommended by RFC 1035 */
123#if defined(CONFIG_DNS_RESOLVER_MAX_ANSWER_SIZE)
124#define DNS_RESOLVER_MAX_BUF_SIZE CONFIG_DNS_RESOLVER_MAX_ANSWER_SIZE
125#else
126#define DNS_RESOLVER_MAX_BUF_SIZE 512
127#endif /* CONFIG_DNS_RESOLVER_MAX_ANSWER_SIZE */
128
129/* Make sure that we can compile things even if CONFIG_DNS_RESOLVER
130 * is not enabled.
131 */
132#if defined(CONFIG_DNS_RESOLVER_MAX_SERVERS)
133#define DNS_RESOLVER_MAX_SERVERS CONFIG_DNS_RESOLVER_MAX_SERVERS
134#else
135#define DNS_RESOLVER_MAX_SERVERS 0
136#endif
137
138#if defined(CONFIG_DNS_NUM_CONCUR_QUERIES)
139#define DNS_NUM_CONCUR_QUERIES CONFIG_DNS_NUM_CONCUR_QUERIES
140#else
141#define DNS_NUM_CONCUR_QUERIES 1
142#endif
143
144#if defined(CONFIG_NET_IF_MAX_IPV6_COUNT)
145#define MAX_IPV6_IFACE_COUNT CONFIG_NET_IF_MAX_IPV6_COUNT
146#else
147#define MAX_IPV6_IFACE_COUNT 1
148#endif
149
150#if defined(CONFIG_NET_IF_MAX_IPV4_COUNT)
151#define MAX_IPV4_IFACE_COUNT CONFIG_NET_IF_MAX_IPV4_COUNT
152#else
153#define MAX_IPV4_IFACE_COUNT 1
154#endif
155
156/* If mDNS is enabled, then add some extra well known multicast servers to the
157 * server list.
158 */
159#if defined(CONFIG_MDNS_RESOLVER)
160#if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4)
161#define MDNS_SERVER_COUNT 2
162#else
163#define MDNS_SERVER_COUNT 1
164#endif /* CONFIG_NET_IPV6 && CONFIG_NET_IPV4 */
165#else
166#define MDNS_SERVER_COUNT 0
167#endif /* CONFIG_MDNS_RESOLVER */
168
169/* If LLMNR is enabled, then add some extra well known multicast servers to the
170 * server list.
171 */
172#if defined(CONFIG_LLMNR_RESOLVER)
173#if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4)
174#define LLMNR_SERVER_COUNT 2
175#else
176#define LLMNR_SERVER_COUNT 1
177#endif /* CONFIG_NET_IPV6 && CONFIG_NET_IPV4 */
178#else
179#define LLMNR_SERVER_COUNT 0
180#endif /* CONFIG_MDNS_RESOLVER */
181
182#define DNS_MAX_MCAST_SERVERS (MDNS_SERVER_COUNT + LLMNR_SERVER_COUNT)
183
184#if defined(CONFIG_MDNS_RESPONDER)
185#if defined(CONFIG_NET_IPV6)
186#define MDNS_MAX_IPV6_IFACE_COUNT CONFIG_NET_IF_MAX_IPV6_COUNT
187#else
188#define MDNS_MAX_IPV6_IFACE_COUNT 0
189#endif /* CONFIG_NET_IPV6 */
190
191#if defined(CONFIG_NET_IPV4)
192#define MDNS_MAX_IPV4_IFACE_COUNT CONFIG_NET_IF_MAX_IPV4_COUNT
193#else
194#define MDNS_MAX_IPV4_IFACE_COUNT 0
195#endif /* CONFIG_NET_IPV4 */
196
197#define MDNS_MAX_POLL (MDNS_MAX_IPV4_IFACE_COUNT + MDNS_MAX_IPV6_IFACE_COUNT)
198#else
199#define MDNS_MAX_POLL 0
200#endif /* CONFIG_MDNS_RESPONDER */
201
202#if defined(CONFIG_LLMNR_RESPONDER)
203#if defined(CONFIG_NET_IPV6) && defined(CONFIG_NET_IPV4)
204#define LLMNR_MAX_POLL 2
205#else
206#define LLMNR_MAX_POLL 1
207#endif
208#else
209#define LLMNR_MAX_POLL 0
210#endif /* CONFIG_LLMNR_RESPONDER */
211
212#define DNS_RESOLVER_MAX_POLL (DNS_RESOLVER_MAX_SERVERS + DNS_MAX_MCAST_SERVERS)
213
214/* Cap the max poll to 32 */
215BUILD_ASSERT(DNS_RESOLVER_MAX_POLL <= 32,
216 "DNS_RESOLVER_MAX_POLL " STRINGIFY(DNS_RESOLVER_MAX_POLL)
217 " must be smaller or equal than " STRINGIFY(32));
218
220#define DNS_DISPATCHER_MAX_POLL (DNS_RESOLVER_MAX_POLL + MDNS_MAX_POLL + LLMNR_MAX_POLL)
221
222#if defined(CONFIG_ZVFS_POLL_MAX)
223BUILD_ASSERT(CONFIG_ZVFS_POLL_MAX >= DNS_DISPATCHER_MAX_POLL,
224 "CONFIG_ZVFS_POLL_MAX must be larger than " STRINGIFY(DNS_DISPATCHER_MAX_POLL));
225#endif
226
230enum dns_socket_type {
231 DNS_SOCKET_RESOLVER = 1,
232 DNS_SOCKET_RESPONDER = 2
233};
234
236struct mdns_responder_context;
237struct dns_socket_dispatcher;
238
253typedef int (*dns_socket_dispatcher_cb)(struct dns_socket_dispatcher *ctx, int sock,
254 struct net_sockaddr *addr, size_t addrlen,
255 struct net_buf *buf, size_t data_len);
256
258struct dns_socket_dispatcher {
260 sys_snode_t node;
262 const struct net_socket_service_desc *svc;
266 union {
267 void *ctx;
268 struct dns_resolve_context *resolve_ctx;
269 struct mdns_responder_context *mdns_ctx;
270 };
271
273 enum dns_socket_type type;
275 union {
277 struct net_sockaddr_storage local_addr_storage;
279 /* Use the local_addr_storage instead of this one. */
280 struct net_sockaddr local_addr;
282 };
284 dns_socket_dispatcher_cb cb;
286 struct zsock_pollfd *fds;
288 int fds_len;
290 int sock;
292 int ifindex;
296 struct dns_socket_dispatcher *pair;
300 bool paired;
302 struct k_mutex lock;
304 k_timeout_t buf_timeout;
305};
306
316int dns_dispatcher_register(struct dns_socket_dispatcher *ctx);
317
327int dns_dispatcher_unregister(struct dns_socket_dispatcher *ctx);
328
330
340
344 size_t textlen;
347};
348
362
372
379
380 union {
382 struct {
385
387 union {
389 struct net_sockaddr_storage ai_addr_storage;
392 struct net_sockaddr ai_addr;
394 };
395
398 };
399
401 struct {
404
405 union {
410#if defined(CONFIG_DNS_RESOLVER_PRIVATE_RR_SUPPORT) || defined(__DOXYGEN__)
413#endif /* CONFIG_DNS_RESOLVER_PRIVATE_RR_SUPPORT */
414 };
415 };
416 };
417};
418
458
478typedef void (*dns_resolve_cb_t)(enum dns_resolve_status status,
479 struct dns_addrinfo *info,
480 void *user_data);
481
493typedef void (*dns_resolve_pkt_fw_cb_t)(struct net_buf *dns_data, size_t buf_len, void *user_data);
494
496
497enum dns_resolve_context_state {
498 DNS_RESOLVE_CONTEXT_UNINITIALIZED = 0,
499 DNS_RESOLVE_CONTEXT_ACTIVE,
500 DNS_RESOLVE_CONTEXT_DEACTIVATING,
501 DNS_RESOLVE_CONTEXT_INACTIVE,
502};
503
505
513 union {
515 struct net_sockaddr_storage dns_server_addr;
517 struct net_sockaddr dns_server;
519 };
520
522 int sock;
523
528
531
534
537
540 struct dns_socket_dispatcher dispatcher;
541
543 bool in_dispatch;
545 } servers[DNS_RESOLVER_MAX_POLL];
546
549 struct zsock_pollfd fds[DNS_RESOLVER_MAX_POLL];
551
553 struct k_mutex lock;
554
559
569
572
578
581
593 const char *query;
594
597
600
608
614
615 /* Number of additional queries sent to resolve CNAME record
616 * name aliases.
617 */
619
622
625
627 struct {
630
633
637
640 } queries[DNS_NUM_CONCUR_QUERIES];
641
643 enum dns_resolve_context_state state;
644
645#if defined(CONFIG_DNS_RESOLVER_PACKET_FORWARDING) || defined(__DOXYGEN__)
648#endif /* CONFIG_DNS_RESOLVER_PACKET_FORWARDING */
649
652 int init_called;
654};
655
657
658struct mdns_probe_user_data {
659 struct mdns_responder_context *ctx;
660 char query[DNS_MAX_NAME_SIZE + 1];
661 uint16_t dns_id;
662};
663
664struct mdns_responder_context {
665 struct net_sockaddr_storage server_addr;
666 struct dns_socket_dispatcher dispatcher;
667 struct zsock_pollfd fds[1];
668 int sock;
669 struct net_if *iface;
670#if defined(CONFIG_MDNS_RESPONDER_PROBE)
671 struct k_work_delayable probe_timer;
672 struct dns_resolve_context probe_ctx;
673 struct mdns_probe_user_data probe_data;
674#endif
675};
676
678
707 const char *dns_servers_str[],
708 const struct net_sockaddr *dns_servers_sa[]);
709
718
730
744
766 const char *servers_str[],
767 const struct net_sockaddr *servers_sa[],
768 enum dns_server_source source);
769
793 const char *servers_str[],
794 const struct net_sockaddr *servers_sa[],
795 int interfaces[],
796 enum dns_server_source source);
797
806int dns_resolve_remove(struct dns_resolve_context *ctx, int if_index);
807
818int dns_resolve_remove_source(struct dns_resolve_context *ctx, int if_index,
819 enum dns_server_source source);
820
835 const struct net_sockaddr *servers_sa[],
836 int interfaces[]);
837
849 uint16_t dns_id);
850
864 uint16_t dns_id,
865 const char *query_name,
866 enum dns_query_type query_type);
867
897 const char *query,
898 enum dns_query_type type,
899 uint16_t *dns_id,
901 void *user_data,
902 int32_t timeout);
903
930static inline int dns_resolve_service(struct dns_resolve_context *ctx,
931 const char *query,
932 uint16_t *dns_id,
934 void *user_data,
935 int32_t timeout)
936{
937 return dns_resolve_name(ctx, query, DNS_QUERY_TYPE_PTR,
938 dns_id, cb, user_data, timeout);
939}
940
952
953#if defined(CONFIG_DNS_RESOLVER_PACKET_FORWARDING) || defined(__DOXYGEN__)
967{
968 ctx->pkt_fw_cb = cb;
969}
970#endif /* CONFIG_DNS_RESOLVER_PACKET_FORWARDING */
971
1000static inline int dns_get_addr_info(const char *query,
1001 enum dns_query_type type,
1002 uint16_t *dns_id,
1004 void *user_data,
1005 int32_t timeout)
1006{
1008 query,
1009 type,
1010 dns_id,
1011 cb,
1012 user_data,
1013 timeout);
1014}
1015
1025static inline int dns_cancel_addr_info(uint16_t dns_id)
1026{
1028}
1029
1041static inline int dns_cancel_addr_info_with_name(const char *query_name,
1042 enum dns_query_type query_type,
1043 uint16_t dns_id)
1044{
1046 dns_id,
1047 query_name,
1048 query_type);
1049}
1050
1054
1056
1064const char *dns_get_source_str(enum dns_server_source source);
1065
1069#if defined(CONFIG_DNS_RESOLVER_AUTO_INIT)
1070void dns_init_resolver(void);
1071
1072#else
1073#define dns_init_resolver(...)
1074#endif /* CONFIG_DNS_RESOLVER_AUTO_INIT */
1075
1077
1078#ifdef __cplusplus
1079}
1080#endif
1081
1082#endif /* ZEPHYR_INCLUDE_NET_DNS_RESOLVE_H_ */
Header file for the Atomic operations API.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
static bool dns_query_type_is_private(enum dns_query_type type)
Check if query type is a private RR (RFC 6895: 65280-65534).
Definition dns_resolve.h:71
int dns_resolve_reconfigure(struct dns_resolve_context *ctx, const char *servers_str[], const struct net_sockaddr *servers_sa[], enum dns_server_source source)
Reconfigure DNS resolving context.
int dns_resolve_name(struct dns_resolve_context *ctx, const char *query, enum dns_query_type type, uint16_t *dns_id, dns_resolve_cb_t cb, void *user_data, int32_t timeout)
Resolve DNS name.
int dns_resolve_init(struct dns_resolve_context *ctx, const char *dns_servers_str[], const struct net_sockaddr *dns_servers_sa[])
Init DNS resolving context.
static void dns_resolve_enable_packet_forwarding(struct dns_resolve_context *ctx, dns_resolve_pkt_fw_cb_t cb)
Installs the packet forwarding callback to the DNS resolving context.
Definition dns_resolve.h:965
bool dns_resolve_is_active(struct dns_resolve_context *ctx)
Check if DNS resolving context is active.
int dns_resolve_reconfigure_with_interfaces(struct dns_resolve_context *ctx, const char *servers_str[], const struct net_sockaddr *servers_sa[], int interfaces[], enum dns_server_source source)
Reconfigure DNS resolving context with new server list and allowing servers to be specified to a spec...
#define DNS_RR_TYPE_PRIVATE_END_VALUE
Private RR type range end (RFC 6895).
Definition dns_resolve.h:63
static int dns_cancel_addr_info(uint16_t dns_id)
Cancel a pending DNS query.
Definition dns_resolve.h:1025
int dns_resolve_remove(struct dns_resolve_context *ctx, int if_index)
Remove servers from the DNS resolving context.
dns_resolve_status
Status values for the callback.
Definition dns_resolve.h:422
dns_query_type
DNS query type enum.
Definition dns_resolve.h:40
int dns_resolve_init_default(struct dns_resolve_context *ctx)
Init DNS resolving context with default Kconfig options.
int dns_resolve_cancel(struct dns_resolve_context *ctx, uint16_t dns_id)
Cancel a pending DNS query.
void(* dns_resolve_pkt_fw_cb_t)(struct net_buf *dns_data, size_t buf_len, void *user_data)
DNS resolve callback which passes the received packet from DNS server to application.
Definition dns_resolve.h:493
#define DNS_MAX_TEXT_SIZE
Max size of the resolved txt record.
Definition dns_resolve.h:108
dns_resolve_extension
Enumerate the extensions that are available in the address info.
Definition dns_resolve.h:334
#define DNS_RR_TYPE_PRIVATE_START_VALUE
Private RR type range start (RFC 6895).
Definition dns_resolve.h:61
int dns_resolve_close(struct dns_resolve_context *ctx)
Close DNS resolving context.
#define DNS_MAX_NAME_SIZE
Max size of the resolved name.
Definition dns_resolve.h:101
#define DNS_MAX_PRIVATE_DATA_SIZE
Max size of private RR data.
Definition dns_resolve.h:115
static int dns_cancel_addr_info_with_name(const char *query_name, enum dns_query_type query_type, uint16_t dns_id)
Cancel a pending DNS query using id, name and type.
Definition dns_resolve.h:1041
int dns_resolve_remove_source(struct dns_resolve_context *ctx, int if_index, enum dns_server_source source)
Remove servers from the DNS resolving context that were added by a specific source.
struct dns_resolve_context * dns_resolve_get_default(void)
Get default DNS context.
dns_server_source
Entity that added the DNS server.
Definition dns_resolve.h:82
int dns_resolve_cancel_with_name(struct dns_resolve_context *ctx, uint16_t dns_id, const char *query_name, enum dns_query_type query_type)
Cancel a pending DNS query using id, name and type.
static int dns_resolve_service(struct dns_resolve_context *ctx, const char *query, uint16_t *dns_id, dns_resolve_cb_t cb, void *user_data, int32_t timeout)
Resolve DNS service.
Definition dns_resolve.h:930
int dns_resolve_remove_server_addresses(struct dns_resolve_context *ctx, const struct net_sockaddr *servers_sa[], int interfaces[])
Remove servers from the DNS resolving context that have a specific IP address.
static int dns_get_addr_info(const char *query, enum dns_query_type type, uint16_t *dns_id, dns_resolve_cb_t cb, void *user_data, int32_t timeout)
Get IP address info from DNS.
Definition dns_resolve.h:1000
void(* dns_resolve_cb_t)(enum dns_resolve_status status, struct dns_addrinfo *info, void *user_data)
DNS resolve callback.
Definition dns_resolve.h:478
@ DNS_EAI_MEMORY
Memory allocation failure.
Definition dns_resolve.h:442
@ DNS_EAI_NOTCANCELED
Request not canceled.
Definition dns_resolve.h:452
@ DNS_EAI_IDN_ENCODE
IDN encoding failed.
Definition dns_resolve.h:456
@ DNS_EAI_ADDRFAMILY
Address family for NAME not supported.
Definition dns_resolve.h:440
@ DNS_EAI_INPROGRESS
Processing request in progress.
Definition dns_resolve.h:448
@ DNS_EAI_FAIL
Non-recoverable failure in name res.
Definition dns_resolve.h:430
@ DNS_EAI_AGAIN
Temporary failure in name resolution.
Definition dns_resolve.h:428
@ DNS_EAI_NODATA
No address associated with NAME.
Definition dns_resolve.h:432
@ DNS_EAI_NONAME
NAME or SERVICE is unknown.
Definition dns_resolve.h:426
@ DNS_EAI_FAMILY
ai_family not supported
Definition dns_resolve.h:434
@ DNS_EAI_OVERFLOW
Argument buffer overflow.
Definition dns_resolve.h:446
@ DNS_EAI_CANCELED
Request canceled.
Definition dns_resolve.h:450
@ DNS_EAI_BADFLAGS
Invalid value for ai_flags field.
Definition dns_resolve.h:424
@ DNS_EAI_SOCKTYPE
ai_socktype not supported
Definition dns_resolve.h:436
@ DNS_EAI_ALLDONE
All requests done.
Definition dns_resolve.h:454
@ DNS_EAI_SYSTEM
System error returned in errno.
Definition dns_resolve.h:444
@ DNS_EAI_SERVICE
SRV not supported for ai_socktype.
Definition dns_resolve.h:438
@ DNS_QUERY_TYPE_ANY
Request all record types query.
Definition dns_resolve.h:54
@ DNS_QUERY_TYPE_CNAME
Canonical name query.
Definition dns_resolve.h:44
@ DNS_QUERY_TYPE_SRV
Service location query.
Definition dns_resolve.h:52
@ DNS_QUERY_TYPE_TXT
Text query.
Definition dns_resolve.h:48
@ DNS_QUERY_TYPE_PTR
Pointer query.
Definition dns_resolve.h:46
@ DNS_QUERY_TYPE_A
IPv4 query.
Definition dns_resolve.h:42
@ DNS_QUERY_TYPE_AAAA
IPv6 query.
Definition dns_resolve.h:50
@ DNS_QUERY_TYPE_RESERVED
Reserved query type value.
Definition dns_resolve.h:56
@ DNS_RESOLVE_TXT
TXT field is returned.
Definition dns_resolve.h:336
@ DNS_RESOLVE_NONE
No extension in use.
Definition dns_resolve.h:335
@ DNS_RESOLVE_PRIVATE
Private RR is returned.
Definition dns_resolve.h:338
@ DNS_RESOLVE_SRV
SRV field is returned.
Definition dns_resolve.h:337
@ DNS_SOURCE_MANUAL
Server information is added manually, for example by an application.
Definition dns_resolve.h:86
@ DNS_SOURCE_IPV6_RA
Server information is from IPv6 SLAAC (router advertisement).
Definition dns_resolve.h:92
@ DNS_SOURCE_DHCPV4
Server information is from DHCPv4 server.
Definition dns_resolve.h:88
@ DNS_SOURCE_UNKNOWN
Source is unknown.
Definition dns_resolve.h:84
@ DNS_SOURCE_PPP
Server information is from PPP.
Definition dns_resolve.h:94
@ DNS_SOURCE_DHCPV6
Server information is from DHCPv6 server.
Definition dns_resolve.h:90
uint32_t net_socklen_t
Length of a socket address.
Definition net_ip.h:172
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
Public kernel APIs.
Network core definitions.
Public API for network interface.
IPv6 and IPv4 definitions.
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Address info struct is passed to callback that gets all the results.
Definition dns_resolve.h:376
char ai_canonname[20+1]
NET_AF_LOCAL Canonical name of the address.
Definition dns_resolve.h:397
struct dns_resolve_srv ai_srv
SRV record info.
Definition dns_resolve.h:409
struct dns_resolve_txt ai_txt
TXT record info.
Definition dns_resolve.h:407
struct net_sockaddr_storage ai_addr_storage
Socket address info storage.
Definition dns_resolve.h:389
struct dns_resolve_private ai_private
Private RR info.
Definition dns_resolve.h:412
enum dns_resolve_extension ai_extension
What kind of extension is returned.
Definition dns_resolve.h:403
net_socklen_t ai_addrlen
Length of the ai_addr field or ai_canonname.
Definition dns_resolve.h:384
uint8_t ai_family
Address family of the address information and discriminator.
Definition dns_resolve.h:378
Result callbacks.
Definition dns_resolve.h:566
const char * query
String containing the thing to resolve like www.example.com.
Definition dns_resolve.h:593
uint16_t query_hash
Hash of the DNS name + query type we are querying.
Definition dns_resolve.h:607
uint16_t orig_query_hash
Hash of the original DNS name + query type as requested by the caller.
Definition dns_resolve.h:613
k_timepoint_t deadline
Query deadline used to keep server fallback within the original timeout.
Definition dns_resolve.h:624
uint8_t additional_queries
Definition dns_resolve.h:618
struct dns_resolve_context * ctx
Back pointer to ctx, needed in timeout handler.
Definition dns_resolve.h:571
atomic_t sent
Bitset of servers that have already been queried.
Definition dns_resolve.h:629
void * user_data
User data.
Definition dns_resolve.h:580
struct k_work_delayable timer
Timeout timer.
Definition dns_resolve.h:568
uint16_t id
DNS id of this query.
Definition dns_resolve.h:599
enum dns_resolve_status last_status
Most recent terminal status reported by an attempted server.
Definition dns_resolve.h:639
atomic_t failed
Bitset of servers that already failed this query.
Definition dns_resolve.h:635
atomic_t pending
Bitset of servers currently awaiting a reply.
Definition dns_resolve.h:632
dns_resolve_cb_t cb
Result callback.
Definition dns_resolve.h:577
bool cb_called
Flag to indicate that the callback has been called at least once.
Definition dns_resolve.h:621
enum dns_query_type query_type
Query type.
Definition dns_resolve.h:596
Information about one configured DNS server.
Definition dns_resolve.h:511
uint8_t is_mdns
Is this server mDNS one.
Definition dns_resolve.h:533
struct net_sockaddr_storage dns_server_addr
DNS server information.
Definition dns_resolve.h:515
enum dns_server_source source
Source of the DNS server, e.g., manual, DHCPv4/6, etc.
Definition dns_resolve.h:530
uint8_t is_llmnr
Is this server LLMNR one.
Definition dns_resolve.h:536
int if_index
Network interface index if the DNS resolving should be done via this interface.
Definition dns_resolve.h:527
int sock
Connection to the DNS server.
Definition dns_resolve.h:522
DNS resolve context structure.
Definition dns_resolve.h:509
dns_resolve_pkt_fw_cb_t pkt_fw_cb
DNS packet forwarding callback.
Definition dns_resolve.h:647
k_timeout_t buf_timeout
This timeout is also used when a buffer is required from the buffer pools.
Definition dns_resolve.h:558
struct dns_resolve_context::dns_pending_query queries[DNS_NUM_CONCUR_QUERIES]
struct dns_resolve_context::dns_server_info servers[DNS_RESOLVER_MAX_POLL]
List of configured DNS servers.
enum dns_resolve_context_state state
Is this context in use.
Definition dns_resolve.h:643
struct k_mutex lock
Prevent concurrent access.
Definition dns_resolve.h:553
Private RR record information.
Definition dns_resolve.h:364
uint8_t data[128]
Raw data from the private RR.
Definition dns_resolve.h:370
size_t datalen
Length of the data field.
Definition dns_resolve.h:368
uint16_t type
RR type value (in private use range 65280-65534).
Definition dns_resolve.h:366
SRV record information.
Definition dns_resolve.h:350
uint16_t priority
Priority of the server order, lower value means higher priority.
Definition dns_resolve.h:352
char target[20+1]
Target field (NULL terminated).
Definition dns_resolve.h:360
size_t targetlen
Length of the target field.
Definition dns_resolve.h:358
uint16_t weight
Weight of the server for load balancing.
Definition dns_resolve.h:354
uint16_t port
Port number of the service.
Definition dns_resolve.h:356
TXT record information.
Definition dns_resolve.h:342
size_t textlen
Length of the text field.
Definition dns_resolve.h:344
char text[64+1]
Text field (NULL terminated).
Definition dns_resolve.h:346
Kernel mutex structure.
Definition kernel.h:3500
Kernel timeout type.
Definition clock.h:65
Kernel timepoint type.
Definition clock.h:289
A structure used to submit work after a delay.
Definition kernel.h:4691
Network buffer representation.
Definition net_buf.h:1054
uint8_t user_data[]
System metadata for this buffer.
Definition net_buf.h:1164
Generic sockaddr struct.
Definition net_ip.h:455
Definition of the monitored socket/file descriptor.
Definition socket_poll.h:31