2 * Copyright (c) 2019-2020 Apple Inc. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * https://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __DNSSD_PRIVATE_H__
18 #define __DNSSD_PRIVATE_H__
20 #include <dispatch/dispatch.h>
23 #include <os/object.h>
25 #if OS_OBJECT_USE_OBJC
26 #define DNSSD_DECL(NAME) OS_OBJECT_DECL_SUBCLASS(dnssd_ ## NAME, dnssd_object)
27 #define DNSSD_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
29 OS_OBJECT_DECL(dnssd_object
,);
31 #define DNSSD_DECL(NAME) typedef struct dnssd_ ## NAME ## _s * dnssd_ ## NAME ## _t
32 #define DNSSD_RETURNS_RETAINED
37 #define DNSSD_ASSUME_NONNULL_BEGIN OS_ASSUME_NONNULL_BEGIN
38 #define DNSSD_ASSUME_NONNULL_END OS_ASSUME_NONNULL_END
40 DNSSD_DECL(getaddrinfo
);
41 DNSSD_DECL(getaddrinfo_result
);
42 DNSSD_DECL(cname_array
);
44 DNSSD_ASSUME_NONNULL_BEGIN
46 #if OS_OBJECT_USE_OBJC
47 typedef dnssd_object_t dnssd_any_t
;
49 #if !defined(__cplusplus)
51 dnssd_object_t object
;
52 dnssd_getaddrinfo_t gai
;
53 dnssd_getaddrinfo_result_t gai_result
;
54 dnssd_cname_array_t cname_array
;
55 } dnssd_any_t
__attribute__((__transparent_union__
));
57 typedef void * dnssd_any_t
;
61 #define DNSSD_MALLOC __attribute__((__malloc__))
62 #define DNSSD_AVAILABLE SPI_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0))
64 #if __has_attribute(noescape)
65 #define DNSSD_NOESCAPE __attribute__((__noescape__))
67 #define DNSSD_NOESCAPE
74 * Increments the reference count of a dnssd object.
80 * Calls to dnssd_retain() must be balanced with calls to dnssd_release().
84 dnssd_retain(dnssd_any_t object
);
85 #if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
87 #define dnssd_retain(object) [(object) retain]
92 * Decrements the reference count of a dnssd object.
98 * Calls to dnssd_retain() must be balanced with calls to dnssd_release().
102 dnssd_release(dnssd_any_t object
);
103 #if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
105 #define dnssd_release(object) [(object) release]
111 * Provides a textual description of a dnssd object.
117 * Textual description of the object as a C string.
120 * The string returned by this function must be released with <code>free(3)</code>.
123 DNSSD_MALLOC
char * _Nullable
124 dnssd_copy_description(dnssd_any_t object
);
128 * Creates a getaddrinfo object.
131 * A new getaddrinfo object.
134 * A getaddrinfo object resolves a hostname to its IPv4 and IPv6 addresses.
137 DNSSD_RETURNS_RETAINED dnssd_getaddrinfo_t _Nullable
138 dnssd_getaddrinfo_create(void);
142 * Specifies the queue on which to invoke the getaddrinfo object's result and event blocks.
145 * The getaddrinfo object.
151 * This call must be made before activating the getaddrinfo object.
153 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
157 dnssd_getaddrinfo_set_queue(dnssd_getaddrinfo_t gai
, dispatch_queue_t queue
);
161 * Specifies the DNSServiceFlags to use for the getaddrinfo operation.
164 * The getaddrinfo object.
170 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
174 dnssd_getaddrinfo_set_flags(dnssd_getaddrinfo_t gai
, DNSServiceFlags flags
);
176 #define DNSSD_GETADDRINFO_SUPPORTS_ACCOUNT_ID 1
180 * Specifies the account id to use for the getaddrinfo operation.
183 * The getaddrinfo object.
189 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
191 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
193 dnssd_getaddrinfo_set_account_id(dnssd_getaddrinfo_t gai
, const char * account_id
);
197 * Specifies the hostname to resolve.
200 * The getaddrinfo object.
203 * Hostname as a fully-qualified domain name.
206 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
210 dnssd_getaddrinfo_set_hostname(dnssd_getaddrinfo_t gai
, const char *hostname
);
212 #define DNSSD_GETADDRINFO_SUPPORTS_SERVICE_SCHEME 1
216 * Specifies the optional service scheme to resolve.
219 * The getaddrinfo object.
221 * @param service_scheme
222 * Service scheme as a string, such as "_443._https".
225 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
227 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
229 dnssd_getaddrinfo_set_service_scheme(dnssd_getaddrinfo_t gai
, const char * _Nullable service_scheme
);
233 * Specifies the index of the interface via which to resolve the hostname.
236 * The getaddrinfo object.
238 * @param interface_index
242 * If <code>kDNSServiceInterfaceIndexAny</code> is used as the interface index, then special behavior applies. If
243 * the hostname is in the "local." domain, then an attempt will be made to resolve the hostname via all active
244 * mDNS-capable interfaces. If the hostname is in any other domain, then the hostname will be resolved via the
247 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
251 dnssd_getaddrinfo_set_interface_index(dnssd_getaddrinfo_t gai
, uint32_t interface_index
);
255 * Specifies the types of addresses to which to resolve the hostname.
258 * The getaddrinfo object.
264 * Set <code>protocols</code> to <code>kDNSServiceProtocol_IPv4</code> to resolve the hostname to IPv4 addresses.
266 * Set <code>protocols</code> to <code>kDNSServiceProtocol_IPv6</code> to resolve the hostname to IPv6 addresses.
268 * Set <code>protocols</code> to <code>kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6</code> to resolve the
269 * hostname to both IPv4 and IPv6 addresses.
271 * Set <code>protocols</code> to 0 to limit resolution to addresses of protocols of which the host has routable
272 * addresses. That is, an attempt will be made to resolve the hostname to IPv4 addresses if and only if the host
273 * has a routable IPv4 address. Likewise, an attempt will be made to resolve the hostname to IPv6 addresses if and
274 * only if the host has a routable IPv6 address.
276 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
280 dnssd_getaddrinfo_set_protocols(dnssd_getaddrinfo_t gai
, DNSServiceProtocol protocols
);
284 * Sets the process ID (PID) of the process on whose behalf the getaddrinfo operation is being performed.
287 * The getaddrinfo object.
290 * PID of the process being represented.
293 * If a delegate PID is set, then the calling process must have the proper entitlement in order for the
294 * getaddrinfo operation to not fail with a kDNSServiceErr_NotAuth error.
296 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_uuid()</code>.
297 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_audit_token()</code>.
299 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
303 dnssd_getaddrinfo_set_delegate_pid(dnssd_getaddrinfo_t gai
, pid_t pid
);
307 * Sets the UUID of the process on whose behalf the getaddrinfo operation is being performed.
310 * The getaddrinfo object.
313 * UUID of the process being represented.
316 * If a delegate UUID is set, then the calling process must have the proper entitlement in order for the
317 * getaddrinfo operation to not fail with the <code>kDNSServiceErr_NotAuth</code> error.
319 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_pid()</code>.
320 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_audit_token()</code>.
322 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
326 dnssd_getaddrinfo_set_delegate_uuid(dnssd_getaddrinfo_t gai
, uuid_t _Nonnull uuid
);
328 #define DNSSD_GETADDRINFO_SUPPORTS_DELEGATE_AUDIT_TOKEN 1
332 * Sets the audit token of the process on whose behalf the getaddrinfo operation is being performed.
335 * The getaddrinfo object.
338 * audit token of the process being represented.
341 * If a delegate audit token is set, then the calling process must have the proper entitlement in order for the
342 * getaddrinfo operation to not fail with the <code>kDNSServiceErr_NotAuth</code> error.
344 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_pid()</code>.
345 * This function is an alternative to <code>dnssd_getaddrinfo_set_delegate_uuid()</code>.
347 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
349 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
351 dnssd_getaddrinfo_set_delegate_audit_token(dnssd_getaddrinfo_t gai
, audit_token_t audit_token
);
355 * Specifies whether or not getaddrinfo results (of types <code>dnssd_getaddrinfo_result_type_add</code> and
356 * <code>dnssd_getaddrinfo_result_type_expired</code>) should include authentication tags from the stub resolver.
359 * The getaddrinfo object.
362 * Pass <code>true</code> if authenticated results are needed, otherwise, pass <code>false</code>.
365 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
369 dnssd_getaddrinfo_set_need_authenticated_results(dnssd_getaddrinfo_t gai
, bool need
);
371 #define DNSSD_GETADDRINFO_SUPPORTS_ENCRYPTED_QUERIES 1
375 * Specifies whether or not getaddrinfo queries must use encrypted transports to the next DNS server.
378 * The getaddrinfo object.
381 * Pass <code>true</code> if encrypted queries are required, otherwise, pass <code>false</code>.
383 * @param fallback_config
384 * If not NULL, specify a custom resolver configuration to use if no encrypted resolver configuation is otherwise
388 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
392 dnssd_getaddrinfo_set_need_encrypted_query(dnssd_getaddrinfo_t gai
, bool need
, _Nullable xpc_object_t fallback_config
);
396 * Add a resolver UUID that represents a resolver configuration registered with the system that should
397 * be applied to this resolution. Multiple UUIDs can be set.
400 * The getaddrinfo object.
403 * UUID of a resolver configuration registered with the system.
406 * This function has no effect on a getaddrinfo object that has been activated or invalidated.
411 dnssd_getaddrinfo_add_resolver_uuid(dnssd_getaddrinfo_t gai
, uuid_t _Nonnull uuid
);
415 * Activates a getaddrinfo object.
418 * The getaddrinfo object.
421 * This function has no effect on a getaddrinfo object that has already been activated or has been invalidated.
425 dnssd_getaddrinfo_activate(dnssd_getaddrinfo_t gai
);
429 * Asynchronously invalidates a getaddrinfo object.
432 * The getaddrinfo object.
435 * As a result of calling this function, the getaddrinfo object's event handler will be invoked with a
436 * <code>dnssd_event_invalidated</code> event. After this, the object's event and result handlers will never be
439 * This function has no effect on a getaddrinfo object that has already been invalidated.
443 dnssd_getaddrinfo_invalidate(dnssd_getaddrinfo_t gai
);
447 * Handler for getaddrinfo results.
449 * @param result_array
450 * C array of getaddrinfo results.
452 * @param result_count
453 * Size of the array in terms of number of results.
455 typedef void (^dnssd_getaddrinfo_result_handler_t
)(dnssd_getaddrinfo_result_t _Nonnull
* _Nonnull result_array
,
456 size_t result_count
);
460 * Specifies a getaddrinfo object's result handler.
463 * The getaddrinfo object.
470 dnssd_getaddrinfo_set_result_handler(dnssd_getaddrinfo_t gai
, dnssd_getaddrinfo_result_handler_t _Nullable handler
);
474 * Events that can occur during the lifetime of a getaddrinfo object.
477 /*! @const dnssd_event_error An error occurred. */
478 dnssd_event_error
= 1,
479 /*! @const dnssd_event_remove_all All results prior to this event are no longer valid. */
480 dnssd_event_remove_all
= 2,
481 /*! @const dnssd_event_invalidated The object has been invalidated. */
482 dnssd_event_invalidated
= 3,
487 * Handler for getaddrinfo events.
493 * The error associated with a <code>dnssd_event_error</code> event. Ignore for all other types of events.
496 * After a <code>dnssd_event_invalidated</code> event, a getaddrinfo object's result and event handlers will never
499 typedef void (^dnssd_event_handler_t
)(dnssd_event_t event
, DNSServiceErrorType error
);
503 * Sets a getaddrinfo object's event handler.
506 * The getaddrinfo object.
513 dnssd_getaddrinfo_set_event_handler(dnssd_getaddrinfo_t gai
, dnssd_event_handler_t _Nullable handler
);
517 * Types of getaddrinfo results.
520 /*! @const dnssd_getaddrinfo_result_type_add The contained hostname and address pair is valid. */
521 dnssd_getaddrinfo_result_type_add
= 1,
522 /*! @const dnssd_getaddrinfo_result_type_remove The contained hostname and address pair is no longer valid. */
523 dnssd_getaddrinfo_result_type_remove
= 2,
524 /*! @const dnssd_getaddrinfo_result_type_no_address The contained hostname has no address of a particular type. */
525 dnssd_getaddrinfo_result_type_no_address
= 3,
526 /*! @const dnssd_getaddrinfo_result_type_expired A hostname and address pair contained came from an expired cached record and may no longer be valid. */
527 dnssd_getaddrinfo_result_type_expired
= 4,
528 /*! @const dnssd_getaddrinfo_result_type_service_binding A hostname has associated service binding information. */
529 dnssd_getaddrinfo_result_type_service_binding
= 5,
530 } dnssd_getaddrinfo_result_type_t
;
534 * Gets a getaddrinfo result's type.
537 * The getaddrinfo result.
543 dnssd_getaddrinfo_result_type_t
544 dnssd_getaddrinfo_result_get_type(dnssd_getaddrinfo_result_t gai_result
);
548 * Gets a getaddrinfo result's actual hostname.
551 * The getaddrinfo result.
554 * The getaddrinfo result's actual hostname.
557 * The hostname returned by this function is the canonical name of the hostname that was requested. In other
558 * words, it's the canonical name of the hostname set with <code>dnssd_getaddrinfo_set_hostname()</code>.
560 * The pointer returned by this function is valid until the getaddrinfo result is released.
564 dnssd_getaddrinfo_result_get_actual_hostname(dnssd_getaddrinfo_result_t gai_result
);
568 * Gets a getaddrinfo result's address.
571 * The getaddrinfo result.
574 * The getaddrinfo result's address as a sockaddr structure.
577 * For getaddrinfo results of type <code>dnssd_getaddrinfo_result_type_no_address</code>, the sockaddr structure's
578 * sa_family member variable can be used to determine the type of address that the hostname lacks.
581 const struct sockaddr
*
582 dnssd_getaddrinfo_result_get_address(dnssd_getaddrinfo_result_t gai_result
);
586 * Gets a getaddrinfo result's hostname.
589 * The getaddrinfo result.
592 * The getaddrinfo result's hostname.
595 * The hostname returned by this function is the hostname whose resolution was requested. In other words, it's
596 * equal to the hostname set with <code>dnssd_getaddrinfo_set_hostname()</code>.
598 * The pointer returned by this function is valid until the getaddrinfo result is released.
602 dnssd_getaddrinfo_result_get_hostname(dnssd_getaddrinfo_result_t gai_result
);
606 * Gets the interface index to which a getaddrinfo result pertains.
609 * The getaddrinfo result.
612 * For hostnames that were resolved via mDNS, the return value is the index of the interface via which the
613 * hostname was resolved. For hostnames that were resolved via DNS, the return value is 0.
617 dnssd_getaddrinfo_result_get_interface_index(dnssd_getaddrinfo_result_t gai_result
);
621 * Gets a getaddrinfo result's authentication tag.
624 * The getaddrinfo result.
627 * If non-NULL, gets set to the length of the authentication tag.
630 * A pointer to the getaddrinfo result's authentication tag, if it has one. Otherwise, NULL.
633 * The returned pointer, if non-NULL, is valid until the getaddrinfo result is released.
636 const void * _Nullable
637 dnssd_getaddrinfo_result_get_authentication_tag(dnssd_getaddrinfo_result_t gai_result
, size_t *_Nullable out_length
);
641 * Types of protocols used for getaddrinfo results.
644 /*! @const dnssd_getaddrinfo_result_protocol_udp The answers were retrieved using UDP. */
645 dnssd_getaddrinfo_result_protocol_udp
= 1,
646 /*! @const dnssd_getaddrinfo_result_protocol_tcp The answers were retrieved using TCP. */
647 dnssd_getaddrinfo_result_protocol_tcp
= 2,
648 /*! @const dnssd_getaddrinfo_result_protocol_tls The answers were retrieved using DNS over TLS. */
649 dnssd_getaddrinfo_result_protocol_tls
= 3,
650 /*! @const dnssd_getaddrinfo_result_protocol_https The answers were retrieved using DNS over HTTPS. */
651 dnssd_getaddrinfo_result_protocol_https
= 4,
652 } dnssd_getaddrinfo_result_protocol_t
;
654 #define DNSSD_GETADDRINFO_HAS_GET_PROTOCOL 1
658 * Gets a getaddrinfo result's protocol.
661 * The getaddrinfo result.
666 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
667 dnssd_getaddrinfo_result_protocol_t
668 dnssd_getaddrinfo_result_get_protocol(dnssd_getaddrinfo_result_t gai_result
);
670 #define DNSSD_GETADDRINFO_HAS_GET_PROVIDER_NAME 1
674 * Gets a getaddrinfo result's DNS provider name, if applicable.
677 * The getaddrinfo result.
682 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
683 const char * _Nullable
684 dnssd_getaddrinfo_result_get_provider_name(dnssd_getaddrinfo_result_t gai_result
);
688 * Checks if a getaddrinfo result has valid service binding information.
691 * The getaddrinfo result.
694 * Returns true if service binding information is valid.
696 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
698 dnssd_getaddrinfo_result_service_is_valid(dnssd_getaddrinfo_result_t gai_result
);
700 #define DNSSD_GETADDRINFO_SERVICE_PRIORITY_ALIAS 0
704 * Gets a getaddrinfo result's service binding priority.
707 * The getaddrinfo result.
710 * Service binding priority.
712 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
714 dnssd_getaddrinfo_result_get_service_priority(dnssd_getaddrinfo_result_t gai_result
);
718 * Gets a getaddrinfo result's service binding port.
721 * The getaddrinfo result.
724 * Service binding port.
726 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
728 dnssd_getaddrinfo_result_get_service_port(dnssd_getaddrinfo_result_t gai_result
);
732 * Gets a getaddrinfo result's service name.
735 * The getaddrinfo result.
738 * String containing the service binding name.
740 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
741 const char * _Nullable
742 dnssd_getaddrinfo_result_get_service_name(dnssd_getaddrinfo_result_t gai_result
);
746 * Gets a getaddrinfo result's associated DoH URI if present.
749 * The getaddrinfo result.
752 * String containing a DoH URI, if present.
754 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
755 const char * _Nullable
756 dnssd_getaddrinfo_result_get_doh_uri(dnssd_getaddrinfo_result_t gai_result
);
760 * Gets a getaddrinfo result's ECH (Encrypted Client Hello) configuration.
763 * The getaddrinfo result.
766 * If non-NULL, gets set to the length of the ECH config.
769 * A pointer to the getaddrinfo result's ECH config, if it has one. Otherwise, NULL.
772 * The returned pointer, if non-NULL, is valid until the getaddrinfo result is released.
774 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
775 const void * _Nullable
776 dnssd_getaddrinfo_result_get_ech_config(dnssd_getaddrinfo_result_t gai_result
, size_t *_Nullable out_length
);
780 typedef bool (^dnssd_getaddrinfo_enumerate_alpn_values_block_t
)(const char *alpn
);
784 * Enumerates a getaddrinfo result's service binding ALPN (application layer protocol negotiation) hints.
787 * The getaddrinfo result.
790 * A block to invoke for each ALPN hint.
792 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
794 dnssd_getaddrinfo_result_enumerate_alpn_values(dnssd_getaddrinfo_result_t gai_result
,
795 DNSSD_NOESCAPE dnssd_getaddrinfo_enumerate_alpn_values_block_t enumerator
);
797 typedef bool (^dnssd_getaddrinfo_enumerate_addresses_block_t
)(const struct sockaddr
*address
);
801 * Enumerates a getaddrinfo result's service address hints.
804 * The getaddrinfo result.
807 * A block to invoke for each address hint.
809 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
811 dnssd_getaddrinfo_result_enumerate_service_address_hints(dnssd_getaddrinfo_result_t gai_result
,
812 DNSSD_NOESCAPE dnssd_getaddrinfo_enumerate_addresses_block_t enumerator
);
819 * Gets the canonical names, if any, of a getaddrinfo result's hostname.
822 * The getaddrinfo result.
825 * An array containing zero or more canonical names.
828 * Canonical names will not be provided for a getaddrinfo objects's results unless the
829 * <code>kDNSServiceFlagsReturnIntermediates</code> flag was set for the getaddrinfo object with
830 * <code>dnssd_getaddrinfo_set_flags()</code>.
832 * The canonical names in the array are ordered in the following way. For non-empty arrays, the first
833 * canonical name in the array is the immediate canonical name of the getaddrinfo operation's hostname.
834 * For all canonical names beyond the first, a canonical name is the immediate canonical name of the
835 * canonical name that precedes it in the array.
837 * For hostnames that have no canonical names, i.e., hostnames that aren't aliases, an empty array will be
840 * The array returned by this function is guaranteed to be valid during the lifetime of the getaddrinfo
841 * result. If the array is needed beyond the lifetime of the getaddrinfo result, then the array must be
844 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
846 dnssd_getaddrinfo_result_get_cnames(dnssd_getaddrinfo_result_t gai_result
);
850 * Determines whether a getaddrinfo result was the product of cached DNS records, i.e., no additional DNS
851 * queries needed to be sent by mDNSResponder to provide the result.
854 * The getaddrinfo result.
857 * Returns <code>true</code> if the result came from cached DNS records, otherwise, returns
858 * <code>false</code>.
860 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
862 dnssd_getaddrinfo_result_is_from_cache(dnssd_getaddrinfo_result_t gai_result
);
866 * Gets the count of canonical names in a canonical name array.
869 * The canonical name array.
872 * The count of canonical names in the canonical name array.
874 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
876 dnssd_cname_array_get_count(dnssd_cname_array_t cname_array
);
880 * Gets the canonical name at a specific index in a canonical name array.
883 * The canonical name array.
886 * The zero-based index of the canonical name to get. The index must be no greater than the array's count,
887 * i.e., the value returned by <code>dnssd_cname_array_get_count()</code> for the array.
890 * The canonical name at the specified index as a C string.
893 * The pointer returned by this function is guaranteed to be valid until the array is released.
895 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
896 const char * _Nullable
897 dnssd_cname_array_get_cname(dnssd_cname_array_t cname_array
, size_t index
);
899 static inline const char *
900 dnssd_getaddrinfo_result_type_to_string(dnssd_getaddrinfo_result_type_t result
)
903 case dnssd_getaddrinfo_result_type_add
: return "Add";
904 case dnssd_getaddrinfo_result_type_remove
: return "Remove";
905 case dnssd_getaddrinfo_result_type_no_address
: return "NoAddress";
906 case dnssd_getaddrinfo_result_type_expired
: return "Expired";
907 case dnssd_getaddrinfo_result_type_service_binding
: return "ServiceBinding";
912 static inline const char *
913 dnssd_getaddrinfo_result_protocol_to_string(dnssd_getaddrinfo_result_protocol_t protocol
)
916 case dnssd_getaddrinfo_result_protocol_udp
: return "UDP";
917 case dnssd_getaddrinfo_result_protocol_tcp
: return "TCP";
918 case dnssd_getaddrinfo_result_protocol_tls
: return "TLS";
919 case dnssd_getaddrinfo_result_protocol_https
: return "HTTPS";
924 static inline const char *
925 dnssd_event_to_string(dnssd_event_t event
)
928 case dnssd_event_remove_all
: return "RemoveAll";
929 case dnssd_event_error
: return "Error";
930 case dnssd_event_invalidated
: return "Invalidated";
937 DNSSD_ASSUME_NONNULL_END
940 #if OS_OBJECT_USE_OBJC && __has_feature(objc_arc)
941 #define dnssd_retain_arc_safe(OBJ) (OBJ)
942 #define dnssd_release_arc_safe(OBJ) do {} while (0)
944 #define dnssd_retain_arc_safe(OBJ) dnssd_retain(OBJ)
945 #define dnssd_release_arc_safe(OBJ) dnssd_release(OBJ)
948 #define dnssd_getaddrinfo_forget(X) \
951 dnssd_getaddrinfo_invalidate(*(X)); \
952 dnssd_release_arc_safe(*(X)); \
957 #endif // __DNSSD_PRIVATE_H__