1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Domain Name System (DNS)                                            */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
26 /*                                                                        */
27 /*    nxd_dns.h                                           PORTABLE C      */
28 /*                                                           6.1.5        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Yuxin Zhou, Microsoft Corporation                                   */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the NetX Domain Name System Protocol (DNS)        */
36 /*    component, including all data types and external references.        */
37 /*    It is assumed that nx_api.h and nx_port.h have already been         */
38 /*    included.                                                           */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
45 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
46 /*                                            resulting in version 6.1    */
47 /*  12-31-2020     Yuxin Zhou               Modified comment(s), prevented*/
48 /*                                            infinite loop in name       */
49 /*                                            compression, resulting in   */
50 /*                                            version 6.1.3               */
51 /*  03-02-2021     Yuxin Zhou               Modified comment(s), and      */
52 /*                                            improved the logic of       */
53 /*                                            receiving dns response,     */
54 /*                                            resulting in version 6.1.5  */
55 /*                                                                        */
56 /**************************************************************************/
57 
58 #ifndef NXD_DNS_H
59 #define NXD_DNS_H
60 
61 /* Determine if a C++ compiler is being used.  If so, ensure that standard
62    C is used to process the API information.  */
63 
64 #ifdef   __cplusplus
65 
66 /* Yes, C++ compiler is present.  Use standard C.  */
67 extern   "C" {
68 
69 #endif
70 
71 #include "nx_udp.h"
72 #include "nx_ipv4.h"
73 #include "nx_ipv6.h"
74 
75 /* Define the DNS ID.  */
76 
77 #define NX_DNS_ID                       0x444e5320UL
78 
79 /* Define message and name limits.  */
80 
81 #define NX_DNS_LABEL_MAX                63          /* Maximum Label (between to dots) size                 */
82 #define NX_DNS_NAME_MAX                 255         /* Maximum Name size                                    */
83 #define NX_DNS_IP_LOOKUP_SIZE           75          /* IPv6 needs 66 characters for the address plus 8 for the ip6.arpa plus null           */
84                                                     /* IPv4 needs 12 characters max for the address plus 12 for the IN-ADDR.ARPA plus null  */
85 
86 
87 /* Define offsets into the DNS message buffer.  */
88 
89 #define NX_DNS_ID_OFFSET                0           /* Offset to ID code in DNS buffer                      */
90 #define NX_DNS_FLAGS_OFFSET             2           /* Offset to flags in DNS buffer                        */
91 #define NX_DNS_QDCOUNT_OFFSET           4           /* Offset to Question Count in DNS buffer               */
92 #define NX_DNS_ANCOUNT_OFFSET           6           /* Offset to Answer Count in DNS buffer                 */
93 #define NX_DNS_NSCOUNT_OFFSET           8           /* Offset to Authority Count in DNS buffer              */
94 #define NX_DNS_ARCOUNT_OFFSET           10          /* Offset to Additional Info. Count in DNS buffer       */
95 #define NX_DNS_QDSECT_OFFSET            12          /* Offset to Question Section in DNS buffer             */
96 
97 
98 /* Define return code constants.  */
99 
100 #define NX_DNS_SUCCESS                  0x00        /* DNS success                                          */
101 #define NX_DNS_ERROR                    0xA0        /* DNS internal error                                   */
102 #define NX_DNS_NO_SERVER                0xA1        /* No DNS server was specified                          */
103 #define NX_DNS_TIMEOUT                  0xA2        /* DNS timeout occurred                                 */
104 #define NX_DNS_QUERY_FAILED             0xA3        /* DNS query failed; no DNS server sent an 'answer'     */
105 #define NX_DNS_BAD_ADDRESS_ERROR        0xA4        /* Improperly formatted IPv4 or IPv6 address            */
106 #define NX_DNS_SIZE_ERROR               0xA5        /* DNS destination size is too small                    */
107 #define NX_DNS_MALFORMED_PACKET         0xA6        /* Improperly formed or corrupted DNS packet received   */
108 #define NX_DNS_BAD_ID_ERROR             0xA7        /* DNS packet from server does not match query ID       */
109 #define NX_DNS_PARAM_ERROR              0xA8        /* Invalid non pointer input to API                     */
110 #define NX_DNS_SERVER_NOT_FOUND         0xA9        /* Server not found in Client list of DNS servers       */
111 #define NX_DNS_PACKET_CREATE_ERROR      0xAA        /* Error creating DNS packet                            */
112 #define NX_DNS_EMPTY_DNS_SERVER_LIST    0xAB        /* DNS Client's list of DNS servers is empty            */
113 #define NX_DNS_SERVER_AUTH_ERROR        0xAC        /* Server not able to authenticate answer/authority data*/
114 #define NX_DNS_ZERO_GATEWAY_IP_ADDRESS  0xAD        /* DNS Client IP instance has a zero gateway IP address */
115 #define NX_DNS_MISMATCHED_RESPONSE      0xAE        /* Server response type does not match the query request*/
116 #define NX_DNS_DUPLICATE_ENTRY          0xAF        /* Duplicate entry exists in DNS server table           */
117 #define NX_DNS_RETRY_A_QUERY            0xB0        /* SOA status returned; web site only exists as IPv4    */
118 #define NX_DNS_IPV6_DISABLED_ERROR      0xB1        /* Cannot process AAAA or PTR record with IPv6 disabled */
119 #define NX_DNS_INVALID_ADDRESS_TYPE     0xB2        /* IP address type (e.g. IPv6) not supported            */
120 #define NX_DNS_IPV6_NOT_SUPPORTED       0xB3        /* Cannot process AAAA or PTR record with IPv6 disabled */
121 #define NX_DNS_NEED_MORE_RECORD_BUFFER  0xB4        /* The buffer size is not enough.                       */
122 #define NX_DNS_FEATURE_NOT_SUPPORTED    0xB5        /* The requested feature is not supported in this build */
123 #define NX_DNS_NAME_MISMATCH            0xB6        /* The name mismatch.                                   */
124 #define NX_DNS_CACHE_ERROR              0xB7        /* The Cache size is not enough.                        */
125 
126 
127 /* Define constants for the flags word.  */
128 
129 #define NX_DNS_QUERY_MASK               0x8000
130 #define NX_DNS_RESPONSE_FLAG            0x8000
131 #define NX_DNS_ERROR_MASK               0x8002      /* Server response indicates an error or data not authenticated by server */
132 
133 
134 #define NX_DNS_OPCODE_QUERY             (0 << 12)   /* Shifted right 12 is still 0                          */
135 #define NX_DNS_OPCODE_IQUERY            (1 << 12)   /* 1 shifted right by 12                                */
136 #define NX_DNS_OPCODE_STATUS            (2 << 12)   /* 2 shifted right by 12                                */
137 
138 #define NX_DNS_AA_FLAG                  0x0400      /* Authoritative Answer                                 */
139 #define NX_DNS_TC_FLAG                  0x0200      /* Truncated                                            */
140 #define NX_DNS_RD_FLAG                  0x0100      /* Recursive Query                                      */
141 #define NX_DNS_RA_FLAG                  0x0080      /* Recursion Available                                  */
142 #define NX_DNS_FA_FLAG                  0x0010      /* Force Authentication                                 */
143 
144 #define NX_DNS_RCODE_MASK               0x000f      /* Isolate the Result Code                              */
145 #define NX_DNS_RCODE_SUCCESS            0
146 #define NX_DNS_RCODE_FORMAT_ERR         1
147 #define NX_DNS_RCODE_SERVER_ERR         2
148 #define NX_DNS_RCODE_NAME_ERR           3
149 #define NX_DNS_RCODE_NOT_IMPL           4
150 #define NX_DNS_RCODE_REFUSED            5
151 
152 #define NX_DNS_QUERY_FLAGS  (NX_DNS_OPCODE_QUERY | NX_DNS_RD_FLAG)  /* | NX_DNS_FA_FLAG */
153 
154 /* Define name compression masks.  */
155 
156 #define NX_DNS_COMPRESS_MASK            0xc0
157 #define NX_DNS_COMPRESS_VALUE           0xc0
158 #define NX_DNS_POINTER_MASK             0xc000
159 
160 /* Define resource record types.  */
161 
162 #define NX_DNS_RR_TYPE_A                1           /* Host address                                         */
163 #define NX_DNS_RR_TYPE_NS               2           /* Authoritative name server                            */
164 #define NX_DNS_RR_TYPE_MD               3           /* Mail destination (Obsolete - use MX)                 */
165 #define NX_DNS_RR_TYPE_MF               4           /* Mail forwarder (Obsolete - use MX)                   */
166 #define NX_DNS_RR_TYPE_CNAME            5           /* Canonical name for an alias                          */
167 #define NX_DNS_RR_TYPE_SOA              6           /* Marks the start of a zone of authority               */
168 #define NX_DNS_RR_TYPE_MB               7           /* Mailbox domain name (EXPERIMENTAL)                   */
169 #define NX_DNS_RR_TYPE_MG               8           /* Mail group member (EXPERIMENTAL)                     */
170 #define NX_DNS_RR_TYPE_MR               9           /* Mail rename domain name (EXPERIMENTAL)               */
171 #define NX_DNS_RR_TYPE_NULL             10          /* Null RR (EXPERIMENTAL)                               */
172 #define NX_DNS_RR_TYPE_WKS              11          /* Well known service description                       */
173 #define NX_DNS_RR_TYPE_PTR              12          /* Domain name pointer                                  */
174 #define NX_DNS_RR_TYPE_HINFO            13          /* Host information                                     */
175 #define NX_DNS_RR_TYPE_MINFO            14          /* Mailbox or mail list information                     */
176 #define NX_DNS_RR_TYPE_MX               15          /* Mail exchange                                        */
177 #define NX_DNS_RR_TYPE_TXT              16          /* Text strings                                         */
178 #define NX_DNS_RR_TYPE_AAAA             28          /* IPv6 Host address                                    */
179 #define NX_DNS_RR_TYPE_SRV              33          /* The location of services                             */
180 
181 
182 /* Define constants for Qtypes (queries).  */
183 
184 #define NX_DNS_RR_TYPE_AXFR             252         /* Request for a transfer of an entire zone             */
185 #define NX_DNS_RR_TYPE_MAILB            253         /* Request for mailbox-related records (MB, MG or MR)   */
186 #define NX_DNS_RR_TYPE_MAILA            254         /* Request for mail agent RRs (Obsolete - see MX)       */
187 #define NX_DNS_RR_TYPE_ALL              255         /* Request for all records                              */
188 
189 /* Define resource record classes.  */
190 
191 #define NX_DNS_RR_CLASS_IN              1           /* Internet                                             */
192 #define NX_DNS_RR_CLASS_CS              2           /* CSNET class (Obsolete)                               */
193 #define NX_DNS_RR_CLASS_CH              3           /* CHAOS class                                          */
194 #define NX_DNS_RR_CLASS_HS              4           /* Hesiod [Dyer 87]                                     */
195 
196 
197 /* Define constant valid for Qtypes (queries).  */
198 
199 #define NX_DNS_RR_CLASS_ALL                     255         /* Any class   */
200 
201 /* Define the TCP and UDP port number */
202 
203 #define NX_DNS_PORT                             53          /* Port for TX,RX and TCP/UDP */
204 
205 
206 /* Start of configurable options. */
207 
208 /* Set the IP instance gateway server to be the DNS server if the gateway address is non zero.  */
209 /*
210 #define NX_DNS_IP_GATEWAY_AND_DNS_SERVER
211 */
212 
213 /* Determine if the Client will create its own packet pool
214    or let the host application create one. See nx_dns_packet_pool_set
215    for how to set the DNS packet pool from the host application.   */
216 /*
217 #define NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
218 */
219 
220 /* Enable the feature to clear off old DNS packets before sending a fresh query.  */
221 /*
222 #define NX_DNS_CLIENT_CLEAR_QUEUE
223 */
224 
225 /* Enable the feature to send the TXT, CNAME, NS, MX, SRV, SOA DNS types query.  */
226 /*
227 #define NX_DNS_ENABLE_EXTENDED_RR_TYPES
228 */
229 
230 /* Enable the cache to store the resource record.  */
231 /*
232 #define NX_DNS_CACHE_ENABLE
233 */
234 
235 /* Define UDP socket create options.  */
236 
237 #ifndef NX_DNS_TYPE_OF_SERVICE
238 #define NX_DNS_TYPE_OF_SERVICE          NX_IP_NORMAL
239 #endif
240 
241 #ifndef NX_DNS_FRAGMENT_OPTION
242 #define NX_DNS_FRAGMENT_OPTION          NX_DONT_FRAGMENT
243 #endif
244 
245 #ifndef NX_DNS_TIME_TO_LIVE
246 #define NX_DNS_TIME_TO_LIVE                     0x80
247 #endif
248 
249 /* Define the queue depth of the DNS Client socket. */
250 
251 #ifndef NX_DNS_QUEUE_DEPTH
252 #define NX_DNS_QUEUE_DEPTH                      5
253 #endif
254 
255 /* Define the maximum size of DNS message. 512 is the maximum size defined in RFC 1035 section 2.3.4. */
256 
257 #ifndef NX_DNS_MESSAGE_MAX
258 #define NX_DNS_MESSAGE_MAX                      512
259 #endif
260 
261 /* Define a payload to include the maximum size DNS message plus the Ethernet, IP and UDP overhead. */
262 
263 #ifndef NX_DNS_PACKET_PAYLOAD_UNALIGNED
264 #define NX_DNS_PACKET_PAYLOAD_UNALIGNED         (NX_UDP_PACKET + NX_DNS_MESSAGE_MAX)
265 #endif
266 
267 /* Round up to a 4 byte aligned packet payload. */
268 
269 #define NX_DNS_PACKET_PAYLOAD                   (((NX_DNS_PACKET_PAYLOAD_UNALIGNED + sizeof(ULONG) - 1)/sizeof(ULONG)) * sizeof(ULONG))
270 
271 /* Define the size (e.g. number of packets) of the DNS Client
272    packet pool for sending out DNS messages. */
273 
274 #ifndef NX_DNS_PACKET_POOL_SIZE
275 #define NX_DNS_PACKET_POOL_SIZE                 (16 * (NX_DNS_PACKET_PAYLOAD + sizeof(NX_PACKET)))
276 #endif
277 
278 
279 /* Define the maximum number of retries to a DNS server. */
280 
281 #ifndef NX_DNS_MAX_RETRIES
282 #define NX_DNS_MAX_RETRIES                      3
283 #endif
284 
285 /* Define size of the DNS server list. Remember to allow for one 'null' terminating
286    e.g. zero IP address entry for this list. */
287 
288 #ifndef NX_DNS_MAX_SERVERS
289 #define NX_DNS_MAX_SERVERS                      5
290 #endif
291 
292 /* Define the maximum amount of time to retransmit a DNS query. The default wait time is 64 seconds.
293    the retransmission policy are recommended in RFC1035 page 32.  */
294 #ifndef NX_DNS_MAX_RETRANS_TIMEOUT
295 #define NX_DNS_MAX_RETRANS_TIMEOUT             (64 * NX_IP_PERIODIC_RATE)
296 #endif
297 
298 /* Define the timeout option in timer ticks for allocating a packet
299    from the DNS Client packet pool. */
300 
301 #ifndef NX_DNS_PACKET_ALLOCATE_TIMEOUT
302 #define NX_DNS_PACKET_ALLOCATE_TIMEOUT          NX_IP_PERIODIC_RATE
303 #endif
304 
305 /* Define the maximum number of pointers allowed in name compression.  */
306 #ifndef NX_DNS_MAX_COMPRESSION_POINTERS
307 #define NX_DNS_MAX_COMPRESSION_POINTERS        16
308 #endif
309 
310 /* Define the basic DNS data structure.  */
311 
312 typedef struct NX_IP_DNS_STRUCT
313 {
314     ULONG           nx_dns_id;                                      /* DNS ID                                                   */
315     UCHAR           *nx_dns_domain;                                 /* Pointer to domain name                                   */
316     USHORT          nx_dns_lookup_type;                             /* DNS look up type                                         */
317     USHORT          nx_dns_transmit_id;                             /* DNS message transmit identifier                          */
318     NX_IP           *nx_dns_ip_ptr;                                 /* Pointer to associated IP structure                       */
319     NXD_ADDRESS     nx_dns_server_ip_array[NX_DNS_MAX_SERVERS];     /* List of DNS server IP addresses                          */
320     ULONG           nx_dns_retries;                                 /* DNS query retries                                        */
321 #ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
322     NX_PACKET_POOL  nx_dns_pool;                                    /* The pool of UDP data packets for DNS messages            */
323     UCHAR           nx_dns_pool_area[NX_DNS_PACKET_POOL_SIZE];
324 #endif
325     NX_PACKET_POOL  *nx_dns_packet_pool_ptr;                        /* Pointer to DNS Client packet pool                        */
326     NX_UDP_SOCKET   nx_dns_socket;                                  /* DNS Socket                                               */
327     TX_MUTEX        nx_dns_mutex;                                   /* DNS Mutex to protect DNS instance                        */
328 #ifdef NX_DNS_CACHE_ENABLE
329     UCHAR*          nx_dns_cache;                                   /* Pointer to the cache.                                    */
330     UINT            nx_dns_cache_size;                              /* The size of cache.                                       */
331     ULONG           nx_dns_rr_count;                                /* The number of resource records in the cache.             */
332     ULONG           nx_dns_string_count;                            /* The number of strings in the cache.                      */
333     ULONG           nx_dns_string_bytes;                            /* The number of total bytes in string table in the cache.  */
334     VOID            (*nx_dns_cache_full_notify)(struct NX_IP_DNS_STRUCT *);
335 #endif /* NX_DNS_CACHE_ENABLE  */
336 } NX_DNS;
337 
338 
339 /* Define the RDATA structure.  */
340 /********************************************************************************/
341 /*                               Type A                                         */
342 /********************************************************************************/
343 
344 /* A RDATA format
345                         1                   2                   3
346     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
347     |-------------------------------------------------------------|
348     |                           ADDRESS                           |
349     |-------------------------------------------------------------|
350 */
351 /* The host name may have multiple addresses,so we need a buffer to record the all addresses.
352    return_buffer must be 4-byte aligned.  This return buffer is used to store IP addresses returned from the server.
353    record_number stores the number of entries in the buffer. If the server returns more entries than the buffer
354    can hold, the entries exceeding the buffer size are dropped. */
355 
356 /* Layout of the buffer
357    |-------------------------------------------------------------------------------------|
358    |ip.address.0|ip.address.1|ip.address.2|.......                          |ip.address.n|
359    |-------------------------------------------------------------------------------------|
360 */
361 
362 /********************************************************************************/
363 /*                            Type AAAA                                         */
364 /********************************************************************************/
365 /* AAAA RDATA format
366                         1                   2                   3
367     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
368     |-------------------------------------------------------------|
369     |                           ADDRESS                           |
370     |-------------------------------------------------------------|
371     |                           ADDRESS                           |
372     |-------------------------------------------------------------|
373     |                           ADDRESS                           |
374     |-------------------------------------------------------------|
375     |                           ADDRESS                           |
376     |-------------------------------------------------------------|
377 */
378 
379 typedef struct NX_DNS_IPV6_ADDRESS_STRUCT
380 {
381     ULONG           ipv6_address[4];
382 } NX_DNS_IPV6_ADDRESS;
383 
384 
385 /* The return_buffer must be 4-byte aligned.  This return buffer is used to store IP addresses returned from the server. */
386 /* The record_number in the query stores the number of entries in the buffer. If the server returns more entries than the buffer
387    can hold, the entries exceeding the buffer size are dropped. */
388 
389 /* Layout of the buffer
390    |---------------------------------------------------------------|
391    |ip.address.0[0]|ip.address.0[1]|ip.address.0[2]|ip.address.0[3]|
392    |---------------------------------------------------------------|
393    |ip.address.1[0]|ip.address.1[1]|ip.address.1[2]|ip.address.1[3]|
394    |---------------------------------------------------------------|
395    |                                                               |
396    |        ..........................................             |
397    |                                                               |
398    |---------------------------------------------------------------|
399    |ip.address.n[0]|ip.address.n[1]|ip.address.n[2]|ip.address.n[3]|
400    |---------------------------------------------------------------|
401 
402 */
403 
404 /********************************************************************************/
405 /*                                PTR                                           */
406 /********************************************************************************/
407 /* PTR RDATA format
408                         1                   2                   3
409     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
410     |-------------------------------------------------------------|
411     /                            PTRDNAME                         /
412     /                                                             /
413     |-------------------------------------------------------------|
414 */
415 
416 
417 #ifdef NX_DNS_ENABLE_EXTENDED_RR_TYPES
418 
419 /********************************************************************************/
420 /*                             Type NS                                          */
421 /********************************************************************************/
422 /* NS RDATA format
423                         1                   2                   3
424     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
425     |-------------------------------------------------------------|
426     /                             NSDNAME                         /
427     /                                                             /
428     |-------------------------------------------------------------|
429 */
430 
431 typedef struct NX_DNS_NS_ENTRY_STRUCT
432 {
433     ULONG           nx_dns_ns_ipv4_address;        /* The name server ipv4 address.  */
434     UCHAR           *nx_dns_ns_hostname_ptr;       /* The name server.  */
435 } NX_DNS_NS_ENTRY;
436 
437 /* Store the message in one buffer.  Layout of the buffer:
438 
439  record_buffer         |---------------------------------------------------------------|
440              entry 0   |xx.xx.xx.xx               |Pointer to the host name string     |
441  record_buffer + 8     |---------------------------------------------------------------|
442              entry 1   |xx.xx.xx.xx               |Pointer to the host name string     |
443  record_buffer + 16    |---------------------------------------------------------------|
444              entry 2   |xx.xx.xx.xx               |Pointer to the host name string     |
445  record_buffer + 24    |---------------------------------------------------------------|
446              entry 3   |xx.xx.xx.xx               |Pointer to the host name string     |
447  record_buffer + 32    |---------------------------------------------------------------|
448              entry 4   |xx.xx.xx.xx               |Pointer to the host name string     |
449  record_buffer + 40    |---------------------------------------------------------------|
450                        |xx.xx.xx.xx               |Pointer to the host name string     |
451                        |---------------------------------------------------------------|
452                        |                               | ns_hostname 4                 |
453                        |ns_hostname 3              | ns_hostname 2                     |
454                        |ns_hostname 1         | ns_hostname 0                          |
455  record_buffer + max   |---------------------------------------------------------------|
456  */
457 
458 /********************************************************************************/
459 /*                                CNAME                                         */
460 /********************************************************************************/
461 /* CNAME RDATA format
462                         1                   2                   3
463     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
464     |-------------------------------------------------------------|
465     /                            CNAME                            /
466     /                                                             /
467     |-------------------------------------------------------------|
468 */
469 
470 
471 /********************************************************************************/
472 /*                                 MX                                           */
473 /********************************************************************************/
474 /* MX RDATA format
475                         1
476     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
477     |-----------------------------|
478     |         PREFERECE           |
479     |-----------------------------|
480     /         EXCHANGE            /
481     /                             /
482     |-----------------------------|
483 */
484 
485 /* Define the mail exchange record type */
486 typedef struct NX_DNS_MAIL_EXCHANGE_ENTRY_STRUCT
487 {
488     ULONG           nx_dns_mx_ipv4_address;           /* The mail exchange server ipv4 address.  */
489     USHORT          nx_dns_mx_preference;             /* The preference given to this RR, Lower values are preferred. */
490     USHORT          nx_dns_mx_reserved0;              /* Keep 4-byte aligned.  */
491     UCHAR           *nx_dns_mx_hostname_ptr;          /* The mail exchange server host name.  */
492 } NX_DNS_MX_ENTRY;
493 
494 /* Layout of the buffer
495  record_buffer         |---------------------------------------------------------|
496              entry 0   |xx.xx.xx.xx|preference|res|pointer to host name string   |
497  record_buffer + 12    |---------------------------------------------------------|
498              entry 1   |xx.xx.xx.xx|preference|res|pointer to host name string   |
499  record_buffer + 24    |---------------------------------------------------------|
500              entry 2   |xx.xx.xx.xx|preference|res|pointer to host name string   |
501  record_buffer + 36    |---------------------------------------------------------|
502              entry 3   |xx.xx.xx.xx|preference|res|pointer to host name string   |
503  record_buffer + 48    |---------------------------------------------------------|
504              entry 4   |xx.xx.xx.xx|preference|res|pointer to host name string   |
505  record_buffer + 60    |---------------------------------------------------------|
506                        |xx.xx.xx.xx|preference|res|pointer to host name string   |
507                        |---------------------------------------------------------|
508                        |                         | mx_hostname 4                 |
509                        |mx_hostname 3        | mx_hostname 2                     |
510                        |mx_hostname 1   | mx_hostname 0                          |
511  record_buffer + max   |---------------------------------------------------------|
512 */
513 
514 /********************************************************************************/
515 /*                                SRV                                           */
516 /********************************************************************************/
517 
518 /* Define the service record type. */
519 typedef struct NX_DNS_SERVICE_ENTRY_STRUCT
520 {
521     ULONG           nx_dns_srv_ipv4_address;
522     USHORT          nx_dns_srv_priority;
523     USHORT          nx_dns_srv_weight;
524     USHORT          nx_dns_srv_port_number;
525     USHORT          nx_dns_srv_reserved0;
526     UCHAR           *nx_dns_srv_hostname_ptr;
527 } NX_DNS_SRV_ENTRY;
528 
529 /* Layout of the buffer:
530 
531  record_buffer         |-------------------------------------------------------------------|
532              entry 0   |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
533  record_buffer + 16    |-------------------------------------------------------------------|
534              entry 1   |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
535  record_buffer + 32    |-------------------------------------------------------------------|
536              entry 2   |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
537  record_buffer + 48    |-------------------------------------------------------------------|
538              entry 3   |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
539  record_buffer + 64    |-------------------------------------------------------------------|
540              entry 4   |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
541  record_buffer + 80    |-------------------------------------------------------------------|
542                        |xx.xx.xx.xx|priority|weight|port|res|pointer to host name string   |
543                        |                                   | srv_hostname 4                |
544                        |srv_hostname 3                  | srv_hostname 2                   |
545                        |srv_hostname 1             | srv_hostname 0                        |
546  record_buffer + max   |-------------------------------------------------------------------|
547 
548 */
549 /********************************************************************************/
550 /*                                TXT                                           */
551 /********************************************************************************/
552 /* TXT RDATA format
553                         1                   2                   3
554     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
555     |-------------------------------------------------------------|
556     /                            TXT-DATA                         /
557     /                                                             /
558     |-------------------------------------------------------------|
559 */
560 
561 /********************************************************************************/
562 /*                                SOA                                           */
563 /********************************************************************************/
564 /* SOA RDATA format
565                         1                   2                   3
566     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
567     |-------------------------------------------------------------|
568     /                            MNAME                            /
569     /                                                             /
570     |-------------------------------------------------------------|
571     /                            RNAME                            /
572     /                                                             /
573     |-------------------------------------------------------------|
574     |                            SERIAL                           |
575     |-------------------------------------------------------------|
576     |                            REFRESH                          |
577     |-------------------------------------------------------------|
578     |                            RETRY                            |
579     |-------------------------------------------------------------|
580     |                            EXPIRE                           |
581     |-------------------------------------------------------------|
582     |                            MINMUM                           |
583     |-------------------------------------------------------------|
584 */
585 
586 /* Define the service record type. */
587 
588 typedef struct NX_DNS_SOA_ENTRY_STRUCT
589 {
590 
591     UCHAR           *nx_dns_soa_host_mname_ptr;
592     UCHAR           *nx_dns_soa_host_rname_ptr;
593     ULONG           nx_dns_soa_serial;
594     ULONG           nx_dns_soa_refresh;
595     ULONG           nx_dns_soa_retry;
596     ULONG           nx_dns_soa_expire;
597     ULONG           nx_dns_soa_minmum;
598 } NX_DNS_SOA_ENTRY;
599 
600 /* Layout of the buffer
601  record_buffer
602 
603                        |-------------------------------------------------------------------|
604                        | pointer to primary name server| pointer to responsible mailbox    |
605                        |-------------------------------------------------------------------|
606                        |   serial   |  refresh   |    retry   |   expire   |   minmum      |
607                        |-------------------------------------------------------------------|
608                        | soa_host_mname         | soa_host_rname                           |
609                        |-------------------------------------------------------------------|
610  */
611 
612 /********************************************************************************/
613 /*                                LOC                                           */
614 /********************************************************************************/
615 /* To be implemented */
616 
617 /********************************************************************************/
618 /*                                NAPTR                                         */
619 /********************************************************************************/
620 /* To be implemented */
621 
622 /********************************************************************************/
623 /*                                DNAME                                           */
624 /********************************************************************************/
625 /* To be implemented */
626 
627 #endif
628 
629 
630 /* Define the RDATA structure.  */
631 
632 /* A RDATA format
633       0                             1
634       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
635     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
636     |                     ADDRESS                   |
637     |                                               |
638     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
639 */
640 
641 typedef struct NX_DNS_RR_A_STRUCT
642 {
643     ULONG           nx_dns_rr_a_address;
644 } NX_DNS_RR_A;
645 
646 /* AAAA RDATA format
647       0                             1
648       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
649     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
650     |                                               |
651     |                                               |
652     |                                               |
653     |                   IPv6 ADDRESS                |
654     |                                               |
655     |                                               |
656     |                                               |
657     |                                               |
658     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
659 */
660 
661 typedef struct NX_DNS_RR_AAAA_STRUCT
662 {
663     ULONG*          nx_dns_rr_aaaa_address;         /* Keep the same resource record structure size, store the rdata information into cache with string.  */
664 } NX_DNS_RR_AAAA;
665 
666 
667 /* PTR RDATA format
668       0                             1
669       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
670     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
671     /                     PTRDNAME                  /
672     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
673 */
674 
675 typedef struct NX_DNS_RR_PTR_STRUCT
676 {
677     UCHAR*          nx_dns_rr_ptr_name;
678 } NX_DNS_RR_PTR;
679 
680 
681 /* NS RDATA format
682       0                             1
683       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
684     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
685     /                     NSDNAME                   /
686     /                                               /
687     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
688 */
689 
690 typedef struct NX_DNS_RR_NS_STRUCT
691 {
692     UCHAR*          nx_dns_rr_ns_name;
693 } NX_DNS_RR_NS;
694 
695 /* CNMAE RDATA format
696       0                             1
697       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
698     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
699     /                     CNAME                     /
700     /                                               /
701     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
702 */
703 
704 typedef struct NX_DNS_RR_CNAME_STRUCT
705 {
706     UCHAR*          nx_dns_rr_cname_name;
707 } NX_DNS_RR_CNAME;
708 
709 
710 /* MX RDATA format
711       0                             1
712       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
713     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
714     |                     PREFERENCE                |
715     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
716     /                     NEWNAME                   /
717     /                                               /
718     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
719 */
720 
721 typedef struct NX_DNS_RR_MX_STRUCT
722 {
723     UCHAR*          nx_dns_rr_mx_rdata;             /* Keep the same resource record structure size, store the rdata information into cache with string. "preference, newname" */
724 } NX_DNS_RR_MX;
725 
726 /* TXT RDATA format
727       0                             1
728       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
729     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
730     /                     TXT-DATA                  /
731     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
732 */
733 
734 typedef struct NX_DNS_RR_TXT_STRUCT
735 {
736     UCHAR*          nx_dns_rr_txt_data;
737 } NX_DNS_RR_TXT;
738 
739 /* SRV RDATA format
740       0                             1
741       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
742     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
743     |                     PRIORITY                  |
744     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
745     |                     WEIGHTS                   |
746     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
747     |                     PORT                      |
748     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
749     /                     TARGET                    /
750     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
751 */
752 
753 typedef struct NX_DNS_RR_SRV_STRUCT
754 {
755     UCHAR*          nx_dns_rr_srv_rdata;        /* Keep the same resource record structure size, store the rdata information into cache with string, "priority, weights, port,target".  */
756 } NX_DNS_RR_SRV;
757 
758 
759 /* SOA RDATA format
760       0                             1
761       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
762     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
763     /                     MNAME                     /
764     /                                               /
765     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
766     /                     RNAME                     /
767     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
768     |                     SERIAL                    |
769     |                                               |
770     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
771     |                     REFRESH                   |
772     |                                               |
773     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
774     |                     RETRY                     |
775     |                                               |
776     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
777     |                     EXPIRE                    |
778     |                                               |
779     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
780     |                     MINMUM                    |
781     |                                               |
782     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
783 */
784 
785 typedef struct NX_DNS_RR_SOA_STRUCT
786 {
787     UCHAR*          nx_dns_rr_soa_rdata;            /* Keep the same resource record structure size, store the rdata information into cache with string.
788                                                        "Mname, Rname, Serial, Refresh, Retry, Expire, Minmum"  */
789 } NX_DNS_RR_SOA;
790 
791 
792 /* The following data structure is used to store the resource records(RRs). */
793 typedef struct NX_DNS_RR_STRUCT
794 {
795 
796     UCHAR*  nx_dns_rr_name;                     /* Owner's name,i.e., the name of the node to which this resource record pertains. */
797 
798     USHORT  nx_dns_rr_type;                     /* RR TYPE.                                                 */
799 
800     USHORT  nx_dns_rr_class;                    /* RR CLASS.                                                */
801 
802     ULONG   nx_dns_rr_ttl;                      /* The time interval that the RR may be cached before the source of the information should again be consulted. */
803 
804     ULONG   nx_dns_rr_last_used_time;           /* Define the last used time for the peer RR.               */
805 
806     /* Union that holds resource record data. */
807     union   nx_dns_rr_rdata_union
808     {
809         NX_DNS_RR_A         nx_dns_rr_rdata_a;
810         NX_DNS_RR_AAAA      nx_dns_rr_rdata_aaaa;
811         NX_DNS_RR_PTR       nx_dns_rr_rdata_ptr;
812         NX_DNS_RR_SRV       nx_dns_rr_rdata_srv;
813         NX_DNS_RR_TXT       nx_dns_rr_rdata_txt;
814         NX_DNS_RR_CNAME     nx_dns_rr_rdata_cname;
815         NX_DNS_RR_NS        nx_dns_rr_rdata_ns;
816         NX_DNS_RR_MX        nx_dns_rr_rdata_mx;
817         NX_DNS_RR_SOA       nx_dns_rr_rdata_soa;
818     } nx_dns_rr_rdata;
819 
820 }NX_DNS_RR;
821 
822 
823 #ifndef NX_DNS_SOURCE_CODE
824 
825 /* Application caller is present, perform API mapping.  */
826 
827 /* Determine if error checking is desired.  If so, map API functions
828    to the appropriate error checking front-ends.  Otherwise, map API
829    functions to the core functions that actually perform the work.
830    Note: error checking is enabled by default.  */
831 
832 #ifdef NX_DISABLE_ERROR_CHECKING
833 
834 /* Services without error checking.  */
835 
836 #define nx_dns_create                               _nx_dns_create
837 #define nx_dns_delete                               _nx_dns_delete
838 #define nx_dns_packet_pool_set                      _nx_dns_packet_pool_set
839 #define nx_dns_host_by_address_get                  _nx_dns_host_by_address_get
840 #define nx_dns_host_by_name_get                     _nx_dns_host_by_name_get
841 #define nx_dns_ipv4_address_by_name_get             _nx_dns_ipv4_address_by_name_get
842 
843 #ifdef NX_DNS_ENABLE_EXTENDED_RR_TYPES
844 #define nx_dns_cname_get                            _nx_dns_cname_get
845 #define nx_dns_domain_name_server_get               _nx_dns_domain_name_server_get
846 #define nx_dns_host_text_get                        _nx_dns_host_text_get
847 #define nx_dns_domain_mail_exchange_get             _nx_dns_domain_mail_exchange_get
848 #define nx_dns_domain_service_get                   _nx_dns_domain_service_get
849 #define nx_dns_authority_zone_start_get             _nx_dns_authority_zone_start_get
850 #define nx_dns_info_by_name_get                     _nx_dns_info_by_name_get
851 #endif
852 
853 #define nx_dns_server_add                           _nx_dns_server_add
854 #define nx_dns_server_remove                        _nx_dns_server_remove
855 #define nx_dns_server_remove_all                    _nx_dns_server_remove_all
856 #define nx_dns_server_get                           _nx_dns_server_get
857 #define nx_dns_get_serverlist_size                  _nx_dns_get_serverlist_size
858 
859 #define nxd_dns_ipv6_address_by_name_get            _nxd_dns_ipv6_address_by_name_get
860 #define nxd_dns_host_by_address_get                 _nxd_dns_host_by_address_get
861 #define nxd_dns_host_by_name_get                    _nxd_dns_host_by_name_get
862 #define nxd_dns_server_add                          _nxd_dns_server_add
863 #define nxd_dns_server_remove                       _nxd_dns_server_remove
864 #define nxd_dns_server_get                          _nxd_dns_server_get
865 
866 #ifdef NX_DNS_CACHE_ENABLE
867 #define nx_dns_cache_initialize                     _nx_dns_cache_initialize
868 #define nx_dns_cache_notify_set                     _nx_dns_cache_notify_set
869 #define nx_dns_cache_notify_clear                   _nx_dns_cache_notify_clear
870 #endif /* NX_DNS_CACHE_ENABLE  */
871 
872 #else
873 
874 /* Services with error checking.  */
875 
876 #define nx_dns_create                               _nxe_dns_create
877 #define nx_dns_delete                               _nxe_dns_delete
878 #define nx_dns_packet_pool_set                      _nxe_dns_packet_pool_set
879 #define nx_dns_host_by_address_get                  _nxe_dns_host_by_address_get
880 #define nx_dns_host_by_name_get                     _nxe_dns_host_by_name_get
881 #define nx_dns_ipv4_address_by_name_get             _nxe_dns_ipv4_address_by_name_get
882 
883 #ifdef NX_DNS_ENABLE_EXTENDED_RR_TYPES
884 #define nx_dns_cname_get                            _nxe_dns_cname_get
885 #define nx_dns_domain_name_server_get               _nxe_dns_domain_name_server_get
886 #define nx_dns_host_text_get                        _nxe_dns_host_text_get
887 #define nx_dns_domain_mail_exchange_get             _nxe_dns_domain_mail_exchange_get
888 #define nx_dns_domain_service_get                   _nxe_dns_domain_service_get
889 #define nx_dns_authority_zone_start_get             _nxe_dns_authority_zone_start_get
890 #define nx_dns_info_by_name_get                     _nxe_dns_info_by_name_get
891 #endif
892 
893 #define nx_dns_server_add                           _nxe_dns_server_add
894 #define nx_dns_server_remove                        _nxe_dns_server_remove
895 #define nx_dns_server_remove_all                    _nxe_dns_server_remove_all
896 #define nx_dns_server_get                           _nxe_dns_server_get
897 #define nx_dns_get_serverlist_size                  _nxe_dns_get_serverlist_size
898 
899 #define nxd_dns_ipv6_address_by_name_get            _nxde_dns_ipv6_address_by_name_get
900 #define nxd_dns_host_by_address_get                 _nxde_dns_host_by_address_get
901 #define nxd_dns_host_by_name_get                    _nxde_dns_host_by_name_get
902 #define nxd_dns_server_add                          _nxde_dns_server_add
903 #define nxd_dns_server_remove                       _nxde_dns_server_remove
904 #define nxd_dns_server_get                          _nxde_dns_server_get
905 
906 #ifdef NX_DNS_CACHE_ENABLE
907 #define nx_dns_cache_initialize                     _nxe_dns_cache_initialize
908 #define nx_dns_cache_notify_set                     _nxe_dns_cache_notify_set
909 #define nx_dns_cache_notify_clear                   _nxe_dns_cache_notify_clear
910 #endif /* NX_DNS_CACHE_ENABLE  */
911 
912 #endif
913 
914 /* Define the prototypes accessible to the application software.  */
915 
916 UINT        nx_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name);
917 UINT        nx_dns_delete(NX_DNS *dns_ptr);
918 UINT        nx_dns_packet_pool_set(NX_DNS *dns_ptr, NX_PACKET_POOL *packet_pool_ptr);
919 UINT        nx_dns_server_add(NX_DNS *dns_ptr, ULONG server_address);
920 UINT        nx_dns_server_remove(NX_DNS *dns_ptr, ULONG server_address);
921 UINT        nx_dns_server_remove_all(NX_DNS *dns_ptr);
922 UINT        nx_dns_server_get(NX_DNS *dns_ptr, UINT index, ULONG *dns_server_address);
923 UINT        nx_dns_get_serverlist_size(NX_DNS *dns_ptr, UINT *server_list_size);
924 UINT        nx_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, ULONG wait_option);
925 UINT        nx_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG ip_address, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
926 UINT        nx_dns_ipv4_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
927 
928 #ifdef NX_DNS_ENABLE_EXTENDED_RR_TYPES
929 UINT        nx_dns_cname_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
930 UINT        nx_dns_domain_name_server_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
931 UINT        nx_dns_host_text_get(NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
932 UINT        nx_dns_domain_mail_exchange_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
933 UINT        nx_dns_domain_service_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
934 UINT        nx_dns_authority_zone_start_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
935 UINT        nx_dns_info_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, USHORT* host_port, ULONG wait_option);
936 #endif
937 
938 UINT        nxd_dns_ipv6_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
939 UINT        nxd_dns_host_by_address_get(NX_DNS *dns_ptr, NXD_ADDRESS *ip_address, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
940 UINT        nxd_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, NXD_ADDRESS *host_address_ptr, ULONG wait_option, UINT lookup_type);
941 UINT        nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *dns_server_address);
942 UINT        nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address);
943 UINT        nxd_dns_server_get(NX_DNS *dns_ptr, UINT index, NXD_ADDRESS *dns_server_address);
944 
945 #ifdef NX_DNS_CACHE_ENABLE
946 UINT        nx_dns_cache_initialize(NX_DNS *dns_ptr, VOID *cache_ptr, UINT cache_size);
947 UINT        nx_dns_cache_notify_set(NX_DNS *dns_ptr, VOID (*cache_full_notify_cb)(NX_DNS *dns_ptr));
948 UINT        nx_dns_cache_notify_clear(NX_DNS *dns_ptr);
949 #endif /* NX_DNS_CACHE_ENABLE  */
950 
951 #else
952 
953 /* DNS source code is being compiled, do not perform any API mapping.  */
954 
955 UINT        _nxe_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name);
956 UINT        _nx_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name);
957 UINT        _nxe_dns_delete(NX_DNS *dns_ptr);
958 UINT        _nx_dns_delete(NX_DNS *dns_ptr);
959 UINT        _nxe_dns_packet_pool_set(NX_DNS *dns_ptr, NX_PACKET_POOL *packet_pool_ptr);
960 UINT        _nx_dns_packet_pool_set(NX_DNS *dns_ptr, NX_PACKET_POOL *packet_pool_ptr);
961 UINT        _nxe_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG ip_address, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
962 UINT        _nx_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG ip_address, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
963 UINT        _nxe_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, ULONG wait_option);
964 UINT        _nx_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, ULONG wait_option);
965 UINT        _nxe_dns_ipv4_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
966 UINT        _nx_dns_ipv4_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
967 
968 #ifdef NX_DNS_ENABLE_EXTENDED_RR_TYPES
969 UINT        _nxe_dns_cname_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size,ULONG wait_option);
970 UINT        _nx_dns_cname_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size,ULONG wait_option);
971 UINT        _nxe_dns_domain_name_server_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
972 UINT        _nx_dns_domain_name_server_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
973 UINT        _nxe_dns_host_text_get(NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
974 UINT        _nx_dns_host_text_get(NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
975 UINT        _nxe_dns_domain_mail_exchange_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
976 UINT        _nx_dns_domain_mail_exchange_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
977 UINT        _nxe_dns_domain_service_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
978 UINT        _nx_dns_domain_service_get(NX_DNS *dns_ptr, UCHAR *host_name,  VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
979 UINT        _nxe_dns_authority_zone_start_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
980 UINT        _nx_dns_authority_zone_start_get (NX_DNS *dns_ptr, UCHAR *host_name,  UCHAR *record_buffer, UINT buffer_size, ULONG wait_option);
981 UINT        _nxe_dns_info_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, USHORT* host_port, ULONG wait_option);
982 UINT        _nx_dns_info_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, ULONG *host_address_ptr, USHORT* host_port, ULONG wait_option);
983 #endif
984 
985 UINT        _nxe_dns_server_add(NX_DNS *dns_ptr, ULONG server_address);
986 UINT        _nx_dns_server_add(NX_DNS *dns_ptr, ULONG server_address);
987 UINT        _nxe_dns_server_remove(NX_DNS *dns_ptr, ULONG server_address);
988 UINT        _nx_dns_server_remove(NX_DNS *dns_ptr, ULONG server_address);
989 UINT        _nxe_dns_server_remove_all(NX_DNS *dns_ptr);
990 UINT        _nx_dns_server_remove_all(NX_DNS *dns_ptr);
991 UINT        _nxe_dns_server_get(NX_DNS *dns_ptr, UINT index, ULONG *dns_server_address);
992 UINT        _nx_dns_server_get(NX_DNS *dns_ptr, UINT index, ULONG *dns_server_address);
993 UINT        _nxe_dns_get_serverlist_size(NX_DNS *dns_ptr, UINT *server_list_size);
994 UINT        _nx_dns_get_serverlist_size(NX_DNS *dns_ptr, UINT *server_list_size);
995 UINT        _nxde_dns_ipv6_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
996 UINT        _nxd_dns_ipv6_address_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, VOID *record_buffer, UINT buffer_size, UINT *record_count, ULONG wait_option);
997 UINT        _nxde_dns_host_by_address_get(NX_DNS *dns_ptr, NXD_ADDRESS *host_address_ptr, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
998 UINT        _nxd_dns_host_by_address_get(NX_DNS *dns_ptr, NXD_ADDRESS *host_address_ptr, UCHAR *host_name_ptr, UINT host_name_buffer_size, ULONG wait_option);
999 UINT        _nxde_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, NXD_ADDRESS *host_address_ptr, ULONG wait_option, UINT lookup_type);
1000 UINT        _nxd_dns_host_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, NXD_ADDRESS *host_address_ptr, ULONG wait_option, UINT lookup_type);
1001 UINT        _nxde_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *server_address);
1002 UINT        _nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *server_address);
1003 UINT        _nxde_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address);
1004 UINT        _nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address);
1005 UINT        _nxde_dns_server_get(NX_DNS *dns_ptr, UINT index, NXD_ADDRESS *dns_server_address);
1006 UINT        _nxd_dns_server_get(NX_DNS *dns_ptr, UINT index, NXD_ADDRESS *dns_server_address);
1007 
1008 #ifdef NX_DNS_CACHE_ENABLE
1009 UINT        _nxe_dns_cache_initialize(NX_DNS *dns_ptr, VOID *cache_ptr, UINT cache_size);
1010 UINT        _nx_dns_cache_initialize(NX_DNS *dns_ptr, VOID *cache_ptr, UINT cache_size);
1011 UINT        _nxe_dns_cache_notify_set(NX_DNS *dns_ptr, VOID (*cache_full_notify_cb)(NX_DNS *dns_ptr));
1012 UINT        _nx_dns_cache_notify_set(NX_DNS *dns_ptr, VOID (*cache_full_notify_cb)(NX_DNS *dns_ptr));
1013 UINT        _nxe_dns_cache_notify_clear(NX_DNS *dns_ptr);
1014 UINT        _nx_dns_cache_notify_clear(NX_DNS *dns_ptr);
1015 #endif /* NX_DNS_CACHE_ENABLE  */
1016 
1017 #endif
1018 
1019 /* Internal DNS response getting function.  */
1020 UINT        _nx_dns_response_get(NX_DNS *dns_ptr, UCHAR *host_name, UCHAR *record_buffer, UINT buffer_size,
1021                                  UINT *record_count, ULONG wait_option);
1022 
1023 /* Determine if a C++ compiler is being used.  If so, complete the standard
1024    C conditional started above.  */
1025 #ifdef   __cplusplus
1026         }
1027 #endif
1028 
1029 #endif  /* NXD_DNS_H */
1030 
1031