1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * These .Net APIs are a work in progress, currently being discussed and refined.
21 * If you plan to build an application based on these APIs, you may wish to
22 * statically link this code into your application, or otherwise distribute
23 * the DLL so that it installs into the same folder as your application
24 * (not into any common system area where it might interfere with other
25 * applications using a future completed version of these APIs).
26 * If you plan to do this, please be sure to inform us by sending email
27 * to bonjour@apple.com to let us know.
28 * You may want to discuss what you're doing on the Bonjour mailing
29 * list to see if others in similar positions have any suggestions for you:
31 * <http://lists.apple.com/bonjour-dev/>
34 Change History (most recent first):
37 Revision 1.9 2006/08/14 23:25:43 cheshire
38 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
40 Revision 1.8 2005/02/10 22:35:33 cheshire
41 <rdar://problem/3727944> Update name
43 Revision 1.7 2004/12/16 19:56:12 cheshire
46 Revision 1.6 2004/09/20 22:47:06 cheshire
47 Add cautionary comment
49 Revision 1.5 2004/09/16 18:16:27 shersche
50 Cleanup to parameter names
51 Submitted by: prepin@gmail.com
53 Revision 1.4 2004/09/13 19:35:57 shersche
54 <rdar://problem/3798941> Add Apple.DNSSD namespace to MC++ wrapper class
55 <rdar://problem/3798950> Change all instances of unsigned short to int
56 Bug #: 3798941, 3798950
58 Revision 1.3 2004/07/27 07:12:10 shersche
59 make TextRecord an instantiable class object
61 Revision 1.2 2004/07/19 07:48:34 shersche
62 fix bug in DNSService.Register when passing in NULL text record, add TextRecord APIs
64 Revision 1.1 2004/06/26 04:01:22 shersche
77 using namespace System
;
78 using namespace System::Net
;
79 using namespace System::Runtime::InteropServices
;
80 using namespace System::Threading
;
81 using namespace System::Collections
;
88 public __gc
class ServiceRef
;
90 public __value
enum ServiceFlags
: int
93 /* MoreComing indicates to a callback that at least one more result is
94 * queued and will be delivered following immediately after this one.
95 * Applications should not update their UI to display browse
96 * results when the MoreComing flag is set, because this would
97 * result in a great deal of ugly flickering on the screen.
98 * Applications should instead wait until until MoreComing is not set,
99 * and then update their UI.
100 * When MoreComing is not set, that doesn't mean there will be no more
101 * answers EVER, just that there are no more answers immediately
102 * available right now at this instant. If more answers become available
103 * in the future they will be delivered as usual.
108 /* Flags for domain enumeration and browse/query reply callbacks.
109 * "Default" applies only to enumeration and is only valid in
110 * conjuction with "Add". An enumeration callback with the "Add"
111 * flag NOT set indicates a "Remove", i.e. the domain is no longer
116 /* Flag for specifying renaming behavior on name conflict when registering
117 * non-shared records. By default, name conflicts are automatically handled
118 * by renaming the service. NoAutoRename overrides this behavior - with this
119 * flag set, name conflicts will result in a callback. The NoAutorename flag
120 * is only valid if a name is explicitly specified when registering a service
121 * (i.e. the default name is not used.)
126 /* Flag for registering individual records on a connected
127 * DNSServiceRef. Shared indicates that there may be multiple records
128 * with this name on the network (e.g. PTR records). Unique indicates that
130 * record's name is to be unique on the network (e.g. SRV records).
134 RegistrationDomains
= 128,
135 /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomain
137 * BrowseDomains enumerates domains recommended for browsing, RegistrationDo
139 * enumerates domains recommended for registration.
144 public __value
enum ErrorCode
: int
151 BadReference
= -65541,
154 Unsupported
= -65544,
155 AlreadyRegistered
= -65547,
156 NameConflict
= -65548,
158 Incompatible
= -65551,
159 BadinterfaceIndex
= -65552
162 * mDNS Error codes are in the range
163 * FFFE FF00 (-65792) to FFFE FFFF (-65537)
167 public __gc
class DNSServiceException
181 System::Exception
* innerException
191 * This is a thin MC++ class facade on top of a DNSRecordRef
193 public __gc
class RecordRef
199 m_impl
= new RecordRefImpl
;
200 m_impl
->m_ref
= NULL
;
208 __nogc
class RecordRefImpl
215 RecordRefImpl
* m_impl
;
222 * This is a thin MC++ class facade on top of a DNSServiceRef
224 public __gc
class ServiceRef
: public IDisposable
228 ServiceRef(Object
* callback
);
233 * This does an underlying DNSServiceRefDeallocate(). After
234 * calling Dispose, the ServiceRef is no longer usable.
240 * Internal - Dispatch an EnumerateDomains callback
243 EnumerateDomainsDispatch
252 * Internal - Dispatch a Register callback
265 * Internal - Dispatch a Browse callback
273 String
* serviceName
,
279 * Internal - Dispatch a Resolve callback
294 * Internal - Dispatch a RegisterRecord callback
297 RegisterRecordDispatch
305 * Internal - Dispatch a QueryRecord callback
321 * Internal - A non managed class to wrap a DNSServiceRef
323 __nogc
class ServiceRefImpl
335 * Sets up events for threaded operation
341 * Main processing thread
347 * Calls DNSServiceRefDeallocate()
353 * Called from dnssd.dll
355 static void DNSSD_API
356 EnumerateDomainsCallback
359 DNSServiceFlags flags
,
360 uint32_t interfaceIndex
,
361 DNSServiceErrorType errorCode
,
362 const char * replyDomain
,
366 static void DNSSD_API
370 DNSServiceFlags flags
,
371 DNSServiceErrorType errorCode
,
373 const char * regtype
,
378 static void DNSSD_API
382 DNSServiceFlags flags
,
383 uint32_t interfaceIndex
,
384 DNSServiceErrorType errorCode
,
385 const char * serviceName
,
386 const char * regtype
,
387 const char * replyDomain
,
391 static void DNSSD_API
395 DNSServiceFlags flags
,
396 uint32_t interfaceIndex
,
397 DNSServiceErrorType errorCode
,
398 const char * fullname
,
399 const char * hosttarget
,
400 uint16_t notAnIntPort
,
402 const char * txtRecord
,
406 static void DNSSD_API
407 RegisterRecordCallback
410 DNSRecordRef RecordRef
,
411 DNSServiceFlags flags
,
412 DNSServiceErrorType errorCode
,
416 static void DNSSD_API
419 DNSServiceRef DNSServiceRef
,
420 DNSServiceFlags flags
,
421 uint32_t interfaceIndex
,
422 DNSServiceErrorType errorCode
,
423 const char * fullname
,
433 HANDLE m_socketEvent
;
438 gcroot
<ServiceRef
*> m_outer
;
450 ServiceRefImpl
* m_impl
;
453 /*********************************************************************************************
455 * TXT Record Construction Functions
457 *********************************************************************************************/
460 * A typical calling sequence for TXT record construction is something like:
462 * DNSService.TextRecord tr = new DNSService.TextRecord(1024);
467 * DNSServiceRegister( ... tr.GetLength(), tr.GetBytes() ... );
473 * Opaque internal data type.
474 * Note: Represents a DNS-SD TXT record.
478 /* TextRecord::TextRecord()
480 * Creates a new empty TextRecord .
484 public __gc
class TextRecord
490 m_impl
= new TextRecordImpl();
491 TXTRecordCreate(&m_impl
->m_ref
, 0, NULL
);
496 TXTRecordDeallocate(&m_impl
->m_ref
);
500 __nogc
class TextRecordImpl
507 TextRecordImpl
* m_impl
;
512 * Adds a key (optionally with value) to a TextRecord. If the "key" already
513 * exists in the TextRecord, then the current value will be replaced with
515 * Keys may exist in four states with respect to a given TXT record:
516 * - Absent (key does not appear at all)
517 * - Present with no value ("key" appears alone)
518 * - Present with empty value ("key=" appears in TXT record)
519 * - Present with non-empty value ("key=value" appears in TXT record)
520 * For more details refer to "Data Syntax for DNS-SD TXT Records" in
521 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
523 * key: A null-terminated string which only contains printable ASCII
524 * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
525 * 14 characters or less (not counting the terminating null).
527 * value: Any binary value. For values that represent
528 * textual data, UTF-8 is STRONGLY recommended.
529 * For values that represent textual data, valueSize
530 * should NOT include the terminating null (if any)
531 * at the end of the string.
532 * If NULL, then "key" will be added with no value.
533 * If non-NULL but valueSize is zero, then "key=" will be
534 * added with empty value.
536 * exceptions: Throws kDNSServiceErr_Invalid if the "key" string contains
537 * illegal characters.
538 * Throws kDNSServiceErr_NoMemory if adding this key would
539 * exceed the available storage.
546 Byte value
[] /* may be NULL */
552 * Removes a key from a TextRecord. The "key" must be an
553 * ASCII string which exists in the TextRecord.
555 * key: A key name which exists in the TextRecord.
557 * exceptions: Throws kDNSServiceErr_NoSuchKey if the "key" does not
558 * exist in the TextRecord.
571 * Allows you to determine the length of the raw bytes within a TextRecord.
573 * return value : Returns the size of the raw bytes inside a TextRecord
574 * which you can pass directly to DNSServiceRegister() or
575 * to DNSServiceUpdateRecord().
576 * Returns 0 if the TextRecord is empty.
588 * Allows you to retrieve a pointer to the raw bytes within a TextRecord.
590 * return value: Returns a pointer to the bytes inside the TextRecord
591 * which you can pass directly to DNSServiceRegister() or
592 * to DNSServiceUpdateRecord().
602 /*********************************************************************************************
604 * TXT Record Parsing Functions
606 *********************************************************************************************/
609 * A typical calling sequence for TXT record parsing is something like:
611 * Receive TXT record data in DNSServiceResolve() callback
612 * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
613 * val1ptr = DNSService.TextService.GetValue(txtRecord, "key1", &len1);
614 * val2ptr = DNSService.TextService.GetValue(txtRecord, "key2", &len2);
622 * Allows you to determine if a given TXT Record contains a specified key.
624 * txtRecord: Pointer to the received TXT Record bytes.
626 * key: A null-terminated ASCII string containing the key name.
628 * return value: Returns 1 if the TXT Record contains the specified key.
629 * Otherwise, it returns 0.
643 * Allows you to retrieve the value for a given key from a TXT Record.
645 * txtRecord: Pointer to the received TXT Record bytes.
647 * key: A null-terminated ASCII string containing the key name.
649 * return value: Returns NULL if the key does not exist in this TXT record,
650 * or exists with no value (to differentiate between
651 * these two cases use ContainsKey()).
653 * if the key exists with empty or non-empty value.
654 * For empty value, length of byte array will be zero.
655 * For non-empty value, it will be the length of value data.
668 * Returns the number of keys stored in the TXT Record. The count
669 * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
671 * txtRecord: Pointer to the received TXT Record bytes.
673 * return value: Returns the total number of keys in the TXT Record.
686 * Allows you to retrieve a key name and value pointer, given an index into
687 * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
688 * It's also possible to iterate through keys in a TXT record by simply
689 * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
690 * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
693 * For keys with no value, *value is set to NULL and *valueLen is zero.
694 * For keys with empty value, *value is non-NULL and *valueLen is zero.
695 * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
697 * txtRecord: Pointer to the received TXT Record bytes.
699 * index: An index into the TXT Record.
701 * key: A string buffer used to store the key name.
702 * On return, the buffer contains a string
703 * giving the key name. DNS-SD TXT keys are usually
704 * 14 characters or less.
706 * return value: Record bytes that holds the value data.
708 * exceptions: Throws kDNSServiceErr_Invalid if index is greater than
722 public __abstract __gc
class DNSService
726 /*********************************************************************************************
730 *********************************************************************************************/
732 /* DNSServiceEnumerateDomains()
734 * Asynchronously enumerate domains available for browsing and registration.
735 * Currently, the only domain returned is "local.", but other domains will be returned in future.
737 * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
741 * EnumerateDomainsReply Delegate
743 * This Delegate is invoked upon a reply from an EnumerateDomains call.
745 * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
747 * flags: Possible values are:
752 * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
753 * interface is determined via the if_nametoindex() family of calls.)
755 * errorCode: Will be NoError (0) on success, otherwise indicates
756 * the failure that occurred (other parameters are undefined if errorCode is nonzero).
758 * replyDomain: The name of the domain.
763 EnumerateDomainsReply
772 /* DNSServiceEnumerateDomains() Parameters:
775 * flags: Possible values are:
776 * BrowseDomains to enumerate domains recommended for browsing.
777 * RegistrationDomains to enumerate domains recommended
780 * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
781 * (the index for a given interface is determined via the if_nametoindex()
782 * family of calls.) Most applications will pass 0 to enumerate domains on
785 * callback: The delegate to be called when a domain is found or the call asynchronously
789 * return value: Returns initialize ServiceRef on succeses (any subsequent, asynchronous
790 * errors are delivered to the delegate), otherwise throws an exception indicating
791 * the error that occurred (the callback is not invoked and the ServiceRef
792 * is not initialized.)
795 static public ServiceRef
*
800 EnumerateDomainsReply
* callback
803 /*********************************************************************************************
805 * Service Registration
807 *********************************************************************************************/
809 /* Register a service that is discovered via Browse() and Resolve() calls.
811 * RegisterReply() Callback Parameters:
813 * sdRef: The ServiceRef initialized by Register().
815 * flags: Currently unused, reserved for future use.
817 * errorCode: Will be NoError on success, otherwise will
818 * indicate the failure that occurred (including name conflicts, if the
819 * NoAutoRename flag was passed to the
820 * callout.) Other parameters are undefined if errorCode is nonzero.
822 * name: The service name registered (if the application did not specify a name in
823 * DNSServiceRegister(), this indicates what name was automatically chosen).
825 * regtype: The type of service registered, as it was passed to the callout.
827 * domain: The domain on which the service was registered (if the application did not
828 * specify a domain in Register(), this indicates the default domain
829 * on which the service was registered).
844 /* Register() Parameters:
846 * flags: Indicates the renaming behavior on name conflict (most applications
847 * will pass 0). See flag definitions above for details.
849 * interfaceIndex: If non-zero, specifies the interface on which to register the service
850 * (the index for a given interface is determined via the if_nametoindex()
851 * family of calls.) Most applications will pass 0 to register on all
852 * available interfaces. Pass -1 to register a service only on the local
853 * machine (service will not be visible to remote hosts.)
855 * name: If non-NULL, specifies the service name to be registered.
856 * Most applications will not specify a name, in which case the
857 * computer name is used (this name is communicated to the client via
860 * regtype: The service type followed by the protocol, separated by a dot
861 * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
862 * New service types should be registered at htp://www.dns-sd.org/ServiceTypes.html.
864 * domain: If non-NULL, specifies the domain on which to advertise the service.
865 * Most applications will not specify a domain, instead automatically
866 * registering in the default domain(s).
868 * host: If non-NULL, specifies the SRV target host name. Most applications
869 * will not specify a host, instead automatically using the machine's
870 * default host name(s). Note that specifying a non-NULL host does NOT
871 * create an address record for that host - the application is responsible
872 * for ensuring that the appropriate address record exists, or creating it
873 * via DNSServiceRegisterRecord().
875 * port: The port, in host byte order, on which the service accepts connections.
876 * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
877 * by browsing, but will cause a name conflict if another client tries to
878 * register that same name). Most clients will not use placeholder services.
880 * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
881 * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
882 * <length byte> <data> ...
884 * callback: The delegate to be called when the registration completes or asynchronously
885 * fails. The client MAY pass NULL for the callback - The client will NOT be notified
886 * of the default values picked on its behalf, and the client will NOT be notified of any
887 * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
888 * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
889 * The client may still deregister the service at any time via DNSServiceRefDeallocate().
891 * return value: Returns initialize ServiceRef (any subsequent, asynchronous
892 * errors are delivered to the callback), otherwise throws an exception indicating
893 * the error that occurred (the callback is never invoked and the DNSServiceRef
894 * is not initialized.)
897 static public ServiceRef
*
908 RegisterReply
* callback
913 * Add a record to a registered service. The name of the record will be the same as the
914 * registered service's name.
915 * The record can later be updated or deregistered by passing the RecordRef initialized
916 * by this function to UpdateRecord() or RemoveRecord().
921 * sdRef: A ServiceRef initialized by Register().
923 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
924 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
925 * If the above ServiceRef is disposed, RecordRef is also
926 * invalidated and may not be used further.
928 * flags: Currently ignored, reserved for future use.
930 * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
932 * rdata: The raw rdata to be contained in the added resource record.
934 * ttl: The time to live of the resource record, in seconds.
936 * return value: Returns initialized RecordRef, otherwise throws
937 * an exception indicating the error that occurred (the RecordRef is not initialized).
940 static public RecordRef
*
952 * Update a registered resource record. The record must either be:
953 * - The primary txt record of a service registered via Register()
954 * - A record added to a registered service via AddRecord()
955 * - An individual record registered by RegisterRecord()
960 * sdRef: A ServiceRef that was initialized by Register()
961 * or CreateConnection().
963 * RecordRef: A RecordRef initialized by AddRecord, or NULL to update the
964 * service's primary txt record.
966 * flags: Currently ignored, reserved for future use.
968 * rdata: The new rdata to be contained in the updated resource record.
970 * ttl: The time to live of the updated resource record, in seconds.
972 * return value: No return value on success, otherwise throws an exception
973 * indicating the error that occurred.
987 * Remove a record previously added to a service record set via AddRecord(), or deregister
988 * an record registered individually via RegisterRecord().
992 * sdRef: A ServiceRef initialized by Register() (if the
993 * record being removed was registered via AddRecord()) or by
994 * CreateConnection() (if the record being removed was registered via
997 * recordRef: A RecordRef initialized by a successful call to AddRecord()
998 * or RegisterRecord().
1000 * flags: Currently ignored, reserved for future use.
1002 * return value: Nothing on success, otherwise throws an
1003 * exception indicating the error that occurred.
1014 /*********************************************************************************************
1018 *********************************************************************************************/
1020 /* Browse for instances of a service.
1023 * BrowseReply() Parameters:
1025 * sdRef: The DNSServiceRef initialized by Browse().
1027 * flags: Possible values are MoreComing and Add.
1028 * See flag definitions for details.
1030 * interfaceIndex: The interface on which the service is advertised. This index should
1031 * be passed to Resolve() when resolving the service.
1033 * errorCode: Will be NoError (0) on success, otherwise will
1034 * indicate the failure that occurred. Other parameters are undefined if
1035 * the errorCode is nonzero.
1037 * serviceName: The service name discovered.
1039 * regtype: The service type, as passed in to Browse().
1041 * domain: The domain on which the service was discovered (if the application did not
1042 * specify a domain in Browse(), this indicates the domain on which the
1043 * service was discovered.)
1053 ErrorCode errorCode
,
1059 /* DNSServiceBrowse() Parameters:
1061 * sdRef: A pointer to an uninitialized ServiceRef. Call ServiceRef.Dispose()
1062 * to terminate the browse.
1064 * flags: Currently ignored, reserved for future use.
1066 * interfaceIndex: If non-zero, specifies the interface on which to browse for services
1067 * (the index for a given interface is determined via the if_nametoindex()
1068 * family of calls.) Most applications will pass 0 to browse on all available
1069 * interfaces. Pass -1 to only browse for services provided on the local host.
1071 * regtype: The service type being browsed for followed by the protocol, separated by a
1072 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1074 * domain: If non-NULL, specifies the domain on which to browse for services.
1075 * Most applications will not specify a domain, instead browsing on the
1076 * default domain(s).
1078 * callback: The delegate to be called when an instance of the service being browsed for
1079 * is found, or if the call asynchronously fails.
1081 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1082 * errors are delivered to the callback), otherwise throws an exception indicating
1083 * the error that occurred (the callback is not invoked and the ServiceRef
1084 * is not initialized.)
1087 static public ServiceRef
*
1094 BrowseReply
* callback
1097 /* ResolveReply() Parameters:
1099 * Resolve a service name discovered via Browse() to a target host name, port number, and
1102 * Note: Applications should NOT use Resolve() solely for txt record monitoring - use
1103 * QueryRecord() instead, as it is more efficient for this task.
1105 * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
1106 * ServiceRef.Dispose().
1108 * Note: Resolve() behaves correctly for typical services that have a single SRV record and
1109 * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
1110 * SRV or TXT records, QueryRecord() should be used.
1112 * ResolveReply Callback Parameters:
1114 * sdRef: The DNSServiceRef initialized by Resolve().
1116 * flags: Currently unused, reserved for future use.
1118 * interfaceIndex: The interface on which the service was resolved.
1120 * errorCode: Will be NoError (0) on success, otherwise will
1121 * indicate the failure that occurred. Other parameters are undefined if
1122 * the errorCode is nonzero.
1124 * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
1125 * (Any literal dots (".") are escaped with a backslash ("\."), and literal
1126 * backslashes are escaped with a second backslash ("\\"), e.g. a web server
1127 * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
1128 * This is the appropriate format to pass to standard system DNS APIs such as
1129 * res_query(), or to the special-purpose functions included in this API that
1130 * take fullname parameters.
1132 * hosttarget: The target hostname of the machine providing the service. This name can
1133 * be passed to functions like gethostbyname() to identify the host's IP address.
1135 * port: The port, in host byte order, on which connections are accepted for this service.
1137 * txtRecord: The service's primary txt record, in standard txt record format.
1147 ErrorCode errorCode
,
1154 /* Resolve() Parameters
1156 * flags: Currently ignored, reserved for future use.
1158 * interfaceIndex: The interface on which to resolve the service. The client should
1159 * pass the interface on which the servicename was discovered, i.e.
1160 * the interfaceIndex passed to the DNSServiceBrowseReply callback,
1161 * or 0 to resolve the named service on all available interfaces.
1163 * name: The servicename to be resolved.
1165 * regtype: The service type being resolved followed by the protocol, separated by a
1166 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1168 * domain: The domain on which the service is registered, i.e. the domain passed
1169 * to the DNSServiceBrowseReply callback.
1171 * callback: The delegate to be called when a result is found, or if the call
1172 * asynchronously fails.
1175 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1176 * errors are delivered to the callback), otherwise throws an exception indicating
1177 * the error that occurred (the callback is never invoked and the DNSServiceRef
1178 * is not initialized.)
1181 static public ServiceRef
*
1189 ResolveReply
* callback
1192 /*********************************************************************************************
1194 * Special Purpose Calls (most applications will not use these)
1196 *********************************************************************************************/
1198 /* CreateConnection/RegisterRecord
1200 * Register an individual resource record on a connected ServiceRef.
1202 * Note that name conflicts occurring for records registered via this call must be handled
1203 * by the client in the callback.
1206 * RecordReply() parameters:
1208 * sdRef: The connected ServiceRef initialized by
1209 * CreateConnection().
1211 * RecordRef: The RecordRef initialized by RegisterRecord(). If the above
1212 * ServiceRef.Dispose is called, this RecordRef is
1213 * invalidated, and may not be used further.
1215 * flags: Currently unused, reserved for future use.
1217 * errorCode: Will be NoError on success, otherwise will
1218 * indicate the failure that occurred (including name conflicts.)
1219 * Other parameters are undefined if errorCode is nonzero.
1228 ErrorCode errorCode
,
1232 /* CreateConnection()
1234 * Create a connection to the daemon allowing efficient registration of
1235 * multiple individual records.
1240 * callback: The delegate to be called when a result is found, or if the call
1241 * asynchronously fails (e.g. because of a name conflict.)
1243 * return value: Returns initialize ServiceRef on success, otherwise throws
1244 * an exception indicating the specific failure that occurred (in which
1245 * case the ServiceRef is not initialized).
1248 static public ServiceRef
*
1251 RegisterRecordReply
* callback
1255 /* RegisterRecord() Parameters:
1257 * sdRef: A ServiceRef initialized by CreateConnection().
1259 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
1260 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
1261 * (To deregister ALL records registered on a single connected ServiceRef
1262 * and deallocate each of their corresponding RecordRefs, call
1263 * ServiceRef.Dispose()).
1265 * flags: Possible values are Shared or Unique
1266 * (see flag type definitions for details).
1268 * interfaceIndex: If non-zero, specifies the interface on which to register the record
1269 * (the index for a given interface is determined via the if_nametoindex()
1270 * family of calls.) Passing 0 causes the record to be registered on all interfaces.
1271 * Passing -1 causes the record to only be visible on the local host.
1273 * fullname: The full domain name of the resource record.
1275 * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
1278 * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
1281 * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
1283 * ttl: The time to live of the resource record, in seconds.
1286 * return value: Returns initialize RecordRef on succeses (any subsequent, asynchronous
1287 * errors are delivered to the callback), otherwise throws an exception indicating
1288 * the error that occurred (the callback is never invoked and the RecordRef is
1291 static public RecordRef
*
1305 /* DNSServiceQueryRecord
1307 * Query for an arbitrary DNS record.
1310 * QueryRecordReply() Delegate Parameters:
1312 * sdRef: The ServiceRef initialized by QueryRecord().
1314 * flags: Possible values are MoreComing and
1315 * Add. The Add flag is NOT set for PTR records
1316 * with a ttl of 0, i.e. "Remove" events.
1318 * interfaceIndex: The interface on which the query was resolved (the index for a given
1319 * interface is determined via the if_nametoindex() family of calls).
1321 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
1322 * indicate the failure that occurred. Other parameters are undefined if
1323 * errorCode is nonzero.
1325 * fullname: The resource record's full domain name.
1327 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1329 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1331 * rdata: The raw rdata of the resource record.
1333 * ttl: The resource record's time to live, in seconds.
1343 ErrorCode errorCode
,
1351 /* QueryRecord() Parameters:
1353 * flags: Pass LongLivedQuery to create a "long-lived" unicast
1354 * query in a non-local domain. Without setting this flag, unicast queries
1355 * will be one-shot - that is, only answers available at the time of the call
1356 * will be returned. By setting this flag, answers (including Add and Remove
1357 * events) that become available after the initial call is made will generate
1358 * callbacks. This flag has no effect on link-local multicast queries.
1360 * interfaceIndex: If non-zero, specifies the interface on which to issue the query
1361 * (the index for a given interface is determined via the if_nametoindex()
1362 * family of calls.) Passing 0 causes the name to be queried for on all
1363 * interfaces. Passing -1 causes the name to be queried for only on the
1366 * fullname: The full domain name of the resource record to be queried for.
1368 * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
1369 * as defined in nameser.h.
1371 * rrclass: The class of the resource record, as defined in nameser.h
1372 * (usually 1 for the Internet class).
1374 * callback: The delegate to be called when a result is found, or if the call
1375 * asynchronously fails.
1378 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1379 * errors are delivered to the callback), otherwise throws an exception indicating
1380 * the error that occurred (the callback is never invoked and the ServiceRef
1381 * is not initialized.)
1384 static public ServiceRef
*
1392 QueryRecordReply
* callback
1397 * Instruct the daemon to verify the validity of a resource record that appears to
1398 * be out of date (e.g. because tcp connection to a service's target failed.)
1399 * Causes the record to be flushed from the daemon's cache (as well as all other
1400 * daemons' caches on the network) if the record is determined to be invalid.
1404 * flags: Currently unused, reserved for future use.
1406 * fullname: The resource record's full domain name.
1408 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1410 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1412 * rdata: The raw rdata of the resource record.