2 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * These .Net APIs are a work in progress, currently being discussed and refined.
27 * If you plan to build an application based on these APIs, you may wish to
28 * statically link this code into your application, or otherwise distribute
29 * the DLL so that it installs into the same folder as your application
30 * (not into any common system area where it might interfere with other
31 * applications using a future completed version of these APIs).
32 * If you plan to do this, please be sure to inform us by sending email
33 * to rendezvous@apple.com to let us know.
34 * You may want to discuss what you're doing on the Rendezvous mailing
35 * list to see if others in similar positions have any suggestions for you:
37 * <http://lists.apple.com/mailman/listinfo/rendezvous-dev/>
40 Change History (most recent first):
43 Revision 1.6 2004/09/20 22:47:06 cheshire
44 Add cautionary comment
46 Revision 1.5 2004/09/16 18:16:27 shersche
47 Cleanup to parameter names
48 Submitted by: prepin@gmail.com
50 Revision 1.4 2004/09/13 19:35:57 shersche
51 <rdar://problem/3798941> Add Apple.DNSSD namespace to MC++ wrapper class
52 <rdar://problem/3798950> Change all instances of unsigned short to int
53 Bug #: 3798941, 3798950
55 Revision 1.3 2004/07/27 07:12:10 shersche
56 make TextRecord an instantiable class object
58 Revision 1.2 2004/07/19 07:48:34 shersche
59 fix bug in DNSService.Register when passing in NULL text record, add TextRecord APIs
61 Revision 1.1 2004/06/26 04:01:22 shersche
74 using namespace System
;
75 using namespace System::Net
;
76 using namespace System::Runtime::InteropServices
;
77 using namespace System::Threading
;
78 using namespace System::Collections
;
85 public __gc
class ServiceRef
;
87 public __value
enum ServiceFlags
: int
90 /* MoreComing indicates to a callback that at least one more result is
91 * queued and will be delivered following immediately after this one.
92 * Applications should not update their UI to display browse
93 * results when the MoreComing flag is set, because this would
94 * result in a great deal of ugly flickering on the screen.
95 * Applications should instead wait until until MoreComing is not set,
96 * and then update their UI.
97 * When MoreComing is not set, that doesn't mean there will be no more
98 * answers EVER, just that there are no more answers immediately
99 * available right now at this instant. If more answers become available
100 * in the future they will be delivered as usual.
105 /* Flags for domain enumeration and browse/query reply callbacks.
106 * "Default" applies only to enumeration and is only valid in
107 * conjuction with "Add". An enumeration callback with the "Add"
108 * flag NOT set indicates a "Remove", i.e. the domain is no longer
113 /* Flag for specifying renaming behavior on name conflict when registering
114 * non-shared records. By default, name conflicts are automatically handled
115 * by renaming the service. NoAutoRename overrides this behavior - with this
116 * flag set, name conflicts will result in a callback. The NoAutorename flag
117 * is only valid if a name is explicitly specified when registering a service
118 * (ie the default name is not used.)
123 /* Flag for registering individual records on a connected
124 * DNSServiceRef. Shared indicates that there may be multiple records
125 * with this name on the network (e.g. PTR records). Unique indicates that
127 * record's name is to be unique on the network (e.g. SRV records).
131 RegistrationDomains
= 128,
132 /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomain
134 * BrowseDomains enumerates domains recommended for browsing, RegistrationDo
136 * enumerates domains recommended for registration.
141 public __value
enum ErrorCode
: int
148 BadReference
= -65541,
151 Unsupported
= -65544,
152 AlreadyRegistered
= -65547,
153 NameConflict
= -65548,
155 Incompatible
= -65551,
156 BadinterfaceIndex
= -65552
159 * mDNS Error codes are in the range
160 * FFFE FF00 (-65792) to FFFE FFFF (-65537)
164 public __gc
class DNSServiceException
178 System::Exception
* innerException
188 * This is a thin MC++ class facade on top of a DNSRecordRef
190 public __gc
class RecordRef
196 m_impl
= new RecordRefImpl
;
197 m_impl
->m_ref
= NULL
;
205 __nogc
class RecordRefImpl
212 RecordRefImpl
* m_impl
;
219 * This is a thin MC++ class facade on top of a DNSServiceRef
221 public __gc
class ServiceRef
: public IDisposable
225 ServiceRef(Object
* callback
);
230 * This does an underlying DNSServiceRefDeallocate(). After
231 * calling Dispose, the ServiceRef is no longer usable.
237 * Internal - Dispatch an EnumerateDomains callback
240 EnumerateDomainsDispatch
249 * Internal - Dispatch a Register callback
262 * Internal - Dispatch a Browse callback
270 String
* serviceName
,
276 * Internal - Dispatch a Resolve callback
291 * Internal - Dispatch a RegisterRecord callback
294 RegisterRecordDispatch
302 * Internal - Dispatch a QueryRecord callback
318 * Internal - A non managed class to wrap a DNSServiceRef
320 __nogc
class ServiceRefImpl
332 * Sets up events for threaded operation
338 * Main processing thread
344 * Calls DNSServiceRefDeallocate()
350 * Called from dnssd.dll
352 static void DNSSD_API
353 EnumerateDomainsCallback
356 DNSServiceFlags flags
,
357 uint32_t interfaceIndex
,
358 DNSServiceErrorType errorCode
,
359 const char * replyDomain
,
363 static void DNSSD_API
367 DNSServiceFlags flags
,
368 DNSServiceErrorType errorCode
,
370 const char * regtype
,
375 static void DNSSD_API
379 DNSServiceFlags flags
,
380 uint32_t interfaceIndex
,
381 DNSServiceErrorType errorCode
,
382 const char * serviceName
,
383 const char * regtype
,
384 const char * replyDomain
,
388 static void DNSSD_API
392 DNSServiceFlags flags
,
393 uint32_t interfaceIndex
,
394 DNSServiceErrorType errorCode
,
395 const char * fullname
,
396 const char * hosttarget
,
397 uint16_t notAnIntPort
,
399 const char * txtRecord
,
403 static void DNSSD_API
404 RegisterRecordCallback
407 DNSRecordRef RecordRef
,
408 DNSServiceFlags flags
,
409 DNSServiceErrorType errorCode
,
413 static void DNSSD_API
416 DNSServiceRef DNSServiceRef
,
417 DNSServiceFlags flags
,
418 uint32_t interfaceIndex
,
419 DNSServiceErrorType errorCode
,
420 const char * fullname
,
430 HANDLE m_socketEvent
;
435 gcroot
<ServiceRef
*> m_outer
;
447 ServiceRefImpl
* m_impl
;
450 /*********************************************************************************************
452 * TXT Record Construction Functions
454 *********************************************************************************************/
457 * A typical calling sequence for TXT record construction is something like:
459 * DNSService.TextRecord tr = new DNSService.TextRecord(1024);
464 * DNSServiceRegister( ... tr.GetLength(), tr.GetBytes() ... );
470 * Opaque internal data type.
471 * Note: Represents a DNS-SD TXT record.
475 /* TextRecord::TextRecord()
477 * Creates a new empty TextRecord .
481 public __gc
class TextRecord
487 m_impl
= new TextRecordImpl();
488 TXTRecordCreate(&m_impl
->m_ref
, 0, NULL
);
493 TXTRecordDeallocate(&m_impl
->m_ref
);
497 __nogc
class TextRecordImpl
504 TextRecordImpl
* m_impl
;
509 * Adds a key (optionally with value) to a TextRecord. If the "key" already
510 * exists in the TextRecord, then the current value will be replaced with
512 * Keys may exist in four states with respect to a given TXT record:
513 * - Absent (key does not appear at all)
514 * - Present with no value ("key" appears alone)
515 * - Present with empty value ("key=" appears in TXT record)
516 * - Present with non-empty value ("key=value" appears in TXT record)
517 * For more details refer to "Data Syntax for DNS-SD TXT Records" in
518 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
520 * key: A null-terminated string which only contains printable ASCII
521 * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
522 * 14 characters or less (not counting the terminating null).
524 * value: Any binary value. For values that represent
525 * textual data, UTF-8 is STRONGLY recommended.
526 * For values that represent textual data, valueSize
527 * should NOT include the terminating null (if any)
528 * at the end of the string.
529 * If NULL, then "key" will be added with no value.
530 * If non-NULL but valueSize is zero, then "key=" will be
531 * added with empty value.
533 * exceptions: Throws kDNSServiceErr_Invalid if the "key" string contains
534 * illegal characters.
535 * Throws kDNSServiceErr_NoMemory if adding this key would
536 * exceed the available storage.
543 Byte value
[] /* may be NULL */
549 * Removes a key from a TextRecord. The "key" must be an
550 * ASCII string which exists in the TextRecord.
552 * key: A key name which exists in the TextRecord.
554 * exceptions: Throws kDNSServiceErr_NoSuchKey if the "key" does not
555 * exist in the TextRecord.
568 * Allows you to determine the length of the raw bytes within a TextRecord.
570 * return value : Returns the size of the raw bytes inside a TextRecord
571 * which you can pass directly to DNSServiceRegister() or
572 * to DNSServiceUpdateRecord().
573 * Returns 0 if the TextRecord is empty.
585 * Allows you to retrieve a pointer to the raw bytes within a TextRecord.
587 * return value: Returns a pointer to the bytes inside the TextRecord
588 * which you can pass directly to DNSServiceRegister() or
589 * to DNSServiceUpdateRecord().
599 /*********************************************************************************************
601 * TXT Record Parsing Functions
603 *********************************************************************************************/
606 * A typical calling sequence for TXT record parsing is something like:
608 * Receive TXT record data in DNSServiceResolve() callback
609 * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
610 * val1ptr = DNSService.TextService.GetValue(txtRecord, "key1", &len1);
611 * val2ptr = DNSService.TextService.GetValue(txtRecord, "key2", &len2);
619 * Allows you to determine if a given TXT Record contains a specified key.
621 * txtRecord: Pointer to the received TXT Record bytes.
623 * key: A null-terminated ASCII string containing the key name.
625 * return value: Returns 1 if the TXT Record contains the specified key.
626 * Otherwise, it returns 0.
640 * Allows you to retrieve the value for a given key from a TXT Record.
642 * txtRecord: Pointer to the received TXT Record bytes.
644 * key: A null-terminated ASCII string containing the key name.
646 * return value: Returns NULL if the key does not exist in this TXT record,
647 * or exists with no value (to differentiate between
648 * these two cases use ContainsKey()).
650 * if the key exists with empty or non-empty value.
651 * For empty value, length of byte array will be zero.
652 * For non-empty value, it will be the length of value data.
665 * Returns the number of keys stored in the TXT Record. The count
666 * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
668 * txtRecord: Pointer to the received TXT Record bytes.
670 * return value: Returns the total number of keys in the TXT Record.
683 * Allows you to retrieve a key name and value pointer, given an index into
684 * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
685 * It's also possible to iterate through keys in a TXT record by simply
686 * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
687 * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
690 * For keys with no value, *value is set to NULL and *valueLen is zero.
691 * For keys with empty value, *value is non-NULL and *valueLen is zero.
692 * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
694 * txtRecord: Pointer to the received TXT Record bytes.
696 * index: An index into the TXT Record.
698 * key: A string buffer used to store the key name.
699 * On return, the buffer contains a string
700 * giving the key name. DNS-SD TXT keys are usually
701 * 14 characters or less.
703 * return value: Record bytes that holds the value data.
705 * exceptions: Throws kDNSServiceErr_Invalid if index is greater than
719 public __abstract __gc
class DNSService
723 /*********************************************************************************************
727 *********************************************************************************************/
729 /* DNSServiceEnumerateDomains()
731 * Asynchronously enumerate domains available for browsing and registration.
732 * Currently, the only domain returned is "local.", but other domains will be returned in future.
734 * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
738 * EnumerateDomainsReply Delegate
740 * This Delegate is invoked upon a reply from an EnumerateDomains call.
742 * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
744 * flags: Possible values are:
749 * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
750 * interface is determined via the if_nametoindex() family of calls.)
752 * errorCode: Will be NoError (0) on success, otherwise indicates
753 * the failure that occurred (other parameters are undefined if errorCode is nonzero).
755 * replyDomain: The name of the domain.
760 EnumerateDomainsReply
769 /* DNSServiceEnumerateDomains() Parameters:
772 * flags: Possible values are:
773 * BrowseDomains to enumerate domains recommended for browsing.
774 * RegistrationDomains to enumerate domains recommended
777 * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
778 * (the index for a given interface is determined via the if_nametoindex()
779 * family of calls.) Most applications will pass 0 to enumerate domains on
782 * callback: The delegate to be called when a domain is found or the call asynchronously
786 * return value: Returns initialize ServiceRef on succeses (any subsequent, asynchronous
787 * errors are delivered to the delegate), otherwise throws an exception indicating
788 * the error that occurred (the callback is not invoked and the ServiceRef
789 * is not initialized.)
792 static public ServiceRef
*
797 EnumerateDomainsReply
* callback
800 /*********************************************************************************************
802 * Service Registration
804 *********************************************************************************************/
806 /* Register a service that is discovered via Browse() and Resolve() calls.
808 * RegisterReply() Callback Parameters:
810 * sdRef: The ServiceRef initialized by Register().
812 * flags: Currently unused, reserved for future use.
814 * errorCode: Will be NoError on success, otherwise will
815 * indicate the failure that occurred (including name conflicts, if the
816 * NoAutoRename flag was passed to the
817 * callout.) Other parameters are undefined if errorCode is nonzero.
819 * name: The service name registered (if the application did not specify a name in
820 * DNSServiceRegister(), this indicates what name was automatically chosen).
822 * regtype: The type of service registered, as it was passed to the callout.
824 * domain: The domain on which the service was registered (if the application did not
825 * specify a domain in Register(), this indicates the default domain
826 * on which the service was registered).
841 /* Register() Parameters:
843 * flags: Indicates the renaming behavior on name conflict (most applications
844 * will pass 0). See flag definitions above for details.
846 * interfaceIndex: If non-zero, specifies the interface on which to register the service
847 * (the index for a given interface is determined via the if_nametoindex()
848 * family of calls.) Most applications will pass 0 to register on all
849 * available interfaces. Pass -1 to register a service only on the local
850 * machine (service will not be visible to remote hosts.)
852 * name: If non-NULL, specifies the service name to be registered.
853 * Most applications will not specify a name, in which case the
854 * computer name is used (this name is communicated to the client via
857 * regtype: The service type followed by the protocol, separated by a dot
858 * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
859 * New service types should be registered at htp://www.dns-sd.org/ServiceTypes.html.
861 * domain: If non-NULL, specifies the domain on which to advertise the service.
862 * Most applications will not specify a domain, instead automatically
863 * registering in the default domain(s).
865 * host: If non-NULL, specifies the SRV target host name. Most applications
866 * will not specify a host, instead automatically using the machine's
867 * default host name(s). Note that specifying a non-NULL host does NOT
868 * create an address record for that host - the application is responsible
869 * for ensuring that the appropriate address record exists, or creating it
870 * via DNSServiceRegisterRecord().
872 * port: The port, in host byte order, on which the service accepts connections.
873 * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
874 * by browsing, but will cause a name conflict if another client tries to
875 * register that same name). Most clients will not use placeholder services.
877 * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
878 * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
879 * <length byte> <data> ...
881 * callback: The delegate to be called when the registration completes or asynchronously
882 * fails. The client MAY pass NULL for the callback - The client will NOT be notified
883 * of the default values picked on its behalf, and the client will NOT be notified of any
884 * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
885 * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
886 * The client may still deregister the service at any time via DNSServiceRefDeallocate().
888 * return value: Returns initialize ServiceRef (any subsequent, asynchronous
889 * errors are delivered to the callback), otherwise throws an exception indicating
890 * the error that occurred (the callback is never invoked and the DNSServiceRef
891 * is not initialized.)
894 static public ServiceRef
*
905 RegisterReply
* callback
910 * Add a record to a registered service. The name of the record will be the same as the
911 * registered service's name.
912 * The record can later be updated or deregistered by passing the RecordRef initialized
913 * by this function to UpdateRecord() or RemoveRecord().
918 * sdRef: A ServiceRef initialized by Register().
920 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
921 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
922 * If the above ServiceRef is disposed, RecordRef is also
923 * invalidated and may not be used further.
925 * flags: Currently ignored, reserved for future use.
927 * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
929 * rdata: The raw rdata to be contained in the added resource record.
931 * ttl: The time to live of the resource record, in seconds.
933 * return value: Returns initialized RecordRef, otherwise throws
934 * an exception indicating the error that occurred (the RecordRef is not initialized).
937 static public RecordRef
*
949 * Update a registered resource record. The record must either be:
950 * - The primary txt record of a service registered via Register()
951 * - A record added to a registered service via AddRecord()
952 * - An individual record registered by RegisterRecord()
957 * sdRef: A ServiceRef that was initialized by Register()
958 * or CreateConnection().
960 * RecordRef: A RecordRef initialized by AddRecord, or NULL to update the
961 * service's primary txt record.
963 * flags: Currently ignored, reserved for future use.
965 * rdata: The new rdata to be contained in the updated resource record.
967 * ttl: The time to live of the updated resource record, in seconds.
969 * return value: No return value on success, otherwise throws an exception
970 * indicating the error that occurred.
984 * Remove a record previously added to a service record set via AddRecord(), or deregister
985 * an record registered individually via RegisterRecord().
989 * sdRef: A ServiceRef initialized by Register() (if the
990 * record being removed was registered via AddRecord()) or by
991 * CreateConnection() (if the record being removed was registered via
994 * recordRef: A RecordRef initialized by a successful call to AddRecord()
995 * or RegisterRecord().
997 * flags: Currently ignored, reserved for future use.
999 * return value: Nothing on success, otherwise throws an
1000 * exception indicating the error that occurred.
1011 /*********************************************************************************************
1015 *********************************************************************************************/
1017 /* Browse for instances of a service.
1020 * BrowseReply() Parameters:
1022 * sdRef: The DNSServiceRef initialized by Browse().
1024 * flags: Possible values are MoreComing and Add.
1025 * See flag definitions for details.
1027 * interfaceIndex: The interface on which the service is advertised. This index should
1028 * be passed to Resolve() when resolving the service.
1030 * errorCode: Will be NoError (0) on success, otherwise will
1031 * indicate the failure that occurred. Other parameters are undefined if
1032 * the errorCode is nonzero.
1034 * serviceName: The service name discovered.
1036 * regtype: The service type, as passed in to Browse().
1038 * domain: The domain on which the service was discovered (if the application did not
1039 * specify a domain in Browse(), this indicates the domain on which the
1040 * service was discovered.)
1050 ErrorCode errorCode
,
1056 /* DNSServiceBrowse() Parameters:
1058 * sdRef: A pointer to an uninitialized ServiceRef. Call ServiceRef.Dispose()
1059 * to terminate the browse.
1061 * flags: Currently ignored, reserved for future use.
1063 * interfaceIndex: If non-zero, specifies the interface on which to browse for services
1064 * (the index for a given interface is determined via the if_nametoindex()
1065 * family of calls.) Most applications will pass 0 to browse on all available
1066 * interfaces. Pass -1 to only browse for services provided on the local host.
1068 * regtype: The service type being browsed for followed by the protocol, separated by a
1069 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1071 * domain: If non-NULL, specifies the domain on which to browse for services.
1072 * Most applications will not specify a domain, instead browsing on the
1073 * default domain(s).
1075 * callback: The delegate to be called when an instance of the service being browsed for
1076 * is found, or if the call asynchronously fails.
1078 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1079 * errors are delivered to the callback), otherwise throws an exception indicating
1080 * the error that occurred (the callback is not invoked and the ServiceRef
1081 * is not initialized.)
1084 static public ServiceRef
*
1091 BrowseReply
* callback
1094 /* ResolveReply() Parameters:
1096 * Resolve a service name discovered via Browse() to a target host name, port number, and
1099 * Note: Applications should NOT use Resolve() solely for txt record monitoring - use
1100 * QueryRecord() instead, as it is more efficient for this task.
1102 * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
1103 * ServiceRef.Dispose().
1105 * Note: Resolve() behaves correctly for typical services that have a single SRV record and
1106 * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
1107 * SRV or TXT records, QueryRecord() should be used.
1109 * ResolveReply Callback Parameters:
1111 * sdRef: The DNSServiceRef initialized by Resolve().
1113 * flags: Currently unused, reserved for future use.
1115 * interfaceIndex: The interface on which the service was resolved.
1117 * errorCode: Will be NoError (0) on success, otherwise will
1118 * indicate the failure that occurred. Other parameters are undefined if
1119 * the errorCode is nonzero.
1121 * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
1122 * (Any literal dots (".") are escaped with a backslash ("\."), and literal
1123 * backslashes are escaped with a second backslash ("\\"), e.g. a web server
1124 * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
1125 * This is the appropriate format to pass to standard system DNS APIs such as
1126 * res_query(), or to the special-purpose functions included in this API that
1127 * take fullname parameters.
1129 * hosttarget: The target hostname of the machine providing the service. This name can
1130 * be passed to functions like gethostbyname() to identify the host's IP address.
1132 * port: The port, in host byte order, on which connections are accepted for this service.
1134 * txtRecord: The service's primary txt record, in standard txt record format.
1144 ErrorCode errorCode
,
1151 /* Resolve() Parameters
1153 * flags: Currently ignored, reserved for future use.
1155 * interfaceIndex: The interface on which to resolve the service. The client should
1156 * pass the interface on which the servicename was discovered, i.e.
1157 * the interfaceIndex passed to the DNSServiceBrowseReply callback,
1158 * or 0 to resolve the named service on all available interfaces.
1160 * name: The servicename to be resolved.
1162 * regtype: The service type being resolved followed by the protocol, separated by a
1163 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1165 * domain: The domain on which the service is registered, i.e. the domain passed
1166 * to the DNSServiceBrowseReply callback.
1168 * callback: The delegate to be called when a result is found, or if the call
1169 * asynchronously fails.
1172 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1173 * errors are delivered to the callback), otherwise throws an exception indicating
1174 * the error that occurred (the callback is never invoked and the DNSServiceRef
1175 * is not initialized.)
1178 static public ServiceRef
*
1186 ResolveReply
* callback
1189 /*********************************************************************************************
1191 * Special Purpose Calls (most applications will not use these)
1193 *********************************************************************************************/
1195 /* CreateConnection/RegisterRecord
1197 * Register an individual resource record on a connected ServiceRef.
1199 * Note that name conflicts occurring for records registered via this call must be handled
1200 * by the client in the callback.
1203 * RecordReply() parameters:
1205 * sdRef: The connected ServiceRef initialized by
1206 * CreateConnection().
1208 * RecordRef: The RecordRef initialized by RegisterRecord(). If the above
1209 * ServiceRef.Dispose is called, this RecordRef is
1210 * invalidated, and may not be used further.
1212 * flags: Currently unused, reserved for future use.
1214 * errorCode: Will be NoError on success, otherwise will
1215 * indicate the failure that occurred (including name conflicts.)
1216 * Other parameters are undefined if errorCode is nonzero.
1225 ErrorCode errorCode
,
1229 /* CreateConnection()
1231 * Create a connection to the daemon allowing efficient registration of
1232 * multiple individual records.
1237 * callback: The delegate to be called when a result is found, or if the call
1238 * asynchronously fails (e.g. because of a name conflict.)
1240 * return value: Returns initialize ServiceRef on success, otherwise throws
1241 * an exception indicating the specific failure that occurred (in which
1242 * case the ServiceRef is not initialized).
1245 static public ServiceRef
*
1248 RegisterRecordReply
* callback
1252 /* RegisterRecord() Parameters:
1254 * sdRef: A ServiceRef initialized by CreateConnection().
1256 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
1257 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
1258 * (To deregister ALL records registered on a single connected ServiceRef
1259 * and deallocate each of their corresponding RecordRefs, call
1260 * ServiceRef.Dispose()).
1262 * flags: Possible values are Shared or Unique
1263 * (see flag type definitions for details).
1265 * interfaceIndex: If non-zero, specifies the interface on which to register the record
1266 * (the index for a given interface is determined via the if_nametoindex()
1267 * family of calls.) Passing 0 causes the record to be registered on all interfaces.
1268 * Passing -1 causes the record to only be visible on the local host.
1270 * fullname: The full domain name of the resource record.
1272 * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
1275 * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
1278 * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
1280 * ttl: The time to live of the resource record, in seconds.
1283 * return value: Returns initialize RecordRef on succeses (any subsequent, asynchronous
1284 * errors are delivered to the callback), otherwise throws an exception indicating
1285 * the error that occurred (the callback is never invoked and the RecordRef is
1288 static public RecordRef
*
1302 /* DNSServiceQueryRecord
1304 * Query for an arbitrary DNS record.
1307 * QueryRecordReply() Delegate Parameters:
1309 * sdRef: The ServiceRef initialized by QueryRecord().
1311 * flags: Possible values are MoreComing and
1312 * Add. The Add flag is NOT set for PTR records
1313 * with a ttl of 0, i.e. "Remove" events.
1315 * interfaceIndex: The interface on which the query was resolved (the index for a given
1316 * interface is determined via the if_nametoindex() family of calls).
1318 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
1319 * indicate the failure that occurred. Other parameters are undefined if
1320 * errorCode is nonzero.
1322 * fullname: The resource record's full domain name.
1324 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1326 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1328 * rdata: The raw rdata of the resource record.
1330 * ttl: The resource record's time to live, in seconds.
1340 ErrorCode errorCode
,
1348 /* QueryRecord() Parameters:
1350 * flags: Pass LongLivedQuery to create a "long-lived" unicast
1351 * query in a non-local domain. Without setting this flag, unicast queries
1352 * will be one-shot - that is, only answers available at the time of the call
1353 * will be returned. By setting this flag, answers (including Add and Remove
1354 * events) that become available after the initial call is made will generate
1355 * callbacks. This flag has no effect on link-local multicast queries.
1357 * interfaceIndex: If non-zero, specifies the interface on which to issue the query
1358 * (the index for a given interface is determined via the if_nametoindex()
1359 * family of calls.) Passing 0 causes the name to be queried for on all
1360 * interfaces. Passing -1 causes the name to be queried for only on the
1363 * fullname: The full domain name of the resource record to be queried for.
1365 * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
1366 * as defined in nameser.h.
1368 * rrclass: The class of the resource record, as defined in nameser.h
1369 * (usually 1 for the Internet class).
1371 * callback: The delegate to be called when a result is found, or if the call
1372 * asynchronously fails.
1375 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1376 * errors are delivered to the callback), otherwise throws an exception indicating
1377 * the error that occurred (the callback is never invoked and the ServiceRef
1378 * is not initialized.)
1381 static public ServiceRef
*
1389 QueryRecordReply
* callback
1394 * Instruct the daemon to verify the validity of a resource record that appears to
1395 * be out of date (e.g. because tcp connection to a service's target failed.)
1396 * Causes the record to be flushed from the daemon's cache (as well as all other
1397 * daemons' caches on the network) if the record is determined to be invalid.
1401 * flags: Currently unused, reserved for future use.
1403 * fullname: The resource record's full domain name.
1405 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1407 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1409 * rdata: The raw rdata of the resource record.