dns_client.c
Go to the documentation of this file.
1 /**
2  * @file dns_client.c
3  * @brief DNS client (Domain Name System)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 //Switch to the appropriate trace level
30 #define TRACE_LEVEL DNS_TRACE_LEVEL
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "dns/dns_cache.h"
35 #include "dns/dns_client.h"
36 #include "dns/dns_common.h"
37 #include "dns/dns_debug.h"
38 #include "debug.h"
39 
40 //Check TCP/IP stack configuration
41 #if (DNS_CLIENT_SUPPORT == ENABLED)
42 
43 
44 /**
45  * @brief Resolve a host name using DNS
46  * @param[in] interface Underlying network interface
47  * @param[in] name Name of the host to be resolved
48  * @param[in] type Host type (IPv4 or IPv6)
49  * @param[out] ipAddr IP address corresponding to the specified host name
50  **/
51 
54 {
55  error_t error;
56  DnsCacheEntry *entry;
57 
58 #if (NET_RTOS_SUPPORT == ENABLED)
59  systime_t delay;
60 
61  //Debug message
62  TRACE_INFO("Resolving host name %s (DNS resolver)...\r\n", name);
63 #endif
64 
65  //Get exclusive access
67 
68  //Search the DNS cache for the specified host name
69  entry = dnsFindEntry(interface, name, type, HOST_NAME_RESOLVER_DNS);
70 
71  //Check whether a matching entry has been found
72  if(entry)
73  {
74  //Host name already resolved?
75  if(entry->state == DNS_STATE_RESOLVED ||
76  entry->state == DNS_STATE_PERMANENT)
77  {
78  //Return the corresponding IP address
79  *ipAddr = entry->ipAddr;
80  //Successful host name resolution
81  error = NO_ERROR;
82  }
83  else
84  {
85  //Host name resolution is in progress...
86  error = ERROR_IN_PROGRESS;
87  }
88  }
89  else
90  {
91  //If no entry exists, then create a new one
92  entry = dnsCreateEntry();
93 
94  //Record the host name whose IP address is unknown
95  strcpy(entry->name, name);
96 
97  //Initialize DNS cache entry
98  entry->type = type;
100  entry->interface = interface;
101  //Select primary DNS server
102  entry->dnsServerNum = 0;
103  //Get an ephemeral port number
104  entry->port = udpGetDynamicPort();
105 
106  //An identifier is used by the DNS client to match replies
107  //with corresponding requests
108  entry->id = (uint16_t) netGetRand();
109 
110  //Callback function to be called when a DNS response is received
111  error = udpAttachRxCallback(interface, entry->port, dnsProcessResponse, NULL);
112 
113  //Check status code
114  if(!error)
115  {
116  //Initialize retransmission counter
118  //Send DNS query
119  error = dnsSendQuery(entry);
120 
121  //DNS message successfully sent?
122  if(!error)
123  {
124  //Save the time at which the query message was sent
125  entry->timestamp = osGetSystemTime();
126  //Set timeout value
129  //Decrement retransmission counter
130  entry->retransmitCount--;
131 
132  //Switch state
133  entry->state = DNS_STATE_IN_PROGRESS;
134  //Host name resolution is in progress
135  error = ERROR_IN_PROGRESS;
136  }
137  else
138  {
139  //Unregister callback function
140  udpDetachRxCallback(interface, entry->port);
141  }
142  }
143  }
144 
145  //Release exclusive access
147 
148 #if (NET_RTOS_SUPPORT == ENABLED)
149  //Set default polling interval
151 
152  //Wait the host name resolution to complete
153  while(error == ERROR_IN_PROGRESS)
154  {
155  //Wait until the next polling period
156  osDelayTask(delay);
157 
158  //Get exclusive access
160 
161  //Search the DNS cache for the specified host name
162  entry = dnsFindEntry(interface, name, type, HOST_NAME_RESOLVER_DNS);
163 
164  //Check whether a matching entry has been found
165  if(entry)
166  {
167  //Host name successfully resolved?
168  if(entry->state == DNS_STATE_RESOLVED)
169  {
170  //Return the corresponding IP address
171  *ipAddr = entry->ipAddr;
172  //Successful host name resolution
173  error = NO_ERROR;
174  }
175  }
176  else
177  {
178  //Host name resolution failed
179  error = ERROR_FAILURE;
180  }
181 
182  //Release exclusive access
184 
185  //Backoff support for less aggressive polling
186  delay = MIN(delay * 2, DNS_CACHE_MAX_POLLING_INTERVAL);
187  }
188 
189  //Check status code
190  if(error)
191  {
192  //Failed to resolve host name
193  TRACE_INFO("Host name resolution failed!\r\n");
194  }
195  else
196  {
197  //Successful host name resolution
198  TRACE_INFO("Host name resolved to %s...\r\n", ipAddrToString(ipAddr, NULL));
199  }
200 #endif
201 
202  //Return status code
203  return error;
204 }
205 
206 
207 /**
208  * @brief Send a DNS query message
209  * @param[in] entry Pointer to a valid DNS cache entry
210  * @return Error code
211  **/
212 
214 {
215  error_t error;
216  size_t length;
217  size_t offset;
218  NetBuffer *buffer;
220  DnsQuestion *dnsQuestion;
222 
223 #if (IPV4_SUPPORT == ENABLED)
224  //An IPv4 address is expected?
225  if(entry->type == HOST_TYPE_IPV4)
226  {
227  //Point to the IPv4 context
228  Ipv4Context *ipv4Context = &entry->interface->ipv4Context;
229 
230  //Out of range index?
232  return ERROR_NO_DNS_SERVER;
233 
234  //Select the relevant DNS server
235  destIpAddr.length = sizeof(Ipv4Addr);
236  destIpAddr.ipv4Addr = ipv4Context->dnsServerList[entry->dnsServerNum];
237 
238  //Make sure the IP address is valid
239  if(destIpAddr.ipv4Addr == IPV4_UNSPECIFIED_ADDR)
240  return ERROR_NO_DNS_SERVER;
241  }
242  else
243 #endif
244 #if (IPV6_SUPPORT == ENABLED)
245  //An IPv6 address is expected?
246  if(entry->type == HOST_TYPE_IPV6)
247  {
248  //Point to the IPv6 context
249  Ipv6Context *ipv6Context = &entry->interface->ipv6Context;
250 
251  //Out of range index?
253  return ERROR_NO_DNS_SERVER;
254 
255  //Select the relevant DNS server
256  destIpAddr.length = sizeof(Ipv6Addr);
257  destIpAddr.ipv6Addr = ipv6Context->dnsServerList[entry->dnsServerNum];
258 
259  //Make sure the IP address is valid
261  return ERROR_NO_DNS_SERVER;
262  }
263  else
264 #endif
265  //Invalid host type?
266  {
267  //Report an error
269  }
270 
271  //Allocate a memory buffer to hold the DNS query message
272  buffer = udpAllocBuffer(DNS_MESSAGE_MAX_SIZE, &offset);
273  //Failed to allocate buffer?
274  if(buffer == NULL)
275  return ERROR_OUT_OF_MEMORY;
276 
277  //Point to the DNS header
278  message = netBufferAt(buffer, offset);
279 
280  //Format DNS query message
281  message->id = htons(entry->id);
282  message->qr = 0;
283  message->opcode = DNS_OPCODE_QUERY;
284  message->aa = 0;
285  message->tc = 0;
286  message->rd = 1;
287  message->ra = 0;
288  message->z = 0;
289  message->rcode = DNS_RCODE_NO_ERROR;
290 
291  //The DNS query contains one question
292  message->qdcount = HTONS(1);
293  message->ancount = 0;
294  message->nscount = 0;
295  message->arcount = 0;
296 
297  //Length of the DNS query message
298  length = sizeof(DnsHeader);
299 
300  //Encode the host name using the DNS name notation
301  length += dnsEncodeName(entry->name, message->questions);
302 
303  //Point to the corresponding question structure
304  dnsQuestion = DNS_GET_QUESTION(message, length);
305 
306 #if (IPV4_SUPPORT == ENABLED)
307  //An IPv4 address is expected?
308  if(entry->type == HOST_TYPE_IPV4)
309  {
310  //Fill in question structure
311  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_A);
312  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
313  }
314 #endif
315 #if (IPV6_SUPPORT == ENABLED)
316  //An IPv6 address is expected?
317  if(entry->type == HOST_TYPE_IPV6)
318  {
319  //Fill in question structure
320  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_AAAA);
321  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
322  }
323 #endif
324 
325  //Update the length of the DNS query message
326  length += sizeof(DnsQuestion);
327 
328  //Adjust the length of the multi-part buffer
329  netBufferSetLength(buffer, offset + length);
330 
331  //Debug message
332  TRACE_INFO("Sending DNS message (%" PRIuSIZE " bytes)...\r\n", length);
333  //Dump message
335 
336  //Send DNS query message
337  error = udpSendDatagramEx(entry->interface, entry->port,
338  &destIpAddr, DNS_PORT, buffer, offset, 0);
339 
340  //Free previously allocated memory
341  netBufferFree(buffer);
342  //Return status code
343  return error;
344 }
345 
346 
347 /**
348  * @brief Process incoming DNS response message
349  * @param[in] interface Underlying network interface
350  * @param[in] pseudoHeader UDP pseudo header
351  * @param[in] udpHeader UDP header
352  * @param[in] buffer Multi-part buffer containing the incoming DNS message
353  * @param[in] offset Offset to the first byte of the DNS message
354  * @param[in] param Callback function parameter (not used)
355  **/
356 
357 void dnsProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
358  const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *param)
359 {
360  uint_t i;
361  uint_t j;
362  size_t pos;
363  size_t length;
365  DnsQuestion *question;
366  DnsResourceRecord *record;
367  DnsCacheEntry *entry;
368 
369  //Retrieve the length of the DNS message
370  length = netBufferGetLength(buffer) - offset;
371 
372  //Ensure the DNS message is valid
373  if(length < sizeof(DnsHeader))
374  return;
376  return;
377 
378  //Point to the DNS message header
379  message = netBufferAt(buffer, offset);
380  //Sanity check
381  if(message == NULL)
382  return;
383 
384  //Debug message
385  TRACE_INFO("DNS message received (%" PRIuSIZE " bytes)...\r\n", length);
386  //Dump message
388 
389  //Check message type
390  if(!message->qr)
391  return;
392  //The DNS message shall contain one question
393  if(ntohs(message->qdcount) != 1)
394  return;
395 
396  //Loop through DNS cache entries
397  for(i = 0; i < DNS_CACHE_SIZE; i++)
398  {
399  //Point to the current entry
400  entry = &dnsCache[i];
401 
402  //DNS name resolution in progress?
403  if(entry->state == DNS_STATE_IN_PROGRESS &&
405  {
406  //Check destination port number
407  if(entry->port == ntohs(udpHeader->destPort))
408  {
409  //Compare identifier against the expected one
410  if(ntohs(message->id) != entry->id)
411  break;
412 
413  //Point to the first question
414  pos = sizeof(DnsHeader);
415  //Parse domain name
416  pos = dnsParseName(message, length, pos, NULL, 0);
417 
418  //Invalid name?
419  if(!pos)
420  break;
421  //Malformed DNS message?
422  if((pos + sizeof(DnsQuestion)) > length)
423  break;
424 
425  //Compare domain name
426  if(dnsCompareName(message, length, sizeof(DnsHeader), entry->name, 0))
427  break;
428 
429  //Point to the corresponding entry
430  question = DNS_GET_QUESTION(message, pos);
431 
432  //Check the class of the query
433  if(ntohs(question->qclass) != DNS_RR_CLASS_IN)
434  break;
435 
436  //Check the type of the query
437  if(entry->type == HOST_TYPE_IPV4 && ntohs(question->qtype) != DNS_RR_TYPE_A)
438  break;
439  if(entry->type == HOST_TYPE_IPV6 && ntohs(question->qtype) != DNS_RR_TYPE_AAAA)
440  break;
441 
442  //Check return code
443  if(message->rcode != DNS_RCODE_NO_ERROR)
444  {
445  //The entry should be deleted since name resolution has failed
446  dnsDeleteEntry(entry);
447  //Exit immediately
448  break;
449  }
450 
451  //Point to the first answer
452  pos += sizeof(DnsQuestion);
453 
454  //Parse answer resource records
455  for(j = 0; j < ntohs(message->ancount); j++)
456  {
457  //Parse domain name
458  pos = dnsParseName(message, length, pos, NULL, 0);
459  //Invalid name?
460  if(!pos)
461  break;
462 
463  //Point to the associated resource record
464  record = DNS_GET_RESOURCE_RECORD(message, pos);
465  //Point to the resource data
466  pos += sizeof(DnsResourceRecord);
467 
468  //Make sure the resource record is valid
469  if(pos > length)
470  break;
471  if((pos + ntohs(record->rdlength)) > length)
472  break;
473 
474 #if (IPV4_SUPPORT == ENABLED)
475  //IPv4 address expected?
476  if(entry->type == HOST_TYPE_IPV4)
477  {
478  //A resource record found?
479  if(ntohs(record->rtype) == DNS_RR_TYPE_A &&
480  ntohs(record->rdlength) == sizeof(Ipv4Addr))
481  {
482  //Copy the IPv4 address
483  entry->ipAddr.length = sizeof(Ipv4Addr);
484  ipv4CopyAddr(&entry->ipAddr.ipv4Addr, record->rdata);
485 
486  //Save current time
487  entry->timestamp = osGetSystemTime();
488  //Save TTL value
489  entry->timeout = ntohl(record->ttl) * 1000;
490 
491  //Limit the lifetime of the DNS cache entries
492  if(entry->timeout >= DNS_MAX_LIFETIME)
493  entry->timeout = DNS_MAX_LIFETIME;
494  if(entry->timeout <= DNS_MIN_LIFETIME)
495  entry->timeout = DNS_MIN_LIFETIME;
496 
497  //Unregister UDP callback function
498  udpDetachRxCallback(interface, entry->port);
499  //Host name successfully resolved
500  entry->state = DNS_STATE_RESOLVED;
501  //Exit immediately
502  break;
503  }
504  }
505 #endif
506 #if (IPV6_SUPPORT == ENABLED)
507  //IPv6 address expected?
508  if(entry->type == HOST_TYPE_IPV6)
509  {
510  //AAAA resource record found?
511  if(ntohs(record->rtype) == DNS_RR_TYPE_AAAA &&
512  ntohs(record->rdlength) == sizeof(Ipv6Addr))
513  {
514  //Copy the IPv6 address
515  entry->ipAddr.length = sizeof(Ipv6Addr);
516  ipv6CopyAddr(&entry->ipAddr.ipv6Addr, record->rdata);
517 
518  //Save current time
519  entry->timestamp = osGetSystemTime();
520  //Save TTL value
521  entry->timeout = ntohl(record->ttl) * 1000;
522 
523  //Limit the lifetime of the DNS cache entries
524  if(entry->timeout >= DNS_MAX_LIFETIME)
525  entry->timeout = DNS_MAX_LIFETIME;
526  if(entry->timeout <= DNS_MIN_LIFETIME)
527  entry->timeout = DNS_MIN_LIFETIME;
528 
529  //Unregister UDP callback function
530  udpDetachRxCallback(interface, entry->port);
531  //Host name successfully resolved
532  entry->state = DNS_STATE_RESOLVED;
533  //Exit immediately
534  break;
535  }
536  }
537 #endif
538  //Point to the next resource record
539  pos += ntohs(record->rdlength);
540  }
541 
542  //We are done
543  break;
544  }
545  }
546  }
547 }
548 
549 #endif
#define DNS_GET_QUESTION(message, offset)
Definition: dns_common.h:61
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:232
error_t dnsSendQuery(DnsCacheEntry *entry)
Send a DNS query message.
Definition: dns_client.c:213
__start_packed struct @151 DnsQuestion
Question format.
#define DNS_GET_RESOURCE_RECORD(message, offset)
Definition: dns_common.h:62
uint32_t systime_t
Definition: compiler_port.h:44
IPv6 address.
Definition: dns_common.h:131
DnsCacheEntry dnsCache[DNS_CACHE_SIZE]
Definition: dns_cache.c:49
#define ipv6CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv6.h:115
char char_t
Definition: compiler_port.h:41
HostnameResolver protocol
Name resolution protocol.
Definition: dns_cache.h:98
#define DNS_CLIENT_MAX_TIMEOUT
Definition: dns_client.h:61
Ipv4Addr ipv4Addr
Definition: ip.h:63
systime_t osGetSystemTime(void)
Retrieve system time.
TCP/IP stack core.
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
Definition: net_mem.c:280
Debugging facilities.
Internet.
Definition: dns_common.h:108
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:295
Generic error code.
Definition: error.h:43
error_t dnsResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using DNS.
Definition: dns_client.c:52
uint8_t message[]
Definition: chap.h:150
error_t netBufferSetLength(NetBuffer *buffer, size_t length)
Adjust the length of a multi-part buffer.
Definition: net_mem.c:318
IpAddr ipAddr
IP address.
Definition: dns_cache.h:104
Invalid parameter.
Definition: error.h:45
HostType type
IPv4 or IPv6 host?
Definition: dns_cache.h:97
#define IPV4_DNS_SERVER_LIST_SIZE
Definition: ipv4.h:61
DNS cache management.
IP network address.
Definition: ip.h:57
__start_packed struct @183 Ipv6Addr
IPv6 network address.
Ipv4Addr dnsServerList[IPV4_DNS_SERVER_LIST_SIZE]
DNS servers.
Definition: ipv4.h:327
systime_t timeout
Retransmission timeout.
Definition: dns_cache.h:106
char_t * ipAddrToString(const IpAddr *ipAddr, char_t *str)
Convert a binary IP address to a string representation.
Definition: ip.c:685
char_t type
#define htons(value)
Definition: cpu_endian.h:390
uint16_t id
Identifier used to match queries and responses.
Definition: dns_cache.h:102
#define HTONS(value)
Definition: cpu_endian.h:388
systime_t timestamp
Time stamp to manage entry lifetime.
Definition: dns_cache.h:105
uint8_t ipAddr[4]
Definition: mib_common.h:185
Data logging functions for debugging purpose (DNS)
uint16_t port
Port number used by the resolver.
Definition: dns_cache.h:101
#define ntohl(value)
Definition: cpu_endian.h:397
DNS client (Domain Name System)
char_t name[DNS_MAX_NAME_LEN+1]
Domain name.
Definition: dns_cache.h:103
#define DNS_CLIENT_MAX_RETRIES
Definition: dns_client.h:47
__start_packed struct @150 DnsHeader
DNS message header.
DnsCacheEntry * dnsFindEntry(NetInterface *interface, const char_t *name, HostType type, HostnameResolver protocol)
Search the DNS cache for a given domain name.
Definition: dns_cache.c:181
#define ntohs(value)
Definition: cpu_endian.h:396
uint32_t netGetRand(void)
Get a random value.
Definition: net.c:1523
DNS cache entry.
Definition: dns_cache.h:94
HostType
Host types.
Definition: socket.h:168
void * netBufferAt(const NetBuffer *buffer, size_t offset)
Returns a pointer to the data at the specified position.
Definition: net_mem.c:411
char_t name[]
uint_t dnsServerNum
This parameter selects between the primary and secondary DNS server.
Definition: dns_cache.h:100
Ipv6Addr dnsServerList[IPV6_DNS_SERVER_LIST_SIZE]
DNS servers.
Definition: ipv6.h:470
__start_packed struct @126 UdpHeader
UDP header.
void osDelayTask(systime_t delay)
Delay routine.
error_t udpAttachRxCallback(NetInterface *interface, uint16_t port, UdpRxCallback callback, void *param)
Register user callback.
Definition: udp.c:723
void dnsDeleteEntry(DnsCacheEntry *entry)
Delete the specified DNS cache entry.
Definition: dns_cache.c:148
int_t dnsCompareName(const DnsHeader *message, size_t length, size_t pos, const char_t *name, uint_t level)
Compare domain names.
Definition: dns_common.c:238
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:86
DnsCacheEntry * dnsCreateEntry(void)
Create a new entry in the DNS cache.
Definition: dns_cache.c:99
#define MIN(a, b)
Definition: os_port.h:60
#define DNS_MIN_LIFETIME
Definition: dns_client.h:68
NetInterface * interface
Underlying network interface.
Definition: dns_cache.h:99
#define DNS_CACHE_MAX_POLLING_INTERVAL
Definition: dns_cache.h:66
#define DNS_CACHE_INIT_POLLING_INTERVAL
Definition: dns_cache.h:59
error_t udpDetachRxCallback(NetInterface *interface, uint16_t port)
Unregister user callback.
Definition: udp.c:770
void dnsDumpMessage(const DnsHeader *message, size_t length)
Dump DNS message for debugging purpose.
Definition: dns_debug.c:50
NetBuffer * udpAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold a UDP packet.
Definition: udp.c:656
#define TRACE_INFO(...)
Definition: debug.h:86
size_t dnsParseName(const DnsHeader *message, size_t length, size_t pos, char_t *dest, uint_t level)
Decode a domain name that uses the DNS name encoding.
Definition: dns_common.c:128
systime_t maxTimeout
Maximum retransmission timeout.
Definition: dns_cache.h:107
Success.
Definition: error.h:42
#define DNS_MESSAGE_MAX_SIZE
Definition: dns_common.h:43
error_t
Error codes.
Definition: error.h:40
Ipv4Addr destIpAddr
Definition: ipcp.h:76
size_t dnsEncodeName(const char_t *src, uint8_t *dest)
Encode a domain name using the DNS name notation.
Definition: dns_common.c:54
size_t length
Definition: ip.h:59
unsigned int uint_t
Definition: compiler_port.h:43
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
Ipv6Addr ipv6Addr
Definition: ip.h:66
#define PRIuSIZE
Definition: compiler_port.h:72
#define DNS_MAX_LIFETIME
Definition: dns_client.h:75
error_t udpSendDatagramEx(NetInterface *interface, uint16_t srcPort, const IpAddr *destIpAddr, uint16_t destPort, NetBuffer *buffer, size_t offset, uint8_t ttl)
Send a UDP datagram (raw interface)
Definition: udp.c:448
#define NetInterface
Definition: net.h:34
uint16_t udpGetDynamicPort(void)
Get an ephemeral port number.
Definition: udp.c:86
IP pseudo header.
Definition: ip.h:76
#define DNS_PORT
Definition: dns_common.h:55
const Ipv6Addr IPV6_UNSPECIFIED_ADDR
Definition: ipv6.c:65
__start_packed struct @152 DnsResourceRecord
Resource record format.
#define IPV4_UNSPECIFIED_ADDR
Definition: ipv4.h:95
#define IPV6_DNS_SERVER_LIST_SIZE
Definition: ipv6.h:92
OsMutex netMutex
Definition: net.c:70
IPv4 context.
Definition: ipv4.h:317
IPv6 context.
Definition: ipv6.h:460
DnsState state
Entry state.
Definition: dns_cache.h:96
void dnsProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *param)
Process incoming DNS response message.
Definition: dns_client.c:357
#define DNS_CLIENT_INIT_TIMEOUT
Definition: dns_client.h:54
uint8_t length
Definition: dtls_misc.h:140
uint_t retransmitCount
Retransmission counter.
Definition: dns_cache.h:108
Common DNS routines.
Host address.
Definition: dns_common.h:121
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
#define ipv6CompAddr(ipAddr1, ipAddr2)
Definition: ipv6.h:119
#define ipv4CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv4.h:133
#define DNS_CACHE_SIZE
Definition: dns_cache.h:45