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/>
42 using namespace System
;
43 using namespace System::Net
;
44 using namespace System::Runtime::InteropServices
;
45 using namespace System::Threading
;
46 using namespace System::Collections
;
53 public __gc
class ServiceRef
;
55 public __value
enum ServiceFlags
: int
58 /* MoreComing indicates to a callback that at least one more result is
59 * queued and will be delivered following immediately after this one.
60 * Applications should not update their UI to display browse
61 * results when the MoreComing flag is set, because this would
62 * result in a great deal of ugly flickering on the screen.
63 * Applications should instead wait until until MoreComing is not set,
64 * and then update their UI.
65 * When MoreComing is not set, that doesn't mean there will be no more
66 * answers EVER, just that there are no more answers immediately
67 * available right now at this instant. If more answers become available
68 * in the future they will be delivered as usual.
73 /* Flags for domain enumeration and browse/query reply callbacks.
74 * "Default" applies only to enumeration and is only valid in
75 * conjuction with "Add". An enumeration callback with the "Add"
76 * flag NOT set indicates a "Remove", i.e. the domain is no longer
81 /* Flag for specifying renaming behavior on name conflict when registering
82 * non-shared records. By default, name conflicts are automatically handled
83 * by renaming the service. NoAutoRename overrides this behavior - with this
84 * flag set, name conflicts will result in a callback. The NoAutorename flag
85 * is only valid if a name is explicitly specified when registering a service
86 * (i.e. the default name is not used.)
91 /* Flag for registering individual records on a connected
92 * DNSServiceRef. Shared indicates that there may be multiple records
93 * with this name on the network (e.g. PTR records). Unique indicates that
95 * record's name is to be unique on the network (e.g. SRV records).
99 RegistrationDomains
= 128,
100 /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomain
102 * BrowseDomains enumerates domains recommended for browsing, RegistrationDo
104 * enumerates domains recommended for registration.
109 public __value
enum ErrorCode
: int
116 BadReference
= -65541,
119 Unsupported
= -65544,
120 AlreadyRegistered
= -65547,
121 NameConflict
= -65548,
123 Incompatible
= -65551,
124 BadinterfaceIndex
= -65552
127 * mDNS Error codes are in the range
128 * FFFE FF00 (-65792) to FFFE FFFF (-65537)
132 public __gc
class DNSServiceException
146 System::Exception
* innerException
156 * This is a thin MC++ class facade on top of a DNSRecordRef
158 public __gc
class RecordRef
164 m_impl
= new RecordRefImpl
;
165 m_impl
->m_ref
= NULL
;
173 __nogc
class RecordRefImpl
180 RecordRefImpl
* m_impl
;
187 * This is a thin MC++ class facade on top of a DNSServiceRef
189 public __gc
class ServiceRef
: public IDisposable
193 ServiceRef(Object
* callback
);
198 * This does an underlying DNSServiceRefDeallocate(). After
199 * calling Dispose, the ServiceRef is no longer usable.
205 * Internal - Dispatch an EnumerateDomains callback
208 EnumerateDomainsDispatch
217 * Internal - Dispatch a Register callback
230 * Internal - Dispatch a Browse callback
238 String
* serviceName
,
244 * Internal - Dispatch a Resolve callback
259 * Internal - Dispatch a RegisterRecord callback
262 RegisterRecordDispatch
270 * Internal - Dispatch a QueryRecord callback
286 * Internal - A non managed class to wrap a DNSServiceRef
288 __nogc
class ServiceRefImpl
300 * Sets up events for threaded operation
306 * Main processing thread
312 * Calls DNSServiceRefDeallocate()
318 * Called from dnssd.dll
320 static void DNSSD_API
321 EnumerateDomainsCallback
324 DNSServiceFlags flags
,
325 uint32_t interfaceIndex
,
326 DNSServiceErrorType errorCode
,
327 const char * replyDomain
,
331 static void DNSSD_API
335 DNSServiceFlags flags
,
336 DNSServiceErrorType errorCode
,
338 const char * regtype
,
343 static void DNSSD_API
347 DNSServiceFlags flags
,
348 uint32_t interfaceIndex
,
349 DNSServiceErrorType errorCode
,
350 const char * serviceName
,
351 const char * regtype
,
352 const char * replyDomain
,
356 static void DNSSD_API
360 DNSServiceFlags flags
,
361 uint32_t interfaceIndex
,
362 DNSServiceErrorType errorCode
,
363 const char * fullname
,
364 const char * hosttarget
,
365 uint16_t notAnIntPort
,
367 const char * txtRecord
,
371 static void DNSSD_API
372 RegisterRecordCallback
375 DNSRecordRef RecordRef
,
376 DNSServiceFlags flags
,
377 DNSServiceErrorType errorCode
,
381 static void DNSSD_API
384 DNSServiceRef DNSServiceRef
,
385 DNSServiceFlags flags
,
386 uint32_t interfaceIndex
,
387 DNSServiceErrorType errorCode
,
388 const char * fullname
,
398 HANDLE m_socketEvent
;
403 gcroot
<ServiceRef
*> m_outer
;
415 ServiceRefImpl
* m_impl
;
418 /*********************************************************************************************
420 * TXT Record Construction Functions
422 *********************************************************************************************/
425 * A typical calling sequence for TXT record construction is something like:
427 * DNSService.TextRecord tr = new DNSService.TextRecord(1024);
432 * DNSServiceRegister( ... tr.GetLength(), tr.GetBytes() ... );
438 * Opaque internal data type.
439 * Note: Represents a DNS-SD TXT record.
443 /* TextRecord::TextRecord()
445 * Creates a new empty TextRecord .
449 public __gc
class TextRecord
455 m_impl
= new TextRecordImpl();
456 TXTRecordCreate(&m_impl
->m_ref
, 0, NULL
);
461 TXTRecordDeallocate(&m_impl
->m_ref
);
465 __nogc
class TextRecordImpl
472 TextRecordImpl
* m_impl
;
477 * Adds a key (optionally with value) to a TextRecord. If the "key" already
478 * exists in the TextRecord, then the current value will be replaced with
480 * Keys may exist in four states with respect to a given TXT record:
481 * - Absent (key does not appear at all)
482 * - Present with no value ("key" appears alone)
483 * - Present with empty value ("key=" appears in TXT record)
484 * - Present with non-empty value ("key=value" appears in TXT record)
485 * For more details refer to "Data Syntax for DNS-SD TXT Records" in
486 * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
488 * key: A null-terminated string which only contains printable ASCII
489 * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
490 * 14 characters or less (not counting the terminating null).
492 * value: Any binary value. For values that represent
493 * textual data, UTF-8 is STRONGLY recommended.
494 * For values that represent textual data, valueSize
495 * should NOT include the terminating null (if any)
496 * at the end of the string.
497 * If NULL, then "key" will be added with no value.
498 * If non-NULL but valueSize is zero, then "key=" will be
499 * added with empty value.
501 * exceptions: Throws kDNSServiceErr_Invalid if the "key" string contains
502 * illegal characters.
503 * Throws kDNSServiceErr_NoMemory if adding this key would
504 * exceed the available storage.
511 Byte value
[] /* may be NULL */
517 * Removes a key from a TextRecord. The "key" must be an
518 * ASCII string which exists in the TextRecord.
520 * key: A key name which exists in the TextRecord.
522 * exceptions: Throws kDNSServiceErr_NoSuchKey if the "key" does not
523 * exist in the TextRecord.
536 * Allows you to determine the length of the raw bytes within a TextRecord.
538 * return value : Returns the size of the raw bytes inside a TextRecord
539 * which you can pass directly to DNSServiceRegister() or
540 * to DNSServiceUpdateRecord().
541 * Returns 0 if the TextRecord is empty.
553 * Allows you to retrieve a pointer to the raw bytes within a TextRecord.
555 * return value: Returns a pointer to the bytes inside the TextRecord
556 * which you can pass directly to DNSServiceRegister() or
557 * to DNSServiceUpdateRecord().
567 /*********************************************************************************************
569 * TXT Record Parsing Functions
571 *********************************************************************************************/
574 * A typical calling sequence for TXT record parsing is something like:
576 * Receive TXT record data in DNSServiceResolve() callback
577 * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
578 * val1ptr = DNSService.TextService.GetValue(txtRecord, "key1", &len1);
579 * val2ptr = DNSService.TextService.GetValue(txtRecord, "key2", &len2);
587 * Allows you to determine if a given TXT Record contains a specified key.
589 * txtRecord: Pointer to the received TXT Record bytes.
591 * key: A null-terminated ASCII string containing the key name.
593 * return value: Returns 1 if the TXT Record contains the specified key.
594 * Otherwise, it returns 0.
608 * Allows you to retrieve the value for a given key from a TXT Record.
610 * txtRecord: Pointer to the received TXT Record bytes.
612 * key: A null-terminated ASCII string containing the key name.
614 * return value: Returns NULL if the key does not exist in this TXT record,
615 * or exists with no value (to differentiate between
616 * these two cases use ContainsKey()).
618 * if the key exists with empty or non-empty value.
619 * For empty value, length of byte array will be zero.
620 * For non-empty value, it will be the length of value data.
633 * Returns the number of keys stored in the TXT Record. The count
634 * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
636 * txtRecord: Pointer to the received TXT Record bytes.
638 * return value: Returns the total number of keys in the TXT Record.
651 * Allows you to retrieve a key name and value pointer, given an index into
652 * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
653 * It's also possible to iterate through keys in a TXT record by simply
654 * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
655 * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
658 * For keys with no value, *value is set to NULL and *valueLen is zero.
659 * For keys with empty value, *value is non-NULL and *valueLen is zero.
660 * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
662 * txtRecord: Pointer to the received TXT Record bytes.
664 * index: An index into the TXT Record.
666 * key: A string buffer used to store the key name.
667 * On return, the buffer contains a string
668 * giving the key name. DNS-SD TXT keys are usually
669 * 14 characters or less.
671 * return value: Record bytes that holds the value data.
673 * exceptions: Throws kDNSServiceErr_Invalid if index is greater than
687 public __abstract __gc
class DNSService
691 /*********************************************************************************************
695 *********************************************************************************************/
697 /* DNSServiceEnumerateDomains()
699 * Asynchronously enumerate domains available for browsing and registration.
700 * Currently, the only domain returned is "local.", but other domains will be returned in future.
702 * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
706 * EnumerateDomainsReply Delegate
708 * This Delegate is invoked upon a reply from an EnumerateDomains call.
710 * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
712 * flags: Possible values are:
717 * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
718 * interface is determined via the if_nametoindex() family of calls.)
720 * errorCode: Will be NoError (0) on success, otherwise indicates
721 * the failure that occurred (other parameters are undefined if errorCode is nonzero).
723 * replyDomain: The name of the domain.
728 EnumerateDomainsReply
737 /* DNSServiceEnumerateDomains() Parameters:
740 * flags: Possible values are:
741 * BrowseDomains to enumerate domains recommended for browsing.
742 * RegistrationDomains to enumerate domains recommended
745 * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
746 * (the index for a given interface is determined via the if_nametoindex()
747 * family of calls.) Most applications will pass 0 to enumerate domains on
750 * callback: The delegate to be called when a domain is found or the call asynchronously
754 * return value: Returns initialize ServiceRef on succeses (any subsequent, asynchronous
755 * errors are delivered to the delegate), otherwise throws an exception indicating
756 * the error that occurred (the callback is not invoked and the ServiceRef
757 * is not initialized.)
760 static public ServiceRef
*
765 EnumerateDomainsReply
* callback
768 /*********************************************************************************************
770 * Service Registration
772 *********************************************************************************************/
774 /* Register a service that is discovered via Browse() and Resolve() calls.
776 * RegisterReply() Callback Parameters:
778 * sdRef: The ServiceRef initialized by Register().
780 * flags: Currently unused, reserved for future use.
782 * errorCode: Will be NoError on success, otherwise will
783 * indicate the failure that occurred (including name conflicts, if the
784 * NoAutoRename flag was passed to the
785 * callout.) Other parameters are undefined if errorCode is nonzero.
787 * name: The service name registered (if the application did not specify a name in
788 * DNSServiceRegister(), this indicates what name was automatically chosen).
790 * regtype: The type of service registered, as it was passed to the callout.
792 * domain: The domain on which the service was registered (if the application did not
793 * specify a domain in Register(), this indicates the default domain
794 * on which the service was registered).
809 /* Register() Parameters:
811 * flags: Indicates the renaming behavior on name conflict (most applications
812 * will pass 0). See flag definitions above for details.
814 * interfaceIndex: If non-zero, specifies the interface on which to register the service
815 * (the index for a given interface is determined via the if_nametoindex()
816 * family of calls.) Most applications will pass 0 to register on all
817 * available interfaces. Pass -1 to register a service only on the local
818 * machine (service will not be visible to remote hosts.)
820 * name: If non-NULL, specifies the service name to be registered.
821 * Most applications will not specify a name, in which case the
822 * computer name is used (this name is communicated to the client via
825 * regtype: The service type followed by the protocol, separated by a dot
826 * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
827 * New service types should be registered at htp://www.dns-sd.org/ServiceTypes.html.
829 * domain: If non-NULL, specifies the domain on which to advertise the service.
830 * Most applications will not specify a domain, instead automatically
831 * registering in the default domain(s).
833 * host: If non-NULL, specifies the SRV target host name. Most applications
834 * will not specify a host, instead automatically using the machine's
835 * default host name(s). Note that specifying a non-NULL host does NOT
836 * create an address record for that host - the application is responsible
837 * for ensuring that the appropriate address record exists, or creating it
838 * via DNSServiceRegisterRecord().
840 * port: The port, in host byte order, on which the service accepts connections.
841 * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
842 * by browsing, but will cause a name conflict if another client tries to
843 * register that same name). Most clients will not use placeholder services.
845 * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
846 * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
847 * <length byte> <data> ...
849 * callback: The delegate to be called when the registration completes or asynchronously
850 * fails. The client MAY pass NULL for the callback - The client will NOT be notified
851 * of the default values picked on its behalf, and the client will NOT be notified of any
852 * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
853 * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
854 * The client may still deregister the service at any time via DNSServiceRefDeallocate().
856 * return value: Returns initialize ServiceRef (any subsequent, asynchronous
857 * errors are delivered to the callback), otherwise throws an exception indicating
858 * the error that occurred (the callback is never invoked and the DNSServiceRef
859 * is not initialized.)
862 static public ServiceRef
*
873 RegisterReply
* callback
878 * Add a record to a registered service. The name of the record will be the same as the
879 * registered service's name.
880 * The record can later be updated or deregistered by passing the RecordRef initialized
881 * by this function to UpdateRecord() or RemoveRecord().
886 * sdRef: A ServiceRef initialized by Register().
888 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
889 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
890 * If the above ServiceRef is disposed, RecordRef is also
891 * invalidated and may not be used further.
893 * flags: Currently ignored, reserved for future use.
895 * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
897 * rdata: The raw rdata to be contained in the added resource record.
899 * ttl: The time to live of the resource record, in seconds.
901 * return value: Returns initialized RecordRef, otherwise throws
902 * an exception indicating the error that occurred (the RecordRef is not initialized).
905 static public RecordRef
*
917 * Update a registered resource record. The record must either be:
918 * - The primary txt record of a service registered via Register()
919 * - A record added to a registered service via AddRecord()
920 * - An individual record registered by RegisterRecord()
925 * sdRef: A ServiceRef that was initialized by Register()
926 * or CreateConnection().
928 * RecordRef: A RecordRef initialized by AddRecord, or NULL to update the
929 * service's primary txt record.
931 * flags: Currently ignored, reserved for future use.
933 * rdata: The new rdata to be contained in the updated resource record.
935 * ttl: The time to live of the updated resource record, in seconds.
937 * return value: No return value on success, otherwise throws an exception
938 * indicating the error that occurred.
952 * Remove a record previously added to a service record set via AddRecord(), or deregister
953 * an record registered individually via RegisterRecord().
957 * sdRef: A ServiceRef initialized by Register() (if the
958 * record being removed was registered via AddRecord()) or by
959 * CreateConnection() (if the record being removed was registered via
962 * recordRef: A RecordRef initialized by a successful call to AddRecord()
963 * or RegisterRecord().
965 * flags: Currently ignored, reserved for future use.
967 * return value: Nothing on success, otherwise throws an
968 * exception indicating the error that occurred.
979 /*********************************************************************************************
983 *********************************************************************************************/
985 /* Browse for instances of a service.
988 * BrowseReply() Parameters:
990 * sdRef: The DNSServiceRef initialized by Browse().
992 * flags: Possible values are MoreComing and Add.
993 * See flag definitions for details.
995 * interfaceIndex: The interface on which the service is advertised. This index should
996 * be passed to Resolve() when resolving the service.
998 * errorCode: Will be NoError (0) on success, otherwise will
999 * indicate the failure that occurred. Other parameters are undefined if
1000 * the errorCode is nonzero.
1002 * serviceName: The service name discovered.
1004 * regtype: The service type, as passed in to Browse().
1006 * domain: The domain on which the service was discovered (if the application did not
1007 * specify a domain in Browse(), this indicates the domain on which the
1008 * service was discovered.)
1018 ErrorCode errorCode
,
1024 /* DNSServiceBrowse() Parameters:
1026 * sdRef: A pointer to an uninitialized ServiceRef. Call ServiceRef.Dispose()
1027 * to terminate the browse.
1029 * flags: Currently ignored, reserved for future use.
1031 * interfaceIndex: If non-zero, specifies the interface on which to browse for services
1032 * (the index for a given interface is determined via the if_nametoindex()
1033 * family of calls.) Most applications will pass 0 to browse on all available
1034 * interfaces. Pass -1 to only browse for services provided on the local host.
1036 * regtype: The service type being browsed for followed by the protocol, separated by a
1037 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1039 * domain: If non-NULL, specifies the domain on which to browse for services.
1040 * Most applications will not specify a domain, instead browsing on the
1041 * default domain(s).
1043 * callback: The delegate to be called when an instance of the service being browsed for
1044 * is found, or if the call asynchronously fails.
1046 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1047 * errors are delivered to the callback), otherwise throws an exception indicating
1048 * the error that occurred (the callback is not invoked and the ServiceRef
1049 * is not initialized.)
1052 static public ServiceRef
*
1059 BrowseReply
* callback
1062 /* ResolveReply() Parameters:
1064 * Resolve a service name discovered via Browse() to a target host name, port number, and
1067 * Note: Applications should NOT use Resolve() solely for txt record monitoring - use
1068 * QueryRecord() instead, as it is more efficient for this task.
1070 * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
1071 * ServiceRef.Dispose().
1073 * Note: Resolve() behaves correctly for typical services that have a single SRV record and
1074 * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
1075 * SRV or TXT records, QueryRecord() should be used.
1077 * ResolveReply Callback Parameters:
1079 * sdRef: The DNSServiceRef initialized by Resolve().
1081 * flags: Currently unused, reserved for future use.
1083 * interfaceIndex: The interface on which the service was resolved.
1085 * errorCode: Will be NoError (0) on success, otherwise will
1086 * indicate the failure that occurred. Other parameters are undefined if
1087 * the errorCode is nonzero.
1089 * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
1090 * (Any literal dots (".") are escaped with a backslash ("\."), and literal
1091 * backslashes are escaped with a second backslash ("\\"), e.g. a web server
1092 * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
1093 * This is the appropriate format to pass to standard system DNS APIs such as
1094 * res_query(), or to the special-purpose functions included in this API that
1095 * take fullname parameters.
1097 * hosttarget: The target hostname of the machine providing the service. This name can
1098 * be passed to functions like gethostbyname() to identify the host's IP address.
1100 * port: The port, in host byte order, on which connections are accepted for this service.
1102 * txtRecord: The service's primary txt record, in standard txt record format.
1112 ErrorCode errorCode
,
1119 /* Resolve() Parameters
1121 * flags: Currently ignored, reserved for future use.
1123 * interfaceIndex: The interface on which to resolve the service. The client should
1124 * pass the interface on which the servicename was discovered, i.e.
1125 * the interfaceIndex passed to the DNSServiceBrowseReply callback,
1126 * or 0 to resolve the named service on all available interfaces.
1128 * name: The servicename to be resolved.
1130 * regtype: The service type being resolved followed by the protocol, separated by a
1131 * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
1133 * domain: The domain on which the service is registered, i.e. the domain passed
1134 * to the DNSServiceBrowseReply callback.
1136 * callback: The delegate to be called when a result is found, or if the call
1137 * asynchronously fails.
1140 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1141 * errors are delivered to the callback), otherwise throws an exception indicating
1142 * the error that occurred (the callback is never invoked and the DNSServiceRef
1143 * is not initialized.)
1146 static public ServiceRef
*
1154 ResolveReply
* callback
1157 /*********************************************************************************************
1159 * Special Purpose Calls (most applications will not use these)
1161 *********************************************************************************************/
1163 /* CreateConnection/RegisterRecord
1165 * Register an individual resource record on a connected ServiceRef.
1167 * Note that name conflicts occurring for records registered via this call must be handled
1168 * by the client in the callback.
1171 * RecordReply() parameters:
1173 * sdRef: The connected ServiceRef initialized by
1174 * CreateConnection().
1176 * RecordRef: The RecordRef initialized by RegisterRecord(). If the above
1177 * ServiceRef.Dispose is called, this RecordRef is
1178 * invalidated, and may not be used further.
1180 * flags: Currently unused, reserved for future use.
1182 * errorCode: Will be NoError on success, otherwise will
1183 * indicate the failure that occurred (including name conflicts.)
1184 * Other parameters are undefined if errorCode is nonzero.
1193 ErrorCode errorCode
,
1197 /* CreateConnection()
1199 * Create a connection to the daemon allowing efficient registration of
1200 * multiple individual records.
1205 * callback: The delegate to be called when a result is found, or if the call
1206 * asynchronously fails (e.g. because of a name conflict.)
1208 * return value: Returns initialize ServiceRef on success, otherwise throws
1209 * an exception indicating the specific failure that occurred (in which
1210 * case the ServiceRef is not initialized).
1213 static public ServiceRef
*
1216 RegisterRecordReply
* callback
1220 /* RegisterRecord() Parameters:
1222 * sdRef: A ServiceRef initialized by CreateConnection().
1224 * RecordRef: A pointer to an uninitialized RecordRef. Upon succesfull completion of this
1225 * call, this ref may be passed to UpdateRecord() or RemoveRecord().
1226 * (To deregister ALL records registered on a single connected ServiceRef
1227 * and deallocate each of their corresponding RecordRefs, call
1228 * ServiceRef.Dispose()).
1230 * flags: Possible values are Shared or Unique
1231 * (see flag type definitions for details).
1233 * interfaceIndex: If non-zero, specifies the interface on which to register the record
1234 * (the index for a given interface is determined via the if_nametoindex()
1235 * family of calls.) Passing 0 causes the record to be registered on all interfaces.
1236 * Passing -1 causes the record to only be visible on the local host.
1238 * fullname: The full domain name of the resource record.
1240 * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
1243 * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
1246 * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
1248 * ttl: The time to live of the resource record, in seconds.
1251 * return value: Returns initialize RecordRef on succeses (any subsequent, asynchronous
1252 * errors are delivered to the callback), otherwise throws an exception indicating
1253 * the error that occurred (the callback is never invoked and the RecordRef is
1256 static public RecordRef
*
1270 /* DNSServiceQueryRecord
1272 * Query for an arbitrary DNS record.
1275 * QueryRecordReply() Delegate Parameters:
1277 * sdRef: The ServiceRef initialized by QueryRecord().
1279 * flags: Possible values are MoreComing and
1280 * Add. The Add flag is NOT set for PTR records
1281 * with a ttl of 0, i.e. "Remove" events.
1283 * interfaceIndex: The interface on which the query was resolved (the index for a given
1284 * interface is determined via the if_nametoindex() family of calls).
1286 * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
1287 * indicate the failure that occurred. Other parameters are undefined if
1288 * errorCode is nonzero.
1290 * fullname: The resource record's full domain name.
1292 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1294 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1296 * rdata: The raw rdata of the resource record.
1298 * ttl: The resource record's time to live, in seconds.
1308 ErrorCode errorCode
,
1316 /* QueryRecord() Parameters:
1318 * flags: Pass LongLivedQuery to create a "long-lived" unicast
1319 * query in a non-local domain. Without setting this flag, unicast queries
1320 * will be one-shot - that is, only answers available at the time of the call
1321 * will be returned. By setting this flag, answers (including Add and Remove
1322 * events) that become available after the initial call is made will generate
1323 * callbacks. This flag has no effect on link-local multicast queries.
1325 * interfaceIndex: If non-zero, specifies the interface on which to issue the query
1326 * (the index for a given interface is determined via the if_nametoindex()
1327 * family of calls.) Passing 0 causes the name to be queried for on all
1328 * interfaces. Passing -1 causes the name to be queried for only on the
1331 * fullname: The full domain name of the resource record to be queried for.
1333 * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
1334 * as defined in nameser.h.
1336 * rrclass: The class of the resource record, as defined in nameser.h
1337 * (usually 1 for the Internet class).
1339 * callback: The delegate to be called when a result is found, or if the call
1340 * asynchronously fails.
1343 * return value: Returns initialized ServiceRef on succeses (any subsequent, asynchronous
1344 * errors are delivered to the callback), otherwise throws an exception indicating
1345 * the error that occurred (the callback is never invoked and the ServiceRef
1346 * is not initialized.)
1349 static public ServiceRef
*
1357 QueryRecordReply
* callback
1362 * Instruct the daemon to verify the validity of a resource record that appears to
1363 * be out of date (e.g. because tcp connection to a service's target failed.)
1364 * Causes the record to be flushed from the daemon's cache (as well as all other
1365 * daemons' caches on the network) if the record is determined to be invalid.
1369 * flags: Currently unused, reserved for future use.
1371 * fullname: The resource record's full domain name.
1373 * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
1375 * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
1377 * rdata: The raw rdata of the resource record.