Seungjae Yoo | 529d53c | 2024-05-14 14:36:18 +0900 | [diff] [blame] | 1 | // Copyright 2024, The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! Implementation of the AIDL interface of Vmnic. |
| 16 | |
| 17 | use anyhow::anyhow; |
| 18 | use android_system_virtualizationservice_internal::aidl::android::system::virtualizationservice_internal::IVmnic::IVmnic; |
| 19 | use binder::{self, ExceptionCode, Interface, IntoBinderResult, ParcelFileDescriptor}; |
Seungjae Yoo | 13af0b6 | 2024-05-20 14:15:13 +0900 | [diff] [blame] | 20 | use log::info; |
Seungjae Yoo | 529d53c | 2024-05-14 14:36:18 +0900 | [diff] [blame] | 21 | |
| 22 | #[derive(Debug, Default)] |
| 23 | pub struct Vmnic {} |
| 24 | |
| 25 | impl Vmnic { |
| 26 | pub fn init() -> Vmnic { |
| 27 | Vmnic::default() |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl Interface for Vmnic {} |
| 32 | |
| 33 | impl IVmnic for Vmnic { |
Seungjae Yoo | 13af0b6 | 2024-05-20 14:15:13 +0900 | [diff] [blame] | 34 | fn createTapInterface(&self, iface_name_suffix: &str) -> binder::Result<ParcelFileDescriptor> { |
| 35 | let ifname = format!("avf_tap_{iface_name_suffix}"); |
| 36 | info!("Creating TAP interface {}", ifname); |
| 37 | |
Seungjae Yoo | 529d53c | 2024-05-14 14:36:18 +0900 | [diff] [blame] | 38 | Err(anyhow!("Creating TAP network interface is not supported yet")) |
| 39 | .or_binder_exception(ExceptionCode::UNSUPPORTED_OPERATION) |
| 40 | } |
| 41 | } |