Skip to main content

Client

Trait Client 

Source
pub trait Client {
    // Required methods
    fn driver(&self) -> &dyn Driver;
    fn recv(&mut self, data: &[u8], checksum: &ChecksumState);
    fn rx_mtu(&mut self) -> usize;

    // Provided method
    fn recv_segments(&mut self, segments: &[&[u8]], checksum: &ChecksumState) { ... }
}
Expand description

A consomme client.

Required Methods§

Source

fn driver(&self) -> &dyn Driver

Gets the driver to use for handling new connections.

TODO: generalize connection creation to allow pluggable model (not just OS sockets) and remove this.

Source

fn recv(&mut self, data: &[u8], checksum: &ChecksumState)

Transmits a packet to the client.

If checksum.ipv4, checksum.tcp, or checksum.udp are set, then the packet contains an IPv4 header, TCP header, and/or UDP header with a valid checksum.

TODO: support >MTU sized packets (RSC/LRO/GRO).

Source

fn rx_mtu(&mut self) -> usize

Specifies the maximum size for the next call to recv.

This is the MTU including the Ethernet frame header. This must be at least MIN_MTU.

Return 0 to indicate that there are no buffers available for receiving data.

Provided Methods§

Source

fn recv_segments(&mut self, segments: &[&[u8]], checksum: &ChecksumState)

Transmits a packet whose bytes are provided as multiple discontiguous segments, delivered in order as a single logical packet.

This lets callers avoid linearizing a frame into a scratch buffer when its payload is not contiguous (for example, a header segment followed by TCP window bytes that wrap a ring buffer). The checksum argument has the same meaning as for Client::recv.

The default implementation copies the segments into a contiguous buffer and forwards to Client::recv. Clients that can write discontiguous data directly to the guest should override this to eliminate the copy.

Implementors§