blob: 64432585f990ee6d0b1d1866b807ba364c552542 [file] [log] [blame]
Seungjae Yoo529d53c2024-05-14 14:36:18 +09001// 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
17use anyhow::anyhow;
18use android_system_virtualizationservice_internal::aidl::android::system::virtualizationservice_internal::IVmnic::IVmnic;
19use binder::{self, ExceptionCode, Interface, IntoBinderResult, ParcelFileDescriptor};
Seungjae Yoo13af0b62024-05-20 14:15:13 +090020use log::info;
Seungjae Yoo529d53c2024-05-14 14:36:18 +090021
22#[derive(Debug, Default)]
23pub struct Vmnic {}
24
25impl Vmnic {
26 pub fn init() -> Vmnic {
27 Vmnic::default()
28 }
29}
30
31impl Interface for Vmnic {}
32
33impl IVmnic for Vmnic {
Seungjae Yoo13af0b62024-05-20 14:15:13 +090034 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 Yoo529d53c2024-05-14 14:36:18 +090038 Err(anyhow!("Creating TAP network interface is not supported yet"))
39 .or_binder_exception(ExceptionCode::UNSUPPORTED_OPERATION)
40 }
41}