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 /**   Multicast Domain Name System (mDNS)                                 */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 /**************************************************************************/
23 /*                                                                        */
24 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
25 /*                                                                        */
26 /*    nxd_mdns.h                                          PORTABLE C      */
27 /*                                                           6.3.0        */
28 /*  AUTHOR                                                                */
29 /*                                                                        */
30 /*    Yuxin Zhou, Microsoft Corporation                                   */
31 /*                                                                        */
32 /*  DESCRIPTION                                                           */
33 /*                                                                        */
34 /*    This file defines the NetX Multicast Domain Name System (mDNS)      */
35 /*    component, including all data types and external references.        */
36 /*    It is assumed that nx_api.h and nx_port.h have already been         */
37 /*    included.                                                           */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
44 /*  09-30-2020     Yuxin Zhou               Modified comment(s), improved */
45 /*                                            buffer length verification, */
46 /*                                            resulting in version 6.1    */
47 /*  12-31-2020     Yuxin Zhou               Modified comment(s),          */
48 /*                                            prevented infinite loop in  */
49 /*                                            name compression,           */
50 /*                                            resulting in version 6.1.3  */
51 /*  04-25-2022     Yuxin Zhou               Modified comment(s),          */
52 /*                                            fixed the issue of timer,   */
53 /*                                            resulting in version 6.1.11 */
54 /*  10-31-2023     Bo Chen                  Modified comment(s), and      */
55 /*                                            corrected the symbols check,*/
56 /*                                            resulting in version 6.3.0  */
57 /*                                                                        */
58 /**************************************************************************/
59 
60 #ifndef NXD_MDNS_H
61 #define NXD_MDNS_H
62 
63 /* Determine if a C++ compiler is being used.  If so, ensure that standard
64    C is used to process the API information.  */
65 
66 
67 
68 #ifdef   __cplusplus
69 
70 /* Yes, C++ compiler is present.  Use standard C.  */
71 extern   "C" {
72 
73 #endif
74 
75 #include "nx_api.h"
76 #include "nx_udp.h"
77 #include "nx_ip.h"
78 #ifdef FEATURE_NX_IPV6
79 #include "nx_ipv6.h"
80 #endif /* FEATURE_NX_IPV6  */
81 
82 
83 /* Define the Multicast DNS ID.  */
84 #define NX_MDNS_ID                              0x4d444e53UL
85 
86 /* Define macros that get the data on unaligned address.  */
87 #define NX_MDNS_GET_USHORT_DATA(data)           (USHORT)((*(data) << 8) | (*(data + 1)))
88 #define NX_MDNS_GET_ULONG_DATA(data)            (ULONG)((*(data) << 24) | (*(data + 1) << 16) | (*(data + 2) << 8) | (*(data + 3)))
89 
90 /* Disable the mDNS Server functionality.  By default mDNS server
91    function is enabled.  To remove the mDNS server function from
92    the mDNS library, uncomment the following line.  */
93 /*
94 #define NX_MDNS_DISABLE_SERVER
95 */
96 
97 /* Disable the mDNS Client functionality.  By default mDNS client
98    function is enabled.  To remove the mDNS client function from
99    the mDNS library, uncomment the following line.  */
100 /*
101 #define NX_MDNS_DISABLE_CLIENT
102 */
103 
104 /* Enable the feature to check the address and port of mDNS message.
105    By default is enabled. To remove it from the mDNS library,
106    comment the following line.  */
107 #define NX_MDNS_ENABLE_ADDRESS_CHECK
108 
109 /* Enable the Passive Observation Of Failures feature for Client.
110    By default is enabled. To remove it from the mDNS library,
111    comment the following line.
112    Note: This will have no effect if NX_MDNS_DISABLE_CLIENT is defined.  */
113 #define NX_MDNS_ENABLE_CLIENT_POOF
114 
115 /* Enable the feature for Server to generate the Negative Responses.
116    By default is enabled. To remove it from the mDNS library,
117    comment the following line.
118    Note: This will have no effect if NX_MDNS_DISABLE_SERVER is defined.  */
119 #define NX_MDNS_ENABLE_SERVER_NEGATIVE_RESPONSES
120 
121 
122 /* Enable mDNS IPv6 feature, send/process mDNS message over IPv6 address.
123    By default mDNS IPv6 function is disabled. To enable this feature,
124    uncomment the following line.  */
125 /*
126 #define NX_MDNS_ENABLE_IPV6
127 */
128 
129 #ifdef NX_MDNS_ENABLE_IPV6
130 
131 #ifndef FEATURE_NX_IPV6
132 #error "mDNS IPv6 is not supported if IPv6 is not enabled."
133 #endif /* FEATURE_NX_IPV6  */
134 
135 #ifndef NX_ENABLE_IPV6_MULTICAST
136 #error "mDNS IPv6 is not supported if IPv6 multicast is not enabled."
137 #endif /* NX_ENABLE_IPV6_MULTICAST  */
138 
139 #ifndef NX_MDNS_DISABLE_SERVER
140 #ifndef NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY
141 #error "mDNS IPv6 is not supported if IPv6 address change notify is not enabled."
142 #endif /* NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY  */
143 #endif /* NX_MDNS_DISABLE_SERVER  */
144 
145 #endif /* NX_MDNS_ENABLE_IPV6  */
146 
147 
148 /* Define the IPV6 address count of the host name. */
149 #ifndef NX_MDNS_IPV6_ADDRESS_COUNT
150 #define NX_MDNS_IPV6_ADDRESS_COUNT              2
151 #endif /* NX_MDNS_IPV6_ADDRESS_COUNT  */
152 
153 
154 /* Define message and name limits.  */
155 #define NX_MDNS_TYPE_MAX                        21          /* Maximum Type size, <sn>._tcp, <sn> may be up to 15 bytes,
156                                                                plus the underscore and length byte. Including the "_udp" or "_tcp". */
157 #define NX_MDNS_LABEL_MAX                       63          /* Maximum Label (between two dots) size                 */
158 #define NX_MDNS_NAME_MAX                        255         /* Maximum Name size                                     */
159 #define NX_MDNS_IP_LOOKUP_SIZE                  75          /* IPv6 needs 66 characters for the address plus 8 for the ip6.arpa plus null           */
160                                                             /* IPv4 needs 12 characters max for the address plus 12 for the IN-ADDR.ARPA plus null  */
161 
162 
163 /* Define the mDNS's host name cache size. Keep four-byte alignment.   */
164 /* Note: The real host name size plus conflict size (4)
165          must not exceed NX_MDNS_LABEL_MAX and NX_MDNS_HOST_NAME_MAX.
166          such as:
167          the real host name: "NETX-MDNS-HOST"
168          the conflict name: " (2)"
169          the final name: "NETX-MDNS-HOST (2)".  */
170 #ifndef NX_MDNS_HOST_NAME_MAX
171 #define NX_MDNS_HOST_NAME_MAX                   64
172 #endif /* NX_MDNS_HOST_NAME_MAX  */
173 
174 
175 /* Define the mDNS's service name cache size. Keep four-byte alignment.  */
176 /* Note: The real service name size plus conflict size (4)
177          must not exceed NX_MDNS_LABEL_MAX and NX_MDNS_SERVICE_NAME_MAX.
178          such as:
179          the real service name: "NETX-MDNS-SERVICE"
180          the conflict name: " (2)"
181          the final service name: "NETX-MDNS-SERVICE (2)".  */
182 #ifndef NX_MDNS_SERVICE_NAME_MAX
183 #define NX_MDNS_SERVICE_NAME_MAX                64
184 #endif /* NX_MDNS_SERVICE_NAME_MAX  */
185 
186 
187 /* Define the mDNS's domain name max size. */
188 #ifndef NX_MDNS_DOMAIN_NAME_MAX
189 #define NX_MDNS_DOMAIN_NAME_MAX                 16
190 #endif /* NX_MDNS_DOMAIN_NAME_MAX  */
191 
192 /* NX_MDNS_DOMAIN_NAME_MAX must be at least 5 bytes to hold "local". */
193 #if (NX_MDNS_DOMAIN_NAME_MAX < 5)
194 #error "NX_MDNS_DOMAIN_NAME_MAX must be at least 5 bytes!"
195 #endif /* (NX_MDNS_DOMAIN_NAME_MAX < 5) */
196 
197 /* (NX_MDNS_HOST_NAME_MAX + "."(1) + NX_MDNS_DOMAIN_NAME_MAX) must be no more than NX_MDNS_NAME_MAX. */
198 #if ((NX_MDNS_HOST_NAME_MAX + 1 + NX_MDNS_DOMAIN_NAME_MAX) > NX_MDNS_NAME_MAX)
199 #error "(NX_MDNS_HOST_NAME_MAX + 1 + NX_MDNS_DOMAIN_NAME_MAX) must be no more than NX_MDNS_NAME_MAX!"
200 #endif
201 
202 /* Define the conflict count of service name or host name.   */
203 /* Note: the confilict count should be less than 8, since we just append " (x)"
204          between " (2)" and " (9)" during the conflict resolution process.  */
205 #ifndef NX_MDNS_CONFLICT_COUNT
206 #define NX_MDNS_CONFLICT_COUNT                  8
207 #endif/* NX_MDNS_CONFLICT_COUNT  */
208 
209 
210 /* Define the DNS-SD buffer size for storing "_services._dns-sd._udp.local"  */
211 /* Note: the domain can be updated, so the max size should be NX_MDNS_DOMAIN_NAME_MAX + 23.
212          "_services._dns-sd._udp." (23) + NX_MDNS_DOMAIN_NAME_MAX. */
213 #define NX_MDNS_DNS_SD_MAX                      (NX_MDNS_DOMAIN_NAME_MAX + 23)
214 
215 
216 /* Define mDNS Multicast Address.  */
217 #define NX_MDNS_IPV4_MULTICAST_ADDRESS          (IP_ADDRESS(224,0,0,251))
218 
219 
220 /* Define mDNS port.  */
221 #define NX_MDNS_UDP_PORT                        5353
222 
223 
224 /* Define UDP socket create options.  */
225 #ifndef NX_MDNS_UDP_TYPE_OF_SERVICE
226 #define NX_MDNS_UDP_TYPE_OF_SERVICE             NX_IP_NORMAL
227 #endif /* NX_MDNS_UDP_TYPE_OF_SERVICE  */
228 
229 #ifndef NX_MDNS_UDP_FRAGMENT_OPTION
230 #define NX_MDNS_UDP_FRAGMENT_OPTION             NX_DONT_FRAGMENT
231 #endif /* NX_MDNS_UDP_FRAGMENT_OPTION  */
232 
233 #ifndef NX_MDNS_UDP_TIME_TO_LIVE
234 #define NX_MDNS_UDP_TIME_TO_LIVE                0xFF
235 #endif /* NX_MDNS_UDP_TIME_TO_LIVE  */
236 
237 #ifndef NX_MDNS_UDP_QUEUE_DEPTH
238 #define NX_MDNS_UDP_QUEUE_DEPTH                 4
239 #endif /* NX_MDNS_UDP_QUEUE_DEPTH  */
240 
241 
242 /* Define the resource record TTL. In second.  */
243 /* The recommended TTL value for Multicast DNS resource records with a host name as the resource record's name
244    (e.g., A, AAAA, HINFO) or a host name contaned within the resource record's rdata (e.g., SRV, reverse mapping PTR record)
245    should be 120 seconds. The recommended TTL value for other Multicast DNS resource records is 75 minutes.
246    RFC6762, Section10, Page33.  */
247 #ifndef NX_MDNS_RR_TTL_HOST
248 #define NX_MDNS_RR_TTL_HOST                     120
249 #endif /* NX_MDNS_RR_TTL_HOST  */
250 
251 #ifndef NX_MDNS_RR_TTL_OTHER
252 #define NX_MDNS_RR_TTL_OTHER                    4500        /* 75 minutes.  */
253 #endif /* NX_MDNS_RR_TTL_OTHER  */
254 
255 
256 /* Define the mDNS's probing timer interval, default 250ms in spec. In tick.
257    should be: 250 * NX_IP_PERIODIC_RATE / 1000.  */
258 #ifndef NX_MDNS_PROBING_TIMER_COUNT
259 #define NX_MDNS_PROBING_TIMER_COUNT             (250 * NX_IP_PERIODIC_RATE / 1000)
260 #endif /* NX_MDNS_PROBING_TIMER_COUNT  */
261 
262 
263 /* Define the mDNS's announcing timer interval, default 250ms in spec. In tick.
264    should be: 250 * NX_IP_PERIODIC_RATE / 1000.  */
265 #ifndef NX_MDNS_ANNOUNCING_TIMER_COUNT
266 #define NX_MDNS_ANNOUNCING_TIMER_COUNT          (250 * NX_IP_PERIODIC_RATE / 1000)
267 #endif /* NX_MDNS_ANNOUNCING_TIMER_COUNT  */
268 
269 
270 /* Define the mDNS's goodbye timer interval, default 250ms in spec. In tick.
271    should be: 250 * NX_IP_PERIODIC_RATE / 1000.  */
272 #ifndef NX_MDNS_GOODBYE_TIMER_COUNT
273 #define NX_MDNS_GOODBYE_TIMER_COUNT             (250 * NX_IP_PERIODIC_RATE / 1000)
274 #endif /* NX_MDNS_GOODBYE_TIMER_COUNT  */
275 
276 
277 /* Define the mDNS's min query timer interval between two queries, 1 second. In tick.  */
278 #ifndef NX_MDNS_QUERY_MIN_TIMER_COUNT
279 #define NX_MDNS_QUERY_MIN_TIMER_COUNT           NX_IP_PERIODIC_RATE
280 #endif /* NX_MDNS_QUERY_MIN_TIMER_COUNT  */
281 
282 
283 /* Define the mDNS's max query timer interval between first two queries, 60 minutes. In tick.  */
284 #ifndef NX_MDNS_QUERY_MAX_TIMER_COUNT
285 #define NX_MDNS_QUERY_MAX_TIMER_COUNT           (3600 * NX_IP_PERIODIC_RATE)
286 #endif /* NX_MDNS_QUERY_MAX_TIMER_COUNT  */
287 
288 
289 /* Define the mDNS's query delay timer interval, 20-120ms. In tick. */
290 #ifndef NX_MDNS_QUERY_DELAY_MIN
291 #define NX_MDNS_QUERY_DELAY_MIN                 (20 * NX_IP_PERIODIC_RATE / 1000)
292 #endif /* NX_MDNS_QUERY_DELAY_MIN  */
293 
294 #ifndef NX_MDNS_QUERY_DELAY_RANGE
295 #define NX_MDNS_QUERY_DELAY_RANGE               (100 * NX_IP_PERIODIC_RATE / 1000)
296 #endif /* NX_MDNS_QUERY_DELAY_RANGE  */
297 
298 
299 /* Define the mDNS's response delay time interval for multicast query.  */
300 /* The time interval, in ticks, in responding to a query to ensure an interval of at least 1s
301    since the last time the record was multicast. The default value is NX_IP_PERIODIC_RATE ticks.  */
302 #ifndef NX_MDNS_RESPONSE_INTERVAL
303 #define NX_MDNS_RESPONSE_INTERVAL               NX_IP_PERIODIC_RATE
304 #endif /* NX_MDNS_RESPONSE_INTERVAL  */
305 
306 
307 /* Define the mDNS's response delay time interval for probe message.  */
308 /* The time interval, in ticks, in responding to a probe queries to ensure an interval of
309    at least 250ms since the last time the record was multicast. The default value is (250 * NX_IP_PERIODIC_RATE / 1000) ticks.  */
310 #ifndef NX_MDNS_RESPONSE_PROBING_TIMER_COUNT
311 #define NX_MDNS_RESPONSE_PROBING_TIMER_COUNT    (250 * NX_IP_PERIODIC_RATE / 1000)
312 #endif /* NX_MDNS_RESPONSE_PROBING_TIMER_COUNT  */
313 
314 
315 /* Define the mDNS's response delay time interval for unicast query, 10 ms. In tick.  */
316 #ifndef NX_MDNS_RESPONSE_UNIQUE_DELAY
317 #define NX_MDNS_RESPONSE_UNIQUE_DELAY           (10 * NX_IP_PERIODIC_RATE / 1000)
318 #endif /* NX_MDNS_RESPONSE_UNIQUE_DELAY  */
319 
320 
321 /* Define the mDNS's response delay time interval for shared message, 20-120ms. In tick.  */
322 #ifndef NX_MDNS_RESPONSE_SHARED_DELAY_MIN
323 #define NX_MDNS_RESPONSE_SHARED_DELAY_MIN       (20 * NX_IP_PERIODIC_RATE / 1000)
324 #endif /* NX_MDNS_RESPONSE_SHARED_DELAY_MIN */
325 
326 #ifndef NX_MDNS_RESPONSE_SHARED_DELAY_RANGE
327 #define NX_MDNS_RESPONSE_SHARED_DELAY_RANGE     (100 * NX_IP_PERIODIC_RATE / 1000)
328 #endif /* NX_MDNS_RESPONSE_SHARED_DELAY_RANGE  */
329 
330 
331 /* Define the mDNS's response delay time interval for query with TC, 400-500 ms. In tick.  */
332 #ifndef NX_MDNS_RESPONSE_TC_DELAY_MIN
333 #define NX_MDNS_RESPONSE_TC_DELAY_MIN           (400 * NX_IP_PERIODIC_RATE / 1000)
334 #endif /* NX_MDNS_RESPONSE_TC_DELAY_MIN  */
335 
336 #ifndef NX_MDNS_RESPONSE_TC_DELAY_RANGE
337 #define NX_MDNS_RESPONSE_TC_DELAY_RANGE         (100 * NX_IP_PERIODIC_RATE / 1000)
338 #endif /* NX_MDNS_RESPONSE_TC_DELAY_RANGE  */
339 
340 
341 /* Define the mDNS's random delay timer count, 120 ms. In tick.  */
342 /* This value allows a response to include messages that would be sent within
343    the next 120ms range.  */
344 #ifndef NX_MDNS_TIMER_COUNT_RANGE
345 #define NX_MDNS_TIMER_COUNT_RANGE               (120 * NX_IP_PERIODIC_RATE / 1000)
346 #endif /* NX_MDNS_TIMER_COUNT_RANGE  */
347 
348 
349 /* Define the mDNS's probing retransmit count. The defaul value is 3.  */
350 #ifndef NX_MDNS_PROBING_RETRANSMIT_COUNT
351 #define NX_MDNS_PROBING_RETRANSMIT_COUNT        3
352 #endif /* NX_MDNS_PROBING_RETRANSMIT_COUNT  */
353 
354 
355 /* Define the mDNS's goodbye retransmit count. The defaul value is 1.  */
356 #ifndef NX_MDNS_GOODBYE_RETRANSMIT_COUNT
357 #define NX_MDNS_GOODBYE_RETRANSMIT_COUNT        1
358 #endif /* NX_MDNS_GOODBYE_RETRANSMIT_COUNT  */
359 
360 
361 /* Passive Observation Of Failures.
362    If a host sees queries, for which a record in its cache would be
363    expected to be given as an answer in a multicast response, but no
364    such answer is seen, then the host may take this as an indication
365    that the record may no longer be valid.
366    After seesing NX_MDNS_POOF_MIN_COUNT of these queries, and seeing
367    no multicast response containing the expected answer with in
368    NX_MDNS_POOF_TIMER_COUNT, delete the RR from the cache.
369    RFC6762, Section10.5, Page38.  */
370 
371 /* Define the Passive Observation Of Failures min count. The defaul value is 2.  */
372 #ifndef NX_MDNS_POOF_MIN_COUNT
373 #define NX_MDNS_POOF_MIN_COUNT                  2
374 #endif /* NX_MDNS_POOF_MIN_COUNT  */
375 
376 /* Define the Passive Observation Of Failures timer count, 10 seconds in spec. In tick. */
377 #ifndef NX_MDNS_POOF_TIMER_COUNT
378 #define NX_MDNS_POOF_TIMER_COUNT                (10 * NX_IP_PERIODIC_RATE)
379 #endif /* NX_MDNS_POOF_TIMER_COUNT  */
380 
381 
382 /* Define the RR delete delay timer.  */
383 /* Queriers receiving a Multicast DNS response with a TTL of zero SHOULD
384    NOT immediately delete the record from the cache, but instead record
385    a TTL of 1 and then delete the record one second later. In tick.  */
386 #ifndef NX_MDNS_RR_DELETE_DELAY_TIMER_COUNT
387 #define NX_MDNS_RR_DELETE_DELAY_TIMER_COUNT     NX_IP_PERIODIC_RATE
388 #endif /* NX_MDNS_RR_DELETE_DELAY_TIMER_COUNT  */
389 
390 /* Define the maximum number of pointers allowed in name compression.  */
391 #ifndef NX_MDNS_MAX_COMPRESSION_POINTERS
392 #define NX_MDNS_MAX_COMPRESSION_POINTERS        16
393 #endif /* NX_MDNS_MAX_COMPRESSION_POINTERS  */
394 
395 
396 /* Define the default mDNS's announcing value.  */
397 #define NX_MDNS_ANNOUNCING_PERIOD               NX_IP_PERIODIC_RATE
398 #define NX_MDNS_ANNOUNCING_COUNT                1
399 #define NX_MDNS_ANNOUNCING_FACTOR               1
400 #define NX_MDNS_ANNOUNCING_RETRANS_INTERVAL     0
401 #define NX_MDNS_ANNOUNCING_PERIOD_INTERVAL      0xFFFFFFFF
402 #define NX_MDNS_ANNOUNCING_MAX_TIME             3
403 #define NX_MDNS_ANNOUNCING_FOREVER              0xFF
404 
405 
406 /* Define the max ttl. In second.  */
407 #define NX_MDNS_RR_MAX_TTL                      0xFFFFFFFF/NX_IP_PERIODIC_RATE
408 
409 
410 /* Define the RR update retransmit count.
411    The querier should plan to issure a query at 80%, 85%, 90%, 95% of the record lifetime.  */
412 #define NX_MDNS_RR_UPDATE_COUNT                 4
413 
414 
415 /* Define the Address length.  */
416 #define NX_MDNS_IPV4_ADDRESS_LENGTH             4
417 #define NX_MDNS_IPV6_ADDRESS_LENGTH             16
418 
419 
420 /* Define mDNS event flags.  */
421 #define NX_MDNS_ALL_EVENTS                      ((ULONG) 0xFFFFFFFF)    /* All event flags.                         */
422 #define NX_MDNS_PKT_RX_EVENT                    ((ULONG) 0x00000001)    /* Receive the mDNS packet.                 */
423 #define NX_MDNS_QUERY_SEND_EVENT                ((ULONG) 0x00000002)    /* Send the mDNS Query packet.              */
424 #define NX_MDNS_RESPONSE_SEND_EVENT             ((ULONG) 0x00000004)    /* Send the mDNS Response packet.           */
425 #define NX_MDNS_PROBING_SEND_EVENT              ((ULONG) 0x00000008)    /* Send the mDNS Probing packet.            */
426 #define NX_MDNS_ANNOUNCING_SEND_EVENT           ((ULONG) 0x00000010)    /* Send the mDNS Announcing packet.         */
427 #define NX_MDNS_GOODBYE_SEND_EVENT              ((ULONG) 0x00000020)    /* Send the mDNS Goodbye packet.            */
428 #define NX_MDNS_TIMER_EVENT                     ((ULONG) 0x00000040)    /* Process the mDNS timer event.            */
429 #define NX_MDNS_ADDRESS_CHANGE_EVENT            ((ULONG) 0x00000080)    /* Process the mDNS address change event.   */
430 #define NX_MDNS_RR_ELAPSED_TIMER_EVENT          ((ULONG) 0x00000100)    /* Process the mDNS rr elapsed tiemr event. */
431 
432 
433 /* Define return code constants.  */
434 #define NX_MDNS_SUCCESS                         0x00        /* mDNS Success.                                        */
435 #define NX_MDNS_ERROR                           0xA1        /* mDNS internal error.                                 */
436 #define NX_MDNS_PARAM_ERROR                     0xA2        /* mDNS parameters error.                               */
437 #define NX_MDNS_CACHE_ERROR                     0xA3        /* The Cache size is not enough.                        */
438 #define NX_MDNS_UNSUPPORTED_TYPE                0xA4        /* The unsupported resource record type.                */
439 #define NX_MDNS_DATA_SIZE_ERROR                 0xA5        /* The data size is too big.                            */
440 #define NX_MDNS_AUTH_ERROR                      0xA6        /* Attempting to parse too large a data.                */
441 #define NX_MDNS_PACKET_ERROR                    0xA7        /* The packet can not add the resource record.          */
442 #define NX_MDNS_DEST_ADDRESS_ERROR              0xA9        /* The destination address error.                       */
443 #define NX_MDNS_UDP_PORT_ERROR                  0xB0        /* The udp port error.                                  */
444 #define NX_MDNS_NOT_LOCAL_LINK                  0xB1        /* The message that not originate from the local link.  */
445 #define NX_MDNS_EXCEED_MAX_LABEL                0xB2        /* The data exceed the max laber size.                  */
446 #define NX_MDNS_EXIST_UNIQUE_RR                 0xB3        /* At least one Unqiue record in the cache.             */
447 #define NX_MDNS_EXIST_SHARED_RR                 0xB4        /* At least one shared record in the cache.             */
448 #define NX_MDNS_EXIST_SAME_QUERY                0xB5        /* Exist the same query record in the cache.            */
449 #define NX_MDNS_EXIST_SAME_SERVICE              0xB6        /* Exist the same service.                              */
450 #define NX_MDNS_NO_RR                           0xB7        /* No response for one-shot query.                      */
451 #define NX_MDNS_NO_KNOWN_ANSWER                 0xB8        /* No known answer for query.                           */
452 #define NX_MDNS_NAME_MISMATCH                   0xB9        /* The name mismatch.                                   */
453 #define NX_MDNS_NOT_STARTED                     0xC0        /* mDNS does not start.                                 */
454 #define NX_MDNS_HOST_NAME_ERROR                 0xC1        /* mDNS host name error.                                */
455 #define NX_MDNS_NO_MORE_ENTRIES                 0xC2        /* No more entries be found.                            */
456 #define NX_MDNS_SERVICE_TYPE_MISMATCH           0xC3        /* The service type mismatch                            */
457 #define NX_MDNS_NOT_ENABLED                     0xC4        /* mDNS does not enable.                                */
458 #define NX_MDNS_ALREADY_ENABLED                 0xC5        /* mDNS already enabled.                                */
459 
460 
461 /* Define the local host/service register notify state.  */
462 #define NX_MDNS_LOCAL_HOST_REGISTERED_SUCCESS   1           /* mDNS Server: Local host registered success.          */
463 #define NX_MDNS_LOCAL_HOST_REGISTERED_FAILURE   2           /* mDNS Server: Local host registered failure.          */
464 #define NX_MDNS_LOCAL_SERVICE_REGISTERED_SUCCESS 3          /* mDNS Server: Local service registered success.       */
465 #define NX_MDNS_LOCAL_SERVICE_REGISTERED_FAILURE 4          /* mDNS Server: Local service registered failure.       */
466 
467 /* Define the peer service change notify state.  */
468 #define NX_MDNS_PEER_SERVICE_RECEIVED           1           /* mDNS Client: Peer service received.                  */
469 #define NX_MDNS_PEER_SERVICE_DELETED            2           /* mDNS Client: Peer service deleted.                   */
470 #define NX_MDNS_PEER_SERVICE_UPDATED            3           /* mDNS Client: Peer service address updated.           */
471 
472 /* Define the cache notify state.  */
473 #define NX_MDNS_CACHE_STATE_FULL                1           /* mDNS Cache is full, and cannot fill the RR.          */
474 #define NX_MDNS_CACHE_STATE_FRAGMENTED          2           /* mDNS Cache is fragmented, and cannot fill the RR.    */
475 
476 /* Define cache type.  */
477 #define NX_MDNS_CACHE_TYPE_LOCAL                0           /* Local cache.                                         */
478 #define NX_MDNS_CACHE_TYPE_PEER                 1           /* Peer cache.                                          */
479 
480 
481 /* Define offsets into the DNS message buffer.  */
482 #define NX_MDNS_ID_OFFSET                       0           /* Offset to ID code in DNS buffer                      */
483 #define NX_MDNS_FLAGS_OFFSET                    2           /* Offset to flags in DNS buffer                        */
484 #define NX_MDNS_QDCOUNT_OFFSET                  4           /* Offset to Question Count in DNS buffer               */
485 #define NX_MDNS_ANCOUNT_OFFSET                  6           /* Offset to Answer Count in DNS buffer                 */
486 #define NX_MDNS_NSCOUNT_OFFSET                  8           /* Offset to Authority Count in DNS buffer              */
487 #define NX_MDNS_ARCOUNT_OFFSET                  10          /* Offset to Additional Info. Count in DNS buffer       */
488 #define NX_MDNS_QDSECT_OFFSET                   12          /* Offset to Question Section in DNS buffer             */
489 
490 
491 /* Define constants for the flags word.  */
492 #define NX_MDNS_QUERY_MASK                      0x0000
493 #define NX_MDNS_QUERY_FLAG                      0x0000
494 #define NX_MDNS_RESPONSE_FLAG                   0x8000
495 #define NX_MDNS_ERROR_MASK                      0x000F
496 #define NX_MDNS_TOP_BIT_MASK                    0x7FFF
497 
498 #define NX_MDNS_OPCODE_QUERY                    (0 << 12)   /* Shifted right 12 is still 0                          */
499 #define NX_MDNS_OPCODE_IQUERY                   (1 << 12)   /* 1 shifted right by 12                                */
500 #define NX_MDNS_OPCODE_STATUS                   (2 << 12)   /* 2 shifted right by 12                                */
501 
502 #define NX_MDNS_AA_FLAG                         0x0400      /* Authoritative Answer                                 */
503 #define NX_MDNS_TC_FLAG                         0x0200      /* Truncated                                            */
504 #define NX_MDNS_RD_FLAG                         0x0100      /* Recursive Query                                      */
505 #define NX_MDNS_RA_FLAG                         0x0080      /* Recursion Available                                  */
506 #define NX_MDNS_FA_FLAG                         0x0010      /* Force Authentication                                 */
507 
508 /* Define name compression masks.  */
509 #define NX_MDNS_COMPRESS_MASK                   0xc0
510 #define NX_MDNS_COMPRESS_VALUE                  0xc0
511 #define NX_MDNS_POINTER_MASK                    0xc000
512 
513 /* Define resource record types.  */
514 #define NX_MDNS_RR_TYPE_A                       1           /* Host address                                         */
515 #define NX_MDNS_RR_TYPE_NS                      2           /* Authoritative name server                            */
516 #define NX_MDNS_RR_TYPE_MD                      3           /* Mail destination (Obsolete - use MX)                 */
517 #define NX_MDNS_RR_TYPE_MF                      4           /* Mail forwarder (Obsolete - use MX)                   */
518 #define NX_MDNS_RR_TYPE_CNAME                   5           /* Canonical name for an alias                          */
519 #define NX_MDNS_RR_TYPE_SOA                     6           /* Marks the start of a zone of authority               */
520 #define NX_MDNS_RR_TYPE_MB                      7           /* Mailbox domain name (EXPERIMENTAL)                   */
521 #define NX_MDNS_RR_TYPE_MG                      8           /* Mail group member (EXPERIMENTAL)                     */
522 #define NX_MDNS_RR_TYPE_MR                      9           /* Mail rename domain name (EXPERIMENTAL)               */
523 #define NX_MDNS_RR_TYPE_NULL                    10          /* Null RR (EXPERIMENTAL)                               */
524 #define NX_MDNS_RR_TYPE_WKS                     11          /* Well known service description                       */
525 #define NX_MDNS_RR_TYPE_PTR                     12          /* Domain name pointer                                  */
526 #define NX_MDNS_RR_TYPE_HINFO                   13          /* Host information                                     */
527 #define NX_MDNS_RR_TYPE_MINFO                   14          /* Mailbox or mail list information                     */
528 #define NX_MDNS_RR_TYPE_MX                      15          /* Mail exchange                                        */
529 #define NX_MDNS_RR_TYPE_TXT                     16          /* Text strings                                         */
530 #define NX_MDNS_RR_TYPE_AAAA                    28          /* IPv6 Host address                                    */
531 #define NX_MDNS_RR_TYPE_SRV                     33          /* The location of services                             */
532 #define NX_MDNS_RR_TYPE_NSEC                    47          /* The type of NSEC RR.                                 */
533 
534 
535 /* Define constants for Qtypes (queries).  */
536 #define NX_MDNS_RR_TYPE_AXFR                    252         /* Request for a transfer of an entire zone             */
537 #define NX_MDNS_RR_TYPE_MAILB                   253         /* Request for mailbox-related records (MB, MG or MR)   */
538 #define NX_MDNS_RR_TYPE_MAILA                   254         /* Request for mail agent RRs (Obsolete - see MX)       */
539 #define NX_MDNS_RR_TYPE_ALL                     255         /* Request for all records                              */
540 
541 
542 /* Define resource record classes.  */
543 #define NX_MDNS_RR_CLASS_IN                     1           /* Internet                                             */
544 #define NX_MDNS_RR_CLASS_CS                     2           /* CSNET class (Obsolete)                               */
545 #define NX_MDNS_RR_CLASS_CH                     3           /* CHAOS class                                          */
546 #define NX_MDNS_RR_CLASS_HS                     4           /* Hesiod [Dyer 87]                                     */
547 #define NX_MDNS_RR_CLASS_ALL                    255         /* Any class                                            */
548 #define NX_MDNS_RR_CLASS_TOP_BIT                0x8000      /* The top bit of class.                                */
549 
550 
551 /* Define the resource record state value.  */
552 #define NX_MDNS_RR_STATE_INVALID                0           /* Invalid resource records.                            */
553 #define NX_MDNS_RR_STATE_PROBING                1           /* mDNS Server probing the resource records.            */
554 #define NX_MDNS_RR_STATE_ANNOUNCING             2           /* mDNS Server announcing the resource records.         */
555 #define NX_MDNS_RR_STATE_GOODBYE                3           /* mDNS Server send the Goodbye.                        */
556 #define NX_MDNS_RR_STATE_SUSPEND                4           /* mDNS Server suspend the resource record.             */
557 #define NX_MDNS_RR_STATE_QUERY                  5           /* mDNS Client send the initial query.                  */
558 #define NX_MDNS_RR_STATE_UPDATING               6           /* mDNS Client send the query to update the RR.         */
559 #define NX_MDNS_RR_STATE_DELETE                 7           /* mDNS Client delete the resource records.             */
560 #define NX_MDNS_RR_STATE_POOF_DELETE            8           /* mDNS Client delete the resource records by Passive Observation Of Failures.*/
561 #define NX_MDNS_RR_STATE_VALID                  9           /* Valid resource records.                              */
562 
563 
564 /* Define the sending type of resource records.  */
565 #define NX_MDNS_RR_SEND_FLAG_CLEAR              0x00        /* Response should not send the Resource records.       */
566 #define NX_MDNS_RR_SEND_MULTICAST               0x01        /* Send the Resource records via multicast.             */
567 #define NX_MDNS_RR_SEND_UNICAST                 0x02        /* Send the Resource records via unicast.               */
568 #define NX_MDNS_RR_SEND_FLAG_MASK               0xF0        /* The mask of send flag.                               */
569 
570 
571 /* Define resource record owner.  */
572 #define NX_MDNS_RR_OWNER_LOCAL                  0           /* Local Resource records.                              */
573 #define NX_MDNS_RR_OWNER_REMOTE                 1           /* Remote Resource records.                             */
574 
575 
576 /* Define resource record set.  */
577 #define NX_MDNS_RR_SET_SHARED                   0           /* Shared Resource records.                             */
578 #define NX_MDNS_RR_SET_UNIQUE                   1           /* Unique Resource records.                             */
579 
580 
581 /* Define the resource record state mask.  */
582 #define NX_MDNS_RR_FLAG_PEER                    0x0001      /* RR owner flag.                                       */
583 #define NX_MDNS_RR_FLAG_UNIQUE                  0x0002      /* RR set flag.                                         */
584 #define NX_MDNS_RR_FLAG_CONTINUOUS_QUERY        0x0004      /* RR query type flag.                                  */
585 #define NX_MDNS_RR_FLAG_DUPLICATE_QUERY         0x0008      /* RR duplicate query flag.                             */
586 #define NX_MDNS_RR_FLAG_ADDITIONAL              0x0010      /* RR additional flag.                                  */
587 #define NX_MDNS_RR_FLAG_UPDATING                0x0020      /* RR updating flag.                                    */
588 #define NX_MDNS_RR_FLAG_DELETE                  0x0040      /* RR delete flag.                                      */
589 #define NX_MDNS_RR_FLAG_ANSWER                  0x0080      /* RR answer flag.                                      */
590 #define NX_MDNS_RR_FLAG_KNOWN_ANSWER            0x0100      /* RR known answer flag.                                */
591 #define NX_MDNS_RR_FLAG_AUTHORIY_ANSWER         0x0200      /* RR authority answer flag.                            */
592 
593 
594 /* Define the type to search the same resource record.  */
595 #define NX_MDNS_RR_MATCH_ALL                    1           /* Match all data: name, type, class, rdata.            */
596 #define NX_MDNS_RR_MATCH_EXCEPT_RDATA           2           /* Match the name, type, class, except rdata.           */
597 
598 
599 /* Define the type to set/add the resource record in cache from packet.  */
600 #define NX_MDNS_RR_OP_LOCAL_SET_QUESTION        0           /* Set resource record question in local cache.         */
601 #define NX_MDNS_RR_OP_LOCAL_SET_ANSWER          1           /* Set resource record answer in local cache.           */
602 #define NX_MDNS_RR_OP_PEER_SET_QUESTION         2           /* Set resource record question in peer cache.          */
603 #define NX_MDNS_RR_OP_PEER_ADD_ANSWER           3           /* Add resource record answer in peer cache.            */
604 
605 
606 /* Define the type for adding question/answer RR into the packet.  */
607 #define NX_MDNS_PACKET_ADD_RR_QUESTION          1           /* Add the question resource record into packet.        */
608 #define NX_MDNS_PACKET_ADD_RR_ANSWER            2           /* Add the answer resource record into packet.          */
609 
610 
611 /* Define mDNS packet type.  */
612 #define NX_MDNS_PACKET_QUERY                    1           /* Query packet.                                        */
613 #define NX_MDNS_PACKET_PROBING                  2           /* Probing packet. Is specific query.                   */
614 #define NX_MDNS_PACKET_RESPONSE                 3           /* Response packet.                                     */
615 
616 
617 /* Define the Add NSEC type.  */
618 #define NX_MDNS_ADD_NSEC_FOR_HOST               0           /* Add the NSEC for host name.                          */
619 #define NX_MDNS_ADD_NSEC_FOR_SERVICE            1           /* Add the NSEC for service.                            */
620 
621 
622 /* Define the RDATA structure.  */
623 
624 /* A RDATA format
625       0                             1
626       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
627     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
628     |                     ADDRESS                   |
629     |                                               |
630     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
631 */
632 
633 typedef struct NX_MDNS_RR_A_STRUCT
634 {
635     ULONG           nx_mdns_rr_a_address;
636 } NX_MDNS_RR_A;
637 
638 
639 /* NS RDATA format
640       0                             1
641       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
642     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
643     /                     NSDNAME                   /
644     /                                               /
645     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
646 */
647 
648 typedef struct NX_MDNS_RR_NS_STRUCT
649 {
650     UCHAR*          nx_mdns_rr_ns_name;
651 } NX_MDNS_RR_NS;
652 
653 /* MD RDATA format
654       0                             1
655       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
656     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
657     /                     MADNAME                   /
658     /                                               /
659     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
660 */
661 
662 typedef struct NX_MDNS_RR_MD_STRUCT
663 {
664     UCHAR*          nx_mdns_rr_md_name;
665 } NX_MDNS_RR_MD;
666 
667 /* MF RDATA format
668       0                             1
669       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
670     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
671     /                     MADNAME                   /
672     /                                               /
673     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
674 */
675 
676 typedef struct NX_MDNS_RR_MF_STRUCT
677 {
678     UCHAR*          nx_mdns_rr_mf_name;
679 } NX_MDNS_RR_MF;
680 
681 /* CNMAE RDATA format
682       0                             1
683       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
684     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
685     /                     CNAME                     /
686     /                                               /
687     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
688 */
689 
690 typedef struct NX_MDNS_RR_CNAME_STRUCT
691 {
692     UCHAR*          nx_mdns_rr_cname_name;
693 } NX_MDNS_RR_CNAME;
694 
695 /* SOA RDATA format
696       0                             1
697       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
698     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
699     /                     MNAME                     /
700     /                                               /
701     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
702     /                     RNAME                     /
703     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
704     |                     SERIAL                    |
705     |                                               |
706     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
707     |                     REFRESH                   |
708     |                                               |
709     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
710     |                     RETRY                     |
711     |                                               |
712     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
713     |                     EXPIRE                    |
714     |                                               |
715     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
716     |                     MINMUM                    |
717     |                                               |
718     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
719 */
720 
721 typedef struct NX_MDNS_RR_SOA_STRUCT
722 {
723     UCHAR*          nx_mdns_rr_soa_mname;
724     UCHAR*          nx_mdns_rr_soa_rname;
725     ULONG           nx_mdns_rr_soa_serial;
726     ULONG           nx_mdns_rr_soa_refresh;
727     ULONG           nx_mdns_rr_soa_retry;
728     ULONG           nx_mdns_rr_soa_expire;
729     ULONG           nx_mdns_rr_soa_minmum;
730 } NX_MDNS_RR_SOA;
731 
732 /* MB RDATA format
733       0                             1
734       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
735     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
736     /                     MADNAME                   /
737     /                                               /
738     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
739 */
740 
741 typedef struct NX_MDNS_RR_MB_STRUCT
742 {
743     UCHAR*          nx_mdns_rr_mb_name;
744 } NX_MDNS_RR_MB;
745 
746 /* MG RDATA format
747       0                             1
748       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
749     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
750     /                     MGMNAME                   /
751     /                                               /
752     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
753 */
754 
755 typedef struct NX_MDNS_RR_MG_STRUCT
756 {
757     UCHAR*          nx_mdns_rr_mg_name;
758 } NX_MDNS_RR_MG;
759 
760 /* MR RDATA format
761       0                             1
762       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
763     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
764     /                     NEWNAME                   /
765     /                                               /
766     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
767 */
768 
769 typedef struct NX_MDNS_RR_MR_STRUCT
770 {
771     UCHAR*          nx_mdns_rr_mr_name;
772 } NX_MDNS_RR_MR;
773 
774 /* NULL RDATA format
775       0                             1
776       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
777     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
778     /                   <anything>                  /
779     /                                               /
780     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
781 */
782 
783 typedef struct NX_MDNS_RR_NULL_STRUCT
784 {
785     UCHAR*          nx_mdns_rr_null_ptr;
786 } NX_MDNS_RR_NULL;
787 
788 /* WKS RDATA format
789       0                             1
790       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
791     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
792     |                     ADDRESS                   |
793     |                                               |
794     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
795     |      PROTOCOL         |                       |
796     |--+--+--+--+--+--+--+--+                       |
797     /                   <BIT MAP>                   /
798     /                                               /
799     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
800 */
801 
802 typedef struct NX_MDNS_RR_WKS_STRUCT
803 {
804     ULONG           nx_mdns_rr_wks_address;
805     UCHAR           nx_mdns_rr_wks_protocol;
806     UCHAR           nx_mdns_rr_wks_reserved[3];
807     UCHAR*          nx_mdns_rr_wks_bit_map;
808 } NX_MDNS_RR_WKS;
809 
810 /* PTR RDATA format
811       0                             1
812       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
813     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
814     /                     PTRDNAME                  /
815     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
816 */
817 
818 typedef struct NX_MDNS_RR_PTR_STRUCT
819 {
820     UCHAR*          nx_mdns_rr_ptr_name;
821 } NX_MDNS_RR_PTR;
822 
823 /* HINFO RDATA format
824       0                             1
825       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
826     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
827     /                     CPU                       /
828     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
829     /                     OS                        /
830     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
831 */
832 
833 typedef struct NX_MDNS_RR_HINFO_STRUCT
834 {
835     UCHAR*          nx_mdns_rr_hinfo_cpu;
836     UCHAR*          nx_mdns_rr_hinfo_os;
837 } NX_MDNS_RR_HINFO;
838 
839 /* MINFO RDATA format
840       0                             1
841       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
842     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
843     /                     RMAILBX                   /
844     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
845     /                     EMAILBX                   /
846     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
847 */
848 
849 typedef struct NX_MDNS_RR_MINFO_STRUCT
850 {
851     UCHAR*          nx_mdns_rr_minfo_cpu;
852     UCHAR*          nx_mdns_rr_minfo_os;
853 } NX_MDNS_RR_MINFO;
854 
855 /* MX RDATA format
856       0                             1
857       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
858     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
859     |                     PREFERENCE                |
860     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
861     /                     NEWNAME                   /
862     /                                               /
863     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
864 */
865 
866 typedef struct NX_MDNS_RR_MX_STRUCT
867 {
868     UCHAR*          nx_mdns_rr_mx_name;
869     USHORT          nx_mdns_rr_mx_preference;
870     USHORT          nx_mdns_rr_mx_reserved;
871 } NX_MDNS_RR_MX;
872 
873 /* TXT RDATA format
874       0                             1
875       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
876     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
877     /                     TXT-DATA                  /
878     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
879 */
880 
881 typedef struct NX_MDNS_RR_TXT_STRUCT
882 {
883     UCHAR*          nx_mdns_rr_txt_data;
884 } NX_MDNS_RR_TXT;
885 
886 /* AAAA RDATA format
887       0                             1
888       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
889     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
890     |                                               |
891     |                                               |
892     |                                               |
893     |                   IPv6 ADDRESS                |
894     |                                               |
895     |                                               |
896     |                                               |
897     |                                               |
898     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
899 */
900 
901 typedef struct NX_MDNS_RR_AAAA_STRUCT
902 {
903     ULONG           nx_mdns_rr_aaaa_address[4];
904 } NX_MDNS_RR_AAAA;
905 
906 /* SRV RDATA format
907       0                             1
908       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
909     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
910     |                     PRIORITY                  |
911     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
912     |                     WEIGHTS                   |
913     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
914     |                     PORT                      |
915     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
916     /                     TARGET                    /
917     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
918 */
919 
920 typedef struct NX_MDNS_RR_SRV_STRUCT
921 {
922     UCHAR*          nx_mdns_rr_srv_target;
923     USHORT          nx_mdns_rr_srv_priority;
924     USHORT          nx_mdns_rr_srv_weights;
925     USHORT          nx_mdns_rr_srv_port;
926     USHORT          nx_mdns_rr_srv_reserved;
927 } NX_MDNS_RR_SRV;
928 
929 
930 /* NSEC RDATA format
931       0                             1
932       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
933     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
934     /                Next Domain Name               /
935     /                                               /
936     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
937     /                Type Bit Maps                  /
938     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
939 */
940 
941 typedef struct NX_MDNS_RR_NSEC_STRUCT
942 {
943     UCHAR*          nx_mdns_rr_nsec_next_domain;
944     UCHAR           nx_mdns_rr_nsec_window_block;
945     UCHAR           nx_mdns_rr_nsec_bitmap_length;
946     UCHAR           nx_mdns_rr_nsec_bitmap[5];          /* Can match the max rr type 6 * 7 = 42.  */
947     UCHAR           nx_mdns_rr_nsec_additional_send;    /* 0 indicate answer, 1 indicate additional.  */
948 } NX_MDNS_RR_NSEC;
949 
950 
951 /* RR definitions. RFC1035.  */
952 /* RR Format.
953       0                             1
954       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
955     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
956     |                                               |
957     /                      NAME                     /
958     /                                               /
959     |                                               |
960     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
961     |                      TYPE                     |
962     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
963     |                      CLASS                    |
964     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
965     |                      TTL                      |
966     |                                               |
967     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
968     |                      RDLENGTH                 |
969     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
970     /                      RDATA                    /
971     /                                               /
972     |--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
973 */
974 
975 /* The following data structure is used to store the resource records(RRs). */
976 typedef struct NX_MDNS_RR_STRUCT
977 {
978 
979     UCHAR*  nx_mdns_rr_name;                    /* Owner's name,i.e., the name of the node to
980                                                    which this resource record pertains.                                 */
981 
982     USHORT  nx_mdns_rr_type;                    /* RR TYPE.                                                             */
983 
984     USHORT  nx_mdns_rr_class;                   /* RR CLASS.                                                            */
985 
986     ULONG   nx_mdns_rr_ttl;                     /* The time interval that the RR may be cached before the source of
987                                                    the information should again be consulted.                           */
988 
989     USHORT  nx_mdns_rr_rdata_length;            /* The length of rdata. nx_mdns_rr_rdata                                */
990 
991     UCHAR   nx_mdns_rr_state;                   /* The resource records state, Probing, Annoncing, Valid.               */
992 
993     UCHAR   nx_mdns_rr_retransmit_count;        /* Define the count for the retransmit the RR.                          */
994 
995     ULONG   nx_mdns_rr_retransmit_lifetime;     /* Define the lifetime for retransmit the RR.                           */
996 
997     ULONG   nx_mdns_rr_timer_count;             /* Define the timer count for the retransmit the RR.                    */
998 
999     ULONG   nx_mdns_rr_elapsed_time;            /* Define the time elasped for the peer RR.                             */
1000 
1001     ULONG   nx_mdns_rr_remaining_ticks;         /* Define the remaining ticks of the peer RR.                           */
1002 
1003     ULONG   nx_mdns_rr_response_interval;       /* Define the time interval for two responses. Local RR.                */
1004 
1005     UCHAR   nx_mdns_rr_interface_index;         /* RR interface index.                                                  */
1006 
1007     UCHAR   nx_mdns_rr_announcing_max_time;     /* RR announcing max time. Local RR.                                    */
1008 
1009     UCHAR   nx_mdns_rr_conflict_count;          /* The conflict count of service name or host name. Local RR.           */
1010 
1011     UCHAR   nx_mdns_rr_poof_count;              /* The Passive Observation Of Failures count of resource record. Peer RR.*/
1012 
1013     UCHAR   nx_mdns_rr_count;                   /* The count of same _services._dns-sd._udp.local PTR resource reocrd.  */
1014 
1015     UCHAR   nx_mdns_rr_send_flag;               /* The flag for seding resource record.                                 */
1016 
1017     USHORT  nx_mdns_rr_word;
1018 
1019     /* Define the state, owner, flag, set of the resource records. This word contains
1020        the following information:
1021 
1022             bits 0      RR Owner, the owner of resource record,
1023                         0 indicates local RR, 1 indicates peer RR.
1024             bits 1      RR Set, the set of resource record,
1025                         0 indicates shared RR, 1 indicates unique RR.
1026             bits 2      RR query type, the query type of resource record,
1027                         0 indicates query the RR use One-shot method, 1 indicates query the RR use Continuous method.
1028             bits 3      RR additional flag, send this resource record as the additional RR.
1029             bits 4      RR query duplicate flag, this resource record is the duplicate quesiton.
1030             bits 5      RR updating flag, this resource record need to be maintenance.
1031             bits 6      RR delete flag, this resource record need to be deleted.
1032             bits 7      RR answer flag, this resource record has been added in answer section.
1033             bits 8      RR known answer flag, send this resource record as the known answer.
1034             bits 9      RR authority answer flag, send this resource record as the authority answer.
1035     */
1036 
1037     /* Union that holds resource record data. */
1038     union   nx_mdns_rr_rdata_union
1039     {
1040         NX_MDNS_RR_A        nx_mdns_rr_rdata_a;
1041         NX_MDNS_RR_AAAA     nx_mdns_rr_rdata_aaaa;
1042         NX_MDNS_RR_PTR      nx_mdns_rr_rdata_ptr;
1043         NX_MDNS_RR_SRV      nx_mdns_rr_rdata_srv;
1044         NX_MDNS_RR_TXT      nx_mdns_rr_rdata_txt;
1045 
1046 #ifdef NX_MDNS_ENABLE_SERVER_NEGATIVE_RESPONSES
1047         NX_MDNS_RR_NSEC     nx_mdns_rr_rdata_nsec;
1048 #endif /* NX_MDNS_ENABLE_SERVER_NEGATIVE_RESPONSES  */
1049 
1050 #ifdef NX_MDNS_ENABLE_EXTENDED_RR_TYPES
1051         NX_MDNS_RR_CNAME    nx_mdns_rr_rdata_cname;
1052         NX_MDNS_RR_NS       nx_mdns_rr_rdata_ns;
1053         NX_MDNS_RR_MX       nx_mdns_rr_rdata_mx;
1054 #endif /* NX_MDNS_ENABLE_EXTENDED_RR_TYPES  */
1055     } nx_mdns_rr_rdata;
1056 
1057 }NX_MDNS_RR;
1058 
1059 /* Buffer usage. */
1060 /*
1061 
1062     |-----------+-----------+-----------+-----------+-----------+------------+-----------+------------+------------|
1063     |   HEAD    |NX_MDNS_RR |NX_MDNS_RR | ..........|  STRING   | CNT | LEN  |  STRING   | CNT | LEN  |    TAIL    |
1064     |-----------+-----------+-----------+-----------+-----------+------------+-----------+------------+------------|
1065 
1066     HEAD: First unused memory at the front of cache. The size is 4 bytes.
1067     NX_MDNS_RR: The Resource Record struct, the size is sizeof(NX_MDNS_RR).
1068     TAIL: It points to the last used memory at the back of cache. Its size is 4 bytes.
1069     LEN: It is the length of STRING, plus the CNT and LEN fields. This field takes 2 bytes.
1070     CNT: It is the reference count of STRING. It takes 2 bytes.
1071     STRING: The content of name string and rdata string, must be null-terminated. Padded with 0s to be 4 byte aligned.
1072 */
1073 
1074 
1075 /* Define the Service structure.  */
1076 typedef struct NX_MDNS_SERVICE_STRUCT
1077 {
1078 
1079     UCHAR*                  service_name;           /* Service instance.                                    */
1080 
1081     UCHAR*                  service_type;           /* Service type.                                        */
1082 
1083     UCHAR*                  service_domain;         /* Service domain.                                      */
1084 
1085     UCHAR                   service_text[NX_MDNS_NAME_MAX+1];       /* Service txt information.             */
1086 
1087     UCHAR                   service_host[NX_MDNS_HOST_NAME_MAX + 1];    /* The target host of the service.  */
1088 
1089     USHORT                  service_port;           /* Service port.                                        */
1090 
1091     USHORT                  service_weight;         /* Service weight.                                      */
1092 
1093     USHORT                  service_priority;       /* Service priority.                                    */
1094 
1095     UCHAR                   interface_index;        /* Service interface idnex.                             */
1096 
1097     UCHAR                   service_text_valid;     /* Flag indicating text fields are valid.               */
1098 
1099     ULONG                   service_ipv4;           /* The IPv4 address for service.                        */
1100 
1101     ULONG                   service_ipv6[NX_MDNS_IPV6_ADDRESS_COUNT][4];    /* The IPv6 address for service.*/
1102 
1103     UCHAR                   buffer[NX_MDNS_NAME_MAX+1]; /* The buffer for service instance, type and domain.*/
1104 
1105 } NX_MDNS_SERVICE;
1106 
1107 
1108 /* Define the basic Multicast DNS data structure.  */
1109 
1110 typedef struct NX_MDNS_STRUCT
1111 {
1112     ULONG                   nx_mdns_id;             /* Multicast DNS ID.                                    */
1113 
1114     NX_IP*                  nx_mdns_ip_ptr;         /* Pointer to associated IP structure.                  */
1115 
1116     NX_UDP_SOCKET           nx_mdns_socket;         /* Multicast DNS Socket.                                */
1117 
1118     TX_MUTEX                nx_mdns_mutex;          /* Multicast DNS Mutex.                                 */
1119 
1120     TX_TIMER                nx_mdns_timer;          /* Multicast DNS TIMER.                                 */
1121 
1122     TX_THREAD               nx_mdns_thread;         /* Multicast DNS processing thread.                     */
1123 
1124     TX_EVENT_FLAGS_GROUP    nx_mdns_events;         /* Multicast DNS event.                                 */
1125 
1126     NX_PACKET_POOL*         nx_mdns_packet_pool_ptr;    /* Pointer to the packet pool.                      */
1127 
1128     UCHAR                   nx_mdns_host_name[NX_MDNS_HOST_NAME_MAX];   /* The Embedded Device name supplied at create.  */
1129 
1130     UCHAR                   nx_mdns_domain_name[NX_MDNS_DOMAIN_NAME_MAX + 1];   /* The mDNS domain name.    */
1131 
1132     UINT                    nx_mdns_interface_enabled[NX_MAX_PHYSICAL_INTERFACES];  /* Interface enable status. */
1133 
1134 #ifdef NX_MDNS_ENABLE_IPV6
1135     UINT                    nx_mdns_ipv6_address_index[NX_MAX_PHYSICAL_INTERFACES]; /* IPv6 link local address index.   */
1136 #endif /* NX_MDNS_ENABLE_IPV6  */
1137 
1138     /* Define the UDP receive suspension list head associated with a count of
1139        how many threads are suspended attempting to receive from the same TCP port.  */
1140     TX_THREAD*              nx_mdns_rr_receive_suspension_list;                 /* The suspended thread.    */
1141 
1142     ULONG                   nx_mdns_rr_receive_suspended_count;                 /* The suspended count.     */
1143 
1144     UCHAR*                  nx_mdns_local_service_cache;        /* Pointer to the cache.                    */
1145 
1146     UINT                    nx_mdns_local_service_cache_size;   /* The size of cache.                       */
1147 
1148     UCHAR*                  nx_mdns_peer_service_cache;         /* Pointer to the cache.                    */
1149 
1150     UINT                    nx_mdns_peer_service_cache_size;    /* The size of cache.                       */
1151 
1152     ULONG                   nx_mdns_service_ignore_mask;        /* The mask specifying services types to be ignored.                        */
1153 
1154     ULONG                   nx_mdns_service_notify_mask;        /* The service mask for listen the service and notify the applicaiton.      */
1155 
1156     ULONG                   nx_mdns_timer_min_count;            /* The minimum timer count indicate the intervals between last timer event and next timer event. */
1157 
1158     USHORT                  nx_mdns_announcing_period;          /* Number of ticks for the initial period. Default value is 1 second.       */
1159 
1160     USHORT                  nx_mdns_announcing_retrans_interval;    /* Number of ticks to wait ticks before sending out repeated announcement message. */
1161 
1162     ULONG                   nx_mdns_announcing_period_interval;     /* Number of ticks between two announcing period.                       */
1163 
1164     UCHAR                   nx_mdns_announcing_count;           /* Number of repetitions between one announcing period. Default value is 1. */
1165 
1166     UCHAR                   nx_mdns_announcing_factor;          /* Telescopic factor, default value is 0. 2^k.                              */
1167 
1168     UCHAR                   nx_mdns_announcing_max_time;        /* Max time of Announcing period, default value is 3.                       */
1169 
1170     UCHAR                   nx_mdns_started;                    /* mDNS task has been started.                                              */
1171 
1172     ULONG                   nx_mdns_local_rr_count;             /* The number of resource records in the local cache.                       */
1173 
1174     ULONG                   nx_mdns_local_string_count;         /* The number of strings in the local cache.                                */
1175 
1176     ULONG                   nx_mdns_local_string_bytes;         /* The number of total bytes in string table in the local cache.            */
1177 
1178     ULONG                   nx_mdns_peer_rr_count;              /* The number of resource records in the peer cache.                        */
1179 
1180     ULONG                   nx_mdns_peer_string_count;          /* The number of strings in the peer cache.                                 */
1181 
1182     ULONG                   nx_mdns_peer_string_bytes;          /* The number of total bytes in string table in the peer cache.             */
1183 
1184     ULONG                   nx_mdns_first_probing_delay;        /* The delay of first probing for unique RR.                                */
1185 
1186     VOID                    (*nx_mdns_probing_notify)(struct NX_MDNS_STRUCT *, UCHAR *, UINT);
1187 
1188     VOID                    (*nx_mdns_service_change_notify)(struct NX_MDNS_STRUCT *, struct NX_MDNS_SERVICE_STRUCT *, UINT);
1189 
1190     VOID                    (*nx_mdns_cache_full_notify)(struct NX_MDNS_STRUCT *, UINT, UINT);
1191 
1192 } NX_MDNS;
1193 
1194 
1195 #ifndef NX_MDNS_SOURCE_CODE
1196 
1197 /* Application caller is present, perform API mapping.  */
1198 
1199 /* Determine if error checking is desired. If so, map mDNS API functions
1200    to the appropriate error checking front-ends.  Otherwise, map API
1201    functions to the core functions that actually perform the work.
1202    Note: error checking is enabled by default.  */
1203 
1204 #ifdef NX_DISABLE_ERROR_CHECKING
1205 
1206 /* Services without error checking.  */
1207 
1208 #define nx_mdns_create                          _nx_mdns_create
1209 #define nx_mdns_delete                          _nx_mdns_delete
1210 #define nx_mdns_enable                          _nx_mdns_enable
1211 #define nx_mdns_disable                         _nx_mdns_disable
1212 #define nx_mdns_cache_notify_set                _nx_mdns_cache_notify_set
1213 #define nx_mdns_cache_notify_clear              _nx_mdns_cache_notify_clear
1214 #define nx_mdns_domain_name_set                 _nx_mdns_domain_name_set
1215 
1216 #ifndef NX_MDNS_DISABLE_SERVER
1217 #define nx_mdns_service_announcement_timing_set _nx_mdns_service_announcement_timing_set
1218 #define nx_mdns_service_add                     _nx_mdns_service_add
1219 #define nx_mdns_service_delete                  _nx_mdns_service_delete
1220 #define nx_mdns_local_cache_clear               _nx_mdns_local_cache_clear
1221 #endif /* NX_MDNS_DISABLE_SERVER  */
1222 
1223 #ifndef NX_MDNS_DISABLE_CLIENT
1224 #define nx_mdns_service_one_shot_query          _nx_mdns_service_one_shot_query
1225 #define nx_mdns_service_continuous_query        _nx_mdns_service_continuous_query
1226 #define nx_mdns_service_query_stop              _nx_mdns_service_query_stop
1227 #define nx_mdns_service_lookup                  _nx_mdns_service_lookup
1228 #define nx_mdns_service_ignore_set              _nx_mdns_service_ignore_set
1229 #define nx_mdns_service_notify_set              _nx_mdns_service_notify_set
1230 #define nx_mdns_service_notify_clear            _nx_mdns_service_notify_clear
1231 #define nx_mdns_host_address_get                _nx_mdns_host_address_get
1232 #define nx_mdns_peer_cache_clear                _nx_mdns_peer_cache_clear
1233 #endif /* NX_MDNS_DISABLE_CLIENT  */
1234 
1235 #else
1236 
1237 #define nx_mdns_create                          _nxe_mdns_create
1238 #define nx_mdns_delete                          _nxe_mdns_delete
1239 #define nx_mdns_enable                          _nxe_mdns_enable
1240 #define nx_mdns_disable                         _nxe_mdns_disable
1241 #define nx_mdns_cache_notify_set                _nxe_mdns_cache_notify_set
1242 #define nx_mdns_cache_notify_clear              _nxe_mdns_cache_notify_clear
1243 #define nx_mdns_domain_name_set                 _nxe_mdns_domain_name_set
1244 
1245 #ifndef NX_MDNS_DISABLE_SERVER
1246 #define nx_mdns_service_announcement_timing_set _nxe_mdns_service_announcement_timing_set
1247 #define nx_mdns_service_add                     _nxe_mdns_service_add
1248 #define nx_mdns_service_delete                  _nxe_mdns_service_delete
1249 #define nx_mdns_local_cache_clear               _nxe_mdns_local_cache_clear
1250 #endif /* NX_MDNS_DISABLE_SERVER  */
1251 
1252 #ifndef NX_MDNS_DISABLE_CLIENT
1253 #define nx_mdns_service_one_shot_query          _nxe_mdns_service_one_shot_query
1254 #define nx_mdns_service_continuous_query        _nxe_mdns_service_continuous_query
1255 #define nx_mdns_service_query_stop              _nxe_mdns_service_query_stop
1256 #define nx_mdns_service_lookup                  _nxe_mdns_service_lookup
1257 #define nx_mdns_service_ignore_set              _nxe_mdns_service_ignore_set
1258 #define nx_mdns_service_notify_set              _nxe_mdns_service_notify_set
1259 #define nx_mdns_service_notify_clear            _nxe_mdns_service_notify_clear
1260 #define nx_mdns_host_address_get                _nxe_mdns_host_address_get
1261 #define nx_mdns_peer_cache_clear                _nxe_mdns_peer_cache_clear
1262 #endif /* NX_MDNS_DISABLE_CLIENT  */
1263 
1264 #endif  /* NX_DISABLE_ERROR_CHECKING */
1265 
1266 #endif   /* NX_MDNS_SOURCE_CODE */
1267 
1268 
1269 /* Define Thread function prototypes.  */
1270 UINT        _nx_mdns_create(NX_MDNS *mdns_ptr, NX_IP *ip_ptr, NX_PACKET_POOL *packet_pool,
1271                             UINT priority, VOID *stack_ptr, ULONG stack_size, UCHAR *host_name,
1272                             VOID *local_cache_ptr, UINT local_cache_size,
1273                             VOID *peer_cache_ptr, UINT peer_cache_size,
1274                             VOID (*probing_notify)(NX_MDNS *mdns_ptr, UCHAR *name, UINT probing_state));
1275 UINT        _nxe_mdns_create(NX_MDNS *mdns_ptr, NX_IP *ip_ptr, NX_PACKET_POOL *packet_pool,
1276                              UINT priority, VOID *stack_ptr, ULONG stack_size, UCHAR *host_name,
1277                              VOID *local_cache_ptr, UINT local_cache_size,
1278                              VOID *peer_cache_ptr, UINT peer_cache_size,
1279                              VOID (*probing_notify)(NX_MDNS *mdns_ptr, UCHAR *name, UINT probing_state));
1280 UINT        _nx_mdns_delete(NX_MDNS *mdns_ptr);
1281 UINT        _nxe_mdns_delete(NX_MDNS *mdns_ptr);
1282 UINT        _nx_mdns_enable(NX_MDNS *mdns_ptr, UINT interface_index);
1283 UINT        _nxe_mdns_enable(NX_MDNS *mdns_ptr, UINT interface_index);
1284 UINT        _nx_mdns_disable(NX_MDNS *mdns_ptr, UINT interface_index);
1285 UINT        _nxe_mdns_disable(NX_MDNS *mdns_ptr, UINT interface_index);
1286 UINT        _nx_mdns_cache_notify_set(NX_MDNS *mdns_ptr, VOID (*cache_full_notify_cb)(NX_MDNS *mdns_ptr, UINT state, UINT cache_type));
1287 UINT        _nxe_mdns_cache_notify_set(NX_MDNS *mdns_ptr, VOID (*cache_full_notify_cb)(NX_MDNS *mdns_ptr, UINT state, UINT cache_type));
1288 UINT        _nx_mdns_cache_notify_clear(NX_MDNS *mdns_ptr);
1289 UINT        _nxe_mdns_cache_notify_clear(NX_MDNS *mdns_ptr);
1290 UINT        _nx_mdns_domain_name_set(NX_MDNS *mdns_ptr, UCHAR *domain_name);
1291 UINT        _nxe_mdns_domain_name_set(NX_MDNS *mdns_ptr, UCHAR *domain_name);
1292 
1293 #ifndef NX_MDNS_DISABLE_SERVER
1294 UINT        _nx_mdns_service_announcement_timing_set(NX_MDNS *mdns_ptr, UINT t, UINT p, UINT k, UINT retrans_interval, ULONG period_interval, UINT max_time);
1295 UINT        _nxe_mdns_service_announcement_timing_set(NX_MDNS *mdns_ptr, UINT t, UINT p, UINT k, UINT retrans_interval, ULONG period_interval, UINT max_time);
1296 UINT        _nx_mdns_service_add(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, UCHAR *txt, ULONG ttl,
1297                                  USHORT priority, USHORT weights, USHORT port, UCHAR is_unique, UINT interface_index);
1298 UINT        _nxe_mdns_service_add(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, UCHAR *txt, ULONG ttl,
1299                                   USHORT priority, USHORT weights, USHORT port, UCHAR is_unique, UINT interface_index);
1300 UINT        _nx_mdns_service_delete(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1301 UINT        _nxe_mdns_service_delete(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1302 UINT        _nx_mdns_local_cache_clear(NX_MDNS *mdns_ptr);
1303 UINT        _nxe_mdns_local_cache_clear(NX_MDNS *mdns_ptr);
1304 #endif /* NX_MDNS_DISABLE_SERVER  */
1305 
1306 #ifndef NX_MDNS_DISABLE_CLIENT
1307 UINT        _nx_mdns_service_one_shot_query(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, NX_MDNS_SERVICE *service, UINT timeout);
1308 UINT        _nxe_mdns_service_one_shot_query(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, NX_MDNS_SERVICE *service, UINT timeout);
1309 UINT        _nx_mdns_service_continuous_query(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1310 UINT        _nxe_mdns_service_continuous_query(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1311 UINT        _nx_mdns_service_query_stop(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1312 UINT        _nxe_mdns_service_query_stop(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type);
1313 UINT        _nx_mdns_service_lookup(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, UINT service_index, NX_MDNS_SERVICE *service);
1314 UINT        _nxe_mdns_service_lookup(NX_MDNS *mdns_ptr, UCHAR *name, UCHAR *type, UCHAR *sub_type, UINT service_index, NX_MDNS_SERVICE *service);
1315 UINT        _nx_mdns_service_ignore_set(NX_MDNS *mdns_ptr, ULONG service_mask);
1316 UINT        _nxe_mdns_service_ignore_set(NX_MDNS *mdns_ptr, ULONG service_mask);
1317 UINT        _nx_mdns_service_notify_set(NX_MDNS *mdns_ptr, ULONG service_mask,
1318                                         VOID (*service_change_notify)(NX_MDNS *mdns_ptr, NX_MDNS_SERVICE *service_ptr, UINT state));
1319 UINT        _nxe_mdns_service_notify_set(NX_MDNS *mdns_ptr, ULONG service_mask,
1320                                         VOID (*service_change_notify)(NX_MDNS *mdns_ptr, NX_MDNS_SERVICE *service_ptr, UINT state));
1321 UINT        _nx_mdns_service_notify_clear(NX_MDNS *mdns_ptr);
1322 UINT        _nxe_mdns_service_notify_clear(NX_MDNS *mdns_ptr);
1323 UINT        _nx_mdns_host_address_get(NX_MDNS *mdns_ptr, UCHAR *host_name, ULONG *ipv4_address, ULONG *ipv6_address, UINT timeout);
1324 UINT        _nxe_mdns_host_address_get(NX_MDNS *mdns_ptr, UCHAR *host_name, ULONG *ipv4_address, ULONG *ipv6_address, UINT timeout);
1325 UINT        _nx_mdns_peer_cache_clear(NX_MDNS *mdns_ptr);
1326 UINT        _nxe_mdns_peer_cache_clear(NX_MDNS *mdns_ptr);
1327 #endif /* NX_MDNS_DISABLE_CLIENT  */
1328 
1329 
1330 /* Determine if a C++ compiler is being used.  If so, complete the standard
1331    C conditional started above.  */
1332 #ifdef   __cplusplus
1333         }
1334 #endif
1335 
1336 #endif  /* NXD_MDNS_H */
1337 
1338