-
Notifications
You must be signed in to change notification settings - Fork 57
/
dns_sd.h
2728 lines (2520 loc) · 130 KB
/
dns_sd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2003-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*! @header DNS Service Discovery
*
* @discussion This section describes the functions, callbacks, and data structures
* that make up the DNS Service Discovery API.
*
* The DNS Service Discovery API is part of Bonjour, Apple's implementation
* of zero-configuration networking (ZEROCONF).
*
* Bonjour allows you to register a network service, such as a
* printer or file server, so that it can be found by name or browsed
* for by service type and domain. Using Bonjour, applications can
* discover what services are available on the network, along with
* all the information -- such as name, IP address, and port --
* necessary to access a particular service.
*
* In effect, Bonjour combines the functions of a local DNS server and
* AppleTalk. Bonjour allows applications to provide user-friendly printer
* and server browsing, among other things, over standard IP networks.
* This behavior is a result of combining protocols such as multicast and
* DNS to add new functionality to the network (such as multicast DNS).
*
* Bonjour gives applications easy access to services over local IP
* networks without requiring the service or the application to support
* an AppleTalk or a Netbeui stack, and without requiring a DNS server
* for the local network.
*/
/* _DNS_SD_H contains the API version number for this header file
* The API version defined in this header file symbol allows for compile-time
* checking, so that C code building with earlier versions of the header file
* can avoid compile errors trying to use functions that aren't even defined
* in those earlier versions. Similar checks may also be performed at run-time:
* => weak linking -- to avoid link failures if run with an earlier
* version of the library that's missing some desired symbol, or
* => DNSServiceGetProperty(DaemonVersion) -- to verify whether the running daemon
* ("system service" on Windows) meets some required minimum functionality level.
*/
#ifndef _DNS_SD_H
#define _DNS_SD_H 8807002
#ifdef __cplusplus
extern "C" {
#endif
/* Set to 1 if libdispatch is supported
* Note: May also be set by project and/or Makefile
*/
#if defined(__APPLE__)
#define _DNS_SD_LIBDISPATCH 1
#else
#define _DNS_SD_LIBDISPATCH 0
#endif
/* standard calling convention under Win32 is __stdcall */
/* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */
/* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */
#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
#define DNSSD_API __stdcall
#else
#define DNSSD_API
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 4))
#define DNSSD_EXPORT __attribute__((visibility("default")))
#else
#define DNSSD_EXPORT
#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>
/* Likewise, on Sun, standard integer types are in sys/types.h */
#elif defined(__sun__)
#include <sys/types.h>
/* EFI does not have stdint.h, or anything else equivalent */
#elif defined(EFI32) || defined(EFI64) || defined(EFIX64)
#include "Tiano.h"
#if !defined(_STDINT_H_)
typedef UINT8 uint8_t;
typedef INT8 int8_t;
typedef UINT16 uint16_t;
typedef INT16 int16_t;
typedef UINT32 uint32_t;
typedef INT32 int32_t;
#endif
/* Windows has its own differences */
#elif defined(_WIN32)
#include <windows.h>
#define _UNUSED
#ifndef _MSL_STDINT_H
typedef UINT8 uint8_t;
typedef INT8 int8_t;
typedef UINT16 uint16_t;
typedef INT16 int16_t;
typedef UINT32 uint32_t;
typedef INT32 int32_t;
#endif
/* All other Posix platforms use stdint.h */
#else
#include <stdint.h>
#endif
#if _DNS_SD_LIBDISPATCH
#include <dispatch/dispatch.h>
#endif
/* DNSServiceRef, DNSRecordRef
*
* Opaque internal data types.
* Note: client is responsible for serializing access to these structures if
* they are shared between concurrent threads.
*/
typedef struct _DNSServiceRef_t *DNSServiceRef;
typedef struct _DNSRecordRef_t *DNSRecordRef;
struct sockaddr;
/*! @enum General flags
* Most DNS-SD API functions and callbacks include a DNSServiceFlags parameter.
* As a general rule, any given bit in the 32-bit flags field has a specific fixed meaning,
* regardless of the function or callback being used. For any given function or callback,
* typically only a subset of the possible flags are meaningful, and all others should be zero.
* The discussion section for each API call describes which flags are valid for that call
* and callback. In some cases, for a particular call, it may be that no flags are currently
* defined, in which case the DNSServiceFlags parameter exists purely to allow future expansion.
* In all cases, developers should expect that in future releases, it is possible that new flag
* values will be defined, and write code with this in mind. For example, code that tests
* if (flags == kDNSServiceFlagsAdd) ...
* will fail if, in a future release, another bit in the 32-bit flags field is also set.
* The reliable way to test whether a particular bit is set is not with an equality test,
* but with a bitwise mask:
* if (flags & kDNSServiceFlagsAdd) ...
* With the exception of kDNSServiceFlagsValidate, each flag can be valid(be set)
* EITHER only as an input to one of the DNSService*() APIs OR only as an output
* (provide status) through any of the callbacks used. For example, kDNSServiceFlagsAdd
* can be set only as an output in the callback, whereas the kDNSServiceFlagsIncludeP2P
* can be set only as an input to the DNSService*() APIs. See comments on kDNSServiceFlagsValidate
* defined in enum below.
*/
enum
{
kDNSServiceFlagsMoreComing = 0x1,
/* MoreComing indicates to a callback that at least one more result is
* queued and will be delivered following immediately after this one.
* When the MoreComing flag is set, applications should not immediately
* update their UI, because this can result in a great deal of ugly flickering
* on the screen, and can waste a great deal of CPU time repeatedly updating
* the screen with content that is then immediately erased, over and over.
* Applications should wait until MoreComing is not set, and then
* update their UI when no more changes are imminent.
* When MoreComing is not set, that doesn't mean there will be no more
* answers EVER, just that there are no more answers immediately
* available right now at this instant. If more answers become available
* 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.
* "Default" applies only to enumeration and is only valid in
* conjunction with "Add". An enumeration callback with the "Add"
* flag NOT set indicates a "Remove", i.e. the domain is no longer
* valid.
*/
kDNSServiceFlagsNoAutoRename = 0x8,
/* Flag for specifying renaming behavior on name conflict when registering
* non-shared records. By default, name conflicts are automatically handled
* by renaming the service. NoAutoRename overrides this behavior - with this
* flag set, name conflicts will result in a callback. The NoAutorename flag
* is only valid if a name is explicitly specified when registering a service
* (i.e. the default name is not used.)
*/
kDNSServiceFlagsShared = 0x10,
kDNSServiceFlagsUnique = 0x20,
/* Flag for registering individual records on a connected
* DNSServiceRef. Shared indicates that there may be multiple records
* with this name on the network (e.g. PTR records). Unique indicates that the
* record's name is to be unique on the network (e.g. SRV records).
*/
kDNSServiceFlagsBrowseDomains = 0x40,
kDNSServiceFlagsRegistrationDomains = 0x80,
/* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains.
* BrowseDomains enumerates domains recommended for browsing, RegistrationDomains
* enumerates domains recommended for registration.
*/
kDNSServiceFlagsLongLivedQuery = 0x100,
/* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */
kDNSServiceFlagsAllowRemoteQuery = 0x200,
/* Flag for creating a record for which we will answer remote queries
* (queries from hosts more than one hop away; hosts not directly connected to the local link).
*/
kDNSServiceFlagsForceMulticast = 0x400,
/* Flag for signifying that a query or registration should be performed exclusively via multicast
* DNS, even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
*/
kDNSServiceFlagsForce = 0x800, // This flag is deprecated.
kDNSServiceFlagsKnownUnique = 0x800,
/*
* Client guarantees that record names are unique, so we can skip sending out initial
* probe messages. Standard name conflict resolution is still done if a conflict is discovered.
* Currently only valid for a DNSServiceRegister call.
*/
kDNSServiceFlagsReturnIntermediates = 0x1000,
/* Flag for returning intermediate results.
* For example, if a query results in an authoritative NXDomain (name does not exist)
* then that result is returned to the client. However the query is not implicitly
* cancelled -- it remains active and if the answer subsequently changes
* (e.g. because a VPN tunnel is subsequently established) then that positive
* result will still be returned to the client.
* Similarly, if a query results in a CNAME record, then in addition to following
* the CNAME referral, the intermediate CNAME result is also returned to the client.
* When this flag is not set, NXDomain errors are not returned, and CNAME records
* are followed silently without informing the client of the intermediate steps.
* (In earlier builds this flag was briefly calledkDNSServiceFlagsReturnCNAME)
*/
kDNSServiceFlagsNonBrowsable = 0x2000,
/* A service registered with the NonBrowsable flag set can be resolved using
* DNSServiceResolve(), but will not be discoverable using DNSServiceBrowse().
* This is for cases where the name is actually a GUID; it is found by other means;
* there is no end-user benefit to browsing to find a long list of opaque GUIDs.
* Using the NonBrowsable flag creates SRV+TXT without the cost of also advertising
* an associated PTR record.
*/
kDNSServiceFlagsShareConnection = 0x4000,
/* For efficiency, clients that perform many concurrent operations may want to use a
* single Unix Domain Socket connection with the background daemon, instead of having a
* separate connection for each independent operation. To use this mode, clients first
* call DNSServiceCreateConnection(&MainRef) to initialize the main DNSServiceRef.
* For each subsequent operation that is to share that same connection, the client copies
* the MainRef, and then passes the address of that copy, setting the ShareConnection flag
* to tell the library that this DNSServiceRef is not a typical uninitialized DNSServiceRef;
* it's a copy of an existing DNSServiceRef whose connection information should be reused.
*
* For example:
*
* DNSServiceErrorType error;
* DNSServiceRef MainRef;
* error = DNSServiceCreateConnection(&MainRef);
* if (error) ...
* DNSServiceRef BrowseRef = MainRef; // Important: COPY the primary DNSServiceRef first...
* error = DNSServiceBrowse(&BrowseRef, kDNSServiceFlagsShareConnection, ...); // then use the copy
* if (error) ...
* ...
* DNSServiceRefDeallocate(BrowseRef); // Terminate the browse operation
* DNSServiceRefDeallocate(MainRef); // Terminate the shared connection
* Also see Point 4.(Don't Double-Deallocate if the MainRef has been Deallocated) in Notes below:
*
* Notes:
*
* 1. Collective kDNSServiceFlagsMoreComing flag
* When callbacks are invoked using a shared DNSServiceRef, the
* kDNSServiceFlagsMoreComing flag applies collectively to *all* active
* operations sharing the same parent DNSServiceRef. If the MoreComing flag is
* set it means that there are more results queued on this parent DNSServiceRef,
* but not necessarily more results for this particular callback function.
* The implication of this for client programmers is that when a callback
* is invoked with the MoreComing flag set, the code should update its
* internal data structures with the new result, and set a variable indicating
* that its UI needs to be updated. Then, later when a callback is eventually
* invoked with the MoreComing flag not set, the code should update *all*
* stale UI elements related to that shared parent DNSServiceRef that need
* updating, not just the UI elements related to the particular callback
* that happened to be the last one to be invoked.
*
* 2. Canceling operations and kDNSServiceFlagsMoreComing
* Whenever you cancel any operation for which you had deferred UI updates
* waiting because of a kDNSServiceFlagsMoreComing flag, you should perform
* those deferred UI updates. This is because, after cancelling the operation,
* you can no longer wait for a callback *without* MoreComing set, to tell
* you do perform your deferred UI updates (the operation has been canceled,
* so there will be no more callbacks). An implication of the collective
* kDNSServiceFlagsMoreComing flag for shared connections is that this
* guideline applies more broadly -- any time you cancel an operation on
* a shared connection, you should perform all deferred UI updates for all
* operations sharing that connection. This is because the MoreComing flag
* might have been referring to events coming for the operation you canceled,
* which will now not be coming because the operation has been canceled.
*
* 3. Only share DNSServiceRef's created with DNSServiceCreateConnection
* Calling DNSServiceCreateConnection(&ref) creates a special shareable DNSServiceRef.
* DNSServiceRef's created by other calls like DNSServiceBrowse() or DNSServiceResolve()
* cannot be shared by copying them and using kDNSServiceFlagsShareConnection.
*
* 4. Don't Double-Deallocate if the MainRef has been Deallocated
* Calling DNSServiceRefDeallocate(ref) for a particular operation's DNSServiceRef terminates
* just that operation. Calling DNSServiceRefDeallocate(ref) for the main shared DNSServiceRef
* (the parent DNSServiceRef, originally created by DNSServiceCreateConnection(&ref))
* automatically terminates the shared connection and all operations that were still using it.
* After doing this, DO NOT then attempt to deallocate any remaining subordinate DNSServiceRef's.
* The memory used by those subordinate DNSServiceRef's has already been freed, so any attempt
* to do a DNSServiceRefDeallocate (or any other operation) on them will result in accesses
* to freed memory, leading to crashes or other equally undesirable results.
*
* 5. Thread Safety
* The dns_sd.h API does not presuppose any particular threading model, and consequently
* 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,
/*
* This flag is meaningful only in DNSServiceQueryRecord which suppresses unusable queries on the
* wire. If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name)
* but this host has no routable IPv6 address, then the call will not try to look up IPv6 addresses
* for "hostname", since any addresses it found would be unlikely to be of any use anyway. Similarly,
* if this host has no routable IPv4 address, the call will not try to look up IPv4 addresses for
* "hostname".
*/
kDNSServiceFlagsTimeout = 0x10000,
/*
* When kDNServiceFlagsTimeout is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo, the query is
* stopped after a certain number of seconds have elapsed. The time at which the query will be stopped
* is determined by the system and cannot be configured by the user. The query will be stopped irrespective
* of whether a response was given earlier or not. When the query is stopped, the callback will be called
* with an error code of kDNSServiceErr_Timeout and a NULL sockaddr will be returned for DNSServiceGetAddrInfo
* and zero length rdata will be returned for DNSServiceQueryRecord.
*/
kDNSServiceFlagsIncludeP2P = 0x20000,
/*
* Include P2P interfaces when kDNSServiceInterfaceIndexAny is specified.
* By default, specifying kDNSServiceInterfaceIndexAny does not include P2P interfaces.
*/
kDNSServiceFlagsWakeOnResolve = 0x40000,
/*
* This flag is meaningful only in DNSServiceResolve. When set, it tries to send a magic packet
* to wake up the client.
*/
kDNSServiceFlagsBackgroundTrafficClass = 0x80000,
/*
* This flag is meaningful for Unicast DNS queries. When set, it uses the background traffic
* class for packets that service the request.
*/
kDNSServiceFlagsIncludeAWDL = 0x100000,
/*
* Include AWDL interface when kDNSServiceInterfaceIndexAny is specified.
*/
kDNSServiceFlagsValidate = 0x200000,
/*
* This flag is meaningful in DNSServiceGetAddrInfo and DNSServiceQueryRecord. This is the ONLY flag to be valid
* as an input to the APIs and also an output through the callbacks in the APIs.
*
* When this flag is passed to DNSServiceQueryRecord and DNSServiceGetAddrInfo to resolve unicast names,
* the response will be validated using DNSSEC. The validation results are delivered using the flags field in
* the callback and kDNSServiceFlagsValidate is marked in the flags to indicate that DNSSEC status is also available.
* When the callback is called to deliver the query results, the validation results may or may not be available.
* If it is not delivered along with the results, the validation status is delivered when the validation completes.
*
* When the validation results are delivered in the callback, it is indicated by marking the flags with
* kDNSServiceFlagsValidate and kDNSServiceFlagsAdd along with the DNSSEC status flags (described below) and a NULL
* sockaddr will be returned for DNSServiceGetAddrInfo and zero length rdata will be returned for DNSServiceQueryRecord.
* DNSSEC validation results are for the whole RRSet and not just individual records delivered in the callback. When
* kDNSServiceFlagsAdd is not set in the flags, applications should implicitly assume that the DNSSEC status of the
* RRSet that has been delivered up until that point is not valid anymore, till another callback is called with
* kDNSServiceFlagsAdd and kDNSServiceFlagsValidate.
*
* The following four flags indicate the status of the DNSSEC validation and marked in the flags field of the callback.
* When any of the four flags is set, kDNSServiceFlagsValidate will also be set. To check the validation status, the
* other applicable output flags should be masked. See kDNSServiceOutputFlags below.
*/
kDNSServiceFlagsSecure = 0x200010,
/*
* 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.
*/
kDNSServiceFlagsInsecure = 0x200020,
/*
* A chain of trust cannot be built starting from a known trust anchor to the response.
*/
kDNSServiceFlagsBogus = 0x200040,
/*
* If the response cannot be verified to be secure due to expired signatures, missing signatures etc.,
* then the results are considered to be bogus.
*/
kDNSServiceFlagsIndeterminate = 0x200080,
/*
* There is no valid trust anchor that can be used to determine whether a response is secure or not.
*/
kDNSServiceFlagsUnicastResponse = 0x400000,
/*
* Request unicast response to query.
*/
kDNSServiceFlagsValidateOptional = 0x800000,
/*
* This flag is identical to kDNSServiceFlagsValidate except for the case where the response
* cannot be validated. If this flag is set in DNSServiceQueryRecord or DNSServiceGetAddrInfo,
* the DNSSEC records will be requested for validation. If they cannot be received for some reason
* during the validation (e.g., zone is not signed, zone is signed but cannot be traced back to
* root, recursive server does not understand DNSSEC etc.), then this will fallback to the default
* behavior where the validation will not be performed and no DNSSEC results will be provided.
*
* If the zone is signed and there is a valid path to a known trust anchor configured in the system
* and the application requires DNSSEC validation irrespective of the DNSSEC awareness in the current
* network, then this option MUST not be used. This is only intended to be used during the transition
* period where the different nodes participating in the DNS resolution may not understand DNSSEC or
* managed properly (e.g. missing DS record) but still want to be able to resolve DNS successfully.
*/
kDNSServiceFlagsWakeOnlyService = 0x1000000,
/*
* This flag is meaningful only in DNSServiceRegister. When set, the service will not be registered
* with sleep proxy server during sleep.
*/
kDNSServiceFlagsThresholdOne = 0x2000000,
kDNSServiceFlagsThresholdFinder = 0x4000000,
kDNSServiceFlagsThresholdReached = kDNSServiceFlagsThresholdOne,
/*
* kDNSServiceFlagsThresholdOne is meaningful only in DNSServiceBrowse. When set,
* the system will stop issuing browse queries on the network once the number
* of answers returned is one or more. It will issue queries on the network
* again if the number of answers drops to zero.
* This flag is for Apple internal use only. Third party developers
* should not rely on this behavior being supported in any given software release.
*
* kDNSServiceFlagsThresholdFinder is meaningful only in DNSServiceBrowse. When set,
* the system will stop issuing browse queries on the network once the number
* of answers has reached the threshold set for Finder.
* It will issue queries on the network again if the number of answers drops below
* this threshold.
* This flag is for Apple internal use only. Third party developers
* should not rely on this behavior being supported in any given software release.
*
* When kDNSServiceFlagsThresholdReached is set in the client callback add or remove event,
* it indicates that the browse answer threshold has been reached and no
* browse requests will be generated on the network until the number of answers falls
* below the threshold value. Add and remove events can still occur based
* on incoming Bonjour traffic observed by the system.
* The set of services return to the client is not guaranteed to represent the
* entire set of services present on the network once the threshold has been reached.
*
* Note, while kDNSServiceFlagsThresholdReached and kDNSServiceFlagsThresholdOne
* have the same value, there isn't a conflict because kDNSServiceFlagsThresholdReached
* is only set in the callbacks and kDNSServiceFlagsThresholdOne is only set on
* input to a DNSServiceBrowse call.
*/
kDNSServiceFlagsPrivateOne = 0x8000000,
/*
* This flag is private and should not be used.
*/
kDNSServiceFlagsPrivateTwo = 0x10000000,
/*
* This flag is private and should not be used.
*/
kDNSServiceFlagsPrivateThree = 0x20000000,
/*
* This flag is private and should not be used.
*/
kDNSServiceFlagsPrivateFour = 0x40000000,
/*
* This flag is private and should not be used.
*/
kDNSServiceFlagsAllowExpiredAnswers = 0x80000000,
/*
* When kDNSServiceFlagsAllowExpiredAnswers is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo,
* if there are matching expired records still in the cache, then they are immediately returned to the
* client, and in parallel a network query for that name is issued. All returned records from the query will
* remain in the cache after expiration.
*/
kDNSServiceFlagsExpiredAnswer = 0x80000000
/*
* When kDNSServiceFlagsAllowExpiredAnswers is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo,
* an expired answer will have this flag set.
*/
};
#define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault)
/* All the output flags excluding the DNSSEC Status flags. Typically used to check DNSSEC Status */
/* Possible protocol values */
enum
{
/* for DNSServiceGetAddrInfo() */
kDNSServiceProtocol_IPv4 = 0x01,
kDNSServiceProtocol_IPv6 = 0x02,
/* 0x04 and 0x08 reserved for future internetwork protocols */
/* for DNSServiceNATPortMappingCreate() */
kDNSServiceProtocol_UDP = 0x10,
kDNSServiceProtocol_TCP = 0x20
/* 0x40 and 0x80 reserved for future transport protocols, e.g. SCTP [RFC 2960]
* or DCCP [RFC 4340]. If future NAT gateways are created that support port
* mappings for these protocols, new constants will be defined here.
*/
};
/*
* The values for DNS Classes and Types are listed in RFC 1035, and are available
* on every OS in its DNS header file. Unfortunately every OS does not have the
* same header file containing DNS Class and Type constants, and the names of
* the constants are not consistent. For example, BIND 8 uses "T_A",
* BIND 9 uses "ns_t_a", Windows uses "DNS_TYPE_A", etc.
* For this reason, these constants are also listed here, so that code using
* the DNS-SD programming APIs can use these constants, so that the same code
* can compile on all our supported platforms.
*/
enum
{
kDNSServiceClass_IN = 1 /* Internet */
};
enum
{
kDNSServiceType_A = 1, /* Host address. */
kDNSServiceType_NS = 2, /* Authoritative server. */
kDNSServiceType_MD = 3, /* Mail destination. */
kDNSServiceType_MF = 4, /* Mail forwarder. */
kDNSServiceType_CNAME = 5, /* Canonical name. */
kDNSServiceType_SOA = 6, /* Start of authority zone. */
kDNSServiceType_MB = 7, /* Mailbox domain name. */
kDNSServiceType_MG = 8, /* Mail group member. */
kDNSServiceType_MR = 9, /* Mail rename name. */
kDNSServiceType_NULL = 10, /* Null resource record. */
kDNSServiceType_WKS = 11, /* Well known service. */
kDNSServiceType_PTR = 12, /* Domain name pointer. */
kDNSServiceType_HINFO = 13, /* Host information. */
kDNSServiceType_MINFO = 14, /* Mailbox information. */
kDNSServiceType_MX = 15, /* Mail routing information. */
kDNSServiceType_TXT = 16, /* One or more text strings (NOT "zero or more..."). */
kDNSServiceType_RP = 17, /* Responsible person. */
kDNSServiceType_AFSDB = 18, /* AFS cell database. */
kDNSServiceType_X25 = 19, /* X_25 calling address. */
kDNSServiceType_ISDN = 20, /* ISDN calling address. */
kDNSServiceType_RT = 21, /* Router. */
kDNSServiceType_NSAP = 22, /* NSAP address. */
kDNSServiceType_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */
kDNSServiceType_SIG = 24, /* Security signature. */
kDNSServiceType_KEY = 25, /* Security key. */
kDNSServiceType_PX = 26, /* X.400 mail mapping. */
kDNSServiceType_GPOS = 27, /* Geographical position (withdrawn). */
kDNSServiceType_AAAA = 28, /* IPv6 Address. */
kDNSServiceType_LOC = 29, /* Location Information. */
kDNSServiceType_NXT = 30, /* Next domain (security). */
kDNSServiceType_EID = 31, /* Endpoint identifier. */
kDNSServiceType_NIMLOC = 32, /* Nimrod Locator. */
kDNSServiceType_SRV = 33, /* Server Selection. */
kDNSServiceType_ATMA = 34, /* ATM Address */
kDNSServiceType_NAPTR = 35, /* Naming Authority PoinTeR */
kDNSServiceType_KX = 36, /* Key Exchange */
kDNSServiceType_CERT = 37, /* Certification record */
kDNSServiceType_A6 = 38, /* IPv6 Address (deprecated) */
kDNSServiceType_DNAME = 39, /* Non-terminal DNAME (for IPv6) */
kDNSServiceType_SINK = 40, /* Kitchen sink (experimental) */
kDNSServiceType_OPT = 41, /* EDNS0 option (meta-RR) */
kDNSServiceType_APL = 42, /* Address Prefix List */
kDNSServiceType_DS = 43, /* Delegation Signer */
kDNSServiceType_SSHFP = 44, /* SSH Key Fingerprint */
kDNSServiceType_IPSECKEY = 45, /* IPSECKEY */
kDNSServiceType_RRSIG = 46, /* RRSIG */
kDNSServiceType_NSEC = 47, /* Denial of Existence */
kDNSServiceType_DNSKEY = 48, /* DNSKEY */
kDNSServiceType_DHCID = 49, /* DHCP Client Identifier */
kDNSServiceType_NSEC3 = 50, /* Hashed Authenticated Denial of Existence */
kDNSServiceType_NSEC3PARAM = 51, /* Hashed Authenticated Denial of Existence */
kDNSServiceType_HIP = 55, /* Host Identity Protocol */
kDNSServiceType_SPF = 99, /* Sender Policy Framework for E-Mail */
kDNSServiceType_UINFO = 100, /* IANA-Reserved */
kDNSServiceType_UID = 101, /* IANA-Reserved */
kDNSServiceType_GID = 102, /* IANA-Reserved */
kDNSServiceType_UNSPEC = 103, /* IANA-Reserved */
kDNSServiceType_TKEY = 249, /* Transaction key */
kDNSServiceType_TSIG = 250, /* Transaction signature. */
kDNSServiceType_IXFR = 251, /* Incremental zone transfer. */
kDNSServiceType_AXFR = 252, /* Transfer zone of authority. */
kDNSServiceType_MAILB = 253, /* Transfer mailbox records. */
kDNSServiceType_MAILA = 254, /* Transfer mail agent records. */
kDNSServiceType_ANY = 255 /* Wildcard match. */
};
/* possible error code values */
enum
{
kDNSServiceErr_NoError = 0,
kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */
kDNSServiceErr_NoSuchName = -65538,
kDNSServiceErr_NoMemory = -65539,
kDNSServiceErr_BadParam = -65540,
kDNSServiceErr_BadReference = -65541,
kDNSServiceErr_BadState = -65542,
kDNSServiceErr_BadFlags = -65543,
kDNSServiceErr_Unsupported = -65544,
kDNSServiceErr_NotInitialized = -65545,
kDNSServiceErr_AlreadyRegistered = -65547,
kDNSServiceErr_NameConflict = -65548,
kDNSServiceErr_Invalid = -65549,
kDNSServiceErr_Firewall = -65550,
kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */
kDNSServiceErr_BadInterfaceIndex = -65552,
kDNSServiceErr_Refused = -65553,
kDNSServiceErr_NoSuchRecord = -65554,
kDNSServiceErr_NoAuth = -65555,
kDNSServiceErr_NoSuchKey = -65556,
kDNSServiceErr_NATTraversal = -65557,
kDNSServiceErr_DoubleNAT = -65558,
kDNSServiceErr_BadTime = -65559, /* Codes up to here existed in Tiger */
kDNSServiceErr_BadSig = -65560,
kDNSServiceErr_BadKey = -65561,
kDNSServiceErr_Transient = -65562,
kDNSServiceErr_ServiceNotRunning = -65563, /* Background daemon not running */
kDNSServiceErr_NATPortMappingUnsupported = -65564, /* NAT doesn't support PCP, NAT-PMP or UPnP */
kDNSServiceErr_NATPortMappingDisabled = -65565, /* NAT supports PCP, NAT-PMP or UPnP, but it's disabled by the administrator */
kDNSServiceErr_NoRouter = -65566, /* No router currently configured (probably no network connectivity) */
kDNSServiceErr_PollingMode = -65567,
kDNSServiceErr_Timeout = -65568
/* mDNS Error codes are in the range
* FFFE FF00 (-65792) to FFFE FFFF (-65537) */
};
/* Maximum length, in bytes, of a service name represented as a */
/* literal C-String, including the terminating NULL at the end. */
#define kDNSServiceMaxServiceName 64
/* Maximum length, in bytes, of a domain name represented as an *escaped* C-String */
/* including the final trailing dot, and the C-String terminating NULL at the end. */
#define kDNSServiceMaxDomainName 1009
/*
* Notes on DNS Name Escaping
* -- 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, as used by the traditional DNS res_query() API, as described below:
*
* 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. 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 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.
*
* The servicename may be up to 63 bytes of UTF-8 text (not counting the C-String
* terminating NULL at the end). The regtype is of the form _service._tcp or
* _service._udp, where the "service" part is 1-15 characters, which may be
* letters, digits, or hyphens. The domain part of the three-part name may be
* any legal domain, providing that the resulting servicename+regtype+domain
* name does not exceed 256 bytes.
*
* For most software, these issues are transparent. When browsing, the discovered
* servicenames should simply be displayed as-is. When resolving, the discovered
* servicename/regtype/domain are simply passed unchanged to DNSServiceResolve().
* When a DNSServiceResolve() succeeds, the returned fullname is already in
* the correct format to pass to standard system DNS APIs such as res_query().
* For converting from servicename/regtype/domain to a single properly-escaped
* full DNS name, the helper function DNSServiceConstructFullName() is provided.
*
* The following (highly contrived) example illustrates the escaping process.
* Suppose you have a service called "Dr. Smith\Dr. Johnson", of type "_ftp._tcp"
* in subdomain "4th. Floor" of subdomain "Building 2" of domain "apple.com."
* The full (escaped) DNS name of this service's SRV record would be:
* Dr\.\032Smith\\Dr\.\032Johnson._ftp._tcp.4th\.\032Floor.Building\0322.apple.com.
*/
/*
* Constants for specifying an interface index
*
* Specific interface indexes are identified via a 32-bit unsigned integer returned
* by the if_nametoindex() family of calls.
*
* If the client passes 0 for interface index, that means "do the right thing",
* which (at present) means, "if the name is in an mDNS local multicast domain
* (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
* on all applicable interfaces, otherwise send via unicast to the appropriate
* DNS server." Normally, most clients will use 0 for interface index to
* automatically get the default sensible behaviour.
*
* If the client passes a positive interface index, then that indicates to do the
* operation only on that one specified interface.
*
* If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
* a service, then that service will be found *only* by other local clients
* on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly
* or kDNSServiceInterfaceIndexAny.
* If a client has a 'private' service, accessible only to other processes
* running on the same machine, this allows the client to advertise that service
* 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 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.
*
* If the kDNSServiceFlagsTimeout and kDNSServiceInterfaceIndexLocalOnly flags
* are set simultaneously when either DNSServiceQueryRecord or DNSServiceGetAddrInfo
* is called then both flags take effect. However, if DNSServiceQueryRecord is called
* with both the kDNSServiceFlagsSuppressUnusable and kDNSServiceInterfaceIndexLocalOnly
* flags set, then the kDNSServiceFlagsSuppressUnusable flag is ignored.
*
* 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.
*
* - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceBrowse or
* DNSServiceQueryRecord, it restricts the operation to P2P.
*
* - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceRegister, it is
* mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P
* set.
*
* - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceResolve, it is
* mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P
* set, because resolving a P2P service may create and/or enable an interface whose
* index is not known a priori. The resolve callback will indicate the index of the
* interface via which the service can be accessed.
*
* If applications pass kDNSServiceInterfaceIndexAny to DNSServiceBrowse
* or DNSServiceQueryRecord, they must set the kDNSServiceFlagsIncludeP2P flag
* to include P2P. In this case, if a service instance or the record being queried
* is found over P2P, the resulting ADD event will indicate kDNSServiceInterfaceIndexP2P
* as the interface index.
*/
#define kDNSServiceInterfaceIndexAny 0
#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;
typedef int32_t DNSServiceErrorType;
/*********************************************************************************************
*
* Version checking
*
*********************************************************************************************/
/* DNSServiceGetProperty() Parameters:
*
* property: The requested property.
* Currently the only property defined is kDNSServiceProperty_DaemonVersion.
*
* result: Place to store result.
* For retrieving DaemonVersion, this should be the address of a uint32_t.
*
* size: Pointer to uint32_t containing size of the result location.
* For retrieving DaemonVersion, this should be sizeof(uint32_t).
* On return the uint32_t is updated to the size of the data returned.
* For DaemonVersion, the returned size is always sizeof(uint32_t), but
* future properties could be defined which return variable-sized results.
*
* return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
* if the daemon (or "system service" on Windows) is not running.
*/
DNSSD_EXPORT
DNSServiceErrorType DNSSD_API DNSServiceGetProperty
(
const char *property, /* Requested property (i.e. kDNSServiceProperty_DaemonVersion) */
void *result, /* Pointer to place to store result */
uint32_t *size /* size of result location */
);
/*
* When requesting kDNSServiceProperty_DaemonVersion, the result pointer must point
* to a 32-bit unsigned integer, and the size parameter must be set to sizeof(uint32_t).
*
* On return, the 32-bit unsigned integer contains the API version number
*
* For example, Mac OS X 10.4.9 has API version 1080400.
* This allows applications to do simple greater-than and less-than comparisons:
* e.g. an application that requires at least API version 1080400 can check:
* if (version >= 1080400) ...
*
* Example usage:
* uint32_t version;
* uint32_t size = sizeof(version);
* DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
* if (!err) printf("DNS_SD API version is %d.%d\n", version / 10000, version / 100 % 100);
*/
#define kDNSServiceProperty_DaemonVersion "DaemonVersion"
/*********************************************************************************************
*
* Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
*
*********************************************************************************************/
/* DNSServiceRefSockFD()
*
* Access underlying Unix domain socket for an initialized DNSServiceRef.
* The DNS Service Discovery implementation uses this socket to communicate between the client and
* the daemon. The application MUST NOT directly read from or write to this socket.
* Access to the socket is provided so that it can be used as a kqueue event source, a CFRunLoop
* event source, in a select() loop, etc. When the underlying event management subsystem (kqueue/
* select/CFRunLoop etc.) indicates to the client that data is available for reading on the
* socket, the client should call DNSServiceProcessResult(), which will extract the daemon's
* reply from the socket, and pass it to the appropriate application callback. By using a run
* loop or select(), results from the daemon can be processed asynchronously. Alternatively,
* 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 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.
*
* sdRef: A DNSServiceRef initialized by any of the DNSService calls.
*
* return value: The DNSServiceRef's underlying socket descriptor, or -1 on
* error.
*/
DNSSD_EXPORT
dnssd_sock_t DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef);
/* DNSServiceProcessResult()
*
* Read a reply from the daemon, calling the appropriate application callback. This call will
* block until the daemon's response is received. Use DNSServiceRefSockFD() in
* conjunction with a run loop or select() to determine the presence of a response from the
* server before calling this function to process the reply without blocking. Call this function
* at any point if it is acceptable to block until the daemon's response arrives. Note that the
* client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is
* a reply from the daemon - the daemon may terminate its connection with a client that does not
* process the daemon's responses.
*
* sdRef: A DNSServiceRef initialized by any of the DNSService calls
* that take a callback parameter.
*
* return value: Returns kDNSServiceErr_NoError on success, otherwise returns
* an error code indicating the specific failure that occurred.
*/
DNSSD_EXPORT
DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef);
/* DNSServiceRefDeallocate()
*
* Terminate a connection with the daemon and free memory associated with the DNSServiceRef.
* Any services or records registered with this DNSServiceRef will be deregistered. Any
* Browse, Resolve, or Query operations called with this reference will be terminated.
*
* Note: If the reference's underlying socket is used in a run loop or select() call, it should
* be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's
* socket.
*
* Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs
* created via this reference will be invalidated by this call - the resource records are
* deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly,
* if the reference was initialized with DNSServiceRegister, and an extra resource record was
* added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call
* is invalidated when this function is called - the DNSRecordRef may not be used in subsequent
* functions.
*
* Note: This call is to be used only with the DNSServiceRef defined by this API.