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 bonjour@apple.com to let us know.
34 * You may want to discuss what you're doing on the Bonjour mailing
35 * list to see if others in similar positions have any suggestions for you:
37 * <http://lists.apple.com/bonjour-dev/>
40 Change History (most recent first):
43 Revision 1.8 2005/02/10 22:35:33 cheshire
44 <rdar://problem/3727944> Update name
46 Revision 1.7 2004/12/16 19:56:12 cheshire
49 Revision 1.6 2004/09/20 22:47:06 cheshire
50 Add cautionary comment
52 Revision 1.5 2004/09/16 18:16:27 shersche
53 Cleanup to parameter names
54 Submitted by: prepin@gmail.com
56 Revision 1.4 2004/09/13 19:35:57 shersche
57 <rdar://problem/3798941> Add Apple.DNSSD namespace to MC++ wrapper class
58 <rdar://problem/3798950> Change all instances of unsigned short to int
59 Bug #: 3798941, 3798950
61 Revision 1.3 2004/07/27 07:12:10 shersche
62 make TextRecord an instantiable class object
64 Revision 1.2 2004/07/19 07:48:34 shersche
65 fix bug in DNSService.Register when passing in NULL text record, add TextRecord APIs
67 Revision 1.1 2004/06/26 04:01:22 shersche
80 using namespace System
;
81 using namespace System::Net
;
82 using namespace System::Runtime::InteropServices
;
83 using namespace System::Threading
;
84 using namespace System::Collections
;
91 public __gc
class ServiceRef
;
93 public __value
enum ServiceFlags
: int
96 /* MoreComing indicates to a callback that at least one more result is
97 * queued and will be delivered following immediately after this one.
98 * Applications should not update their UI to display browse
99 * results when the MoreComing flag is set, because this would
100 * result in a great deal of ugly flickering on the screen.
101 * Applications should instead wait until until MoreComing is not set,
102 * and then update their UI.
103 * When MoreComing is not set, that doesn't mean there will be no more
104 * answers EVER, just that there are no more answers immediately
105 * available right now at this instant. If more answers become available
106 * in the future they will be delivered as usual.
111 /* Flags for domain enumeration and browse/query reply callbacks.
112 * "Default" applies only to enumeration and is only valid in
113 * conjuction with "Add". An enumeration callback with the "Add"
114 * flag NOT set indicates a "Remove", i.e. the domain is no longer
119 /* Flag for specifying renaming behavior on name conflict when registering
120 * non-shared records. By default, name conflicts are automatically handled
121 * by renaming the service. NoAutoRename overrides this behavior - with this
122 * flag set, name conflicts will result in a callback. The NoAutorename flag
123 * is only valid if a name is explicitly specified when registering a service
124 * (i.e. the default name is not used.)
129 /* Flag for registering individual records on a connected
130 * DNSServiceRef. Shared indicates that there may be multiple records
131 * with this name on the network (e.g. PTR records). Unique indicates that
133 * record's name is to be unique on the network (e.g. SRV records).
137 RegistrationDomains
= 128,
138 /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomain
140 * BrowseDomains enumerates domains recommended for browsing, RegistrationDo
142 * enumerates domains recommended for registration.
147 public __value
enum ErrorCode
: int
154 BadReference
= -65541,
157 Unsupported
= -65544,
158 AlreadyRegistered
= -65547,
159 NameConflict
= -65548,
161 Incompatible
= -65551,
162 BadinterfaceIndex
= -65552
165 * mDNS Error codes are in the range
166 * FFFE FF00 (-65792) to FFFE FFFF (-65537)
170 public __gc
class DNSServiceException
184 System::Exception
* innerException
194 * This is a thin MC++ class facade on top of a DNSRecordRef
196 public __gc
class RecordRef
202 m_impl
= new RecordRefImpl
;
203 m_impl
->m_ref
= NULL
;
211 __nogc
class RecordRefImpl
218 RecordRefImpl
* m_impl
;
225 * This is a thin MC++ class facade on top of a DNSServiceRef
227 public __gc
class ServiceRef
: public IDisposable
231 ServiceRef(Object
* callback
);
236 * This does an underlying DNSServiceRefDeallocate(). After
237 * calling Dispose, the ServiceRef is no longer usable.
243 * Internal - Dispatch an EnumerateDomains callback
246 EnumerateDomainsDispatch
255 * Internal - Dispatch a Register callback
268 * Internal - Dispatch a Browse callback
276 String
* serviceName
,
282 * Internal - Dispatch a Resolve callback
297 * Internal - Dispatch a RegisterRecord callback
300 RegisterRecordDispatch
308 * Internal - Dispatch a QueryRecord callback
324 * Internal - A non managed class to wrap a DNSServiceRef
326 __nogc
class ServiceRefImpl
338 * Sets up events for threaded operation
344 * Main processing thread
350 * Calls DNSServiceRefDeallocate()
356 * Called from dnssd.dll
358 static void DNSSD_API
359 EnumerateDomainsCallback
362 DNSServiceFlags flags
,
363 uint32_t interfaceIndex
,
364 DNSServiceErrorType errorCode
,
365 const char * replyDomain
,
369 static void DNSSD_API
373 DNSServiceFlags flags
,
374 DNSServiceErrorType errorCode
,
376 const char * regtype
,
381 static void DNSSD_API
385 DNSServiceFlags flags
,
386 uint32_t interfaceIndex
,
387 DNSServiceErrorType errorCode
,
388 const char * serviceName
,
389 const char * regtype
,
390 const char * replyDomain
,
394 static void DNSSD_API
398 DNSServiceFlags flags
,
399 uint32_t interfaceIndex
,
400 DNSServiceErrorType errorCode
,
401 const char * fullname
,
402 const char * hosttarget
,
403 uint16_t notAnIntPort
,
405 const char * txtRecord
,
409 static void DNSSD_API
410 RegisterRecordCallback
413 DNSRecordRef RecordRef
,
414 DNSServiceFlags flags
,
415 DNSServiceErrorType errorCode
,
419 static void DNSSD_API
422 DNSServiceRef DNSServiceRef
,
423 DNSServiceFlags flags
,
424 uint32_t interfaceIndex
,
425 DNSServiceErrorType errorCode
,
426 const char * fullname
,
436 HANDLE m_socketEvent
;
441 gcroot
<ServiceRef
*> m_outer
;
453 ServiceRefImpl
* m_impl
;
456 /*********************************************************************************************
458 * TXT Record Construction Functions
460 *********************************************************************************************/
463 * A typical calling sequence for TXT record construction is something like:
465 * DNSService.TextRecord tr = new DNSService.TextRecord(1024);
470 * DNSServiceRegister( ... tr.GetLength(), tr.GetBytes() ... );
476 * Opaque internal data type.
477 * Note: Represents a DNS-SD TXT record.
481 /* TextRecord::TextRecord()
483 * Creates a new empty TextRecord .
487 public __gc
class TextRecord
493 m_impl
= new TextRecordImpl();
494 TXTRecordCreate(&m_impl
->m_ref
, 0, NULL
);
499 TXTRecordDeallocate(&m_impl
->m_ref
);
503 __nogc
class TextRecordImpl
510 TextRecordImpl
* m_impl
;
515 * Adds a key (optionally with value) to a TextRecord. If the "key" already
516 * exists in the TextRecord, then the current value will be replaced with
518 * Keys may exist in four states with respect to a given TXT record:
519 * - Absent (key does not appear at all)
520 * - Present with no value ("key" appears alone)
521 * - Present with empty value ("key=" appears in TXT record)
522 * - Present with non-empty value ("key=value" appears in TXT record)
523 * For more details refer to "Data Syntax for DNS-SD TXT Records" in
524 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
526 * key: A null-terminated string which only contains printable ASCII
527 * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
528 * 14 characters or less (not counting the terminating null).
530 * value: Any binary value. For values that represent
531 * textual data, UTF-8 is STRONGLY recommended.
532 * For values that represent textual data, valueSize
533 * should NOT include the terminating null (if any)
534 * at the end of the string.
535 * If NULL, then "key" will be added with no value.
536 * If non-NULL but valueSize is zero, then "key=" will be
537 * added with empty value.
539 * exceptions: Throws kDNSServiceErr_Invalid if the "key" string contains
540 * illegal characters.
541 * Throws kDNSServiceErr_NoMemory if adding this key would
542 * exceed the available storage.
549 Byte value
[] /* may be NULL */
555 * Removes a key from a TextRecord. The "key" must be an
556 * ASCII string which exists in the TextRecord.
558 * key: A key name which exists in the TextRecord.
560 * exceptions: Throws kDNSServiceErr_NoSuchKey if the "key" does not
561 * exist in the TextRecord.
574 * Allows you to determine the length of the raw bytes within a TextRecord.
576 * return value : Returns the size of the raw bytes inside a TextRecord
577 * which you can pass directly to DNSServiceRegister() or
578 * to DNSServiceUpdateRecord().
579 * Returns 0 if the TextRecord is empty.
591 * Allows you to retrieve a pointer to the raw bytes within a TextRecord.
593 * return value: Returns a pointer to the bytes inside the TextRecord
594 * which you can pass directly to DNSServiceRegister() or
595 * to DNSServiceUpdateRecord().
605 /*********************************************************************************************
607 * TXT Record Parsing Functions
609 *********************************************************************************************/
612 * A typical calling sequence for TXT record parsing is something like:
614 * Receive TXT record data in DNSServiceResolve() callback
615 * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
616 * val1ptr = DNSService.TextService.GetValue(txtRecord, "key1", &len1);
617 * val2ptr = DNSService.TextService.GetValue(txtRecord, "key2", &len2);
625 * Allows you to determine if a given TXT Record contains a specified key.
627 * txtRecord: Pointer to the received TXT Record bytes.
629 * key: A null-terminated ASCII string containing the key name.
631 * return value: Returns 1 if the TXT Record contains the specified key.
632 * Otherwise, it returns 0.
646 * Allows you to retrieve the value for a given key from a TXT Record.
648 * txtRecord: Pointer to the received TXT Record bytes.
650 * key: A null-terminated ASCII string containing the key name.
652 * return value: Returns NULL if the key does not exist in this TXT record,
653 * or exists with no value (to differentiate between
654 * these two cases use ContainsKey()).
656 * if the key exists with empty or non-empty value.
657 * For empty value, length of byte array will be zero.
658 * For non-empty value, it will be the length of value data.
671 * Returns the number of keys stored in the TXT Record. The count
672 * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
674 * txtRecord: Pointer to the received TXT Record bytes.
676 * return value: Returns the total number of keys in the TXT Record.
689 * Allows you to retrieve a key name and value pointer, given an index into
690 * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
691 * It's also possible to iterate through keys in a TXT record by simply
692 * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
693 * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
696 * For keys with no value, *value is set to NULL and *valueLen is zero.
697 * For keys with empty value, *value is non-NULL and *valueLen is zero.
698 * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
700 * txtRecord: Pointer to the received TXT Record bytes.
702 * index: An index into the TXT Record.
704 * key: A string buffer used to store the key name.
705 * On return, the buffer contains a string
706 * giving the key name. DNS-SD TXT keys are usually
707 * 14 characters or less.
709 * return value: Record bytes that holds the value data.
711 * exceptions: Throws kDNSServiceErr_Invalid if index is greater than
725 public __abstract __gc
class DNSService
729 /*********************************************************************************************
733 *********************************************************************************************/
735 /* DNSServiceEnumerateDomains()
737 * Asynchronously enumerate domains available for browsing and registration.
738 * Currently, the only domain returned is "local.", but other domains will be returned in future.
740 * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
744 * EnumerateDomainsReply Delegate
746 * This Delegate is invoked upon a reply from an EnumerateDomains call.
748 * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
750 * flags: Possible values are:
755 * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
756 * interface is determined via the if_nametoindex() family of calls.)
758 * errorCode: Will be NoError (0) on success, otherwise indicates
759 * the failure that occurred (other parameters are undefined if errorCode is nonzero).
761 * replyDomain: The name of the domain.
766 EnumerateDomainsReply
775 /* DNSServiceEnumerateDomains() Parameters:
778 * flags: Possible values are:
779 * BrowseDomains to enumerate domains recommended for browsing.
780 * RegistrationDomains to enumerate domains recommended
783 * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
784 * (the index for a given interface is determined via the if_nametoindex()
785 * family of calls.) Most applications will pass 0 to enumerate domains on
788 * callback: The delegate to be called when a domain is found or the call asynchronously
792 * return value: Returns initialize ServiceRef on succeses (any subsequent, asynchronous
793 * errors are delivered to the delegate), otherwise throws an exception indicating
794 * the error that occurred (the callback is not invoked and the ServiceRef
795 * is not initialized.)
798 static public ServiceRef
*
803 EnumerateDomainsReply
* callback
806 /*********************************************************************************************
808 * Service Registration
810 *********************************************************************************************/
812 /* Register a service that is discovered via Browse() and Resolve() calls.
814 * RegisterReply() Callback Parameters:
816 * sdRef: The ServiceRef initialized by Register().
818 * flags: Currently unused, reserved for future use.
820 * errorCode: Will be NoError on success, otherwise will
821 * indicate the failure that occurred (including name conflicts, if the
822 * NoAutoRename flag was passed to the
823 * callout.) Other parameters are undefined if errorCode is nonzero.
825 * name: The service name registered (if the application did not specify a name in
826 * DNSServiceRegister(), this indicates what name was automatically chosen).
828 * regtype: The type of service registered, as it was passed to the callout.
830 * domain: The domain on which the service was registered (if the application did not
831 * specify a domain in Register(), this indicates the default domain
832 * on which the service was registered).
847 /* Register() Parameters:
849 * flags: Indicates the renaming behavior on name conflict (most applications
850 * will pass 0). See flag definitions above for details.
852 * interfaceIndex: If non-zero, specifies the interface on which to register the service
853 * (the index for a given interface is determined via the if_nametoindex()
854 * family of calls.) Most applications will pass 0 to register on all
855 * available interfaces. Pass -1 to register a service only on the local
856 * machine (service will not be visible to remote hosts.)
858 * name: If non-NULL, specifies the service name to be registered.
859 * Most applications will not specify a name, in which case the
860 * computer name is used (this name is communicated to the client via
863 * regtype: The service type followed by the protocol, separated by a dot
864 * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
865 * New service types should be registered at htp://www.dns-sd.org/ServiceTypes.html.
867 * domain: If non-NULL, specifies the domain on which to advertise the service.
868 * Most applications will not specify a domain, instead automatically
869 * registering in the default domain(s).
871 * host: If non-NULL, specifies the SRV target host name. Most applications
872 * will not specify a host, instead automatically using the machine's
873 * default host name(s). Note that specifying a non-NULL host does NOT
874 * create an address record for that host - the application is responsible
875 * for ensuring that the appropriate address record exists, or creating it
876 * via DNSServiceRegisterRecord().
878 * port: The port, in host byte order, on which the service accepts connections.
879 * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
880 * by browsing, but will cause a name conflict if another client tries to
881 * register that same name). Most clients will not use placeholder services.
883 * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
884 * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
885 * <length byte> <data> ...
887 * callback: The delegate to be called when the registration completes or asynchronously
888 * fails. The client MAY pass NULL for the callback - The client will NOT be notified
889 * of the default values picked on its behalf, and the client will NOT be notified of any
890 * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
891 * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
892 * The client may still deregister the service at any time via DNSServiceRefDeallocate().
894 * return value: Returns initialize ServiceRef (any subsequent, asynchronous
895 * errors are delivered to the callback), otherwise throws an exception indicating
896 * the error that occurred (the callback is never invoked and the DNSServiceRef
897 * is not initialized.)
900 static public ServiceRef
*
911 RegisterReply
* callback
916 * Add a record to a registered service. The name of the record will be the same as the
917 * registered service's name.
918 * The record can later be updated or deregistered by passing the RecordRef initialized
919 * by this function to UpdateRecord() or RemoveRecord().
924 * sdRef: A ServiceRef initialized by Register().
926 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
927 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
928 * If the above ServiceRef is disposed, RecordRef is also
929 * invalidated and may not be used further.
931 * flags: Currently ignored, reserved for future use.
933 * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
935 * rdata: The raw rdata to be contained in the added resource record.
937 * ttl: The time to live of the resource record, in seconds.
939 * return value: Returns initialized RecordRef, otherwise throws
940 * an exception indicating the error that occurred (the RecordRef is not initialized).
943 static public RecordRef
*
955 * Update a registered resource record. The record must either be:
956 * - The primary txt record of a service registered via Register()
957 * - A record added to a registered service via AddRecord()
958 * - An individual record registered by RegisterRecord()
963 * sdRef: A ServiceRef that was initialized by Register()
964 * or CreateConnection().
966 * RecordRef: A RecordRef initialized by AddRecord, or NULL to update the
967 * service's primary txt record.
969 * flags: Currently ignored, reserved for future use.
971 * rdata: The new rdata to be contained in the updated resource record.
973 * ttl: The time to live of the updated resource record, in seconds.
975 * return value: No return value on success, otherwise throws an exception
976 * indicating the error that occurred.
990 * Remove a record previously added to a service record set via AddRecord(), or deregister
991 * an record registered individually via RegisterRecord().
995 * sdRef: A ServiceRef initialized by Register() (if the
996 * record being removed was registered via AddRecord()) or by
997 * CreateConnection() (if the record being removed was registered via
1000 * recordRef: A RecordRef initialized by a successful call to AddRecord()
1001 * or RegisterRecord().
1003 * flags: Currently ignored, reserved for future use.
1005 * return value: Nothing on success, otherwise throws an
1006 * exception indicating the error that occurred.
1017 /*********************************************************************************************
1021 *********************************************************************************************/
1023 /* Browse for instances of a service.
1026 * BrowseReply() Parameters:
1028 * sdRef: The DNSServiceRef initialized by Browse().
1030 * flags: Possible values are MoreComing and Add.
1031 * See flag definitions for details.
1033 * interfaceIndex: The interface on which the service is advertised. This index should
1034 * be passed to Resolve() when resolving the service.
1036 * errorCode: Will be NoError (0) on success, otherwise will
1037 * indicate the failure that occurred. Other parameters are undefined if
1038 * the errorCode is nonzero.
1040 * serviceName: The service name discovered.
1042 * regtype: The service type, as passed in to Browse().
1044 * domain: The domain on which the service was discovered (if the application did not
1045 * specify a domain in Browse(), this indicates the domain on which the
1046 * service was discovered.)
1056 ErrorCode errorCode
,
1062 /* DNSServiceBrowse() Parameters:
1064 * sdRef: A pointer to an uninitialized ServiceRef. Call ServiceRef.Dispose()
1065 * to terminate the browse.
1067 * flags: Currently ignored, reserved for future use.
1069 * interfaceIndex: If non-zero, specifies the interface on which to browse for services
1070 * (the index for a given interface is determined via the if_nametoindex()
1071 * family of calls.) Most applications will pass 0 to browse on all available
1072 * interfaces. Pass -1 to only browse for services provided on the local host.
1074 * regtype: The service type being browsed for followed by the protocol, separated by a
1075 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1077 * domain: If non-NULL, specifies the domain on which to browse for services.
1078 * Most applications will not specify a domain, instead browsing on the
1079 * default domain(s).
1081 * callback: The delegate to be called when an instance of the service being browsed for
1082 * is found, or if the call asynchronously fails.
1084 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1085 * errors are delivered to the callback), otherwise throws an exception indicating
1086 * the error that occurred (the callback is not invoked and the ServiceRef
1087 * is not initialized.)
1090 static public ServiceRef
*
1097 BrowseReply
* callback
1100 /* ResolveReply() Parameters:
1102 * Resolve a service name discovered via Browse() to a target host name, port number, and
1105 * Note: Applications should NOT use Resolve() solely for txt record monitoring - use
1106 * QueryRecord() instead, as it is more efficient for this task.
1108 * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
1109 * ServiceRef.Dispose().
1111 * Note: Resolve() behaves correctly for typical services that have a single SRV record and
1112 * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
1113 * SRV or TXT records, QueryRecord() should be used.
1115 * ResolveReply Callback Parameters:
1117 * sdRef: The DNSServiceRef initialized by Resolve().
1119 * flags: Currently unused, reserved for future use.
1121 * interfaceIndex: The interface on which the service was resolved.
1123 * errorCode: Will be NoError (0) on success, otherwise will
1124 * indicate the failure that occurred. Other parameters are undefined if
1125 * the errorCode is nonzero.
1127 * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
1128 * (Any literal dots (".") are escaped with a backslash ("\."), and literal
1129 * backslashes are escaped with a second backslash ("\\"), e.g. a web server
1130 * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
1131 * This is the appropriate format to pass to standard system DNS APIs such as
1132 * res_query(), or to the special-purpose functions included in this API that
1133 * take fullname parameters.
1135 * hosttarget: The target hostname of the machine providing the service. This name can
1136 * be passed to functions like gethostbyname() to identify the host's IP address.
1138 * port: The port, in host byte order, on which connections are accepted for this service.
1140 * txtRecord: The service's primary txt record, in standard txt record format.
1150 ErrorCode errorCode
,
1157 /* Resolve() Parameters
1159 * flags: Currently ignored, reserved for future use.
1161 * interfaceIndex: The interface on which to resolve the service. The client should
1162 * pass the interface on which the servicename was discovered, i.e.
1163 * the interfaceIndex passed to the DNSServiceBrowseReply callback,
1164 * or 0 to resolve the named service on all available interfaces.
1166 * name: The servicename to be resolved.
1168 * regtype: The service type being resolved followed by the protocol, separated by a
1169 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1171 * domain: The domain on which the service is registered, i.e. the domain passed
1172 * to the DNSServiceBrowseReply callback.
1174 * callback: The delegate to be called when a result is found, or if the call
1175 * asynchronously fails.
1178 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1179 * errors are delivered to the callback), otherwise throws an exception indicating
1180 * the error that occurred (the callback is never invoked and the DNSServiceRef
1181 * is not initialized.)
1184 static public ServiceRef
*
1192 ResolveReply
* callback
1195 /*********************************************************************************************
1197 * Special Purpose Calls (most applications will not use these)
1199 *********************************************************************************************/
1201 /* CreateConnection/RegisterRecord
1203 * Register an individual resource record on a connected ServiceRef.
1205 * Note that name conflicts occurring for records registered via this call must be handled
1206 * by the client in the callback.
1209 * RecordReply() parameters:
1211 * sdRef: The connected ServiceRef initialized by
1212 * CreateConnection().
1214 * RecordRef: The RecordRef initialized by RegisterRecord(). If the above
1215 * ServiceRef.Dispose is called, this RecordRef is
1216 * invalidated, and may not be used further.
1218 * flags: Currently unused, reserved for future use.
1220 * errorCode: Will be NoError on success, otherwise will
1221 * indicate the failure that occurred (including name conflicts.)
1222 * Other parameters are undefined if errorCode is nonzero.
1231 ErrorCode errorCode
,
1235 /* CreateConnection()
1237 * Create a connection to the daemon allowing efficient registration of
1238 * multiple individual records.
1243 * callback: The delegate to be called when a result is found, or if the call
1244 * asynchronously fails (e.g. because of a name conflict.)
1246 * return value: Returns initialize ServiceRef on success, otherwise throws
1247 * an exception indicating the specific failure that occurred (in which
1248 * case the ServiceRef is not initialized).
1251 static public ServiceRef
*
1254 RegisterRecordReply
* callback
1258 /* RegisterRecord() Parameters:
1260 * sdRef: A ServiceRef initialized by CreateConnection().
1262 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
1263 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
1264 * (To deregister ALL records registered on a single connected ServiceRef
1265 * and deallocate each of their corresponding RecordRefs, call
1266 * ServiceRef.Dispose()).
1268 * flags: Possible values are Shared or Unique
1269 * (see flag type definitions for details).
1271 * interfaceIndex: If non-zero, specifies the interface on which to register the record
1272 * (the index for a given interface is determined via the if_nametoindex()
1273 * family of calls.) Passing 0 causes the record to be registered on all interfaces.
1274 * Passing -1 causes the record to only be visible on the local host.
1276 * fullname: The full domain name of the resource record.
1278 * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
1281 * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
1284 * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
1286 * ttl: The time to live of the resource record, in seconds.
1289 * return value: Returns initialize RecordRef on succeses (any subsequent, asynchronous
1290 * errors are delivered to the callback), otherwise throws an exception indicating
1291 * the error that occurred (the callback is never invoked and the RecordRef is
1294 static public RecordRef
*
1308 /* DNSServiceQueryRecord
1310 * Query for an arbitrary DNS record.
1313 * QueryRecordReply() Delegate Parameters:
1315 * sdRef: The ServiceRef initialized by QueryRecord().
1317 * flags: Possible values are MoreComing and
1318 * Add. The Add flag is NOT set for PTR records
1319 * with a ttl of 0, i.e. "Remove" events.
1321 * interfaceIndex: The interface on which the query was resolved (the index for a given
1322 * interface is determined via the if_nametoindex() family of calls).
1324 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
1325 * indicate the failure that occurred. Other parameters are undefined if
1326 * errorCode is nonzero.
1328 * fullname: The resource record's full domain name.
1330 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1332 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1334 * rdata: The raw rdata of the resource record.
1336 * ttl: The resource record's time to live, in seconds.
1346 ErrorCode errorCode
,
1354 /* QueryRecord() Parameters:
1356 * flags: Pass LongLivedQuery to create a "long-lived" unicast
1357 * query in a non-local domain. Without setting this flag, unicast queries
1358 * will be one-shot - that is, only answers available at the time of the call
1359 * will be returned. By setting this flag, answers (including Add and Remove
1360 * events) that become available after the initial call is made will generate
1361 * callbacks. This flag has no effect on link-local multicast queries.
1363 * interfaceIndex: If non-zero, specifies the interface on which to issue the query
1364 * (the index for a given interface is determined via the if_nametoindex()
1365 * family of calls.) Passing 0 causes the name to be queried for on all
1366 * interfaces. Passing -1 causes the name to be queried for only on the
1369 * fullname: The full domain name of the resource record to be queried for.
1371 * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
1372 * as defined in nameser.h.
1374 * rrclass: The class of the resource record, as defined in nameser.h
1375 * (usually 1 for the Internet class).
1377 * callback: The delegate to be called when a result is found, or if the call
1378 * asynchronously fails.
1381 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1382 * errors are delivered to the callback), otherwise throws an exception indicating
1383 * the error that occurred (the callback is never invoked and the ServiceRef
1384 * is not initialized.)
1387 static public ServiceRef
*
1395 QueryRecordReply
* callback
1400 * Instruct the daemon to verify the validity of a resource record that appears to
1401 * be out of date (e.g. because tcp connection to a service's target failed.)
1402 * Causes the record to be flushed from the daemon's cache (as well as all other
1403 * daemons' caches on the network) if the record is determined to be invalid.
1407 * flags: Currently unused, reserved for future use.
1409 * fullname: The resource record's full domain name.
1411 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1413 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1415 * rdata: The raw rdata of the resource record.