devices/virtio/net/
sys.rs

1// Copyright 2022 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5cfg_if::cfg_if! {
6    if #[cfg(any(target_os = "android", target_os = "linux"))] {
7        mod linux;
8        use linux as platform;
9    } else if #[cfg(windows)] {
10        pub mod windows;
11        use windows as platform;
12    }
13}
14
15pub struct PendingBuffer {
16    /// According to virtio-spec, the maximum incoming packet will be to 65550 bytes long
17    /// (the maximum size of a TCP or UDP packet, plus the 14 byte ethernet header)
18    /// The 12byte struct virtio_net_hdr is prepended to this, therefore making it for 65562
19    pub buffer: Box<[u8; 65562]>,
20    pub length: u32,
21}
22
23impl PendingBuffer {
24    pub fn new() -> Self {
25        PendingBuffer {
26            buffer: Box::new([0u8; 65562]),
27            length: 0,
28        }
29    }
30}
31
32pub(crate) use platform::process_mrg_rx;
33pub(crate) use platform::process_rx;
34pub(crate) use platform::process_tx;
35pub(crate) use platform::validate_and_configure_tap;
36pub(crate) use platform::virtio_features_to_tap_offload;