llmnr_client.c
Go to the documentation of this file.
1 /**
2  * @file llmnr_client.c
3  * @brief LLMNR client (Link-Local Multicast Name Resolution)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.6
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL LLMNR_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv4/ipv4_misc.h"
37 #include "llmnr/llmnr_client.h"
38 #include "dns/dns_debug.h"
39 #include "debug.h"
40 
41 //Check TCP/IP stack configuration
42 #if (LLMNR_CLIENT_SUPPORT == ENABLED)
43 
44 
45 /**
46  * @brief Resolve a host name using LLMNR
47  * @param[in] interface Underlying network interface
48  * @param[in] name Name of the host to be resolved
49  * @param[in] type Host type (IPv4 or IPv6)
50  * @param[out] ipAddr IP address corresponding to the specified host name
51  **/
52 
55 {
56  error_t error;
57  DnsCacheEntry *entry;
58 
59 #if (NET_RTOS_SUPPORT == ENABLED)
60  systime_t delay;
61 
62  //Debug message
63  TRACE_INFO("Resolving host name %s (LLMNR resolver)...\r\n", name);
64 #endif
65 
66  //Get exclusive access
67  netLock(interface->netContext);
68 
69  //Search the DNS cache for the specified host name
70  entry = dnsFindEntry(interface, name, type, HOST_NAME_RESOLVER_LLMNR);
71 
72  //Check whether a matching entry has been found
73  if(entry != NULL)
74  {
75  //Host name already resolved?
76  if(entry->state == DNS_STATE_RESOLVED ||
77  entry->state == DNS_STATE_PERMANENT)
78  {
79  //Return the corresponding IP address
80  *ipAddr = entry->ipAddr;
81  //Successful host name resolution
82  error = NO_ERROR;
83  }
84  else if(entry->state == DNS_STATE_FAILED)
85  {
86  //The entry should be deleted since name resolution has failed
87  if(entry->refCount == 0)
88  {
89  //The entry should be deleted since name resolution has failed
90  dnsDeleteEntry(entry);
91  }
92 
93  //Report an error
94  error = ERROR_FAILURE;
95  }
96  else
97  {
98 #if (NET_RTOS_SUPPORT == ENABLED)
99  //Increment the reference count
100  entry->refCount++;
101 #endif
102  //Host name resolution is in progress
103  error = ERROR_IN_PROGRESS;
104  }
105  }
106  else
107  {
108  //If no entry exists, then create a new one
109  entry = dnsCreateEntry(interface->netContext);
110 
111  //Record the host name whose IP address is unknown
112  osStrcpy(entry->name, name);
113 
114  //Initialize DNS cache entry
115  entry->type = type;
117  entry->interface = interface;
118 
119  //Get an ephemeral port number
120  entry->port = udpGetDynamicPort(interface->netContext);
121 
122  //An identifier is used by the LLMNR client to match replies with
123  //corresponding requests
124  entry->id = (uint16_t) netGenerateRand(interface->netContext);
125 
126  //Callback function to be called when a LLMNR response is received
127  error = udpRegisterRxCallback(interface, entry->port,
128  llmnrProcessResponse, NULL);
129 
130  //Check status code
131  if(!error)
132  {
133  //Initialize retransmission counter
135  //Send LLMNR query
136  error = llmnrSendQuery(entry);
137 
138  //LLMNR message successfully sent?
139  if(!error)
140  {
141  //Save the time at which the query message was sent
142  entry->timestamp = osGetSystemTime();
143  //Set timeout value
146  //Decrement retransmission counter
147  entry->retransmitCount--;
148 
149  //Switch state
150  entry->state = DNS_STATE_IN_PROGRESS;
151 
152 #if (NET_RTOS_SUPPORT == ENABLED)
153  //Initialize the reference count
154  entry->refCount = 1;
155 #endif
156  //Host name resolution is in progress
157  error = ERROR_IN_PROGRESS;
158  }
159  else
160  {
161  //Unregister UDP callback function
162  udpUnregisterRxCallback(interface, entry->port);
163  }
164  }
165  }
166 
167  //Release exclusive access
168  netUnlock(interface->netContext);
169 
170 #if (NET_RTOS_SUPPORT == ENABLED)
171  //Set default polling interval
173 
174  //Wait the host name resolution to complete
175  while(error == ERROR_IN_PROGRESS)
176  {
177  //Wait until the next polling period
178  osDelayTask(delay);
179 
180  //Get exclusive access
181  netLock(interface->netContext);
182 
183  //Search the DNS cache for the specified host name
184  entry = dnsFindEntry(interface, name, type, HOST_NAME_RESOLVER_LLMNR);
185 
186  //Check whether a matching entry has been found
187  if(entry != NULL)
188  {
189  //Host name successfully resolved?
190  if(entry->state == DNS_STATE_RESOLVED)
191  {
192  //Return the corresponding IP address
193  *ipAddr = entry->ipAddr;
194  //Successful host name resolution
195  error = NO_ERROR;
196  }
197  else if(entry->state == DNS_STATE_FAILED)
198  {
199  //Decrement the reference count
200  if(entry->refCount > 0)
201  {
202  entry->refCount--;
203  }
204 
205  //The entry should be deleted since name resolution has failed
206  if(entry->refCount == 0)
207  {
208  dnsDeleteEntry(entry);
209  }
210 
211  //Report an error
212  error = ERROR_FAILURE;
213  }
214  else
215  {
216  //Host name resolution is in progress
217  }
218  }
219  else
220  {
221  //Host name resolution failed
222  error = ERROR_FAILURE;
223  }
224 
225  //Release exclusive access
226  netUnlock(interface->netContext);
227 
228  //Backoff support for less aggressive polling
229  delay = MIN(delay * 2, DNS_CACHE_MAX_POLLING_INTERVAL);
230  }
231 
232  //Check status code
233  if(error)
234  {
235  //Failed to resolve host name
236  TRACE_INFO("Host name resolution failed!\r\n");
237  }
238  else
239  {
240  //Successful host name resolution
241  TRACE_INFO("Host name resolved to %s...\r\n", ipAddrToString(ipAddr, NULL));
242  }
243 #endif
244 
245  //Return status code
246  return error;
247 }
248 
249 
250 /**
251  * @brief Send a LLMNR query message
252  * @param[in] entry Pointer to a valid DNS cache entry
253  * @return Error code
254  **/
255 
257 {
258  error_t error;
259  size_t length;
260  size_t offset;
261  NetBuffer *buffer;
263  DnsQuestion *dnsQuestion;
265  NetTxAncillary ancillary;
266 
267 #if (IPV4_SUPPORT == ENABLED)
268  //An IPv4 address is expected?
269  if(entry->type == HOST_TYPE_IPV4)
270  {
271  //The IPv4 link-scope multicast address to which a sender sends queries
272  //is 224.0.0.252
273  destIpAddr.length = sizeof(Ipv4Addr);
275  }
276  else
277 #endif
278 #if (IPV6_SUPPORT == ENABLED)
279  //An IPv6 address is expected?
280  if(entry->type == HOST_TYPE_IPV6)
281  {
282  //The IPv6 link-scope multicast address to which a sender sends queries
283  //is ff02:0:0:0:0:0:1:3
284  destIpAddr.length = sizeof(Ipv6Addr);
286  }
287  else
288 #endif
289  //Invalid host type?
290  {
291  //Report an error
293  }
294 
295  //Allocate a memory buffer to hold the LLMNR query message
296  buffer = udpAllocBuffer(LLMNR_MESSAGE_MAX_SIZE, &offset);
297  //Failed to allocate buffer?
298  if(buffer == NULL)
299  return ERROR_OUT_OF_MEMORY;
300 
301  //Point to the LLMNR header
302  message = netBufferAt(buffer, offset, 0);
303 
304  //Format LLMNR query message
305  message->id = htons(entry->id);
306  message->qr = 0;
307  message->opcode = DNS_OPCODE_QUERY;
308  message->c = 0;
309  message->tc = 0;
310  message->t = 0;
311  message->z = 0;
312  message->rcode = DNS_RCODE_NOERROR;
313 
314  //The LLMNR query contains one question
315  message->qdcount = HTONS(1);
316  message->ancount = 0;
317  message->nscount = 0;
318  message->arcount = 0;
319 
320  //Length of the LLMNR query message
321  length = sizeof(DnsHeader);
322 
323  //Encode the host name using the DNS name notation
324  length += dnsEncodeName(entry->name, message->questions);
325 
326  //Point to the corresponding question structure
327  dnsQuestion = DNS_GET_QUESTION(message, length);
328 
329 #if (IPV4_SUPPORT == ENABLED)
330  //An IPv4 address is expected?
331  if(entry->type == HOST_TYPE_IPV4)
332  {
333  //Fill in question structure
334  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_A);
335  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
336  }
337 #endif
338 #if (IPV6_SUPPORT == ENABLED)
339  //An IPv6 address is expected?
340  if(entry->type == HOST_TYPE_IPV6)
341  {
342  //Fill in question structure
343  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_AAAA);
344  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
345  }
346 #endif
347 
348  //Update the length of the LLMNR query message
349  length += sizeof(DnsQuestion);
350 
351  //Adjust the length of the multi-part buffer
352  netBufferSetLength(buffer, offset + length);
353 
354  //Debug message
355  TRACE_INFO("Sending LLMNR message (%" PRIuSIZE " bytes)...\r\n", length);
356  //Dump message
358 
359  //Additional options can be passed to the stack along with the packet
360  ancillary = NET_DEFAULT_TX_ANCILLARY;
361 
362  //For UDP queries, the Hop Limit field in the IPv6 header and the TTL
363  //field in the IPV4 header MAY be set to any value. However, it is
364  //recommended that the value 255 be used for compatibility with early
365  //implementations (refer to RFC 4795, section 2.5)
366  ancillary.ttl = LLMNR_DEFAULT_QUERY_IP_TTL;
367 
368  //LLMNR queries are sent to and received on port 5355
369  error = udpSendBuffer(entry->interface->netContext, entry->interface, NULL,
370  entry->port, &destIpAddr, LLMNR_PORT, buffer, offset, &ancillary);
371 
372  //Free previously allocated memory
373  netBufferFree(buffer);
374 
375  //Return status code
376  return error;
377 }
378 
379 
380 /**
381  * @brief Process LLMNR response message
382  * @param[in] interface Underlying network interface
383  * @param[in] pseudoHeader UDP pseudo header
384  * @param[in] udpHeader UDP header
385  * @param[in] buffer Multi-part buffer containing the incoming LLMNR message
386  * @param[in] offset Offset to the first byte of the LLMNR message
387  * @param[in] ancillary Additional options passed to the stack along with
388  * the packet
389  * @param[in] param Callback function parameter (not used)
390  **/
391 
393  const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader,
394  const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary,
395  void *param)
396 {
397  uint_t i;
398  uint_t j;
399  size_t pos;
400  size_t length;
401  NetContext *context;
403  DnsQuestion *question;
404  DnsResourceRecord *record;
405  DnsCacheEntry *entry;
406 
407  //Point to the TCP/IP stack context
408  context = interface->netContext;
409 
410  //Retrieve the length of the LLMNR message
411  length = netBufferGetLength(buffer) - offset;
412 
413  //Malformed LLMNR message?
414  if(length < sizeof(LlmnrHeader))
415  return;
416 
417  //Point to the LLMNR message header
418  message = netBufferAt(buffer, offset, length);
419  //Malformed LLMNR message?
420  if(message == NULL)
421  return;
422 
423  //Debug message
424  TRACE_INFO("LLMNR message received (%" PRIuSIZE " bytes)...\r\n", length);
425  //Dump message
427 
428  //Discard LLMNR queries
429  if(!message->qr)
430  return;
431 
432  //LLMNR messages received with an opcode other than zero must be silently
433  //ignored
434  if(message->opcode != DNS_OPCODE_QUERY)
435  return;
436 
437  //LLMNR messages received with non-zero response codes must be silently
438  //ignored
439  if(message->rcode != DNS_RCODE_NOERROR)
440  return;
441 
442  //LLMNR senders must silently discard LLMNR responses with QDCOUNT not
443  //equal to one (refer to RFC 4795, section 2.1.1)
444  if(ntohs(message->qdcount) != 1)
445  return;
446 
447  //Loop through DNS cache entries
448  for(i = 0; i < DNS_CACHE_SIZE; i++)
449  {
450  //Point to the current entry
451  entry = &context->dnsCache[i];
452 
453  //LLMNR name resolution in progress?
454  if(entry->state == DNS_STATE_IN_PROGRESS &&
456  {
457  //Check destination port number
458  if(entry->port == ntohs(udpHeader->destPort))
459  {
460  //Compare identifier against the expected one
461  if(ntohs(message->id) != entry->id)
462  break;
463 
464  //Point to the first question
465  pos = sizeof(DnsHeader);
466  //Parse domain name
467  pos = dnsParseName((DnsHeader *) message, length, pos, 0);
468 
469  //Invalid name?
470  if(pos == 0)
471  break;
472  //Malformed DNS message?
473  if((pos + sizeof(DnsQuestion)) > length)
474  break;
475 
476  //Compare domain name
478  entry->name, 0))
479  {
480  break;
481  }
482 
483  //Point to the corresponding entry
484  question = DNS_GET_QUESTION(message, pos);
485 
486  //Check the class of the query
487  if(ntohs(question->qclass) != DNS_RR_CLASS_IN)
488  break;
489 
490  //Check the type of the query
491  if(entry->type == HOST_TYPE_IPV4 &&
492  ntohs(question->qtype) != DNS_RR_TYPE_A)
493  {
494  break;
495  }
496 
497  if(entry->type == HOST_TYPE_IPV6 &&
498  ntohs(question->qtype) != DNS_RR_TYPE_AAAA)
499  {
500  break;
501  }
502 
503  //Point to the first answer
504  pos += sizeof(DnsQuestion);
505 
506  //Parse answer resource records
507  for(j = 0; j < ntohs(message->ancount); j++)
508  {
509  //Parse domain name
510  pos = dnsParseName((DnsHeader *) message, length, pos, 0);
511  //Invalid name?
512  if(pos == 0)
513  break;
514 
515  //Point to the associated resource record
516  record = DNS_GET_RESOURCE_RECORD(message, pos);
517  //Point to the resource data
518  pos += sizeof(DnsResourceRecord);
519 
520  //Make sure the resource record is valid
521  if(pos > length)
522  break;
523  if((pos + ntohs(record->rdlength)) > length)
524  break;
525 
526 #if (IPV4_SUPPORT == ENABLED)
527  //IPv4 address expected?
528  if(entry->type == HOST_TYPE_IPV4)
529  {
530  //A resource record found?
531  if(ntohs(record->rtype) == DNS_RR_TYPE_A &&
532  ntohs(record->rdlength) == sizeof(Ipv4Addr))
533  {
534  //Copy the IPv4 address
535  entry->ipAddr.length = sizeof(Ipv4Addr);
536  ipv4CopyAddr(&entry->ipAddr.ipv4Addr, record->rdata);
537 
538  //Save current time
539  entry->timestamp = osGetSystemTime();
540  //Save TTL value
541  entry->timeout = ntohl(record->ttl) * 1000;
542  //Limit the lifetime of the NBNS cache entries
543  entry->timeout = MIN(entry->timeout, LLMNR_MAX_LIFETIME);
544 
545  //Unregister UDP callback function
546  udpUnregisterRxCallback(interface, entry->port);
547  //Host name successfully resolved
548  entry->state = DNS_STATE_RESOLVED;
549 
550  //Exit immediately
551  break;
552  }
553  }
554 #endif
555 #if (IPV6_SUPPORT == ENABLED)
556  //IPv6 address expected?
557  if(entry->type == HOST_TYPE_IPV6)
558  {
559  //AAAA resource record found?
560  if(ntohs(record->rtype) == DNS_RR_TYPE_AAAA &&
561  ntohs(record->rdlength) == sizeof(Ipv6Addr))
562  {
563  //Copy the IPv6 address
564  entry->ipAddr.length = sizeof(Ipv6Addr);
565  ipv6CopyAddr(&entry->ipAddr.ipv6Addr, record->rdata);
566 
567  //Save current time
568  entry->timestamp = osGetSystemTime();
569  //Save TTL value
570  entry->timeout = ntohl(record->ttl) * 1000;
571  //Limit the lifetime of the NBNS cache entries
572  entry->timeout = MIN(entry->timeout, LLMNR_MAX_LIFETIME);
573 
574  //Unregister UDP callback function
575  udpUnregisterRxCallback(interface, entry->port);
576  //Host name successfully resolved
577  entry->state = DNS_STATE_RESOLVED;
578 
579  //Exit immediately
580  break;
581  }
582  }
583 #endif
584  //Point to the next resource record
585  pos += ntohs(record->rdlength);
586  }
587 
588  //We are done
589  break;
590  }
591  }
592  }
593 }
594 
595 #endif
#define LLMNR_DEFAULT_QUERY_IP_TTL
Definition: llmnr_common.h:55
#define htons(value)
Definition: cpu_endian.h:413
HostType
Host types.
Definition: socket.h:215
@ DNS_STATE_PERMANENT
Definition: dns_cache.h:89
HostType type
IPv4 or IPv6 host?
Definition: dns_cache.h:101
void netUnlock(NetContext *context)
Release exclusive access to the core of the TCP/IP stack.
Definition: net.c:319
#define NetContext
Definition: net.h:36
error_t udpUnregisterRxCallback(NetInterface *interface, uint16_t port)
Unregister user callback.
Definition: udp.c:1080
#define LLMNR_MAX_LIFETIME
Definition: llmnr_client.h:72
size_t dnsParseName(const DnsHeader *message, size_t length, size_t pos, uint_t level)
Decode a domain name that uses the DNS name encoding.
Definition: dns_common.c:131
const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
Definition: net_misc.c:70
IP network address.
Definition: ip.h:94
@ DNS_OPCODE_QUERY
Query.
Definition: dns_common.h:83
#define LLMNR_CLIENT_MAX_TIMEOUT
Definition: llmnr_client.h:65
LlmnrHeader
Definition: llmnr_common.h:105
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t message[]
Definition: chap.h:154
uint32_t netGenerateRand(NetContext *context)
Generate a random 32-bit value.
Definition: net_misc.c:962
error_t llmnrSendQuery(DnsCacheEntry *entry)
Send a LLMNR query message.
Definition: llmnr_client.c:256
systime_t timeout
Retransmission timeout.
Definition: dns_cache.h:110
@ HOST_NAME_RESOLVER_LLMNR
Definition: socket.h:232
char_t * ipAddrToString(const IpAddr *ipAddr, char_t *str)
Convert a binary IP address to a string representation.
Definition: ip.c:810
Ipv6Addr
Definition: ipv6.h:282
uint8_t type
Definition: coap_common.h:176
@ ERROR_OUT_OF_MEMORY
Definition: error.h:63
HostnameResolver protocol
Name resolution protocol.
Definition: dns_cache.h:102
@ DNS_RR_CLASS_IN
Internet.
Definition: dns_common.h:126
char_t name[]
DnsHeader
Definition: dns_common.h:204
uint_t refCount
Reference count for the current entry.
Definition: dns_cache.h:100
IpAddr ipAddr
IP address.
Definition: dns_cache.h:108
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:324
@ HOST_TYPE_IPV6
Definition: socket.h:218
uint16_t id
Identifier used to match queries and responses.
Definition: dns_cache.h:106
@ DNS_RCODE_NOERROR
No error.
Definition: dns_common.h:97
@ ERROR_IN_PROGRESS
Definition: error.h:214
Helper functions for IPv4.
uint16_t port
Port number used by the resolver.
Definition: dns_cache.h:105
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
error_t
Error codes.
Definition: error.h:43
#define DNS_GET_QUESTION(message, offset)
Definition: dns_common.h:65
char_t name[DNS_MAX_NAME_LEN+1]
Domain name.
Definition: dns_cache.h:107
systime_t timestamp
Timestamp to manage entry lifetime.
Definition: dns_cache.h:109
#define DNS_GET_RESOURCE_RECORD(message, offset)
Definition: dns_common.h:66
#define LLMNR_CLIENT_MAX_RETRIES
Definition: llmnr_client.h:51
#define LLMNR_IPV4_MULTICAST_ADDR
Definition: llmnr_common.h:60
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define LLMNR_PORT
Definition: llmnr_common.h:53
@ DNS_STATE_FAILED
Definition: dns_cache.h:88
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:40
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
Definition: net_mem.c:282
DNS cache entry.
Definition: dns_cache.h:98
@ DNS_RR_TYPE_A
Host address.
Definition: dns_common.h:139
#define NetTxAncillary
Definition: net_misc.h:36
systime_t maxTimeout
Maximum retransmission timeout.
Definition: dns_cache.h:111
error_t udpSendBuffer(NetContext *context, NetInterface *interface, const IpAddr *srcIpAddr, uint16_t srcPort, const IpAddr *destIpAddr, uint16_t destPort, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a UDP datagram.
Definition: udp.c:665
error_t llmnrResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using LLMNR.
Definition: llmnr_client.c:53
#define TRACE_INFO(...)
Definition: debug.h:105
uint8_t length
Definition: tcp.h:375
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
void dnsDumpMessage(const DnsHeader *message, size_t length)
Dump DNS message for debugging purpose.
Definition: dns_debug.c:52
#define MIN(a, b)
Definition: os_port.h:63
NetBuffer * udpAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold a UDP packet.
Definition: udp.c:958
size_t length
Definition: ip.h:95
@ HOST_TYPE_IPV4
Definition: socket.h:217
size_t dnsEncodeName(const char_t *src, uint8_t *dest)
Encode a domain name using the DNS name notation.
Definition: dns_common.c:58
const Ipv6Addr LLMNR_IPV6_MULTICAST_ADDR
Definition: llmnr_common.c:45
UdpHeader
Definition: udp.h:85
DnsCacheEntry * dnsCreateEntry(NetContext *context)
Create a new entry in the DNS cache.
Definition: dns_cache.c:104
#define DNS_CACHE_INIT_POLLING_INTERVAL
Definition: dns_cache.h:61
uint16_t udpGetDynamicPort(NetContext *context)
Get an ephemeral port number.
Definition: udp.c:78
#define LLMNR_MESSAGE_MAX_SIZE
Definition: llmnr_common.h:40
uint32_t systime_t
System time.
#define ntohs(value)
Definition: cpu_endian.h:421
char char_t
Definition: compiler_port.h:55
LLMNR client (Link-Local Multicast Name Resolution)
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:186
Ipv4Addr ipv4Addr
Definition: ip.h:99
#define ipv6CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv6.h:132
#define HTONS(value)
Definition: cpu_endian.h:410
#define IpPseudoHeader
Definition: ip.h:36
@ DNS_STATE_IN_PROGRESS
Definition: dns_cache.h:86
NetInterface * interface
Underlying network interface.
Definition: dns_cache.h:103
#define DNS_CACHE_SIZE
Definition: dns_cache.h:47
@ DNS_STATE_RESOLVED
Definition: dns_cache.h:87
error_t netBufferSetLength(NetBuffer *buffer, size_t length)
Adjust the length of a multi-part buffer.
Definition: net_mem.c:322
DnsQuestion
Definition: dns_common.h:215
void dnsDeleteEntry(DnsCacheEntry *entry)
Delete the specified DNS cache entry.
Definition: dns_cache.c:154
#define ipv4CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv4.h:167
void netLock(NetContext *context)
Get exclusive access to the core of the TCP/IP stack.
Definition: net.c:307
void osDelayTask(systime_t delay)
Delay routine.
void * netBufferAt(const NetBuffer *buffer, size_t offset, size_t length)
Returns a pointer to a data segment.
Definition: net_mem.c:418
#define LLMNR_CLIENT_INIT_TIMEOUT
Definition: llmnr_client.h:58
Ipv4Addr ipAddr
Definition: ipcp.h:105
DnsState state
Entry state.
Definition: dns_cache.h:99
error_t udpRegisterRxCallback(NetInterface *interface, uint16_t port, UdpRxCallback callback, void *param)
Register user callback.
Definition: udp.c:1031
Ipv6Addr ipv6Addr
Definition: ip.h:102
uint_t retransmitCount
Retransmission counter.
Definition: dns_cache.h:112
#define PRIuSIZE
unsigned int uint_t
Definition: compiler_port.h:57
TCP/IP stack core.
DnsResourceRecord
Definition: dns_common.h:229
void llmnrProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary, void *param)
Process LLMNR response message.
Definition: llmnr_client.c:392
@ DNS_RR_TYPE_AAAA
IPv6 address.
Definition: dns_common.h:149
Data logging functions for debugging purpose (DNS)
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:213
#define osStrcpy(s1, s2)
Definition: os_port.h:213
#define DNS_CACHE_MAX_POLLING_INTERVAL
Definition: dns_cache.h:68
#define ntohl(value)
Definition: cpu_endian.h:422
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
systime_t osGetSystemTime(void)
Retrieve system time.
Ipv4Addr destIpAddr
Definition: ipcp.h:80