Skip to main content

ActionList

Struct ActionList 

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

A list of actions.

Implementations§

Source§

impl ActionList

Source

pub fn new() -> Self

Create a new empty action list.

Source

pub fn push(&mut self, action: Action)

Add an action to the list.

Source

pub fn output(self, port: impl Into<OutputPort>) -> Self

Output to a port.

Source

pub fn controller(self, max_len: u16) -> Self

Send to controller.

Source

pub fn drop(self) -> Self

Drop the packet.

Source

pub fn set_eth_dst(self, mac: [u8; 6]) -> Self

Set destination MAC.

Source

pub fn set_eth_src(self, mac: [u8; 6]) -> Self

Set source MAC.

Source

pub fn push_vlan(self, tpid: u16) -> Self

Push VLAN tag.

Source

pub fn pop_vlan(self) -> Self

Pop VLAN tag.

Source

pub fn set_vlan_vid(self, vid: u16) -> Self

Set VLAN ID.

Source

pub fn goto_table(self, table: u8) -> Self

Go to another table.

Source

pub fn dec_ttl(self) -> Self

Decrement TTL.

Source

pub fn flood(self) -> Self

Output to all ports except input port (flood).

Source

pub fn all(self) -> Self

Output to all ports.

Source

pub fn normal(self) -> Self

Output using normal L2/L3 switching.

Source

pub fn in_port(self) -> Self

Output to ingress port.

Source

pub fn set_tunnel_id(self, tunnel_id: u64) -> Self

Set tunnel ID (Nicira extension).

Source

pub fn group(self, group_id: u32) -> Self

Output to group table.

Source

pub fn resubmit(self, port: Option<u16>, table: Option<u8>) -> Self

Resubmit to another table (Nicira extension).

  • port: Input port to use (None = current input port)
  • table: Table to resubmit to (None = current table)
Source

pub fn resubmit_table(self, table: u8) -> Self

Resubmit to a specific table (Nicira extension).

Convenience method for resubmit(None, Some(table)).

Source

pub fn ct(self, flags: u16, zone: u16, table: Option<u8>) -> Self

Connection tracking action (Nicira extension).

  • flags: CT flags (commit, force, etc.)
  • zone: CT zone ID
  • table: Table to recirculate to after CT (None = no recirc)
Source

pub fn ct_commit(self, zone: u16) -> Self

Connection tracking with commit (Nicira extension).

Commits the connection to the connection tracking table.

Source

pub fn ct_nat( self, flags: u16, zone: u16, table: Option<u8>, nat: NatConfig, ) -> Self

Connection tracking with NAT (Nicira extension).

Performs connection tracking with Network Address Translation.

§Arguments
  • flags: CT flags (commit, force, etc.)
  • zone: CT zone ID
  • table: Table to recirculate to after CT (None = no recirc)
  • nat: NAT configuration (SNAT or DNAT)
§Example
use rovs_openflow::{ActionList, NatConfig, CT_COMMIT};
use std::net::Ipv4Addr;

// SNAT to 10.0.0.1
ActionList::new().ct_nat(
    CT_COMMIT,
    1,
    Some(2),
    NatConfig::snat(Ipv4Addr::new(10, 0, 0, 1)),
)
Source

pub fn ct_snat(self, zone: u16, table: Option<u8>, addr: Ipv4Addr) -> Self

Connection tracking with SNAT (Nicira extension).

Source NAT: translates the source IP address.

§Example
use std::net::Ipv4Addr;

// SNAT to 10.0.0.1, commit and recirculate to table 2
ActionList::new().ct_snat(
    1,                              // zone
    Some(2),                        // recirc table
    Ipv4Addr::new(10, 0, 0, 1),     // NAT address
)
Source

pub fn ct_dnat(self, zone: u16, table: Option<u8>, addr: Ipv4Addr) -> Self

Connection tracking with DNAT (Nicira extension).

Destination NAT: translates the destination IP address.

§Example
use std::net::Ipv4Addr;

// DNAT to 192.168.1.100:8080
ActionList::new().ct_dnat(
    1,
    Some(2),
    Ipv4Addr::new(192, 168, 1, 100),
)
Source

pub fn learn(self, learn: NxLearn) -> Self

Learn action (Nicira extension).

Creates flows dynamically based on packet content.

Source

pub fn move_field( self, src_field: u32, dst_field: u32, n_bits: u16, src_ofs: u16, dst_ofs: u16, ) -> Self

Move/copy bits between fields (Nicira extension).

Copies n_bits bits from src_field[src_ofs..] to dst_field[dst_ofs..]. Use NXM constants from the nxm module for field headers.

§Example
// Copy ARP source IP to ARP target IP
actions.move_field(nxm::ARP_SPA, nxm::ARP_TPA, 32, 0, 0)
Source

pub fn load_field( self, dst_field: u32, dst_ofs: u16, n_bits: u16, value: u64, ) -> Self

Load immediate value into field (Nicira extension).

Loads value into dst_field[dst_ofs..dst_ofs+n_bits]. Use NXM constants from the nxm module for field headers.

§Example
// Set ARP opcode to 2 (reply)
actions.load_field(nxm::ARP_OP, 0, 16, 2)
Source

pub fn set_arp_op(self, opcode: u16) -> Self

Set ARP opcode (Nicira extension).

Common values: 1 = request, 2 = reply

Source

pub fn set_arp_spa(self, ip: u32) -> Self

Set ARP source protocol address (sender IP).

Source

pub fn set_arp_tpa(self, ip: u32) -> Self

Set ARP target protocol address (target IP).

Source

pub fn set_arp_sha(self, mac: u64) -> Self

Set ARP source hardware address (sender MAC).

Note: MAC is passed as a u64 with the MAC in the lower 48 bits.

Source

pub fn set_arp_tha(self, mac: u64) -> Self

Set ARP target hardware address (target MAC).

Note: MAC is passed as a u64 with the MAC in the lower 48 bits.

Source

pub fn actions(&self) -> &[Action]

Get the actions.

Source

pub fn is_empty(&self) -> bool

Check if the list is empty.

Source

pub fn len(&self) -> usize

Get the number of actions.

Source

pub fn encode(&self) -> Vec<u8>

Encode all actions to wire format.

Actions are concatenated and padded to 8-byte alignment.

Source

pub fn decode(data: &[u8]) -> Result<Self>

Decode all actions from wire format.

Reads actions until the data is exhausted.

Trait Implementations§

Source§

impl Clone for ActionList

Source§

fn clone(&self) -> ActionList

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActionList

Source§

fn default() -> ActionList

Returns the “default value” for a type. Read more
Source§

impl Display for ActionList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.