Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/virtio/vsock/sys/windows/protocol.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
use data_model::Le16;
6
use data_model::Le32;
7
use data_model::Le64;
8
use zerocopy::FromBytes;
9
use zerocopy::Immutable;
10
use zerocopy::IntoBytes;
11
use zerocopy::KnownLayout;
12
13
pub const TYPE_STREAM_SOCKET: u16 = 1;
14
15
/// virtio_vsock_config is the vsock device configuration space defined by the virtio spec.
16
#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]
17
#[repr(C)]
18
pub struct virtio_vsock_config {
19
pub guest_cid: Le64,
20
}
21
22
/// The message header for data packets sent on the tx/rx queues
23
#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]
24
#[repr(C, packed)]
25
#[allow(non_camel_case_types)]
26
pub struct virtio_vsock_hdr {
27
pub src_cid: Le64,
28
pub dst_cid: Le64,
29
pub src_port: Le32,
30
pub dst_port: Le32,
31
pub len: Le32,
32
pub type_: Le16,
33
pub op: Le16,
34
pub flags: Le32,
35
pub buf_alloc: Le32,
36
pub fwd_cnt: Le32,
37
}
38
39
/// An event sent to the event queue
40
#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]
41
#[repr(C)]
42
pub struct virtio_vsock_event {
43
// ID from the virtio_vsock_event_id struct in the virtio spec
44
pub id: Le32,
45
}
46
47
pub mod vsock_op {
48
pub const VIRTIO_VSOCK_OP_INVALID: u16 = 0;
49
50
/* Connect operations */
51
pub const VIRTIO_VSOCK_OP_REQUEST: u16 = 1;
52
pub const VIRTIO_VSOCK_OP_RESPONSE: u16 = 2;
53
pub const VIRTIO_VSOCK_OP_RST: u16 = 3;
54
pub const VIRTIO_VSOCK_OP_SHUTDOWN: u16 = 4;
55
56
/* To send payload */
57
pub const VIRTIO_VSOCK_OP_RW: u16 = 5;
58
59
/* Tell the peer our credit info */
60
pub const VIRTIO_VSOCK_OP_CREDIT_UPDATE: u16 = 6;
61
/* Request the peer to send the credit info to us */
62
pub const VIRTIO_VSOCK_OP_CREDIT_REQUEST: u16 = 7;
63
}
64
65