From 0f4c3218adaa8f89cbd24416783fe7d446e58f95 Mon Sep 17 00:00:00 2001 From: Chris Weir Date: Thu, 16 Sep 2021 19:20:09 -0700 Subject: [PATCH] Move interceptor AIDL definition Move Netlink Interceptor AIDL definition to hardware/interfaces/wifi Bug: 201467304 Test: atest VtsHalNetlinkInterceptorV1_0Test Change-Id: Ia6b1d29b2f2cb45f91ab985ed64c44fdc6d54602 --- wifi/netlinkinterceptor/aidl/Android.bp | 36 +++++++++ .../net/nlinterceptor/IInterceptor.aidl | 41 ++++++++++ .../net/nlinterceptor/IInterceptor.aidl | 41 ++++++++++ .../net/nlinterceptor/InterceptedSocket.aidl | 39 ++++++++++ .../net/nlinterceptor/IInterceptor.aidl | 78 +++++++++++++++++++ .../net/nlinterceptor/InterceptedSocket.aidl | 33 ++++++++ 6 files changed, 268 insertions(+) create mode 100644 wifi/netlinkinterceptor/aidl/Android.bp create mode 100644 wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl create mode 100644 wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl create mode 100644 wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl create mode 100644 wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl create mode 100644 wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl diff --git a/wifi/netlinkinterceptor/aidl/Android.bp b/wifi/netlinkinterceptor/aidl/Android.bp new file mode 100644 index 0000000000..924edee384 --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/Android.bp @@ -0,0 +1,36 @@ +// +// Copyright (C) 2021 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 { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "hardware_interfaces_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["hardware_interfaces_license"], +} + +aidl_interface { + name: "android.hardware.net.nlinterceptor", + vendor_available: true, + srcs: ["android/hardware/net/nlinterceptor/*.aidl"], + stability: "vintf", + backend: { + java: { + enabled: false, + }, + }, +} diff --git a/wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl new file mode 100644 index 0000000000..249b343e8f --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2021 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 -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.hardware.net.nlinterceptor; +@VintfStability +interface IInterceptor { + int createSocket(in int nlFamily, in int clientNlPid, in String clientName); + void closeSocket(in int nlFamily, in int interceptorNlPid); + void subscribeGroup(in int nlFamily, in int interceptorNlPid, in int nlGroup); + void unsubscribeGroup(in int nlFamily, in int interceptorNlPid, in int nlGroup); +} diff --git a/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl new file mode 100644 index 0000000000..3d0f955371 --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2021 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 -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.hardware.net.nlinterceptor; +@VintfStability +interface IInterceptor { + android.hardware.net.nlinterceptor.InterceptedSocket createSocket(in int nlFamily, in int clientNlPid, in String clientName); + void closeSocket(in android.hardware.net.nlinterceptor.InterceptedSocket handle); + void subscribeGroup(in android.hardware.net.nlinterceptor.InterceptedSocket handle, in int nlGroup); + void unsubscribeGroup(in android.hardware.net.nlinterceptor.InterceptedSocket handle, in int nlGroup); +} diff --git a/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl new file mode 100644 index 0000000000..b679be506a --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2021 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 -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.hardware.net.nlinterceptor; +@VintfStability +parcelable InterceptedSocket { + int nlFamily; + int portId; +} diff --git a/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl new file mode 100644 index 0000000000..c222a1efc8 --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 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.hardware.net.nlinterceptor; + +import android.hardware.net.nlinterceptor.InterceptedSocket; + +/** + * Netlink Interceptor + * + * This HAL provides a way for Android services to route their Netlink traffic to a location other + * than the Kernel. One might want to do this for a variety of reasons: + * -> Route Netlink traffic to a different host. + * -> Route Netlink traffic to a different VM. + * -> Convert Netlink commands into proprietary vendor hardware commands. + * + * Some important notes regarding Netlink Interceptor. + * -> All int values are treated as unsigned. + * -> Users of Netlink Interceptor must close their sockets with closeSocket manually. + * -> PID != process ID. In this case, it is "port ID", a unique number assigned by the kernel to a + * given Netlink socket. + * -> Netlink PIDs are only unique per family. This means that for all NETLINK_GENERIC sockets, + * there can only be one socket with PID "1234". HOWEVER, there can ALSO be a Netlink socket + * using NETLINK_ROUTE which has a PID of "1234". Hence, in order to uniquely identify a Netlink + * socket, both the PID and Netlink Family are required. + */ +@VintfStability +interface IInterceptor { + /** + * Creates a Netlink socket on both the HU and TCU, and a bi-directional gRPC stream to carry + * data between them. This must be closed by the caller with closeSocket(). + * + * @param nlFamily - Netlink Family. Support for families other than NETLINK_GENERIC is still + * experimental. + * @param clientNlPid - Port ID of the caller's Netlink socket. + * @param clientName - Human readable name of the caller. Used for debugging. + * + * @return InterceptedSocket identifying the socket on the HU allocated for the caller. + */ + InterceptedSocket createSocket(in int nlFamily, in int clientNlPid, in String clientName); + + /** + * Closes a socket and gRPC stream given the socket's identifier. This must be invoked manually + * by the caller of createSocket(). + * + * @param handle - unique identifier for a socket returned by createSocket. + */ + void closeSocket(in InterceptedSocket handle); + + /** + * Subscribes a socket on the TCU to a Netlink multicast group. + * + * @param handle - unique identifier for a socket returned by createSocket. + * @param nlGroup - A single Netlink multicast group that the caller wants to subscribe to. + */ + void subscribeGroup(in InterceptedSocket handle, in int nlGroup); + + /** + * Unsubscribes a socket on the TCU from a Netlink multicast group. + * + * @param handle - unique identifier for a socket returned by createSocket. + * @param nlGroup - A single Netlink multicast group that the caller wants to unsubscribe from. + */ + void unsubscribeGroup(in InterceptedSocket handle, in int nlGroup); +} diff --git a/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl new file mode 100644 index 0000000000..d74a556cf1 --- /dev/null +++ b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 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.hardware.net.nlinterceptor; + +/** + * Unique identifier for a Netlink socket. + */ +@VintfStability +parcelable InterceptedSocket { + /** + * Netlink family of the identified socket + */ + int nlFamily; + + /** + * Netlink port ID of the identified socket. + */ + int portId; +}