Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/virtio/net/sys.rs
5394 views
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
5
cfg_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
15
pub 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
23
impl PendingBuffer {
24
pub fn new() -> Self {
25
PendingBuffer {
26
buffer: Box::new([0u8; 65562]),
27
length: 0,
28
}
29
}
30
}
31
32
pub(crate) use platform::process_mrg_rx;
33
pub(crate) use platform::process_rx;
34
pub(crate) use platform::process_tx;
35
pub(crate) use platform::validate_and_configure_tap;
36
pub(crate) use platform::virtio_features_to_tap_offload;
37
38