• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.INsdStatusReceiver;
33 import com.android.server.thread.openthread.INsdDiscoverServiceCallback;
34 import com.android.server.thread.openthread.INsdResolveServiceCallback;
35 import com.android.server.thread.openthread.INsdResolveHostCallback;
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,
61                         in String name,
62                         in String type,
63                         in List<String> subtypeList,
64                         int port,
65                         in List<DnsTxtAttribute> txt,
66                         in INsdStatusReceiver receiver,
67                         int listenerId);
68 
69     /**
70      * Registers an mDNS host.
71      *
72      * <p>The listenerId is an integer ID generated by the caller. It's used by the caller and
73      * the NsdPublisher service to uniquely identify a registration.
74      *
75      * @param name the hostname like "my-host"
76      * @param addresses the IPv6 addresses of the host. Each String represents an address.
77      * @param receiver the receiver of the register callback
78      * @param listenerId the ID of the NsdManager.RegistrationListener which is used to
79      *                             identify the registration
80      */
registerHost(in String name, in List<String> addresses, in INsdStatusReceiver receiver, int listenerId)81     void registerHost(in String name,
82                       in List<String> addresses,
83                       in INsdStatusReceiver receiver,
84                       int listenerId);
85 
86     /**
87      * Unregisters an mDNS service.
88      *
89      * <p>To unregister a previously registered service/host/key, the caller must pass in the same
90      * listener which was used when registering the service/host/key.
91      *
92      * @param receiver the receiver of the unregister callback
93      * @param listenerId the ID of the NsdManager.RegistrationListener which is used to
94      *                             identify the registration
95      */
unregister(in INsdStatusReceiver receiver, int listenerId)96     void unregister(in INsdStatusReceiver receiver, int listenerId);
97 
98     /** Resets the NsdPublisher, i.e. clear all registrations. */
reset()99     void reset();
100 
101     /**
102      * Discovers mDNS services of a specific type.
103      *
104      * <p>To stop discovering services, the caller must pass in the same listener ID which was used
105      * when starting discoverying the services.
106      *
107      * @param type the service type
108      * @param callback the callback when a service is found/lost
109      * @param listenerId the ID of the NsdManager.DiscoveryListener which is used to identify the
110      *                             service discovery operation
111      */
discoverService(in String type, in INsdDiscoverServiceCallback callback, int listenerId)112     void discoverService(in String type,
113                          in INsdDiscoverServiceCallback callback,
114                          int listenerId);
115 
116     /**
117      * Stops discovering services of a specific type.
118      *
119      * <p>To stop discovering services, the caller must pass in the same listener ID which was used
120      * when starting discoverying the services.
121      *
122      * @param listenerId the ID of the NsdManager.DiscoveryListener which is used to identify the
123      *                             service discovery operation
124      */
stopServiceDiscovery(int listenerId)125     void stopServiceDiscovery(int listenerId);
126 
127     /**
128      * Resolves an mDNS service instance.
129      *
130      * <p>To stop resolving a service, the caller must pass in the same listener ID which was used
131      * when starting resolving the service.
132      *
133      * @param name the service instance name
134      * @param type the service type
135      * @param callback the callback when a service is updated
136      * @param listenerId the ID of the NsdManager.ServiceInfoCallback which is used to identify the
137      *                             service resolution operation
138      */
resolveService(in String name, in String type, in INsdResolveServiceCallback callback, int listenerId)139     void resolveService(in String name,
140                         in String type,
141                         in INsdResolveServiceCallback callback,
142                         int listenerId);
143 
144     /**
145      * Stops resolving an mDNS service instance.
146      *
147      * <p>To stop resolving a service, the caller must pass in the same listener ID which was used
148      * when starting resolving the service.
149      *
150      * @param listenerId the ID of the NsdManager.ServiceInfoCallback which is used to identify the
151      *                             service resolution operation
152      */
stopServiceResolution(int listenerId)153     void stopServiceResolution(int listenerId);
154 
155     /**
156      * Resolves an mDNS host.
157      *
158      * <p>To stop resolving a host, use stopHostResolution.
159      *
160      * @param name the hostname
161      * @param callback the callback when a host is resolved.
162      * @param listenerId the ID of DnsResolver.Callback which is used to identify the
163      *                             host resolution operation
164      */
resolveHost(in String name, in INsdResolveHostCallback callback, int listenerId)165     void resolveHost(in String name,
166                      in INsdResolveHostCallback callback,
167                      int listenerId);
168 
169     /**
170      * Stops resolving an mDNS host.
171      *
172      * <p>To stop resolving a host, the caller must pass in the same listener ID which was used
173      * when starting resolving the host.
174      *
175      * @param listenerId the ID of the DnsResolver.Callback which is used to identify the
176      *                             host resolution operation
177      */
stopHostResolution(int listenerId)178     void stopHostResolution(int listenerId);
179 }
180