summaryrefslogtreecommitdiffstats
path: root/mDNSResponder/mDNSShared/dns_sd.h
diff options
context:
space:
mode:
Diffstat (limited to 'mDNSResponder/mDNSShared/dns_sd.h')
-rw-r--r--mDNSResponder/mDNSShared/dns_sd.h154
1 files changed, 94 insertions, 60 deletions
diff --git a/mDNSResponder/mDNSShared/dns_sd.h b/mDNSResponder/mDNSShared/dns_sd.h
index cf32ea1e..33ecfef2 100644
--- a/mDNSResponder/mDNSShared/dns_sd.h
+++ b/mDNSResponder/mDNSShared/dns_sd.h
@@ -66,7 +66,7 @@
*/
#ifndef _DNS_SD_H
-#define _DNS_SD_H 6254102
+#define _DNS_SD_H 7650102
#ifdef __cplusplus
extern "C" {
@@ -88,6 +88,13 @@ extern "C" {
#define DNSSD_API
#endif
+#if defined(_WIN32)
+#include <winsock2.h>
+typedef SOCKET dnssd_sock_t;
+#else
+typedef int dnssd_sock_t;
+#endif
+
/* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */
#if defined(__FreeBSD__) && (__FreeBSD__ < 5)
#include <sys/types.h>
@@ -180,6 +187,15 @@ enum
* in the future they will be delivered as usual.
*/
+ kDNSServiceFlagsAutoTrigger = 0x1,
+ /* Valid for browses using kDNSServiceInterfaceIndexAny.
+ * Will auto trigger the browse over AWDL as well once the service is discoveryed
+ * over BLE.
+ * This flag is an input value to DNSServiceBrowse(), which is why we can
+ * use the same value as kDNSServiceFlagsMoreComing, which is an output flag
+ * for various client callbacks.
+ */
+
kDNSServiceFlagsAdd = 0x2,
kDNSServiceFlagsDefault = 0x4,
/* Flags for domain enumeration and browse/query reply callbacks.
@@ -330,10 +346,21 @@ enum
*
* 5. Thread Safety
* The dns_sd.h API does not presuppose any particular threading model, and consequently
- * does no locking of its own (which would require linking some specific threading library).
- * If client code calls API routines on the same DNSServiceRef concurrently
- * from multiple threads, it is the client's responsibility to use a mutext
- * lock or take similar appropriate precautions to serialize those calls.
+ * does no locking internally (which would require linking with a specific threading library).
+ * If the client concurrently, from multiple threads (or contexts), calls API routines using
+ * the same DNSServiceRef, it is the client's responsibility to provide mutual exclusion for
+ * that DNSServiceRef.
+
+ * For example, use of DNSServiceRefDeallocate requires caution. A common mistake is as follows:
+ * Thread B calls DNSServiceRefDeallocate to deallocate sdRef while Thread A is processing events
+ * using sdRef. Doing this will lead to intermittent crashes on thread A if the sdRef is used after
+ * it was deallocated.
+
+ * A telltale sign of this crash type is to see DNSServiceProcessResult on the stack preceding the
+ * actual crash location.
+
+ * To state this more explicitly, mDNSResponder does not queue DNSServiceRefDeallocate so
+ * that it occurs discretely before or after an event is handled.
*/
kDNSServiceFlagsSuppressUnusable = 0x8000,
@@ -405,7 +432,7 @@ enum
kDNSServiceFlagsSecure = 0x200010,
/*
- * The response has been validated by verifying all the signaures in the response and was able to
+ * The response has been validated by verifying all the signatures in the response and was able to
* build a successful authentication chain starting from a known trust anchor.
*/
@@ -673,24 +700,49 @@ enum
* -- or --
* "Why is kDNSServiceMaxDomainName 1009, when the maximum legal domain name is 256 bytes?"
*
- * All strings used in the DNS-SD APIs are UTF-8 strings. Apart from the exceptions noted below,
- * the APIs expect the strings to be properly escaped, using the conventional DNS escaping rules:
+ * All strings used in the DNS-SD APIs are UTF-8 strings.
+ * Apart from the exceptions noted below, the APIs expect the strings to be properly escaped, using the
+ * conventional DNS escaping rules, as used by the traditional DNS res_query() API, as described below:
*
- * '\\' represents a single literal '\' in the name
- * '\.' represents a single literal '.' in the name
+ * Generally all UTF-8 characters (which includes all US ASCII characters) represent themselves,
+ * with two exceptions, the dot ('.') character, which is the label separator,
+ * and the backslash ('\') character, which is the escape character.
+ * The escape character ('\') is interpreted as described below:
+ *
* '\ddd', where ddd is a three-digit decimal value from 000 to 255,
- * represents a single literal byte with that value.
- * A bare unescaped '.' is a label separator, marking a boundary between domain and subdomain.
+ * represents a single literal byte with that value. Any byte value may be
+ * represented in '\ddd' format, even characters that don't strictly need to be escaped.
+ * For example, the ASCII code for 'w' is 119, and therefore '\119' is equivalent to 'w'.
+ * Thus the command "ping '\119\119\119.apple.com'" is the equivalent to the command "ping 'www.apple.com'".
+ * Nonprinting ASCII characters in the range 0-31 are often represented this way.
+ * In particular, the ASCII NUL character (0) cannot appear in a C string because C uses it as the
+ * string terminator character, so ASCII NUL in a domain name has to be represented in a C string as '\000'.
+ * Other characters like space (ASCII code 32) are sometimes represented as '\032'
+ * in contexts where having an actual space character in a C string would be inconvenient.
+ *
+ * Otherwise, for all cases where a '\' is followed by anything other than a three-digit decimal value
+ * from 000 to 255, the character sequence '\x' represents a single literal occurrence of character 'x'.
+ * This is legal for any character, so, for example, '\w' is equivalent to 'w'.
+ * Thus the command "ping '\w\w\w.apple.com'" is the equivalent to the command "ping 'www.apple.com'".
+ * However, this encoding is most useful when representing the characters '.' and '\',
+ * which otherwise would have special meaning in DNS name strings.
+ * This means that the following encodings are particularly common:
+ * '\\' represents a single literal '\' in the name
+ * '\.' represents a single literal '.' in the name
+ *
+ * A lone escape character ('\') appearing at the end of a string is not allowed, since it is
+ * followed by neither a three-digit decimal value from 000 to 255 nor a single character.
+ * If a lone escape character ('\') does appear as the last character of a string, it is silently ignored.
*
* The exceptions, that do not use escaping, are the routines where the full
* DNS name of a resource is broken, for convenience, into servicename/regtype/domain.
* In these routines, the "servicename" is NOT escaped. It does not need to be, since
* it is, by definition, just a single literal string. Any characters in that string
* represent exactly what they are. The "regtype" portion is, technically speaking,
- * escaped, but since legal regtypes are only allowed to contain letters, digits,
- * and hyphens, there is nothing to escape, so the issue is moot. The "domain"
- * portion is also escaped, though most domains in use on the public Internet
- * today, like regtypes, don't contain any characters that need to be escaped.
+ * escaped, but since legal regtypes are only allowed to contain US ASCII letters,
+ * digits, and hyphens, there is nothing to escape, so the issue is moot.
+ * The "domain" portion is also escaped, though most domains in use on the public
+ * Internet today, like regtypes, don't contain any characters that need to be escaped.
* As DNS-SD becomes more popular, rich-text domains for service discovery will
* become common, so software should be written to cope with domains with escaping.
*
@@ -742,12 +794,23 @@ enum
* in a way such that it does not inadvertently appear in service lists on
* all the other machines on the network.
*
- * If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing
- * then it will find *all* records registered on that same local machine.
- * Clients explicitly wishing to discover *only* LocalOnly services can
- * accomplish this by inspecting the interfaceIndex of each service reported
- * to their DNSServiceBrowseReply() callback function, and discarding those
- * where the interface index is not kDNSServiceInterfaceIndexLocalOnly.
+ * If the client passes kDNSServiceInterfaceIndexLocalOnly when querying or
+ * browsing, then the LocalOnly authoritative records and /etc/hosts caches
+ * are searched and will find *all* records registered or configured on that
+ * same local machine.
+ *
+ * If interested in getting negative answers to local questions while querying
+ * or browsing, then set both the kDNSServiceInterfaceIndexLocalOnly and the
+ * kDNSServiceFlagsReturnIntermediates flags. If no local answers exist at this
+ * moment in time, then the reply will return an immediate negative answer. If
+ * local records are subsequently created that answer the question, then those
+ * answers will be delivered, for as long as the question is still active.
+ *
+ * Clients explicitly wishing to discover *only* LocalOnly services during a
+ * browse may do this, without flags, by inspecting the interfaceIndex of each
+ * service reported to a DNSServiceBrowseReply() callback function, and
+ * discarding those answers where the interface index is not set to
+ * kDNSServiceInterfaceIndexLocalOnly.
*
* kDNSServiceInterfaceIndexP2P is meaningful only in Browse, QueryRecord, Register,
* and Resolve operations. It should not be used in other DNSService APIs.
@@ -776,6 +839,7 @@ enum
#define kDNSServiceInterfaceIndexLocalOnly ((uint32_t)-1)
#define kDNSServiceInterfaceIndexUnicast ((uint32_t)-2)
#define kDNSServiceInterfaceIndexP2P ((uint32_t)-3)
+#define kDNSServiceInterfaceIndexBLE ((uint32_t)-4)
typedef uint32_t DNSServiceFlags;
typedef uint32_t DNSServiceProtocol;
@@ -833,29 +897,6 @@ DNSServiceErrorType DNSSD_API DNSServiceGetProperty
#define kDNSServiceProperty_DaemonVersion "DaemonVersion"
-
-// Map the source port of the local UDP socket that was opened for sending the DNS query
-// to the process ID of the application that triggered the DNS resolution.
-//
-/* DNSServiceGetPID() Parameters:
- *
- * srcport: Source port (in network byte order) of the UDP socket that was created by
- * the daemon to send the DNS query on the wire.
- *
- * pid: Process ID of the application that started the name resolution which triggered
- * the daemon to send the query on the wire. The value can be -1 if the srcport
- * cannot be mapped.
- *
- * return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
- * if the daemon is not running. The value of the pid is undefined if the return
- * value has error.
- */
-DNSServiceErrorType DNSSD_API DNSServiceGetPID
-(
- uint16_t srcport,
- int32_t *pid
-);
-
/*********************************************************************************************
*
* Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
@@ -876,8 +917,8 @@ DNSServiceErrorType DNSSD_API DNSServiceGetPID
* a client can choose to fork a thread and have it loop calling "DNSServiceProcessResult(ref);"
* If DNSServiceProcessResult() is called when no data is available for reading on the socket, it
* will block until data does become available, and then process the data and return to the caller.
- * The application is reponsible for checking the return value of DNSServiceProcessResult() to determine
- * if the socket is valid and if it should continue to process data on the socket.
+ * The application is responsible for checking the return value of DNSServiceProcessResult()
+ * to determine if the socket is valid and if it should continue to process data on the socket.
* When data arrives on the socket, the client is responsible for calling DNSServiceProcessResult(ref)
* in a timely fashion -- if the client allows a large backlog of data to build up the daemon
* may terminate the connection.
@@ -888,7 +929,7 @@ DNSServiceErrorType DNSSD_API DNSServiceGetPID
* error.
*/
-int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef);
+dnssd_sock_t DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef);
/* DNSServiceProcessResult()
@@ -1237,7 +1278,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister
* Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe
* with respect to a single DNSServiceRef. If you plan to have multiple threads
* in your program simultaneously add, update, or remove records from the same
- * DNSServiceRef, then it's the caller's responsibility to use a mutext lock
+ * DNSServiceRef, then it's the caller's responsibility to use a mutex lock
* or take similar appropriate precautions to serialize those calls.
*
* Parameters;
@@ -2247,8 +2288,8 @@ typedef union _TXTRecordRef_t { char PrivateData[16]; char *ForceNaturalAlignmen
* For most applications, DNS-SD TXT records are generally
* less than 100 bytes, so in most cases a simple fixed-sized
* 256-byte buffer will be more than sufficient.
- * Recommended size limits for DNS-SD TXT Records are discussed in
- * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
+ * Recommended size limits for DNS-SD TXT Records are discussed in RFC 6763
+ * <https://tools.ietf.org/html/rfc6763#section-6.2>
*
* Note: When passing parameters to and from these TXT record APIs,
* the key name does not include the '=' character. The '=' character
@@ -2298,8 +2339,8 @@ void DNSSD_API TXTRecordDeallocate
* - Present with no value ("key" appears alone)
* - Present with empty value ("key=" appears in TXT record)
* - Present with non-empty value ("key=value" appears in TXT record)
- * For more details refer to "Data Syntax for DNS-SD TXT Records" in
- * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
+ * For more details refer to "Data Syntax for DNS-SD TXT Records" in RFC 6763
+ * <https://tools.ietf.org/html/rfc6763#section-6>
*
* txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
*
@@ -2611,13 +2652,6 @@ DNSServiceErrorType DNSSD_API DNSServiceSleepKeepalive
);
#endif
-#ifdef __APPLE_API_PRIVATE
-
-#define kDNSServiceCompPrivateDNS "PrivateDNS"
-#define kDNSServiceCompMulticastDNS "MulticastDNS"
-
-#endif //__APPLE_API_PRIVATE
-
/* Some C compiler cleverness. We can make the compiler check certain things for us,
* and report errors at compile-time if anything is wrong. The usual way to do this would
* be to use a run-time "if" statement or the conventional run-time "assert" mechanism, but