1 /* 2 * Copyright (c) 2024, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 package com.android.server.thread.openthread; 30 31 import com.android.server.thread.openthread.DnsTxtAttribute; 32 import com.android.server.thread.openthread.INsdDiscoverServiceCallback; 33 import com.android.server.thread.openthread.INsdResolveHostCallback; 34 import com.android.server.thread.openthread.INsdResolveServiceCallback; 35 import com.android.server.thread.openthread.INsdStatusReceiver; 36 37 /** 38 * The service which supports mDNS advertising and discovery by {@link NsdManager}. 39 */ 40 oneway interface INsdPublisher { 41 /** 42 * Registers an mDNS service. 43 * 44 * <p>When the hostname is set to null, register the service with the default host. Otherwise, 45 * register the servcie with the specified hostname. 46 * 47 * <p>The listenerId is an integer ID generated by the caller. It's used by the caller and 48 * the NsdPublisher service to uniquely identify a registration. 49 * 50 * @param hostname the hostname 51 * @param name the service instance name 52 * @param type the service type 53 * @param subtypeList the list of subtypes 54 * @param port the port number of the service 55 * @param txt the entries of the TXT record 56 * @param receiver the receiver of the register callback 57 * @param listenerId the ID of the NsdManager.RegistrationListener which is used to 58 * identify the registration 59 */ registerService(in @ullable String hostname, in String name, in String type, in List<String> subtypeList, int port, in List<DnsTxtAttribute> txt, in INsdStatusReceiver receiver, int listenerId)60 void registerService(in @nullable String hostname, in String name, in String type, 61 in List<String> subtypeList, int port, in List<DnsTxtAttribute> txt, 62 in INsdStatusReceiver receiver, int listenerId); 63 64 /** 65 * Registers an mDNS host. 66 * 67 * <p>The listenerId is an integer ID generated by the caller. It's used by the caller and 68 * the NsdPublisher service to uniquely identify a registration. 69 * 70 * @param name the hostname like "my-host" 71 * @param addresses the IPv6 addresses of the host. Each String represents an address. 72 * @param receiver the receiver of the register callback 73 * @param listenerId the ID of the NsdManager.RegistrationListener which is used to 74 * identify the registration 75 */ registerHost(in String name, in List<String> addresses, in INsdStatusReceiver receiver, int listenerId)76 void registerHost(in String name, in List<String> addresses, in INsdStatusReceiver receiver, 77 int listenerId); 78 79 /** 80 * Unregisters an mDNS service. 81 * 82 * <p>To unregister a previously registered service/host/key, the caller must pass in the same 83 * listener which was used when registering the service/host/key. 84 * 85 * @param receiver the receiver of the unregister callback 86 * @param listenerId the ID of the NsdManager.RegistrationListener which is used to 87 * identify the registration 88 */ unregister(in INsdStatusReceiver receiver, int listenerId)89 void unregister(in INsdStatusReceiver receiver, int listenerId); 90 91 /** Resets the NsdPublisher, i.e. clear all registrations. */ reset()92 void reset(); 93 94 /** 95 * Discovers mDNS services of a specific type. 96 * 97 * <p>To stop discovering services, the caller must pass in the same listener ID which was used 98 * when starting discoverying the services. 99 * 100 * @param type the service type 101 * @param callback the callback when a service is found/lost 102 * @param listenerId the ID of the NsdManager.DiscoveryListener which is used to identify the 103 * service discovery operation 104 */ discoverService(in String type, in INsdDiscoverServiceCallback callback, int listenerId)105 void discoverService(in String type, in INsdDiscoverServiceCallback callback, int listenerId); 106 107 /** 108 * Stops discovering services of a specific type. 109 * 110 * <p>To stop discovering services, the caller must pass in the same listener ID which was used 111 * when starting discoverying the services. 112 * 113 * @param listenerId the ID of the NsdManager.DiscoveryListener which is used to identify the 114 * service discovery operation 115 */ stopServiceDiscovery(int listenerId)116 void stopServiceDiscovery(int listenerId); 117 118 /** 119 * Resolves an mDNS service instance. 120 * 121 * <p>To stop resolving a service, the caller must pass in the same listener ID which was used 122 * when starting resolving the service. 123 * 124 * @param name the service instance name 125 * @param type the service type 126 * @param callback the callback when a service is updated 127 * @param listenerId the ID of the NsdManager.ServiceInfoCallback which is used to identify the 128 * service resolution operation 129 */ resolveService( in String name, in String type, in INsdResolveServiceCallback callback, int listenerId)130 void resolveService( 131 in String name, in String type, in INsdResolveServiceCallback callback, int listenerId); 132 133 /** 134 * Stops resolving an mDNS service instance. 135 * 136 * <p>To stop resolving a service, the caller must pass in the same listener ID which was used 137 * when starting resolving the service. 138 * 139 * @param listenerId the ID of the NsdManager.ServiceInfoCallback which is used to identify the 140 * service resolution operation 141 */ stopServiceResolution(int listenerId)142 void stopServiceResolution(int listenerId); 143 144 /** 145 * Resolves an mDNS host. 146 * 147 * <p>To stop resolving a host, use stopHostResolution. 148 * 149 * @param name the hostname 150 * @param callback the callback when a host is resolved. 151 * @param listenerId the ID of DnsResolver.Callback which is used to identify the 152 * host resolution operation 153 */ resolveHost(in String name, in INsdResolveHostCallback callback, int listenerId)154 void resolveHost(in String name, in INsdResolveHostCallback callback, int listenerId); 155 156 /** 157 * Stops resolving an mDNS host. 158 * 159 * <p>To stop resolving a host, the caller must pass in the same listener ID which was used 160 * when starting resolving the host. 161 * 162 * @param listenerId the ID of the DnsResolver.Callback which is used to identify the 163 * host resolution operation 164 */ stopHostResolution(int listenerId)165 void stopHostResolution(int listenerId); 166 } 167