Skip to content

Commit

Permalink
Merge pull request #145 from rcore-os/vsock
Browse files Browse the repository at this point in the history
Make types needed to use `VirtIOSocket` public.
  • Loading branch information
qwandor authored Jun 14, 2024
2 parents 463096f + 340b0ef commit 7a19f11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/device/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mod vsock;
#[cfg(feature = "alloc")]
pub use connectionmanager::VsockConnectionManager;
pub use error::SocketError;
pub use protocol::{VsockAddr, VMADDR_CID_HOST};
pub use protocol::{StreamShutdown, VsockAddr, VMADDR_CID_HOST};
#[cfg(feature = "alloc")]
pub use vsock::{DisconnectReason, VirtIOSocket, VsockEvent, VsockEventType};
pub use vsock::{ConnectionInfo, DisconnectReason, VirtIOSocket, VsockEvent, VsockEventType};

/// The size in bytes of each buffer used in the RX virtqueue. This must be bigger than
/// `size_of::<VirtioVsockHdr>()`.
Expand Down
5 changes: 5 additions & 0 deletions src/device/socket/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ const EVENT_QUEUE_IDX: u16 = 2;
pub(crate) const QUEUE_SIZE: usize = 8;
const SUPPORTED_FEATURES: Feature = Feature::RING_EVENT_IDX.union(Feature::RING_INDIRECT_DESC);

/// Information about a particular vsock connection.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ConnectionInfo {
/// The address of the peer.
pub dst: VsockAddr,
/// The local port number associated with the connection.
pub src_port: u32,
/// The last `buf_alloc` value the peer sent to us, indicating how much receive buffer space in
/// bytes it has allocated for packet bodies.
Expand All @@ -49,6 +52,8 @@ pub struct ConnectionInfo {
}

impl ConnectionInfo {
/// Creates a new `ConnectionInfo` for the given peer address and local port, and default values
/// for everything else.
pub fn new(destination: VsockAddr, src_port: u32) -> Self {
Self {
dst: destination,
Expand Down

0 comments on commit 7a19f11

Please sign in to comment.