1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Resource definitions for network backends (endpoints).
//!
//! TODO: move the resource definitions to separate crates for each endpoint.
#![warn(missing_docs)]
#![forbid(unsafe_code)]
pub mod mac_address;
/// Null backend.
pub mod null {
use mesh::MeshPayload;
use vm_resource::kind::NetEndpointHandleKind;
use vm_resource::ResourceId;
/// Handle to a null network endpoint, which drops sent packets and never
/// receives packets.
#[derive(MeshPayload)]
pub struct NullHandle;
impl ResourceId<NetEndpointHandleKind> for NullHandle {
const ID: &'static str = "null";
}
}
/// Consomme backend.
pub mod consomme {
use mesh::MeshPayload;
use vm_resource::kind::NetEndpointHandleKind;
use vm_resource::ResourceId;
/// Handle to a Consomme network endpoint.
#[derive(MeshPayload)]
pub struct ConsommeHandle {
/// The CIDR of the network to use.
pub cidr: Option<String>,
}
impl ResourceId<NetEndpointHandleKind> for ConsommeHandle {
const ID: &'static str = "consomme";
}
}
/// Windows vmswitch DirectIO backend.
pub mod dio {
use guid::Guid;
use mesh::MeshPayload;
use vm_resource::kind::NetEndpointHandleKind;
use vm_resource::ResourceId;
/// A Hyper-V networking switch port ID.
#[derive(Copy, Clone, MeshPayload)]
pub struct SwitchPortId {
/// The switch ID.
pub switch: Guid,
/// The allocated port ID.
pub port: Guid,
}
/// Handle to a DirectIO network endpoint.
#[derive(MeshPayload)]
pub struct WindowsDirectIoHandle {
/// The allocated switch port ID.
pub switch_port_id: SwitchPortId,
}
impl ResourceId<NetEndpointHandleKind> for WindowsDirectIoHandle {
const ID: &'static str = "dio";
}
}
/// Linux TAP backend.
pub mod tap {
use mesh::MeshPayload;
use vm_resource::kind::NetEndpointHandleKind;
use vm_resource::ResourceId;
/// A handle to a TAP device.
#[derive(MeshPayload)]
pub struct TapHandle {
/// The name of the TAP device.
///
/// FUTURE: change this to a pre-opened `File`.
pub name: String,
}
impl ResourceId<NetEndpointHandleKind> for TapHandle {
const ID: &'static str = "tap";
}
}