4b22b9337f359bfd063322244f5336cc7c6ffcfars/* -*- Mode: Java; tab-width: 4 -*-
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Licensed under the Apache License, Version 2.0 (the "License");
4b22b9337f359bfd063322244f5336cc7c6ffcfars * you may not use this file except in compliance with the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You may obtain a copy of the License at
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Unless required by applicable law or agreed to in writing, software
4b22b9337f359bfd063322244f5336cc7c6ffcfars * distributed under the License is distributed on an "AS IS" BASIS,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See the License for the specific language governing permissions and
4b22b9337f359bfd063322244f5336cc7c6ffcfars * limitations under the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars This file declares and implements DNSSD, the central Java factory class
4b22b9337f359bfd063322244f5336cc7c6ffcfars for doing DNS Service Discovery. It includes the mostly-abstract public
4b22b9337f359bfd063322244f5336cc7c6ffcfars interface, as well as the Apple* implementation subclasses.
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSSD provides access to DNS Service Discovery features of ZeroConf networking.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars It is a factory class that is used to invoke registration and discovery-related
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome operations. Most operations are non-blocking; clients are called back through an interface
4b22b9337f359bfd063322244f5336cc7c6ffcfars with the result of an operation. Callbacks are made from a separate worker thread.<P>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome For example, in this program<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars <PRE><CODE>
4b22b9337f359bfd063322244f5336cc7c6ffcfars class MyClient implements BrowseListener {
4b22b9337f359bfd063322244f5336cc7c6ffcfars void lookForWebServers() {
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome myBrowser = DNSSD.browse("_http._tcp", this);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public void serviceFound(DNSSDService browser, int flags, int ifIndex,
4b22b9337f359bfd063322244f5336cc7c6ffcfars String serviceName, String regType, String domain) {}
4b22b9337f359bfd063322244f5336cc7c6ffcfars }</CODE></PRE>
4b22b9337f359bfd063322244f5336cc7c6ffcfars <CODE>MyClient.serviceFound()</CODE> would be called for every HTTP server discovered in the
4b22b9337f359bfd063322244f5336cc7c6ffcfars default browse domain(s).
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Flag indicates to a {@link BrowseListener} that another result is
4b22b9337f359bfd063322244f5336cc7c6ffcfars queued. Applications should not update their UI to display browse
4b22b9337f359bfd063322244f5336cc7c6ffcfars results if the MORE_COMING flag is set; they will be called at least once
4b22b9337f359bfd063322244f5336cc7c6ffcfars more with the flag clear.
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** If flag is set in a {@link DomainListener} callback, indicates that the result is the default domain. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** If flag is set, a name conflict will trigger an exception when registering non-shared records.<P>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome A name must be explicitly specified when registering a service if this bit is set
4b22b9337f359bfd063322244f5336cc7c6ffcfars (i.e. the default name may not not be used).
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** If flag is set, allow multiple records with this name on the network (e.g. PTR records)
4b22b9337f359bfd063322244f5336cc7c6ffcfars when registering individual records on a {@link DNSSDRegistration}.
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** If flag is set, records with this name must be unique on the network (e.g. SRV records). */
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Set flag when calling enumerateDomains() to restrict results to domains recommended for browsing. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Set flag when calling enumerateDomains() to restrict results to domains recommended for registration. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static final int REGISTRATION_DOMAINS = ( 1 << 7 );
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Maximum length, in bytes, of a domain name represented as an escaped C-String. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public static final int MAX_DOMAIN_NAME = 1009;
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Pass for ifIndex to specify all available interfaces. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Pass for ifIndex to specify the localhost interface. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Browse for instances of a service.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars Note: browsing consumes network bandwidth. Call {@link DNSSDService#stop} when you have finished browsing.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-zero, specifies the interface on which to browse for services
4b22b9337f359bfd063322244f5336cc7c6ffcfars (the index for a given interface is determined via the if_nametoindex()
4b22b9337f359bfd063322244f5336cc7c6ffcfars family of calls.) Most applications will pass 0 to browse on all available
4b22b9337f359bfd063322244f5336cc7c6ffcfars interfaces. Pass -1 to only browse for services provided on the local host.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type being browsed for followed by the protocol, separated by a
4b22b9337f359bfd063322244f5336cc7c6ffcfars dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-null, specifies the domain on which to browse for services.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Most applications will not specify a domain, instead browsing on the
4b22b9337f359bfd063322244f5336cc7c6ffcfars default domain(s).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when instances of the service are discovered (or disappear).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDService} that represents the active browse operation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static DNSSDService browse( int flags, int ifIndex, String regType, String domain, BrowseListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._makeBrowser( flags, ifIndex, regType, domain, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Browse for instances of a service. Use default flags, ifIndex and domain.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type being browsed for followed by the protocol, separated by a
4b22b9337f359bfd063322244f5336cc7c6ffcfars dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when instances of the service are discovered (or disappear).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDService} that represents the active browse operation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static DNSSDService browse( String regType, BrowseListener listener)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Resolve a service name discovered via browse() to a target host name, port number, and txt record.<P>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Note: Applications should NOT use resolve() solely for txt record monitoring - use
4b22b9337f359bfd063322244f5336cc7c6ffcfars queryRecord() instead, as it is more efficient for this task.<P>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Note: When the desired results have been returned, the client MUST terminate the resolve by
4b22b9337f359bfd063322244f5336cc7c6ffcfars calling {@link DNSSDService#stop}.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars Note: resolve() behaves correctly for typical services that have a single SRV record and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome a single TXT record (the TXT record may be empty.) To resolve non-standard services with
4b22b9337f359bfd063322244f5336cc7c6ffcfars multiple SRV or TXT records, use queryRecord().<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars The interface on which to resolve the service. The client should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome pass the interface on which the serviceName was discovered (i.e.
4b22b9337f359bfd063322244f5336cc7c6ffcfars the ifIndex passed to the serviceFound() callback)
4b22b9337f359bfd063322244f5336cc7c6ffcfars or 0 to resolve the named service on all available interfaces.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param serviceName
4b22b9337f359bfd063322244f5336cc7c6ffcfars The servicename to be resolved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type being resolved followed by the protocol, separated by a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars The domain on which the service is registered, i.e. the domain passed
4b22b9337f359bfd063322244f5336cc7c6ffcfars to the serviceFound() callback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when the service is resolved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDService} that represents the active resolve operation.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public static DNSSDService resolve( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._resolve( flags, ifIndex, serviceName, regType, domain, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Register a service, to be discovered via browse() and resolve() calls.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Possible values are: NO_AUTO_RENAME.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-zero, specifies the interface on which to register the service
4b22b9337f359bfd063322244f5336cc7c6ffcfars (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome family of calls.) Most applications will pass 0 to register on all
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome available interfaces. Pass -1 to register a service only on the local
4b22b9337f359bfd063322244f5336cc7c6ffcfars machine (service will not be visible to remote hosts).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param serviceName
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome If non-null, specifies the service name to be registered.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Applications need not specify a name, in which case the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome computer name is used (this name is communicated to the client via
4b22b9337f359bfd063322244f5336cc7c6ffcfars the serviceRegistered() callback).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type being registered followed by the protocol, separated by a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-null, specifies the domain on which to advertise the service.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Most applications will not specify a domain, instead automatically
4b22b9337f359bfd063322244f5336cc7c6ffcfars registering in the default domain(s).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param host
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-null, specifies the SRV target host name. Most applications
4b22b9337f359bfd063322244f5336cc7c6ffcfars will not specify a host, instead automatically using the machine's
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome default host name(s). Note that specifying a non-null host does NOT
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome create an address record for that host - the application is responsible
4b22b9337f359bfd063322244f5336cc7c6ffcfars for ensuring that the appropriate address record exists, or creating it
4b22b9337f359bfd063322244f5336cc7c6ffcfars via {@link DNSSDRegistration#addRecord}.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param port
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The port on which the service accepts connections. Pass 0 for a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "placeholder" service (i.e. a service that will not be discovered by
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome browsing, but will cause a name conflict if another client tries to
4b22b9337f359bfd063322244f5336cc7c6ffcfars register that same name.) Most clients will not use placeholder services.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The txt record rdata. May be null. Note that a non-null txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
4b22b9337f359bfd063322244f5336cc7c6ffcfars <length byte> <data> ...
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when the service is registered.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDRegistration} that controls the active registration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public static DNSSDRegistration register( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars String domain, String host, int port, TXTRecord txtRecord, RegisterListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._register( flags, ifIndex, serviceName, regType, domain, host, port, txtRecord, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Register a service, to be discovered via browse() and resolve() calls. Use default flags, ifIndex, domain, host and txtRecord.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param serviceName
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome If non-null, specifies the service name to be registered.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Applications need not specify a name, in which case the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome computer name is used (this name is communicated to the client via
4b22b9337f359bfd063322244f5336cc7c6ffcfars the serviceRegistered() callback).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type being registered followed by the protocol, separated by a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param port
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The port on which the service accepts connections. Pass 0 for a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "placeholder" service (i.e. a service that will not be discovered by
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome browsing, but will cause a name conflict if another client tries to
4b22b9337f359bfd063322244f5336cc7c6ffcfars register that same name.) Most clients will not use placeholder services.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when the service is registered.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDRegistration} that controls the active registration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static DNSSDRegistration register( String serviceName, String regType, int port, RegisterListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return register( 0, 0, serviceName, regType, null, null, port, null, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Create a {@link DNSSDRecordRegistrar} allowing efficient registration of
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome multiple individual records.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDRecordRegistrar} that can be used to register records.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static DNSSDRecordRegistrar createRecordRegistrar( RegisterRecordListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._createRecordRegistrar( listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Query for an arbitrary DNS record.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Possible values are: MORE_COMING.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-zero, specifies the interface on which to issue the query
4b22b9337f359bfd063322244f5336cc7c6ffcfars (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome family of calls.) Passing 0 causes the name to be queried for on all
4b22b9337f359bfd063322244f5336cc7c6ffcfars interfaces. Passing -1 causes the name to be queried for only on the
4b22b9337f359bfd063322244f5336cc7c6ffcfars local host.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param serviceName
4b22b9337f359bfd063322244f5336cc7c6ffcfars The full domain name of the resource record to be queried for.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param rrtype
4b22b9337f359bfd063322244f5336cc7c6ffcfars The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
4b22b9337f359bfd063322244f5336cc7c6ffcfars as defined in nameser.h.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param rrclass
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The class of the resource record, as defined in nameser.h
4b22b9337f359bfd063322244f5336cc7c6ffcfars (usually 1 for the Internet class).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when the query completes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDService} that controls the active query.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public static DNSSDService queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._queryRecord( flags, ifIndex, serviceName, rrtype, rrclass, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Asynchronously enumerate domains available for browsing and registration.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars Currently, the only domain returned is "local.", but other domains will be returned in future.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars The enumeration MUST be cancelled by calling {@link DNSSDService#stop} when no more domains
4b22b9337f359bfd063322244f5336cc7c6ffcfars are to be found.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Possible values are: BROWSE_DOMAINS, REGISTRATION_DOMAINS.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-zero, specifies the interface on which to look for domains.
4b22b9337f359bfd063322244f5336cc7c6ffcfars (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome family of calls.) Most applications will pass 0 to enumerate domains on
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome all interfaces.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param listener
4b22b9337f359bfd063322244f5336cc7c6ffcfars This object will get called when domains are found.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return A {@link DNSSDService} that controls the active enumeration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static DNSSDService enumerateDomains( int flags, int ifIndex, DomainListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._enumerateDomains( flags, ifIndex, listener); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Concatenate a three-part domain name (as provided to the listeners) into a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome properly-escaped full domain name. Note that strings passed to listeners are
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome ALREADY ESCAPED where necessary.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param serviceName
4b22b9337f359bfd063322244f5336cc7c6ffcfars The service name - any dots or slashes must NOT be escaped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars May be null (to construct a PTR record name, e.g. "_ftp._tcp.apple.com").
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param regType
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome The registration type followed by the protocol, separated by a dot (e.g. "_ftp._tcp").
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars The domain name, e.g. "apple.com". Any literal dots or backslashes must be escaped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return The full domain name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars public static String constructFullName( String serviceName, String regType, String domain)
4b22b9337f359bfd063322244f5336cc7c6ffcfars { return getInstance()._constructFullName( serviceName, regType, domain); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Instruct the daemon to verify the validity of a resource record that appears to
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome be out of date. (e.g. because tcp connection to a service's target failed.) <P>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome Causes the record to be flushed from the daemon's cache (as well as all other
4b22b9337f359bfd063322244f5336cc7c6ffcfars daemons' caches on the network) if the record is determined to be invalid.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param flags
4b22b9337f359bfd063322244f5336cc7c6ffcfars Currently unused, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars If non-zero, specifies the interface on which to reconfirm the record
4b22b9337f359bfd063322244f5336cc7c6ffcfars (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome family of calls.) Passing 0 causes the name to be reconfirmed on all
4b22b9337f359bfd063322244f5336cc7c6ffcfars interfaces. Passing -1 causes the name to be reconfirmed only on the
4b22b9337f359bfd063322244f5336cc7c6ffcfars local host.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param fullName
4b22b9337f359bfd063322244f5336cc7c6ffcfars The resource record's full domain name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param rrtype
4b22b9337f359bfd063322244f5336cc7c6ffcfars The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param rrclass
4b22b9337f359bfd063322244f5336cc7c6ffcfars The class of the resource record, as defined in nameser.h (usually 1).
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param rdata
4b22b9337f359bfd063322244f5336cc7c6ffcfars The raw rdata of the resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public static void reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars { getInstance()._reconfirmRecord( flags, ifIndex, fullName, rrtype, rrclass, rdata); }
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Return the canonical name of a particular interface index.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifIndex
4b22b9337f359bfd063322244f5336cc7c6ffcfars A valid interface index. Must not be ALL_INTERFACES.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return The name of the interface, which should match java.net.NetworkInterface.getName().
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /** Return the index of a named interface.<P>
4b22b9337f359bfd063322244f5336cc7c6ffcfars @param ifName
4b22b9337f359bfd063322244f5336cc7c6ffcfars A valid interface name. An example is java.net.NetworkInterface.getName().
4b22b9337f359bfd063322244f5336cc7c6ffcfars @return The interface index.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars @see RuntimePermission
4b22b9337f359bfd063322244f5336cc7c6ffcfars /** Return the single instance of DNSSD. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome sm.checkPermission( new RuntimePermission( "getDNSSDInstance"));
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected DNSSDService _makeBrowser( int flags, int ifIndex, String regType, String domain, BrowseListener listener)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome abstract protected DNSSDService _resolve( int flags, int ifIndex, String serviceName, String regType,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome abstract protected DNSSDRegistration _register( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars String domain, String host, int port, TXTRecord txtRecord, RegisterListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected DNSSDRecordRegistrar _createRecordRegistrar( RegisterRecordListener listener)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome abstract protected DNSSDService _queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected DNSSDService _enumerateDomains( int flags, int ifIndex, DomainListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected String _constructFullName( String serviceName, String regType, String domain)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome abstract protected void _reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected String _getNameForIfIndex( int ifIndex);
4b22b9337f359bfd063322244f5336cc7c6ffcfars abstract protected int _getIfIndexForName( String ifName);
4b22b9337f359bfd063322244f5336cc7c6ffcfars String name = System.getProperty( "com.apple.dnssd.DNSSD" );
4b22b9337f359bfd063322244f5336cc7c6ffcfars name = "com.apple.dnssd.AppleDNSSD"; // Fall back to Apple-provided class.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome fInstance = (DNSSD) Class.forName(name).newInstance();
4b22b9337f359bfd063322244f5336cc7c6ffcfars throw new InternalError( "cannot instantiate DNSSD" + e );
4b22b9337f359bfd063322244f5336cc7c6ffcfars// Concrete implementation of DNSSDException
4b22b9337f359bfd063322244f5336cc7c6ffcfars public AppleDNSSDException( int errorCode) { fErrorCode = errorCode; }
4b22b9337f359bfd063322244f5336cc7c6ffcfars final String kMessages[] = { // should probably be put into a resource or something
4b22b9337f359bfd063322244f5336cc7c6ffcfars "UNKNOWN",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NO_SUCH_NAME",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NO_MEMORY",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BAD_PARAM",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BAD_REFERENCE",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BAD_STATE",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BAD_FLAGS",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "UNSUPPORTED",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NOT_INITIALIZED",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NO_CACHE",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "ALREADY_REGISTERED",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NAME_CONFLICT",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "INVALID",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "FIREWALL",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "INCOMPATIBLE",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BAD_INTERFACE_INDEX",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "REFUSED",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NOSUCHRECORD",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NOSUCHKEY",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "NATTRAVERSAL",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "DOUBLENAT",
4b22b9337f359bfd063322244f5336cc7c6ffcfars "BADTIME",
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "TRANSIENT",
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "SERVICENOTRUNNING",
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "NATPORTMAPPINGUNSUPPORTED",
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome "NATPORTMAPPINGDISABLED"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome if (fErrorCode <= UNKNOWN && fErrorCode > ( UNKNOWN - kMessages.length))
4b22b9337f359bfd063322244f5336cc7c6ffcfars return "DNS-SD Error " + String.valueOf( fErrorCode) + ": " + kMessages[ UNKNOWN - fErrorCode];
4b22b9337f359bfd063322244f5336cc7c6ffcfars return super.getMessage() + "(" + String.valueOf( fErrorCode) + ")";
4b22b9337f359bfd063322244f5336cc7c6ffcfars// The concrete, default implementation.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome int libInitResult = InitLibrary( 2); // Current version number (must be sync'd with jnilib version)
4b22b9337f359bfd063322244f5336cc7c6ffcfars throw new InternalError( "cannot instantiate DNSSD: " + new AppleDNSSDException( libInitResult).getMessage());
4b22b9337f359bfd063322244f5336cc7c6ffcfars static public boolean hasAutoCallbacks; // Set by InitLibrary() to value of AUTO_CALLBACKS
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected DNSSDService _makeBrowser( int flags, int ifIndex, String regType, String domain, BrowseListener client)
4b22b9337f359bfd063322244f5336cc7c6ffcfars return new AppleBrowser( flags, ifIndex, regType, domain, client);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected DNSSDService _resolve( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars return new AppleResolver( flags, ifIndex, serviceName, regType, domain, client);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected DNSSDRegistration _register( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars String domain, String host, int port, TXTRecord txtRecord, RegisterListener client)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome return new AppleRegistration( flags, ifIndex, serviceName, regType, domain, host, port,
4b22b9337f359bfd063322244f5336cc7c6ffcfars ( txtRecord != null) ? txtRecord.getRawBytes() : null, client);
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected DNSSDRecordRegistrar _createRecordRegistrar( RegisterRecordListener listener)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected DNSSDService _queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars return new AppleQuery( flags, ifIndex, serviceName, rrtype, rrclass, client);
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected DNSSDService _enumerateDomains( int flags, int ifIndex, DomainListener listener)
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected String _constructFullName( String serviceName, String regType, String domain)
4b22b9337f359bfd063322244f5336cc7c6ffcfars String[] responseHolder = new String[1]; // lame maneuver to get around Java's lack of reference parameters
4b22b9337f359bfd063322244f5336cc7c6ffcfars int rc = ConstructName( serviceName, regType, domain, responseHolder);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected void _reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars ReconfirmRecord( flags, ifIndex, fullName, rrtype, rrclass, rdata);
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected native int ConstructName( String serviceName, String regType, String domain, String[] pOut);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected native void ReconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected static native int InitLibrary( int callerVersion);
4b22b9337f359bfd063322244f5336cc7c6ffcfars public AppleService(BaseListener listener) { fNativeContext = 0; fListener = listener; }
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Block until data arrives, or one second passes. Returns 1 if data present, 0 otherwise. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Call ProcessResults when data appears on socket descriptor. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected long /* warning */ fNativeContext; // Private storage for native side
4b22b9337f359bfd063322244f5336cc7c6ffcfars while ( true )
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Note: We want to allow our DNS-SD operation to be stopped from other threads, so we have to
4b22b9337f359bfd063322244f5336cc7c6ffcfars // block waiting for data *outside* the synchronized section. Because we're doing this unsynchronized
4b22b9337f359bfd063322244f5336cc7c6ffcfars // we have to write some careful code. Suppose our DNS-SD operation is stopped from some other thread,
4b22b9337f359bfd063322244f5336cc7c6ffcfars // and then immediately afterwards that thread (or some third, unrelated thread) starts a new DNS-SD
4b22b9337f359bfd063322244f5336cc7c6ffcfars // operation. The Unix kernel always allocates the lowest available file descriptor to a new socket,
4b22b9337f359bfd063322244f5336cc7c6ffcfars // so the same file descriptor is highly likely to be reused for the new operation, and if our old
4b22b9337f359bfd063322244f5336cc7c6ffcfars // stale ServiceThread accidentally consumes bytes off that new socket we'll get really messed up.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // To guard against that, before calling ProcessResults we check to ensure that our
4b22b9337f359bfd063322244f5336cc7c6ffcfars // fNativeContext has not been deleted, which is a telltale sign that our operation was stopped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // After calling ProcessResults we check again, because it's extremely common for callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars // functions to stop their own operation and start others. For example, a resolveListener callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars // may well stop the resolve and then start a QueryRecord call to monitor the TXT record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // The remaining risk is that between our checking fNativeContext and calling ProcessResults(),
4b22b9337f359bfd063322244f5336cc7c6ffcfars // some other thread could stop the operation and start a new one using same file descriptor, and
4b22b9337f359bfd063322244f5336cc7c6ffcfars // we wouldn't know. To prevent this, the AppleService object's HaltOperation() routine is declared
4b22b9337f359bfd063322244f5336cc7c6ffcfars // synchronized and we perform our checks synchronized on the AppleService object, which ensures
4b22b9337f359bfd063322244f5336cc7c6ffcfars // that HaltOperation() can't execute while we're doing it. Because Java locks are re-entrant this
4b22b9337f359bfd063322244f5336cc7c6ffcfars // locking DOESN'T prevent the callback routine from stopping its own operation, but DOES prevent
4b22b9337f359bfd063322244f5336cc7c6ffcfars // any other thread from stopping it until after the callback has completed and returned to us here.
4b22b9337f359bfd063322244f5336cc7c6ffcfars synchronized (this)
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (fNativeContext == 0) break; // Some other thread stopped our DNSSD operation; time to terminate this thread
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (result == 0) continue; // If BlockForData() said there was no data, go back and block again
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (fNativeContext == 0) break; // Event listener stopped its own DNSSD operation; terminate this thread
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (result != 0) { fListener.operationFailed(this, result); break; } // If error, notify listener
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleBrowser( int flags, int ifIndex, String regType, String domain, BrowseListener client)
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.CreateBrowser( flags, ifIndex, regType, domain));
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected native int CreateBrowser( int flags, int ifIndex, String regType, String domain);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleResolver( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.CreateResolver( flags, ifIndex, serviceName, regType, domain));
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected native int CreateResolver( int flags, int ifIndex, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars// An AppleDNSRecord is a simple wrapper around a dns_sd DNSRecord.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected long fRecord; // Really a DNSRecord; sizeof(long) == sizeof(void*) ?
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected native int Update( int flags, byte[] rData, int ttl);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsclass AppleRegistration extends AppleService implements DNSSDRegistration
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleRegistration( int flags, int ifIndex, String serviceName, String regType, String domain,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome String host, int port, byte[] txtRecord, RegisterListener client)
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.BeginRegister( ifIndex, flags, serviceName, regType, domain, host, port, txtRecord));
4b22b9337f359bfd063322244f5336cc7c6ffcfars public DNSRecord addRecord( int flags, int rrType, byte[] rData, int ttl)
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.AddRecord( flags, rrType, rData, ttl, newRecord));
4b22b9337f359bfd063322244f5336cc7c6ffcfars return new AppleDNSRecord( this); // A record with ref 0 is understood to be primary TXT record
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected native int BeginRegister( int ifIndex, int flags, String serviceName, String regType,
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected native int AddRecord( int flags, int rrType, byte[] rData, int ttl, AppleDNSRecord destObj);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsclass AppleRecordRegistrar extends AppleService implements DNSSDRecordRegistrar
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleRecordRegistrar( RegisterRecordListener listener)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public DNSRecord registerRecord( int flags, int ifIndex, String fullname, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.RegisterRecord( flags, ifIndex, fullname, rrtype, rrclass, rdata, ttl, newRecord));
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome protected native int RegisterRecord( int flags, int ifIndex, String fullname, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars int rrclass, byte[] rdata, int ttl, AppleDNSRecord destObj);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleQuery( int flags, int ifIndex, String serviceName, int rrtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars this.ThrowOnErr( this.CreateQuery( flags, ifIndex, serviceName, rrtype, rrclass));
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars protected native int CreateQuery( int flags, int ifIndex, String serviceName, int rrtype, int rrclass);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome public AppleDomainEnum( int flags, int ifIndex, DomainListener client)
4b22b9337f359bfd063322244f5336cc7c6ffcfars // Sets fNativeContext. Returns non-zero on error.