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-2024 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.4.0
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
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
85  {
86  //Host name resolution is in progress
87  error = ERROR_IN_PROGRESS;
88  }
89  }
90  else
91  {
92  //If no entry exists, then create a new one
93  entry = dnsCreateEntry();
94 
95  //Record the host name whose IP address is unknown
96  osStrcpy(entry->name, name);
97 
98  //Initialize DNS cache entry
99  entry->type = type;
101  entry->interface = interface;
102 
103  //Get an ephemeral port number
104  entry->port = udpGetDynamicPort();
105 
106  //An identifier is used by the LLMNR client to match replies with
107  //corresponding requests
108  entry->id = (uint16_t) netGenerateRand();
109 
110  //Callback function to be called when a LLMNR response is received
111  error = udpAttachRxCallback(interface, entry->port, llmnrProcessResponse,
112  NULL);
113 
114  //Check status code
115  if(!error)
116  {
117  //Initialize retransmission counter
119  //Send LLMNR query
120  error = llmnrSendQuery(entry);
121 
122  //LLMNR message successfully sent?
123  if(!error)
124  {
125  //Save the time at which the query message was sent
126  entry->timestamp = osGetSystemTime();
127  //Set timeout value
130  //Decrement retransmission counter
131  entry->retransmitCount--;
132 
133  //Switch state
134  entry->state = DNS_STATE_IN_PROGRESS;
135  //Host name resolution is in progress
136  error = ERROR_IN_PROGRESS;
137  }
138  else
139  {
140  //Unregister callback function
141  udpDetachRxCallback(interface, entry->port);
142  }
143  }
144  }
145 
146  //Release exclusive access
148 
149 #if (NET_RTOS_SUPPORT == ENABLED)
150  //Set default polling interval
152 
153  //Wait the host name resolution to complete
154  while(error == ERROR_IN_PROGRESS)
155  {
156  //Wait until the next polling period
157  osDelayTask(delay);
158 
159  //Get exclusive access
161 
162  //Search the DNS cache for the specified host name
163  entry = dnsFindEntry(interface, name, type, HOST_NAME_RESOLVER_LLMNR);
164 
165  //Check whether a matching entry has been found
166  if(entry != NULL)
167  {
168  //Host name successfully resolved?
169  if(entry->state == DNS_STATE_RESOLVED)
170  {
171  //Return the corresponding IP address
172  *ipAddr = entry->ipAddr;
173  //Successful host name resolution
174  error = NO_ERROR;
175  }
176  }
177  else
178  {
179  //Host name resolution failed
180  error = ERROR_FAILURE;
181  }
182 
183  //Release exclusive access
185 
186  //Backoff support for less aggressive polling
187  delay = MIN(delay * 2, DNS_CACHE_MAX_POLLING_INTERVAL);
188  }
189 
190  //Check status code
191  if(error)
192  {
193  //Failed to resolve host name
194  TRACE_INFO("Host name resolution failed!\r\n");
195  }
196  else
197  {
198  //Successful host name resolution
199  TRACE_INFO("Host name resolved to %s...\r\n", ipAddrToString(ipAddr, NULL));
200  }
201 #endif
202 
203  //Return status code
204  return error;
205 }
206 
207 
208 /**
209  * @brief Send a LLMNR query message
210  * @param[in] entry Pointer to a valid DNS cache entry
211  * @return Error code
212  **/
213 
215 {
216  error_t error;
217  size_t length;
218  size_t offset;
219  NetBuffer *buffer;
221  DnsQuestion *dnsQuestion;
223  NetTxAncillary ancillary;
224 
225 #if (IPV4_SUPPORT == ENABLED)
226  //An IPv4 address is expected?
227  if(entry->type == HOST_TYPE_IPV4)
228  {
229  //The IPv4 link-scope multicast address to which a sender sends queries
230  //is 224.0.0.252
231  destIpAddr.length = sizeof(Ipv4Addr);
233  }
234  else
235 #endif
236 #if (IPV6_SUPPORT == ENABLED)
237  //An IPv6 address is expected?
238  if(entry->type == HOST_TYPE_IPV6)
239  {
240  //The IPv6 link-scope multicast address to which a sender sends queries
241  //is ff02:0:0:0:0:0:1:3
242  destIpAddr.length = sizeof(Ipv6Addr);
244  }
245  else
246 #endif
247  //Invalid host type?
248  {
249  //Report an error
251  }
252 
253  //Allocate a memory buffer to hold the LLMNR query message
254  buffer = udpAllocBuffer(LLMNR_MESSAGE_MAX_SIZE, &offset);
255  //Failed to allocate buffer?
256  if(buffer == NULL)
257  return ERROR_OUT_OF_MEMORY;
258 
259  //Point to the LLMNR header
260  message = netBufferAt(buffer, offset);
261 
262  //Format LLMNR query message
263  message->id = htons(entry->id);
264  message->qr = 0;
265  message->opcode = DNS_OPCODE_QUERY;
266  message->c = 0;
267  message->tc = 0;
268  message->t = 0;
269  message->z = 0;
270  message->rcode = DNS_RCODE_NOERROR;
271 
272  //The LLMNR query contains one question
273  message->qdcount = HTONS(1);
274  message->ancount = 0;
275  message->nscount = 0;
276  message->arcount = 0;
277 
278  //Length of the LLMNR query message
279  length = sizeof(DnsHeader);
280 
281  //Encode the host name using the DNS name notation
282  length += dnsEncodeName(entry->name, message->questions);
283 
284  //Point to the corresponding question structure
285  dnsQuestion = DNS_GET_QUESTION(message, length);
286 
287 #if (IPV4_SUPPORT == ENABLED)
288  //An IPv4 address is expected?
289  if(entry->type == HOST_TYPE_IPV4)
290  {
291  //Fill in question structure
292  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_A);
293  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
294  }
295 #endif
296 #if (IPV6_SUPPORT == ENABLED)
297  //An IPv6 address is expected?
298  if(entry->type == HOST_TYPE_IPV6)
299  {
300  //Fill in question structure
301  dnsQuestion->qtype = HTONS(DNS_RR_TYPE_AAAA);
302  dnsQuestion->qclass = HTONS(DNS_RR_CLASS_IN);
303  }
304 #endif
305 
306  //Update the length of the LLMNR query message
307  length += sizeof(DnsQuestion);
308 
309  //Adjust the length of the multi-part buffer
310  netBufferSetLength(buffer, offset + length);
311 
312  //Debug message
313  TRACE_INFO("Sending LLMNR message (%" PRIuSIZE " bytes)...\r\n", length);
314  //Dump message
316 
317  //Additional options can be passed to the stack along with the packet
318  ancillary = NET_DEFAULT_TX_ANCILLARY;
319 
320  //For UDP queries, the Hop Limit field in the IPv6 header and the TTL
321  //field in the IPV4 header MAY be set to any value. However, it is
322  //recommended that the value 255 be used for compatibility with early
323  //implementations (refer to RFC 4795, section 2.5)
324  ancillary.ttl = LLMNR_DEFAULT_QUERY_IP_TTL;
325 
326  //LLMNR queries are sent to and received on port 5355
327  error = udpSendBuffer(entry->interface, NULL, entry->port, &destIpAddr,
328  LLMNR_PORT, buffer, offset, &ancillary);
329 
330  //Free previously allocated memory
331  netBufferFree(buffer);
332 
333  //Return status code
334  return error;
335 }
336 
337 
338 /**
339  * @brief Process LLMNR response message
340  * @param[in] interface Underlying network interface
341  * @param[in] pseudoHeader UDP pseudo header
342  * @param[in] udpHeader UDP header
343  * @param[in] buffer Multi-part buffer containing the incoming LLMNR message
344  * @param[in] offset Offset to the first byte of the LLMNR message
345  * @param[in] ancillary Additional options passed to the stack along with
346  * the packet
347  * @param[in] param Callback function parameter (not used)
348  **/
349 
351  const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader,
352  const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary,
353  void *param)
354 {
355  uint_t i;
356  uint_t j;
357  size_t pos;
358  size_t length;
360  DnsQuestion *question;
361  DnsResourceRecord *record;
362  DnsCacheEntry *entry;
363 
364  //Retrieve the length of the LLMNR message
365  length = netBufferGetLength(buffer) - offset;
366 
367  //Ensure the LLMNR message is valid
368  if(length < sizeof(LlmnrHeader))
369  return;
371  return;
372 
373  //Point to the LLMNR message header
374  message = netBufferAt(buffer, offset);
375  //Sanity check
376  if(message == NULL)
377  return;
378 
379  //Debug message
380  TRACE_INFO("LLMNR message received (%" PRIuSIZE " bytes)...\r\n", length);
381  //Dump message
383 
384  //Discard LLMNR queries
385  if(!message->qr)
386  return;
387 
388  //LLMNR messages received with an opcode other than zero must be silently
389  //ignored
390  if(message->opcode != DNS_OPCODE_QUERY)
391  return;
392 
393  //LLMNR messages received with non-zero response codes must be silently
394  //ignored
395  if(message->rcode != DNS_RCODE_NOERROR)
396  return;
397 
398  //LLMNR senders must silently discard LLMNR responses with QDCOUNT not
399  //equal to one (refer to RFC 4795, section 2.1.1)
400  if(ntohs(message->qdcount) != 1)
401  return;
402 
403  //Loop through DNS cache entries
404  for(i = 0; i < DNS_CACHE_SIZE; i++)
405  {
406  //Point to the current entry
407  entry = &dnsCache[i];
408 
409  //LLMNR name resolution in progress?
410  if(entry->state == DNS_STATE_IN_PROGRESS &&
412  {
413  //Check destination port number
414  if(entry->port == ntohs(udpHeader->destPort))
415  {
416  //Compare identifier against the expected one
417  if(ntohs(message->id) != entry->id)
418  break;
419 
420  //Point to the first question
421  pos = sizeof(DnsHeader);
422  //Parse domain name
423  pos = dnsParseName((DnsHeader *) message, length, pos, NULL, 0);
424 
425  //Invalid name?
426  if(!pos)
427  break;
428  //Malformed DNS message?
429  if((pos + sizeof(DnsQuestion)) > length)
430  break;
431 
432  //Compare domain name
434  entry->name, 0))
435  {
436  break;
437  }
438 
439  //Point to the corresponding entry
440  question = DNS_GET_QUESTION(message, pos);
441 
442  //Check the class of the query
443  if(ntohs(question->qclass) != DNS_RR_CLASS_IN)
444  break;
445 
446  //Check the type of the query
447  if(entry->type == HOST_TYPE_IPV4 &&
448  ntohs(question->qtype) != DNS_RR_TYPE_A)
449  {
450  break;
451  }
452 
453  if(entry->type == HOST_TYPE_IPV6 &&
454  ntohs(question->qtype) != DNS_RR_TYPE_AAAA)
455  {
456  break;
457  }
458 
459  //Point to the first answer
460  pos += sizeof(DnsQuestion);
461 
462  //Parse answer resource records
463  for(j = 0; j < ntohs(message->ancount); j++)
464  {
465  //Parse domain name
466  pos = dnsParseName((DnsHeader *) message, length, pos, NULL, 0);
467  //Invalid name?
468  if(!pos)
469  break;
470 
471  //Point to the associated resource record
472  record = DNS_GET_RESOURCE_RECORD(message, pos);
473  //Point to the resource data
474  pos += sizeof(DnsResourceRecord);
475 
476  //Make sure the resource record is valid
477  if(pos > length)
478  break;
479  if((pos + ntohs(record->rdlength)) > length)
480  break;
481 
482 #if (IPV4_SUPPORT == ENABLED)
483  //IPv4 address expected?
484  if(entry->type == HOST_TYPE_IPV4)
485  {
486  //A resource record found?
487  if(ntohs(record->rtype) == DNS_RR_TYPE_A &&
488  ntohs(record->rdlength) == sizeof(Ipv4Addr))
489  {
490  //Copy the IPv4 address
491  entry->ipAddr.length = sizeof(Ipv4Addr);
492  ipv4CopyAddr(&entry->ipAddr.ipv4Addr, record->rdata);
493 
494  //Save current time
495  entry->timestamp = osGetSystemTime();
496  //Save TTL value
497  entry->timeout = ntohl(record->ttl) * 1000;
498  //Limit the lifetime of the NBNS cache entries
499  entry->timeout = MIN(entry->timeout, LLMNR_MAX_LIFETIME);
500 
501  //Unregister UDP callback function
502  udpDetachRxCallback(interface, entry->port);
503  //Host name successfully resolved
504  entry->state = DNS_STATE_RESOLVED;
505  //Exit immediately
506  break;
507  }
508  }
509 #endif
510 #if (IPV6_SUPPORT == ENABLED)
511  //IPv6 address expected?
512  if(entry->type == HOST_TYPE_IPV6)
513  {
514  //AAAA resource record found?
515  if(ntohs(record->rtype) == DNS_RR_TYPE_AAAA &&
516  ntohs(record->rdlength) == sizeof(Ipv6Addr))
517  {
518  //Copy the IPv6 address
519  entry->ipAddr.length = sizeof(Ipv6Addr);
520  ipv6CopyAddr(&entry->ipAddr.ipv6Addr, record->rdata);
521 
522  //Save current time
523  entry->timestamp = osGetSystemTime();
524  //Save TTL value
525  entry->timeout = ntohl(record->ttl) * 1000;
526  //Limit the lifetime of the NBNS cache entries
527  entry->timeout = MIN(entry->timeout, LLMNR_MAX_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
uint8_t message[]
Definition: chap.h:154
uint8_t type
Definition: coap_common.h:176
unsigned int uint_t
Definition: compiler_port.h:50
#define PRIuSIZE
char char_t
Definition: compiler_port.h:48
#define HTONS(value)
Definition: cpu_endian.h:410
#define ntohl(value)
Definition: cpu_endian.h:422
#define htons(value)
Definition: cpu_endian.h:413
#define ntohs(value)
Definition: cpu_endian.h:421
Debugging facilities.
#define TRACE_INFO(...)
Definition: debug.h:95
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:187
DnsCacheEntry dnsCache[DNS_CACHE_SIZE]
Definition: dns_cache.c:52
DnsCacheEntry * dnsCreateEntry(void)
Create a new entry in the DNS cache.
Definition: dns_cache.c:104
#define DNS_CACHE_SIZE
Definition: dns_cache.h:47
#define DNS_CACHE_INIT_POLLING_INTERVAL
Definition: dns_cache.h:61
@ DNS_STATE_RESOLVED
Definition: dns_cache.h:87
@ DNS_STATE_PERMANENT
Definition: dns_cache.h:88
@ DNS_STATE_IN_PROGRESS
Definition: dns_cache.h:86
#define DNS_CACHE_MAX_POLLING_INTERVAL
Definition: dns_cache.h:68
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:242
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:132
size_t dnsEncodeName(const char_t *src, uint8_t *dest)
Encode a domain name using the DNS name notation.
Definition: dns_common.c:58
DnsHeader
Definition: dns_common.h:199
#define DNS_GET_RESOURCE_RECORD(message, offset)
Definition: dns_common.h:64
DnsResourceRecord
Definition: dns_common.h:224
#define DNS_GET_QUESTION(message, offset)
Definition: dns_common.h:63
@ DNS_RCODE_NOERROR
No error.
Definition: dns_common.h:95
@ DNS_OPCODE_QUERY
Query.
Definition: dns_common.h:81
@ DNS_RR_TYPE_A
Host address.
Definition: dns_common.h:137
@ DNS_RR_TYPE_AAAA
IPv6 address.
Definition: dns_common.h:147
@ DNS_RR_CLASS_IN
Internet.
Definition: dns_common.h:124
DnsQuestion
Definition: dns_common.h:210
void dnsDumpMessage(const DnsHeader *message, size_t length)
Dump DNS message for debugging purpose.
Definition: dns_debug.c:52
Data logging functions for debugging purpose (DNS)
error_t
Error codes.
Definition: error.h:43
@ ERROR_IN_PROGRESS
Definition: error.h:213
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_OUT_OF_MEMORY
Definition: error.h:63
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
char_t * ipAddrToString(const IpAddr *ipAddr, char_t *str)
Convert a binary IP address to a string representation.
Definition: ip.c:838
Ipv4Addr ipAddr
Definition: ipcp.h:105
Ipv4Addr destIpAddr
Definition: ipcp.h:80
#define ipv4CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv4.h:148
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:267
Helper functions for IPv4.
Ipv6Addr
Definition: ipv6.h:251
#define ipv6CopyAddr(destIpAddr, srcIpAddr)
Definition: ipv6.h:116
error_t llmnrResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using LLMNR.
Definition: llmnr_client.c:53
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:350
error_t llmnrSendQuery(DnsCacheEntry *entry)
Send a LLMNR query message.
Definition: llmnr_client.c:214
LLMNR client (Link-Local Multicast Name Resolution)
#define LLMNR_CLIENT_MAX_RETRIES
Definition: llmnr_client.h:51
#define LLMNR_CLIENT_INIT_TIMEOUT
Definition: llmnr_client.h:58
#define LLMNR_MAX_LIFETIME
Definition: llmnr_client.h:72
#define LLMNR_CLIENT_MAX_TIMEOUT
Definition: llmnr_client.h:65
const Ipv6Addr LLMNR_IPV6_MULTICAST_ADDR
Definition: llmnr_common.c:45
#define LLMNR_PORT
Definition: llmnr_common.h:53
#define LLMNR_DEFAULT_QUERY_IP_TTL
Definition: llmnr_common.h:55
#define LLMNR_MESSAGE_MAX_SIZE
Definition: llmnr_common.h:40
LlmnrHeader
Definition: llmnr_common.h:105
#define LLMNR_IPV4_MULTICAST_ADDR
Definition: llmnr_common.h:60
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
#define netMutex
Definition: net_legacy.h:195
void * netBufferAt(const NetBuffer *buffer, size_t offset)
Returns a pointer to the data at the specified position.
Definition: net_mem.c:415
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
Definition: net_mem.c:282
error_t netBufferSetLength(NetBuffer *buffer, size_t length)
Adjust the length of a multi-part buffer.
Definition: net_mem.c:322
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
Definition: net_misc.c:71
uint32_t netGenerateRand(void)
Generate a random 32-bit value.
Definition: net_misc.c:888
#define NetRxAncillary
Definition: net_misc.h:40
#define NetTxAncillary
Definition: net_misc.h:36
#define MIN(a, b)
Definition: os_port.h:63
#define osStrcpy(s1, s2)
Definition: os_port.h:207
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osDelayTask(systime_t delay)
Delay routine.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
systime_t osGetSystemTime(void)
Retrieve system time.
uint32_t systime_t
System time.
char_t name[]
HostType
Host types.
Definition: socket.h:204
@ HOST_TYPE_IPV6
Definition: socket.h:207
@ HOST_TYPE_IPV4
Definition: socket.h:206
@ HOST_NAME_RESOLVER_LLMNR
Definition: socket.h:221
DNS cache entry.
Definition: dns_cache.h:97
systime_t timestamp
Time stamp to manage entry lifetime.
Definition: dns_cache.h:107
uint16_t id
Identifier used to match queries and responses.
Definition: dns_cache.h:104
systime_t maxTimeout
Maximum retransmission timeout.
Definition: dns_cache.h:109
HostnameResolver protocol
Name resolution protocol.
Definition: dns_cache.h:100
HostType type
IPv4 or IPv6 host?
Definition: dns_cache.h:99
uint16_t port
Port number used by the resolver.
Definition: dns_cache.h:103
uint_t retransmitCount
Retransmission counter.
Definition: dns_cache.h:110
DnsState state
Entry state.
Definition: dns_cache.h:98
systime_t timeout
Retransmission timeout.
Definition: dns_cache.h:108
char_t name[DNS_MAX_NAME_LEN+1]
Domain name.
Definition: dns_cache.h:105
NetInterface * interface
Underlying network interface.
Definition: dns_cache.h:101
IpAddr ipAddr
IP address.
Definition: dns_cache.h:106
IP network address.
Definition: ip.h:79
Ipv6Addr ipv6Addr
Definition: ip.h:87
Ipv4Addr ipv4Addr
Definition: ip.h:84
size_t length
Definition: ip.h:80
IP pseudo header.
Definition: ip.h:99
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t length
Definition: tcp.h:368
error_t udpDetachRxCallback(NetInterface *interface, uint16_t port)
Unregister user callback.
Definition: udp.c:1019
NetBuffer * udpAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold a UDP packet.
Definition: udp.c:905
error_t udpSendBuffer(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:627
error_t udpAttachRxCallback(NetInterface *interface, uint16_t port, UdpRxCallback callback, void *param)
Register user callback.
Definition: udp.c:978
uint16_t udpGetDynamicPort(void)
Get an ephemeral port number.
Definition: udp.c:80
UdpHeader
Definition: udp.h:85