Path: blob/main/devices/src/virtio/vsock/sys/windows/protocol.rs
5394 views
// Copyright 2022 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34use data_model::Le16;5use data_model::Le32;6use data_model::Le64;7use zerocopy::FromBytes;8use zerocopy::Immutable;9use zerocopy::IntoBytes;10use zerocopy::KnownLayout;1112pub const TYPE_STREAM_SOCKET: u16 = 1;1314/// virtio_vsock_config is the vsock device configuration space defined by the virtio spec.15#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]16#[repr(C)]17pub struct virtio_vsock_config {18pub guest_cid: Le64,19}2021/// The message header for data packets sent on the tx/rx queues22#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]23#[repr(C, packed)]24#[allow(non_camel_case_types)]25pub struct virtio_vsock_hdr {26pub src_cid: Le64,27pub dst_cid: Le64,28pub src_port: Le32,29pub dst_port: Le32,30pub len: Le32,31pub type_: Le16,32pub op: Le16,33pub flags: Le32,34pub buf_alloc: Le32,35pub fwd_cnt: Le32,36}3738/// An event sent to the event queue39#[derive(Copy, Clone, Debug, Default, FromBytes, Immutable, IntoBytes, KnownLayout)]40#[repr(C)]41pub struct virtio_vsock_event {42// ID from the virtio_vsock_event_id struct in the virtio spec43pub id: Le32,44}4546pub mod vsock_op {47pub const VIRTIO_VSOCK_OP_INVALID: u16 = 0;4849/* Connect operations */50pub const VIRTIO_VSOCK_OP_REQUEST: u16 = 1;51pub const VIRTIO_VSOCK_OP_RESPONSE: u16 = 2;52pub const VIRTIO_VSOCK_OP_RST: u16 = 3;53pub const VIRTIO_VSOCK_OP_SHUTDOWN: u16 = 4;5455/* To send payload */56pub const VIRTIO_VSOCK_OP_RW: u16 = 5;5758/* Tell the peer our credit info */59pub const VIRTIO_VSOCK_OP_CREDIT_UPDATE: u16 = 6;60/* Request the peer to send the credit info to us */61pub const VIRTIO_VSOCK_OP_CREDIT_REQUEST: u16 = 7;62}636465