2 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 Change History (most recent first):
28 Revision 1.17 2004/06/01 14:34:48 cheshire
29 For compatibility with older compilers, change '//' comments to ' / * ... * / '
31 Revision 1.16 2004/05/25 17:08:55 cheshire
32 Fix compiler warning (doesn't make sense for function return type to be const)
34 Revision 1.15 2004/05/21 21:41:35 cheshire
35 Add TXT record building and parsing APIs
37 Revision 1.14 2004/05/20 18:40:31 cheshire
38 Remove trailing comma that breaks build on strict compilers
40 Revision 1.13 2004/05/18 23:51:27 cheshire
41 Tidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
43 Revision 1.12 2004/05/07 21:11:07 ksekar
44 API Update: Exposed new core error codes. Added constants for
45 InterfaceIndexAny and InterfaceIndexLocalOnly. Added flag for
46 long-lived unicast queries via DNSServiceQueryRecord.
48 Revision 1.11 2004/05/07 20:51:18 ksekar
49 <rdar://problem/3608226>: dns_sd.h needs to direct developers to
50 register their services at <http://www.dns-sd.org/ServiceTypes.html>
52 Revision 1.10 2004/05/06 18:42:58 ksekar
53 General dns_sd.h API cleanup, including the following radars:
54 <rdar://problem/3592068>: Remove flags with zero value
55 <rdar://problem/3479569>: Passing in NULL causes a crash.
57 Revision 1.9 2004/03/20 05:43:39 cheshire
58 Fix contributed by Terry Lambert & Alfred Perlstein:
59 On FreeBSD 4.x we need to include <sys/types.h> instead of <stdint.h>
61 Revision 1.8 2004/03/19 17:50:40 cheshire
62 Clarify comment about kDNSServiceMaxDomainName
64 Revision 1.7 2004/03/12 08:00:06 cheshire
65 Minor comment changes, headers, and wrap file in extern "C" for the benefit of C++ clients
67 Revision 1.6 2003/12/04 06:24:33 cheshire
68 Clarify meaning of MoreComing/Finished flag
70 Revision 1.5 2003/11/13 23:35:35 ksekar
71 <rdar://problem/3483020>: Header doesn't say that add/remove are possible values for flags
72 Bringing mDNSResponder project copy of dns_sd.h header up to date with
75 Revision 1.4 2003/10/13 23:50:53 ksekar
76 Updated dns_sd clientstub files to bring copies in synch with
77 top-of-tree Libinfo: A memory leak in dnssd_clientstub.c is fixed,
78 and comments in dns_sd.h are improved.
80 Revision 1.3 2003/08/12 19:51:51 cheshire
91 #if defined(__FreeBSD__) && (__FreeBSD_version < 500000)
92 /* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */
93 #include <sys/types.h>
98 /* DNSServiceRef, DNSRecordRef
100 * Opaque internal data types.
101 * Note: client is responsible for serializing access to these structures if
102 * they are shared between concurrent threads.
105 typedef struct _DNSServiceRef_t
*DNSServiceRef
;
106 typedef struct _DNSRecordRef_t
*DNSRecordRef
;
108 /* General flags used in functions defined below */
111 kDNSServiceFlagsMoreComing
= 0x1,
112 /* MoreComing indicates to a callback that at least one more result is
113 * queued and will be delivered following immediately after this one.
114 * Applications should not update their UI to display browse
115 * results when the MoreComing flag is set, because this would
116 * result in a great deal of ugly flickering on the screen.
117 * Applications should instead wait until until MoreComing is not set,
118 * and then update their UI.
119 * When MoreComing is not set, that doesn't mean there will be no more
120 * answers EVER, just that there are no more answers immediately
121 * available right now at this instant. If more answers become available
122 * in the future they will be delivered as usual.
125 kDNSServiceFlagsAdd
= 0x2,
126 kDNSServiceFlagsDefault
= 0x4,
127 /* Flags for domain enumeration and browse/query reply callbacks.
128 * "Default" applies only to enumeration and is only valid in
129 * conjuction with "Add". An enumeration callback with the "Add"
130 * flag NOT set indicates a "Remove", i.e. the domain is no longer
134 kDNSServiceFlagsNoAutoRename
= 0x8,
135 /* Flag for specifying renaming behavior on name conflict when registering
136 * non-shared records. By default, name conflicts are automatically handled
137 * by renaming the service. NoAutoRename overrides this behavior - with this
138 * flag set, name conflicts will result in a callback. The NoAutorename flag
139 * is only valid if a name is explicitly specified when registering a service
140 * (ie the default name is not used.)
143 kDNSServiceFlagsShared
= 0x10,
144 kDNSServiceFlagsUnique
= 0x20,
145 /* Flag for registering individual records on a connected
146 * DNSServiceRef. Shared indicates that there may be multiple records
147 * with this name on the network (e.g. PTR records). Unique indicates that the
148 * record's name is to be unique on the network (e.g. SRV records).
151 kDNSServiceFlagsBrowseDomains
= 0x40,
152 kDNSServiceFlagsRegistrationDomains
= 0x80,
153 /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains.
154 * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains
155 * enumerates domains recommended for registration.
158 kDNSServiceFlagsLongLivedQuery
= 0x100
159 /* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */
162 /* possible error code values */
165 kDNSServiceErr_NoError
= 0,
166 kDNSServiceErr_Unknown
= -65537, /* 0xFFFE FFFF */
167 kDNSServiceErr_NoSuchName
= -65538,
168 kDNSServiceErr_NoMemory
= -65539,
169 kDNSServiceErr_BadParam
= -65540,
170 kDNSServiceErr_BadReference
= -65541,
171 kDNSServiceErr_BadState
= -65542,
172 kDNSServiceErr_BadFlags
= -65543,
173 kDNSServiceErr_Unsupported
= -65544,
174 kDNSServiceErr_NotInitialized
= -65545,
175 kDNSServiceErr_AlreadyRegistered
= -65547,
176 kDNSServiceErr_NameConflict
= -65548,
177 kDNSServiceErr_Invalid
= -65549,
178 kDNSServiceErr_Incompatible
= -65551, /* client library incompatible with daemon */
179 kDNSServiceErr_BadInterfaceIndex
= -65552,
180 kDNSServiceErr_Refused
= -65553,
181 kDNSServiceErr_NoSuchRecord
= -65554,
182 kDNSServiceErr_NoAuth
= -65555,
183 kDNSServiceErr_NoSuchKey
= -65556
184 /* mDNS Error codes are in the range
185 * FFFE FF00 (-65792) to FFFE FFFF (-65537) */
189 /* Maximum length, in bytes, of a domain name represented as an escaped C-String */
190 /* including the final trailing dot, and the C-String terminating NULL at the end */
192 #define kDNSServiceMaxDomainName 1005
194 /* Constants for specifying an interface index. Specific interface indexes are
195 * identified via a 32-bit unsigned integer returned by the if_nametoindex()
199 #define kDNSServiceInterfaceIndexAny 0
200 #define kDNSServiceInterfaceIndexLocalOnly ( (uint32_t) ~0 )
203 typedef uint32_t DNSServiceFlags
;
204 typedef int32_t DNSServiceErrorType
;
207 /*********************************************************************************************
209 * Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
211 *********************************************************************************************/
214 /* DNSServiceRefSockFD()
216 * Access underlying Unix domain socket for an initialized DNSServiceRef.
217 * The DNS Service Discovery implmementation uses this socket to communicate between
218 * the client and the mDNSResponder daemon. The application MUST NOT directly read from
219 * or write to this socket. Access to the socket is provided so that it can be used as a
220 * run loop source, or in a select() loop: when data is available for reading on the socket,
221 * DNSServiceProcessResult() should be called, which will extract the daemon's reply from
222 * the socket, and pass it to the appropriate application callback. By using a run loop or
223 * select(), results from the daemon can be processed asynchronously. Without using these
224 * constructs, DNSServiceProcessResult() will block until the response from the daemon arrives.
225 * The client is responsible for ensuring that the data on the socket is processed in a timely
226 * fashion - the daemon may terminate its connection with a client that does not clear its
229 * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
231 * return value: The DNSServiceRef's underlying socket descriptor, or -1 on
235 int DNSServiceRefSockFD(DNSServiceRef sdRef
);
238 /* DNSServiceProcessResult()
240 * Read a reply from the daemon, calling the appropriate application callback. This call will
241 * block until the daemon's response is received. Use DNSServiceRefSockFD() in
242 * conjunction with a run loop or select() to determine the presence of a response from the
243 * server before calling this function to process the reply without blocking. Call this function
244 * at any point if it is acceptable to block until the daemon's response arrives. Note that the
245 * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is
246 * a reply from the daemon - the daemon may terminate its connection with a client that does not
247 * process the daemon's responses.
249 * sdRef: A DNSServiceRef initialized by any of the DNSService calls
250 * that take a callback parameter.
252 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
253 * an error code indicating the specific failure that occurred.
256 DNSServiceErrorType
DNSServiceProcessResult(DNSServiceRef sdRef
);
259 /* DNSServiceRefDeallocate()
261 * Terminate a connection with the daemon and free memory associated with the DNSServiceRef.
262 * Any services or records registered with this DNSServiceRef will be deregistered. Any
263 * Browse, Resolve, or Query operations called with this reference will be terminated.
265 * Note: If the reference's underlying socket is used in a run loop or select() call, it should
266 * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's
269 * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs
270 * created via this reference will be invalidated by this call - the resource records are
271 * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly,
272 * if the reference was initialized with DNSServiceRegister, and an extra resource record was
273 * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call
274 * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent
277 * Note: This call is to be used only with the DNSServiceRef defined by this API. It is
278 * not compatible with dns_service_discovery_ref objects defined in the legacy Mach-based
279 * DNSServiceDiscovery.h API.
281 * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
285 void DNSServiceRefDeallocate(DNSServiceRef sdRef
);
288 /*********************************************************************************************
292 *********************************************************************************************/
294 /* DNSServiceEnumerateDomains()
296 * Asynchronously enumerate domains available for browsing and registration.
297 * Currently, the only domain returned is "local.", but other domains will be returned in future.
299 * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
303 * DNSServiceDomainEnumReply Callback Parameters:
305 * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
307 * flags: Possible values are:
308 * kDNSServiceFlagsMoreComing
309 * kDNSServiceFlagsAdd
310 * kDNSServiceFlagsDefault
312 * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
313 * interface is determined via the if_nametoindex() family of calls.)
315 * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates
316 * the failure that occurred (other parameters are undefined if errorCode is nonzero).
318 * replyDomain: The name of the domain.
320 * context: The context pointer passed to DNSServiceEnumerateDomains.
324 typedef void (*DNSServiceDomainEnumReply
)
327 DNSServiceFlags flags
,
328 uint32_t interfaceIndex
,
329 DNSServiceErrorType errorCode
,
330 const char *replyDomain
,
335 /* DNSServiceEnumerateDomains() Parameters:
338 * sdRef: A pointer to an uninitialized DNSServiceRef. May be passed to
339 * DNSServiceRefDeallocate() to cancel the enumeration.
341 * flags: Possible values are:
342 * kDNSServiceFlagsBrowseDomains to enumerate domains recommended for browsing.
343 * kDNSServiceFlagsRegistrationDomains to enumerate domains recommended
346 * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
347 * (the index for a given interface is determined via the if_nametoindex()
348 * family of calls.) Most applications will pass 0 to enumerate domains on
351 * callBack: The function to be called when a domain is found or the call asynchronously
354 * context: An application context pointer which is passed to the callback function
357 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
358 * errors are delivered to the callback), otherwise returns an error code indicating
359 * the error that occurred (the callback is not invoked and the DNSServiceRef
360 * is not initialized.)
363 DNSServiceErrorType DNSServiceEnumerateDomains
365 DNSServiceRef
*sdRef
,
366 DNSServiceFlags flags
,
367 uint32_t interfaceIndex
,
368 DNSServiceDomainEnumReply callBack
,
369 void *context
/* may be NULL */
373 /*********************************************************************************************
375 * Service Registration
377 *********************************************************************************************/
379 /* Register a service that is discovered via Browse() and Resolve() calls.
382 * DNSServiceRegisterReply() Callback Parameters:
384 * sdRef: The DNSServiceRef initialized by DNSServiceRegister().
386 * flags: Currently unused, reserved for future use.
388 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
389 * indicate the failure that occurred (including name conflicts, if the
390 * kDNSServiceFlagsNoAutoRename flag was passed to the
391 * callout.) Other parameters are undefined if errorCode is nonzero.
393 * name: The service name registered (if the application did not specify a name in
394 * DNSServiceRegister(), this indicates what name was automatically chosen).
396 * regtype: The type of service registered, as it was passed to the callout.
398 * domain: The domain on which the service was registered (if the application did not
399 * specify a domain in DNSServiceRegister(), this indicates the default domain
400 * on which the service was registered).
402 * context: The context pointer that was passed to the callout.
406 typedef void (*DNSServiceRegisterReply
)
409 DNSServiceFlags flags
,
410 DNSServiceErrorType errorCode
,
418 /* DNSServiceRegister() Parameters:
420 * sdRef: A pointer to an uninitialized DNSServiceRef. If this call succeeds, the reference
422 * DNSServiceRefDeallocate() to deregister the service.
424 * interfaceIndex: If non-zero, specifies the interface on which to register the service
425 * (the index for a given interface is determined via the if_nametoindex()
426 * family of calls.) Most applications will pass 0 to register on all
427 * available interfaces. Pass -1 to register a service only on the local
428 * machine (service will not be visible to remote hosts.)
430 * flags: Indicates the renaming behavior on name conflict (most applications
431 * will pass 0). See flag definitions above for details.
433 * name: If non-NULL, specifies the service name to be registered.
434 * Most applications will not specify a name, in which case the
435 * computer name is used (this name is communicated to the client via
438 * regtype: The service type followed by the protocol, separated by a dot
439 * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
440 * New service types should be registered at htp://www.dns-sd.org/ServiceTypes.html.
442 * domain: If non-NULL, specifies the domain on which to advertise the service.
443 * Most applications will not specify a domain, instead automatically
444 * registering in the default domain(s).
446 * host: If non-NULL, specifies the SRV target host name. Most applications
447 * will not specify a host, instead automatically using the machine's
448 * default host name(s). Note that specifying a non-NULL host does NOT
449 * create an address record for that host - the application is responsible
450 * for ensuring that the appropriate address record exists, or creating it
451 * via DNSServiceRegisterRecord().
453 * port: The port, in network byte order, on which the service accepts connections.
454 * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
455 * by browsing, but will cause a name conflict if another client tries to
456 * register that same name). Most clients will not use placeholder services.
458 * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL.
460 * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
461 * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
462 * <length byte> <data> ...
464 * callBack: The function to be called when the registration completes or asynchronously
465 * fails. The client MAY pass NULL for the callback - The client will NOT be notified
466 * of the default values picked on its behalf, and the client will NOT be notified of any
467 * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
468 * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
469 * The client may still deregister the service at any time via DNSServiceRefDeallocate().
471 * context: An application context pointer which is passed to the callback function
474 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
475 * errors are delivered to the callback), otherwise returns an error code indicating
476 * the error that occurred (the callback is never invoked and the DNSServiceRef
477 * is not initialized.)
481 DNSServiceErrorType DNSServiceRegister
483 DNSServiceRef
*sdRef
,
484 DNSServiceFlags flags
,
485 uint32_t interfaceIndex
,
486 const char *name
, /* may be NULL */
488 const char *domain
, /* may be NULL */
489 const char *host
, /* may be NULL */
492 const void *txtRecord
, /* may be NULL */
493 DNSServiceRegisterReply callBack
, /* may be NULL */
494 void *context
/* may be NULL */
498 /* DNSServiceAddRecord()
500 * Add a record to a registered service. The name of the record will be the same as the
501 * registered service's name.
502 * The record can later be updated or deregistered by passing the RecordRef initialized
503 * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
508 * sdRef: A DNSServiceRef initialized by DNSServiceRegister().
510 * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
511 * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
512 * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also
513 * invalidated and may not be used further.
515 * flags: Currently ignored, reserved for future use.
517 * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
519 * rdlen: The length, in bytes, of the rdata.
521 * rdata: The raw rdata to be contained in the added resource record.
523 * ttl: The time to live of the resource record, in seconds.
525 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
526 * error code indicating the error that occurred (the RecordRef is not initialized).
529 DNSServiceErrorType DNSServiceAddRecord
532 DNSRecordRef
*RecordRef
,
533 DNSServiceFlags flags
,
541 /* DNSServiceUpdateRecord
543 * Update a registered resource record. The record must either be:
544 * - The primary txt record of a service registered via DNSServiceRegister()
545 * - A record added to a registered service via DNSServiceAddRecord()
546 * - An individual record registered by DNSServiceRegisterRecord()
551 * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister()
552 * or DNSServiceCreateConnection().
554 * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the
555 * service's primary txt record.
557 * flags: Currently ignored, reserved for future use.
559 * rdlen: The length, in bytes, of the new rdata.
561 * rdata: The new rdata to be contained in the updated resource record.
563 * ttl: The time to live of the updated resource record, in seconds.
565 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
566 * error code indicating the error that occurred.
569 DNSServiceErrorType DNSServiceUpdateRecord
572 DNSRecordRef RecordRef
, /* may be NULL */
573 DNSServiceFlags flags
,
580 /* DNSServiceRemoveRecord
582 * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister
583 * an record registered individually via DNSServiceRegisterRecord().
587 * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the
588 * record being removed was registered via DNSServiceAddRecord()) or by
589 * DNSServiceCreateConnection() (if the record being removed was registered via
590 * DNSServiceRegisterRecord()).
592 * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord()
593 * or DNSServiceRegisterRecord().
595 * flags: Currently ignored, reserved for future use.
597 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
598 * error code indicating the error that occurred.
601 DNSServiceErrorType DNSServiceRemoveRecord
604 DNSRecordRef RecordRef
,
605 DNSServiceFlags flags
609 /*********************************************************************************************
613 *********************************************************************************************/
615 /* Browse for instances of a service.
618 * DNSServiceBrowseReply() Parameters:
620 * sdRef: The DNSServiceRef initialized by DNSServiceBrowse().
622 * flags: Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
623 * See flag definitions for details.
625 * interfaceIndex: The interface on which the service is advertised. This index should
626 * be passed to DNSServiceResolve() when resolving the service.
628 * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
629 * indicate the failure that occurred. Other parameters are undefined if
630 * the errorCode is nonzero.
632 * serviceName: The service name discovered.
634 * regtype: The service type, as passed in to DNSServiceBrowse().
636 * domain: The domain on which the service was discovered (if the application did not
637 * specify a domain in DNSServicBrowse(), this indicates the domain on which the
638 * service was discovered.)
640 * context: The context pointer that was passed to the callout.
644 typedef void (*DNSServiceBrowseReply
)
647 DNSServiceFlags flags
,
648 uint32_t interfaceIndex
,
649 DNSServiceErrorType errorCode
,
650 const char *serviceName
,
652 const char *replyDomain
,
657 /* DNSServiceBrowse() Parameters:
659 * sdRef: A pointer to an uninitialized DNSServiceRef. May be passed to
660 * DNSServiceRefDeallocate() to terminate the browse.
662 * flags: Currently ignored, reserved for future use.
664 * interfaceIndex: If non-zero, specifies the interface on which to browse for services
665 * (the index for a given interface is determined via the if_nametoindex()
666 * family of calls.) Most applications will pass 0 to browse on all available
667 * interfaces. Pass -1 to only browse for services provided on the local host.
669 * regtype: The service type being browsed for followed by the protocol, separated by a
670 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
672 * domain: If non-NULL, specifies the domain on which to browse for services.
673 * Most applications will not specify a domain, instead browsing on the
676 * callBack: The function to be called when an instance of the service being browsed for
677 * is found, or if the call asynchronously fails.
679 * context: An application context pointer which is passed to the callback function
682 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
683 * errors are delivered to the callback), otherwise returns an error code indicating
684 * the error that occurred (the callback is not invoked and the DNSServiceRef
685 * is not initialized.)
688 DNSServiceErrorType DNSServiceBrowse
690 DNSServiceRef
*sdRef
,
691 DNSServiceFlags flags
,
692 uint32_t interfaceIndex
,
694 const char *domain
, /* may be NULL */
695 DNSServiceBrowseReply callBack
,
696 void *context
/* may be NULL */
700 /* DNSServiceResolve()
702 * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and
705 * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use
706 * DNSServiceQueryRecord() instead, as it is more efficient for this task.
708 * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
709 * DNSServiceRefDeallocate().
711 * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record and
712 * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
713 * SRV or TXT records, DNSServiceQueryRecord() should be used.
715 * DNSServiceResolveReply Callback Parameters:
717 * sdRef: The DNSServiceRef initialized by DNSServiceResolve().
719 * flags: Currently unused, reserved for future use.
721 * interfaceIndex: The interface on which the service was resolved.
723 * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
724 * indicate the failure that occurred. Other parameters are undefined if
725 * the errorCode is nonzero.
727 * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
728 * (Any literal dots (".") are escaped with a backslash ("\."), and literal
729 * backslashes are escaped with a second backslash ("\\"), e.g. a web server
730 * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
731 * This is the appropriate format to pass to standard system DNS APIs such as
732 * res_query(), or to the special-purpose functions included in this API that
733 * take fullname parameters.
735 * hosttarget: The target hostname of the machine providing the service. This name can
736 * be passed to functions like gethostbyname() to identify the host's IP address.
738 * port: The port, in network byte order, on which connections are accepted for this service.
740 * txtLen: The length of the txt record, in bytes.
742 * txtRecord: The service's primary txt record, in standard txt record format.
745 * context: The context pointer that was passed to the callout.
749 typedef void (*DNSServiceResolveReply
)
752 DNSServiceFlags flags
,
753 uint32_t interfaceIndex
,
754 DNSServiceErrorType errorCode
,
755 const char *fullname
,
756 const char *hosttarget
,
759 const char *txtRecord
,
764 /* DNSServiceResolve() Parameters
766 * sdRef: A pointer to an uninitialized DNSServiceRef. May be passed to
767 * DNSServiceRefDeallocate() to terminate the resolve.
769 * flags: Currently ignored, reserved for future use.
771 * interfaceIndex: The interface on which to resolve the service. The client should
772 * pass the interface on which the servicename was discovered, i.e.
773 * the interfaceIndex passed to the DNSServiceBrowseReply callback,
774 * or 0 to resolve the named service on all available interfaces.
776 * name: The servicename to be resolved.
778 * regtype: The service type being resolved followed by the protocol, separated by a
779 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
781 * domain: The domain on which the service is registered, i.e. the domain passed
782 * to the DNSServiceBrowseReply callback.
784 * callBack: The function to be called when a result is found, or if the call
785 * asynchronously fails.
787 * context: An application context pointer which is passed to the callback function
790 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
791 * errors are delivered to the callback), otherwise returns an error code indicating
792 * the error that occurred (the callback is never invoked and the DNSServiceRef
793 * is not initialized.)
796 DNSServiceErrorType DNSServiceResolve
798 DNSServiceRef
*sdRef
,
799 DNSServiceFlags flags
,
800 uint32_t interfaceIndex
,
804 DNSServiceResolveReply callBack
,
805 void *context
/* may be NULL */
809 /*********************************************************************************************
811 * Special Purpose Calls (most applications will not use these)
813 *********************************************************************************************/
815 /* Note on DNS Naming Conventions:
817 * The functions below refer to resource records by their full domain name, unlike the
818 * functions above which divide the name into servicename/regtype/domain fields. In the
819 * functions above, a dot (".") is considered to be a literal dot in the servicename field
820 * (e.g. "Dr. Pepper") and a label separator in the regtype ("_ftp._tcp") or domain
821 * ("apple.com") fields. Literal dots in the domain field would be escaped with a backslash,
822 * and literal backslashes would be escaped with a second backslash (this is generally not an
823 * issue, as domain names on the Internet today almost never use characters other than
824 * letters, digits, or hyphens, and the dots are label separators.) Furthermore, this is
825 * transparent to the caller, so long as the fields are passed between functions without
826 * manipulation. However, the following, special-purpose calls use a single, full domain
827 * name. As such, all dots are considered to be label separators, unless escaped, and all
828 * backslashes are considered to be escape characters, unless preceded by a second backslash.
829 * For example, the name "Dr. Smith \ Dr. Johnson" could be passed literally as a service
830 * name parameter in the above calls, but in the special purpose calls, the dots and backslash
831 * would have to be escaped (e.g. "Dr\. Smith \\ Dr\. Johnson._ftp._tcp.apple.com" for an ftp
832 * service on the apple.com domain.) The function DNSServiceConstructFullName() is provided
833 * to aid in this conversion from servicename/regtype/domain to a single fully-qualified DNS
834 * name with proper escaping.
837 /* DNSServiceCreateConnection()
839 * Create a connection to the daemon allowing efficient registration of
840 * multiple individual records.
845 * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
846 * the reference (via DNSServiceRefDeallocate()) severs the
847 * connection and deregisters all records registered on this connection.
849 * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
850 * an error code indicating the specific failure that occurred (in which
851 * case the DNSServiceRef is not initialized).
854 DNSServiceErrorType
DNSServiceCreateConnection(DNSServiceRef
*sdRef
);
857 /* DNSServiceRegisterRecord
859 * Register an individual resource record on a connected DNSServiceRef.
861 * Note that name conflicts occurring for records registered via this call must be handled
862 * by the client in the callback.
865 * DNSServiceRegisterRecordReply() parameters:
867 * sdRef: The connected DNSServiceRef initialized by
868 * DNSServiceDiscoveryConnect().
870 * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above
871 * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is
872 * invalidated, and may not be used further.
874 * flags: Currently unused, reserved for future use.
876 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
877 * indicate the failure that occurred (including name conflicts.)
878 * Other parameters are undefined if errorCode is nonzero.
880 * context: The context pointer that was passed to the callout.
884 typedef void (*DNSServiceRegisterRecordReply
)
887 DNSRecordRef RecordRef
,
888 DNSServiceFlags flags
,
889 DNSServiceErrorType errorCode
,
894 /* DNSServiceRegisterRecord() Parameters:
896 * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection().
898 * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
899 * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
900 * (To deregister ALL records registered on a single connected DNSServiceRef
901 * and deallocate each of their corresponding DNSServiceRecordRefs, call
902 * DNSServiceRefDealloocate()).
904 * flags: Possible values are kDNSServiceFlagsShared or kDNSServiceFlagsUnique
905 * (see flag type definitions for details).
907 * interfaceIndex: If non-zero, specifies the interface on which to register the record
908 * (the index for a given interface is determined via the if_nametoindex()
909 * family of calls.) Passing 0 causes the record to be registered on all interfaces.
910 * Passing -1 causes the record to only be visible on the local host.
912 * fullname: The full domain name of the resource record.
914 * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
917 * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
920 * rdlen: Length, in bytes, of the rdata.
922 * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
924 * ttl: The time to live of the resource record, in seconds.
926 * callBack: The function to be called when a result is found, or if the call
927 * asynchronously fails (e.g. because of a name conflict.)
929 * context: An application context pointer which is passed to the callback function
932 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
933 * errors are delivered to the callback), otherwise returns an error code indicating
934 * the error that occurred (the callback is never invoked and the DNSRecordRef is
938 DNSServiceErrorType DNSServiceRegisterRecord
941 DNSRecordRef
*RecordRef
,
942 DNSServiceFlags flags
,
943 uint32_t interfaceIndex
,
944 const char *fullname
,
950 DNSServiceRegisterRecordReply callBack
,
951 void *context
/* may be NULL */
955 /* DNSServiceQueryRecord
957 * Query for an arbitrary DNS record.
960 * DNSServiceQueryRecordReply() Callback Parameters:
962 * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord().
964 * flags: Possible values are kDNSServiceFlagsMoreComing and
965 * kDNSServiceFlagsAdd. The Add flag is NOT set for PTR records
966 * with a ttl of 0, i.e. "Remove" events.
968 * interfaceIndex: The interface on which the query was resolved (the index for a given
969 * interface is determined via the if_nametoindex() family of calls).
971 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
972 * indicate the failure that occurred. Other parameters are undefined if
973 * errorCode is nonzero.
975 * fullname: The resource record's full domain name.
977 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
979 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
981 * rdlen: The length, in bytes, of the resource record rdata.
983 * rdata: The raw rdata of the resource record.
985 * ttl: The resource record's time to live, in seconds.
987 * context: The context pointer that was passed to the callout.
991 typedef void (*DNSServiceQueryRecordReply
)
993 DNSServiceRef DNSServiceRef
,
994 DNSServiceFlags flags
,
995 uint32_t interfaceIndex
,
996 DNSServiceErrorType errorCode
,
997 const char *fullname
,
1007 /* DNSServiceQueryRecord() Parameters:
1009 * sdRef: A pointer to an uninitialized DNSServiceRef.
1011 * flags: Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast
1012 * query in a non-local domain. Without setting this flag, unicast queries
1013 * will be one-shot - that is, only answers available at the time of the call
1014 * will be returned. By setting this flag, answers (including Add and Remove
1015 * events) that become available after the initial call is made will generate
1016 * callbacks. This flag has no effect on link-local multicast queries.
1018 * interfaceIndex: If non-zero, specifies the interface on which to issue the query
1019 * (the index for a given interface is determined via the if_nametoindex()
1020 * family of calls.) Passing 0 causes the name to be queried for on all
1021 * interfaces. Passing -1 causes the name to be queried for only on the
1024 * fullname: The full domain name of the resource record to be queried for.
1026 * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
1027 * as defined in nameser.h.
1029 * rrclass: The class of the resource record, as defined in nameser.h
1030 * (usually 1 for the Internet class).
1032 * callBack: The function to be called when a result is found, or if the call
1033 * asynchronously fails.
1035 * context: An application context pointer which is passed to the callback function
1038 * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
1039 * errors are delivered to the callback), otherwise returns an error code indicating
1040 * the error that occurred (the callback is never invoked and the DNSServiceRef
1041 * is not initialized.)
1044 DNSServiceErrorType DNSServiceQueryRecord
1046 DNSServiceRef
*sdRef
,
1047 DNSServiceFlags flags
,
1048 uint32_t interfaceIndex
,
1049 const char *fullname
,
1052 DNSServiceQueryRecordReply callBack
,
1053 void *context
/* may be NULL */
1057 /* DNSServiceReconfirmRecord
1059 * Instruct the daemon to verify the validity of a resource record that appears to
1060 * be out of date (e.g. because tcp connection to a service's target failed.)
1061 * Causes the record to be flushed from the daemon's cache (as well as all other
1062 * daemons' caches on the network) if the record is determined to be invalid.
1066 * flags: Currently unused, reserved for future use.
1068 * fullname: The resource record's full domain name.
1070 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1072 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1074 * rdlen: The length, in bytes, of the resource record rdata.
1076 * rdata: The raw rdata of the resource record.
1080 void DNSServiceReconfirmRecord
1082 DNSServiceFlags flags
,
1083 uint32_t interfaceIndex
,
1084 const char *fullname
,
1092 /*********************************************************************************************
1094 * General Utility Functions
1096 *********************************************************************************************/
1098 /* DNSServiceConstructFullName()
1100 * Concatenate a three-part domain name (as returned by the above callbacks) into a
1101 * properly-escaped full domain name. Note that callbacks in the above functions ALREADY ESCAPE
1102 * strings where necessary.
1106 * fullName: A pointer to a buffer that where the resulting full domain name is to be written.
1107 * The buffer must be kDNSServiceMaxDomainName (1005) bytes in length to
1108 * accommodate the longest legal domain name without buffer overrun.
1110 * service: The service name - any dots or slashes must NOT be escaped.
1111 * May be NULL (to construct a PTR record name, e.g.
1112 * "_ftp._tcp.apple.com").
1114 * regtype: The service type followed by the protocol, separated by a dot
1115 * (e.g. "_ftp._tcp").
1117 * domain: The domain name, e.g. "apple.com". Any literal dots or backslashes
1120 * return value: Returns 0 on success, -1 on error.
1124 int DNSServiceConstructFullName
1127 const char *service
, /* may be NULL */
1128 const char *regtype
,
1133 /*********************************************************************************************
1135 * TXT Record Construction Functions
1137 *********************************************************************************************/
1140 * A typical calling sequence for TXT record construction is something like:
1142 * Client allocates storage for TXTRecord data (e.g. declare buffer on the stack)
1143 * TXTRecordCreate();
1144 * TXTRecordSetValue();
1145 * TXTRecordSetValue();
1146 * TXTRecordSetValue();
1148 * DNSServiceRegister( ... TXTRecordGetLength(), TXTRecordGetBytesPtr() ... );
1149 * TXTRecordDeallocate();
1150 * Explicitly deallocate storage for TXTRecord data (if not allocated on the stack)
1156 * Opaque internal data type.
1157 * Note: Represents a DNS-SD TXT record.
1160 typedef struct _TXTRecordRef_t
{ char private[16]; } TXTRecordRef
;
1163 /* TXTRecordCreate()
1165 * Creates a new empty TXTRecordRef referencing the specified storage.
1167 * If the buffer parameter is NULL, or the specified storage size is not
1168 * large enough to hold a key subsequently added using TXTRecordSetValue(),
1169 * then additional memory will be added as needed using malloc().
1171 * On some platforms, when memory is low, malloc() may fail. In this
1172 * case, TXTRecordSetValue() will return kDNSServiceErr_NoMemory, and this
1173 * error condition will need to be handled as appropriate by the caller.
1175 * You can avoid the need to handle this error condition if you ensure
1176 * that the storage you initially provide is large enough to hold all
1177 * the key/value pairs that are to be added to the record.
1178 * The caller can precompute the exact length required for all of the
1179 * key/value pairs to be added, or simply provide a fixed-sized buffer
1180 * known in advance to be large enough.
1181 * A no-value (key-only) key requires (1 + key length) bytes.
1182 * A key with empty value requires (1 + key length + 1) bytes.
1183 * A key with non-empty value requires (1 + key length + 1 + value length).
1184 * For most applications, DNS-SD TXT records are generally
1185 * less than 100 bytes, so in most cases a simple fixed-sized
1186 * 256-byte buffer will be more than sufficient.
1187 * Recommended size limits for DNS-SD TXT Records are discussed in
1188 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
1190 * txtRecord: A pointer to an uninitialized TXTRecordRef.
1192 * bufferLen: The size of the storage provided in the "buffer" parameter.
1194 * buffer: The storage used to hold the TXTRecord data.
1195 * This storage must remain valid for as long as
1199 void TXTRecordCreate
1201 TXTRecordRef
*txtRecord
,
1207 /* TXTRecordDeallocate()
1209 * Releases any resources allocated in the course of preparing a TXT Record
1210 * using TXTRecordCreate()/TXTRecordSetValue()/TXTRecordRemoveValue().
1211 * Ownership of the buffer provided in TXTRecordCreate() returns to the client.
1213 * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
1217 void TXTRecordDeallocate
1219 TXTRecordRef
*txtRecord
1223 /* TXTRecordSetValue()
1225 * Adds a key (optionally with value) to a TXTRecordRef. If the "key" already
1226 * exists in the TXTRecordRef, then the current value will be replaced with
1228 * Keys may exist in four states with respect to a given TXT record:
1229 * - Absent (key does not appear at all)
1230 * - Present with no value ("key" appears alone)
1231 * - Present with empty value ("key=" appears in TXT record)
1232 * - Present with non-empty value ("key=value" appears in TXT record)
1233 * For more details refer to "Data Syntax for DNS-SD TXT Records" in
1234 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
1236 * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
1238 * key: A null-terminated string which only contains printable ASCII
1239 * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
1240 * 14 characters or less (not counting the terminating null).
1242 * valueSize: The size of the value.
1244 * value: Any binary value. For values that represent
1245 * textual data, UTF-8 is STRONGLY recommended.
1246 * For values that represent textual data, valueSize
1247 * should NOT include the terminating null (if any)
1248 * at the end of the string.
1249 * If NULL, then "key" will be added with no value.
1250 * If non-NULL but valueSize is zero, then "key=" will be
1251 * added with empty value.
1253 * return value: Returns kDNSServiceErr_NoError on success.
1254 * Returns kDNSServiceErr_Invalid if the "key" string contains
1255 * illegal characters.
1256 * Returns kDNSServiceErr_NoMemory if adding this key would
1257 * exceed the available storage.
1260 DNSServiceErrorType TXTRecordSetValue
1262 TXTRecordRef
*txtRecord
,
1264 uint8_t valueSize
, /* may be zero */
1265 const void *value
/* may be NULL */
1269 /* TXTRecordRemoveValue()
1271 * Removes a key from a TXTRecordRef. The "key" must be an
1272 * ASCII string which exists in the TXTRecordRef.
1274 * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
1276 * key: A key name which exists in the TXTRecordRef.
1278 * return value: Returns kDNSServiceErr_NoError on success.
1279 * Returns kDNSServiceErr_NoSuchKey if the "key" does not
1280 * exist in the TXTRecordRef.
1284 DNSServiceErrorType TXTRecordRemoveValue
1286 TXTRecordRef
*txtRecord
,
1291 /* TXTRecordGetLength()
1293 * Allows you to determine the length of the raw bytes within a TXTRecordRef.
1295 * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
1297 * return value: Returns the size of the raw bytes inside a TXTRecordRef
1298 * which you can pass directly to DNSServiceRegister() or
1299 * to DNSServiceUpdateRecord().
1300 * Returns 0 if the TXTRecordRef is empty.
1304 uint16_t TXTRecordGetLength
1306 const TXTRecordRef
*txtRecord
1310 /* TXTRecordGetBytesPtr()
1312 * Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef.
1314 * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
1316 * return value: Returns a pointer to the raw bytes inside the TXTRecordRef
1317 * which you can pass directly to DNSServiceRegister() or
1318 * to DNSServiceUpdateRecord().
1322 const void * TXTRecordGetBytesPtr
1324 const TXTRecordRef
*txtRecord
1328 /*********************************************************************************************
1330 * TXT Record Parsing Functions
1332 *********************************************************************************************/
1335 * A typical calling sequence for TXT record parsing is something like:
1337 * Receive TXT record data in DNSServiceResolve() callback
1338 * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
1339 * val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1);
1340 * val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2);
1342 * bcopy(val1ptr, myval1, len1);
1343 * bcopy(val2ptr, myval2, len2);
1347 * If you wish to retain the values after return from the DNSServiceResolve()
1348 * callback, then you need to copy the data to your own storage using bcopy()
1349 * or similar, as shown in the example above.
1351 * If for some reason you need to parse a TXT record you built yourself
1352 * using the TXT record construction functions above, then you can do
1353 * that using TXTRecordGetLength and TXTRecordGetBytesPtr calls:
1354 * TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len);
1356 * Most applications only fetch keys they know about from a TXT record and
1358 * However, some debugging tools wish to fetch and display all keys.
1359 * To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls.
1362 /* TXTRecordContainsKey()
1364 * Allows you to determine if a given TXT Record contains a specified key.
1366 * txtLen: The size of the received TXT Record.
1368 * txtRecord: Pointer to the received TXT Record bytes.
1370 * key: A null-terminated ASCII string containing the key name.
1372 * return value: Returns 1 if the TXT Record contains the specified key.
1373 * Otherwise, it returns 0.
1377 int TXTRecordContainsKey
1380 const void *txtRecord
,
1385 /* TXTRecordGetValuePtr()
1387 * Allows you to retrieve the value for a given key from a TXT Record.
1389 * txtLen: The size of the received TXT Record
1391 * txtRecord: Pointer to the received TXT Record bytes.
1393 * key: A null-terminated ASCII string containing the key name.
1395 * valueLen: On output, will be set to the size of the "value" data.
1397 * return value: Returns NULL if the key does not exist in this TXT record,
1398 * or exists with no value (to differentiate between
1399 * these two cases use TXTRecordContainsKey()).
1400 * Returns pointer to location within TXT Record bytes
1401 * if the key exists with empty or non-empty value.
1402 * For empty value, valueLen will be zero.
1403 * For non-empty value, valueLen will be length of value data.
1406 const void * TXTRecordGetValuePtr
1409 const void *txtRecord
,
1415 /* TXTRecordGetCount()
1417 * Returns the number of keys stored in the TXT Record. The count
1418 * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
1420 * txtLen: The size of the received TXT Record.
1422 * txtRecord: Pointer to the received TXT Record bytes.
1424 * return value: Returns the total number of keys in the TXT Record.
1428 uint16_t TXTRecordGetCount
1431 const void *txtRecord
1435 /* TXTRecordGetItemAtIndex()
1437 * Allows you to retrieve a key name and value pointer, given an index into
1438 * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
1439 * It's also possible to iterate through keys in a TXT record by simply
1440 * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
1441 * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
1444 * For keys with no value, *value is set to NULL and *valueLen is zero.
1445 * For keys with empty value, *value is non-NULL and *valueLen is zero.
1446 * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
1448 * txtLen: The size of the received TXT Record.
1450 * txtRecord: Pointer to the received TXT Record bytes.
1452 * index: An index into the TXT Record.
1454 * keyBufLen: The size of the string buffer being supplied.
1456 * key: A string buffer used to store the key name.
1457 * On return, the buffer contains a null-terminated C string
1458 * giving the key name. DNS-SD TXT keys are usually
1459 * 14 characters or less. To hold the maximum possible
1460 * key name, the buffer should be 256 bytes long.
1462 * valueLen: On output, will be set to the size of the "value" data.
1464 * value: On output, *value is set to point to location within TXT
1465 * Record bytes that holds the value data.
1467 * return value: Returns kDNSServiceErr_NoError on success.
1468 * Returns kDNSServiceErr_NoMemory if keyBufLen is too short.
1469 * Returns kDNSServiceErr_Invalid if index is greater than
1470 * TXTRecordGetCount()-1.
1473 DNSServiceErrorType TXTRecordGetItemAtIndex
1476 const void *txtRecord
,
1489 #endif /* _DNS_SD_H */