2 * Copyright (c) 2015-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 _DNS_SD_PRIVATE_H
18 #define _DNS_SD_PRIVATE_H
22 #if !defined(DNS_SD_EXCLUDE_PRIVATE_API)
23 #if defined(__APPLE__)
24 #define DNS_SD_EXCLUDE_PRIVATE_API 0
26 #define DNS_SD_EXCLUDE_PRIVATE_API 1
30 // Private flags (kDNSServiceFlagsPrivateOne, kDNSServiceFlagsPrivateTwo, kDNSServiceFlagsPrivateThree, kDNSServiceFlagsPrivateFour, kDNSServiceFlagsPrivateFive) from dns_sd.h
33 kDNSServiceFlagsDenyConstrained
= 0x2000,
35 * This flag is meaningful only for Unicast DNS queries. When set, the daemon will restrict
36 * DNS resolutions on interfaces defined as constrained for that request.
39 kDNSServiceFlagsDenyCellular
= 0x8000000,
41 * This flag is meaningful only for Unicast DNS queries. When set, the daemon will restrict
42 * DNS resolutions on the cellular interface for that request.
44 kDNSServiceFlagsServiceIndex
= 0x10000000,
46 * This flag is meaningful only for DNSServiceGetAddrInfo() for Unicast DNS queries.
47 * When set, DNSServiceGetAddrInfo() will interpret the "interfaceIndex" argument of the call
48 * as the "serviceIndex".
51 kDNSServiceFlagsDenyExpensive
= 0x20000000,
53 * This flag is meaningful only for Unicast DNS queries. When set, the daemon will restrict
54 * DNS resolutions on interfaces defined as expensive for that request.
57 kDNSServiceFlagsPathEvaluationDone
= 0x40000000
59 * This flag is meaningful for only Unicast DNS queries.
60 * When set, it indicates that Network PathEvaluation has already been performed.
64 #if !DNS_SD_EXCLUDE_PRIVATE_API
65 /* DNSServiceCreateDelegateConnection()
69 * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
70 * the reference (via DNSServiceRefDeallocate()) severs the
71 * connection and deregisters all records registered on this connection.
73 * pid : Process ID of the delegate
75 * uuid: UUID of the delegate
77 * Note that only one of the two arguments (pid or uuid) can be specified. If pid
78 * is zero, uuid will be assumed to be a valid value; otherwise pid will be used.
80 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
81 * an error code indicating the specific failure that occurred (in which
82 * case the DNSServiceRef is not initialized). kDNSServiceErr_NotAuth is
83 * returned to indicate that the calling process does not have entitlements
87 DNSServiceErrorType DNSSD_API
DNSServiceCreateDelegateConnection(DNSServiceRef
*sdRef
, int32_t pid
, uuid_t uuid
);
89 // Map the source port of the local UDP socket that was opened for sending the DNS query
90 // to the process ID of the application that triggered the DNS resolution.
92 /* DNSServiceGetPID() Parameters:
94 * srcport: Source port (in network byte order) of the UDP socket that was created by
95 * the daemon to send the DNS query on the wire.
97 * pid: Process ID of the application that started the name resolution which triggered
98 * the daemon to send the query on the wire. The value can be -1 if the srcport
101 * return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
102 * if the daemon is not running. The value of the pid is undefined if the return
106 DNSServiceErrorType DNSSD_API DNSServiceGetPID
113 DNSServiceErrorType DNSSD_API
DNSServiceSetDefaultDomainForUser(DNSServiceFlags flags
, const char *domain
);
115 SPI_AVAILABLE(macos(10.15.4), ios(13.2.2), watchos(6.2), tvos(13.2))
116 DNSServiceErrorType DNSSD_API DNSServiceSleepKeepalive_sockaddr
118 DNSServiceRef
* sdRef
,
119 DNSServiceFlags flags
,
120 const struct sockaddr
* localAddr
,
121 const struct sockaddr
* remoteAddr
,
122 unsigned int timeout
,
123 DNSServiceSleepKeepaliveReply callBack
,
129 * Sets the default DNS resolver settings for the caller's process.
131 * @param plist_data_ptr
132 * Pointer to an nw_resolver_config's binary property list data.
134 * @param plist_data_len
135 * Byte-length of the binary property list data. Ignored if plist_data_ptr is NULL.
137 * @param require_encryption
138 * Pass true if the process requires that DNS queries use an encrypted DNS service, such as DNS over HTTPS.
141 * This function returns kDNSServiceErr_NoError on success, kDNSServiceErr_Invalid if plist_data_len
142 * exceeds 32,768, and kDNSServiceErr_NoMemory if it fails to allocate memory.
145 * These settings only apply to the calling process's DNSServiceGetAddrInfo and DNSServiceQueryRecord
146 * requests. This function exists for code that may still use the legacy DNS-SD API for resolving
147 * hostnames, i.e., it implements the functionality of dnssd_getaddrinfo_set_need_encrypted_query(), but at
148 * a process-wide level of granularity.
150 * Due to underlying IPC limitations, there's currently a 32 KB limit on the size of the binary property
153 SPI_AVAILABLE(macos(10.16), ios(14.0), watchos(7.0), tvos(14.0))
154 DNSServiceErrorType DNSSD_API
DNSServiceSetResolverDefaults(const void *plist_data_ptr
, size_t plist_data_len
,
155 bool require_encryption
);
156 #endif // !DNS_SD_EXCLUDE_PRIVATE_API
158 #define kDNSServiceCompPrivateDNS "PrivateDNS"
159 #define kDNSServiceCompMulticastDNS "MulticastDNS"
161 #endif // _DNS_SD_PRIVATE_H