Skip to main content

VConn

Struct VConn 

Source
pub struct VConn { /* private fields */ }
Expand description

An OpenFlow virtual connection.

Implementations§

Source§

impl VConn

Source

pub async fn connect(addr: &Address) -> Result<Self>

Connect to an OpenFlow switch.

Source

pub fn version(&self) -> Version

Get the negotiated OpenFlow version.

Source

pub async fn send_message(&mut self, msg: &Message) -> Result<()>

Send a message.

Source

pub async fn recv_message(&mut self) -> Result<Message>

Receive a message.

Source

pub async fn send_flow(&mut self, flow: &Flow) -> Result<()>

Send a flow modification to the switch.

This sends the FlowMod message asynchronously without waiting for confirmation. Use send_flow_sync if you need to ensure the flow was successfully installed.

Source

pub async fn send_flow_sync(&mut self, flow: &Flow) -> Result<()>

Send a flow modification and wait for confirmation.

Sends the FlowMod followed by a barrier request, then waits for the barrier reply. If an error occurs (e.g., invalid flow), it will be returned.

This ensures the flow is installed (or rejected) before returning.

Source

pub async fn echo(&mut self) -> Result<()>

Send an echo request and wait for reply.

Source

pub async fn barrier(&mut self) -> Result<()>

Send a barrier and wait for reply.

Source

pub async fn dump_flows(&mut self) -> Result<Vec<FlowStatsEntry>>

Dump all flows from the switch.

Returns all flow entries from all tables. Use dump_flows_filtered for more specific queries.

Source

pub async fn dump_flows_filtered( &mut self, request: FlowStatsRequest, ) -> Result<Vec<FlowStatsEntry>>

Dump flows matching the given filter.

The request can filter by table ID, match fields, cookie, etc.

Source

pub async fn recv_packet_in(&mut self) -> Result<PacketIn>

Wait for and receive a Packet-In message.

This blocks until a Packet-In message is received, handling echo requests and skipping other message types.

Source

pub async fn try_recv_packet_in(&mut self) -> Result<Option<PacketIn>>

Try to receive a Packet-In message without blocking.

Returns Ok(Some(packet_in)) if a Packet-In is available, Ok(None) if a different message was received (and handled), or an error if something went wrong.

Note: This still blocks on the read itself; it just doesn’t loop waiting specifically for a Packet-In.

Source

pub async fn monitor_flows( &mut self, request: FlowMonitorRequest, ) -> Result<Vec<FlowUpdate>>

Register a flow monitor and receive the initial snapshot.

Sends the monitor request and collects the initial flow updates (if NXFMF_INITIAL flag was set in the request). After this returns, use recv_flow_updates() to receive ongoing updates.

Use a dedicated VConn for monitoring — the monitor produces a continuous stream that occupies the connection’s recv path.

Source

pub async fn recv_flow_updates(&mut self) -> Result<Vec<FlowUpdate>>

Receive the next batch of flow monitor updates.

Blocks until flow update messages are received from OVS. Handles echo requests internally. Returns the parsed updates.

Call this in a loop after monitor_flows() to receive ongoing flow change notifications.

Source

pub async fn send_packet_out(&mut self, packet_out: &PacketOut) -> Result<()>

Send a Packet-Out message.

This injects a packet into the switch’s datapath or releases a buffered packet with the specified actions.

Auto Trait Implementations§

§

impl !Freeze for VConn

§

impl !RefUnwindSafe for VConn

§

impl Send for VConn

§

impl Sync for VConn

§

impl Unpin for VConn

§

impl UnsafeUnpin for VConn

§

impl !UnwindSafe for VConn

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.