summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorpaulhu <paulhu@google.com>2022-01-14 15:30:06 +0800
committerpaulhu <paulhu@google.com>2022-04-03 16:04:05 +0000
commit4416b0c8bb36ee0b6ece654cb8887124af1447bf (patch)
tree66fa0927cfbd7544bab3ca612ad81be14ef087b3 /common
parentc5df995932d3fe4f95c95d93cb9f6ba49d77c816 (diff)
downloadnet-4416b0c8bb36ee0b6ece654cb8887124af1447bf.tar.gz
Add MDNS aidl
- Add MDNS aidl that NsdService can communicate with mdns service via binder call instead of using ndc. - Add mdns_aidl_interface to separate the mdns aidl from netd_aidl_interface. Bug: 209894875 Test: atest FrameworksNetTests CtsNetTestCases Change-Id: I7bcbd6146269bdd9ac973d651a676bd9d126ae2d
Diffstat (limited to 'common')
-rw-r--r--common/netd/Android.bp18
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/DiscoveryInfo.aidl45
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/GetAddressInfo.aidl44
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDns.aidl46
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDnsEventListener.aidl50
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/RegistrationInfo.aidl45
-rw-r--r--common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/ResolutionInfo.aidl48
-rw-r--r--common/netd/binder/android/net/mdns/aidl/DiscoveryInfo.aidl79
-rw-r--r--common/netd/binder/android/net/mdns/aidl/GetAddressInfo.aidl69
-rw-r--r--common/netd/binder/android/net/mdns/aidl/IMDns.aidl127
-rw-r--r--common/netd/binder/android/net/mdns/aidl/IMDnsEventListener.aidl66
-rw-r--r--common/netd/binder/android/net/mdns/aidl/RegistrationInfo.aidl78
-rw-r--r--common/netd/binder/android/net/mdns/aidl/ResolutionInfo.aidl92
13 files changed, 807 insertions, 0 deletions
diff --git a/common/netd/Android.bp b/common/netd/Android.bp
index e249e19d..b06d7089 100644
--- a/common/netd/Android.bp
+++ b/common/netd/Android.bp
@@ -156,3 +156,21 @@ aidl_interface {
},
},
}
+
+aidl_interface {
+ name: "mdns_aidl_interface",
+ local_include_dir: "binder",
+ srcs: [
+ "binder/android/net/mdns/aidl/**/*.aidl",
+ ],
+ backend: {
+ java: {
+ sdk_version: "module_current",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.tethering",
+ ],
+ min_sdk_version: "30",
+ },
+ },
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/DiscoveryInfo.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/DiscoveryInfo.aidl
new file mode 100644
index 00000000..d31a3278
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/DiscoveryInfo.aidl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable DiscoveryInfo {
+ int id;
+ int result;
+ @utf8InCpp String serviceName;
+ @utf8InCpp String registrationType;
+ @utf8InCpp String domainName;
+ int interfaceIdx;
+ int netId;
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/GetAddressInfo.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/GetAddressInfo.aidl
new file mode 100644
index 00000000..20492744
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/GetAddressInfo.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable GetAddressInfo {
+ int id;
+ int result;
+ @utf8InCpp String hostname;
+ @utf8InCpp String address;
+ int interfaceIdx;
+ int netId;
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDns.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDns.aidl
new file mode 100644
index 00000000..ecbe966d
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDns.aidl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+interface IMDns {
+ void startDaemon();
+ void stopDaemon();
+ void registerService(in android.net.mdns.aidl.RegistrationInfo info);
+ void discover(in android.net.mdns.aidl.DiscoveryInfo info);
+ void resolve(in android.net.mdns.aidl.ResolutionInfo info);
+ void getServiceAddress(in android.net.mdns.aidl.GetAddressInfo info);
+ void stopOperation(int id);
+ void registerEventListener(in android.net.mdns.aidl.IMDnsEventListener listener);
+ void unregisterEventListener(in android.net.mdns.aidl.IMDnsEventListener listener);
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDnsEventListener.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDnsEventListener.aidl
new file mode 100644
index 00000000..4625cac7
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/IMDnsEventListener.aidl
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2022, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+interface IMDnsEventListener {
+ oneway void onServiceRegistrationStatus(in android.net.mdns.aidl.RegistrationInfo status);
+ oneway void onServiceDiscoveryStatus(in android.net.mdns.aidl.DiscoveryInfo status);
+ oneway void onServiceResolutionStatus(in android.net.mdns.aidl.ResolutionInfo status);
+ oneway void onGettingServiceAddressStatus(in android.net.mdns.aidl.GetAddressInfo status);
+ const int SERVICE_DISCOVERY_FAILED = 602;
+ const int SERVICE_FOUND = 603;
+ const int SERVICE_LOST = 604;
+ const int SERVICE_REGISTRATION_FAILED = 605;
+ const int SERVICE_REGISTERED = 606;
+ const int SERVICE_RESOLUTION_FAILED = 607;
+ const int SERVICE_RESOLVED = 608;
+ const int SERVICE_GET_ADDR_FAILED = 611;
+ const int SERVICE_GET_ADDR_SUCCESS = 612;
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/RegistrationInfo.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/RegistrationInfo.aidl
new file mode 100644
index 00000000..185111b4
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/RegistrationInfo.aidl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable RegistrationInfo {
+ int id;
+ int result;
+ @utf8InCpp String serviceName;
+ @utf8InCpp String registrationType;
+ int port;
+ byte[] txtRecord;
+ int interfaceIdx;
+}
diff --git a/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/ResolutionInfo.aidl b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/ResolutionInfo.aidl
new file mode 100644
index 00000000..4aa7d791
--- /dev/null
+++ b/common/netd/aidl_api/mdns_aidl_interface/current/android/net/mdns/aidl/ResolutionInfo.aidl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.mdns.aidl;
+/* @hide */
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable ResolutionInfo {
+ int id;
+ int result;
+ @utf8InCpp String serviceName;
+ @utf8InCpp String registrationType;
+ @utf8InCpp String domain;
+ @utf8InCpp String serviceFullName;
+ @utf8InCpp String hostname;
+ int port;
+ byte[] txtRecord;
+ int interfaceIdx;
+}
diff --git a/common/netd/binder/android/net/mdns/aidl/DiscoveryInfo.aidl b/common/netd/binder/android/net/mdns/aidl/DiscoveryInfo.aidl
new file mode 100644
index 00000000..f8273828
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/DiscoveryInfo.aidl
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+/**
+ * Discovery service information.
+ * This information combine all arguments that used by both request and callback.
+ * Arguments are used by request:
+ * - id
+ * - registrationType
+ * - interfaceIdx
+ *
+ * Arguments are used by callback:
+ * - id
+ * - serviceName
+ * - registrationType
+ * - domainName
+ * - interfaceIdx
+ * - netId
+ * - result
+ *
+ * {@hide}
+ */
+@JavaOnlyImmutable
+@JavaDerive(equals=true, toString=true)
+parcelable DiscoveryInfo {
+ /**
+ * The operation ID.
+ * Must be unique among all operations (registration/discovery/resolution/getting address) and
+ * can't be reused.
+ * To stop a operation, it needs to use corresponding operation id.
+ */
+ int id;
+
+ /**
+ * The discovery result.
+ */
+ int result;
+
+ /**
+ * The discovered service name.
+ */
+ @utf8InCpp String serviceName;
+
+ /**
+ * The service type being discovered for followed by the protocol, separated by a dot
+ * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
+ */
+ @utf8InCpp String registrationType;
+
+ /**
+ * The domain of the discovered service instance.
+ */
+ @utf8InCpp String domainName;
+
+ /**
+ * The interface index on which to discover services. 0 indicates "all interfaces".
+ */
+ int interfaceIdx;
+
+ /**
+ * The net id on which the service is advertised.
+ */
+ int netId;
+}
diff --git a/common/netd/binder/android/net/mdns/aidl/GetAddressInfo.aidl b/common/netd/binder/android/net/mdns/aidl/GetAddressInfo.aidl
new file mode 100644
index 00000000..d53174a4
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/GetAddressInfo.aidl
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+/**
+ * Get service address information.
+ * This information combine all arguments that used by both request and callback.
+ * Arguments are used by request:
+ * - id
+ * - hostname
+ * - interfaceIdx
+ *
+ * Arguments are used by callback:
+ * - id
+ * - hostname
+ * - interfaceIdx
+ * - netId
+ * - address
+ * - result
+ *
+ * {@hide}
+ */
+@JavaOnlyImmutable
+@JavaDerive(equals=true, toString=true)
+parcelable GetAddressInfo {
+ /**
+ * The operation ID.
+ */
+ int id;
+
+ /**
+ * The getting address result.
+ */
+ int result;
+
+ /**
+ * The fully qualified domain name of the host to be queried for.
+ */
+ @utf8InCpp String hostname;
+
+ /**
+ * The service address info, it's IPv4 or IPv6 addres.
+ */
+ @utf8InCpp String address;
+
+ /**
+ * The interface index on which to issue the query. 0 indicates "all interfaces".
+ */
+ int interfaceIdx;
+
+ /**
+ * The net id to which the answers pertain.
+ */
+ int netId;
+}
diff --git a/common/netd/binder/android/net/mdns/aidl/IMDns.aidl b/common/netd/binder/android/net/mdns/aidl/IMDns.aidl
new file mode 100644
index 00000000..255d70ff
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/IMDns.aidl
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+import android.net.mdns.aidl.DiscoveryInfo;
+import android.net.mdns.aidl.GetAddressInfo;
+import android.net.mdns.aidl.IMDnsEventListener;
+import android.net.mdns.aidl.RegistrationInfo;
+import android.net.mdns.aidl.ResolutionInfo;
+
+/** {@hide} */
+interface IMDns {
+ /**
+ * Start the MDNSResponder daemon.
+ *
+ * @throws ServiceSpecificException with unix errno EALREADY if daemon is already running.
+ */
+ void startDaemon();
+
+ /**
+ * Stop the MDNSResponder daemon.
+ *
+ * @throws ServiceSpecificException with unix errno EBUSY if daemon is still in use.
+ */
+ void stopDaemon();
+
+ /**
+ * Start registering a service.
+ * This operation will send a service registration request to MDNSResponder. Register a listener
+ * via IMDns#registerEventListener to get the registration result SERVICE_REGISTERED/
+ * SERVICE_REGISTRATION_FAILED from callback IMDnsEventListener#onServiceRegistrationStatus.
+ *
+ * @param info The service information to register.
+ *
+ * @throws ServiceSpecificException with one of the following error values:
+ * - Unix errno EBUSY if request id is already in use.
+ * - kDNSServiceErr_* list in dns_sd.h if registration fail.
+ */
+ void registerService(in RegistrationInfo info);
+
+ /**
+ * Start discovering services.
+ * This operation will send a request to MDNSResponder to discover services. Register a listener
+ * via IMDns#registerEventListener to get the discovery result SERVICE_FOUND/SERVICE_LOST/
+ * SERVICE_DISCOVERY_FAILED from callback IMDnsEventListener#onServiceDiscoveryStatus.
+ *
+ * @param info The service to discover.
+ *
+ * @throws ServiceSpecificException with one of the following error values:
+ * - Unix errno EBUSY if request id is already in use.
+ * - kDNSServiceErr_* list in dns_sd.h if discovery fail.
+ */
+ void discover(in DiscoveryInfo info);
+
+ /**
+ * Start resolving the target service.
+ * This operation will send a request to MDNSResponder to resolve the target service. Register a
+ * listener via IMDns#registerEventListener to get the resolution result SERVICE_RESOLVED/
+ * SERVICE_RESOLUTION_FAILED from callback IMDnsEventListener#onServiceResolutionStatus.
+ *
+ * @param info The service to resolve.
+ *
+ * @throws ServiceSpecificException with one of the following error values:
+ * - Unix errno EBUSY if request id is already in use.
+ * - kDNSServiceErr_* list in dns_sd.h if resolution fail.
+ */
+ void resolve(in ResolutionInfo info);
+
+ /**
+ * Start getting the target service address.
+ * This operation will send a request to MDNSResponder to get the target service address.
+ * Register a listener via IMDns#registerEventListener to get the query result
+ * SERVICE_GET_ADDR_SUCCESS/SERVICE_GET_ADDR_FAILED from callback
+ * IMDnsEventListener#onGettingServiceAddressStatus.
+ *
+ * @param info the getting service address information.
+ *
+ * @throws ServiceSpecificException with one of the following error values:
+ * - Unix errno EBUSY if request id is already in use.
+ * - kDNSServiceErr_* list in dns_sd.h if getting address fail.
+ */
+ void getServiceAddress(in GetAddressInfo info);
+
+ /**
+ * Stop a operation which's requested before.
+ *
+ * @param id the operation id to be stopped.
+ *
+ * @throws ServiceSpecificException with unix errno ESRCH if request id is not in use.
+ */
+ void stopOperation(int id);
+
+ /**
+ * Register an event listener.
+ *
+ * @param listener The listener to be registered.
+ *
+ * @throws ServiceSpecificException with one of the following error values:
+ * - Unix errno EINVAL if listener is null.
+ * - Unix errno EEXIST if register duplicated listener.
+ */
+ void registerEventListener(in IMDnsEventListener listener);
+
+ /**
+ * Unregister an event listener.
+ *
+ * @param listener The listener to be unregistered.
+ *
+ * @throws ServiceSpecificException with unix errno EINVAL if listener is null.
+ */
+ void unregisterEventListener(in IMDnsEventListener listener);
+}
+
diff --git a/common/netd/binder/android/net/mdns/aidl/IMDnsEventListener.aidl b/common/netd/binder/android/net/mdns/aidl/IMDnsEventListener.aidl
new file mode 100644
index 00000000..a202a261
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/IMDnsEventListener.aidl
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2022, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+import android.net.mdns.aidl.DiscoveryInfo;
+import android.net.mdns.aidl.GetAddressInfo;
+import android.net.mdns.aidl.RegistrationInfo;
+import android.net.mdns.aidl.ResolutionInfo;
+
+/**
+ * MDNS events which are reported by the MDNSResponder.
+ * This one-way interface defines the asynchronous notifications sent by mdns service to any process
+ * that registered itself via IMDns.registerEventListener.
+ *
+ * {@hide}
+ */
+oneway interface IMDnsEventListener {
+ /**
+ * Types for MDNS operation result.
+ * These are in sync with frameworks/libs/net/common/netd/libnetdutils/include/netdutils/\
+ * ResponseCode.h
+ */
+ const int SERVICE_DISCOVERY_FAILED = 602;
+ const int SERVICE_FOUND = 603;
+ const int SERVICE_LOST = 604;
+ const int SERVICE_REGISTRATION_FAILED = 605;
+ const int SERVICE_REGISTERED = 606;
+ const int SERVICE_RESOLUTION_FAILED = 607;
+ const int SERVICE_RESOLVED = 608;
+ const int SERVICE_GET_ADDR_FAILED = 611;
+ const int SERVICE_GET_ADDR_SUCCESS = 612;
+
+ /**
+ * Notify service registration status.
+ */
+ void onServiceRegistrationStatus(in RegistrationInfo status);
+
+ /**
+ * Notify service discovery status.
+ */
+ void onServiceDiscoveryStatus(in DiscoveryInfo status);
+
+ /**
+ * Notify service resolution status.
+ */
+ void onServiceResolutionStatus(in ResolutionInfo status);
+
+ /**
+ * Notify getting service address status.
+ */
+ void onGettingServiceAddressStatus(in GetAddressInfo status);
+}
diff --git a/common/netd/binder/android/net/mdns/aidl/RegistrationInfo.aidl b/common/netd/binder/android/net/mdns/aidl/RegistrationInfo.aidl
new file mode 100644
index 00000000..54835594
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/RegistrationInfo.aidl
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+/**
+ * Registration service information.
+ * This information combine all arguments that used by both request and callback.
+ * Arguments are used by request:
+ * - id
+ * - serviceName
+ * - registrationType
+ * - port
+ * - txtRecord
+ * - interfaceIdx
+ *
+ * Arguments are used by callback:
+ * - id
+ * - serviceName
+ * - registrationType
+ * - result
+ *
+ * {@hide}
+ */
+@JavaOnlyImmutable
+@JavaDerive(equals=true, toString=true)
+parcelable RegistrationInfo {
+ /**
+ * The operation ID.
+ */
+ int id;
+
+ /**
+ * The registration result.
+ */
+ int result;
+
+ /**
+ * The service name to be registered.
+ */
+ @utf8InCpp String serviceName;
+
+ /**
+ * The service type followed by the protocol, separated by a dot (e.g. "_ftp._tcp"). The service
+ * type must be an underscore, followed by 1-15 characters, which may be letters, digits, or
+ * hyphens. The transport protocol must be "_tcp" or "_udp". New service types should be
+ * registered at <http://www.dns-sd.org/ServiceTypes.html>.
+ */
+ @utf8InCpp String registrationType;
+
+ /**
+ * The port on which the service accepts connections.
+ */
+ int port;
+
+ /**
+ * The txt record.
+ */
+ byte[] txtRecord;
+
+ /**
+ * The interface index on which to register the service. 0 indicates "all interfaces".
+ */
+ int interfaceIdx;
+}
diff --git a/common/netd/binder/android/net/mdns/aidl/ResolutionInfo.aidl b/common/netd/binder/android/net/mdns/aidl/ResolutionInfo.aidl
new file mode 100644
index 00000000..26e0cee7
--- /dev/null
+++ b/common/netd/binder/android/net/mdns/aidl/ResolutionInfo.aidl
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.mdns.aidl;
+
+/**
+ * Resolution service information.
+ * This information combine all arguments that used by both request and callback.
+ * Arguments are used by request:
+ * - id
+ * - serviceName
+ * - registrationType
+ * - domain
+ * - interfaceIdx
+ *
+ * Arguments are used by callback:
+ * - id
+ * - port
+ * - serviceFullName
+ * - hostname
+ * - txtRecord
+ * - interfaceIdx
+ * - result
+ *
+ * {@hide}
+ */
+@JavaOnlyImmutable
+@JavaDerive(equals=true, toString=true)
+parcelable ResolutionInfo {
+ /**
+ * The operation ID.
+ */
+ int id;
+
+ /**
+ * The resolution result.
+ */
+ int result;
+
+ /**
+ * The service name to be resolved.
+ */
+ @utf8InCpp String serviceName;
+
+ /**
+ * The service type to be resolved.
+ */
+ @utf8InCpp String registrationType;
+
+ /**
+ * The service domain to be resolved.
+ */
+ @utf8InCpp String domain;
+
+ /**
+ * The resolved full service domain name, in the form <servicename>.<protocol>.<domain>.
+ */
+ @utf8InCpp String serviceFullName;
+
+ /**
+ * The target hostname of the machine providing the service.
+ */
+ @utf8InCpp String hostname;
+
+ /**
+ * The port on which connections are accepted for this service.
+ */
+ int port;
+
+ /**
+ * The service's txt record.
+ */
+ byte[] txtRecord;
+
+ /**
+ * The interface index on which to resolve the service. 0 indicates "all interfaces".
+ */
+ int interfaceIdx;
+}