Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make types needed to use VirtIOSocket public. #145

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading