Skip to main content

Match

Struct Match 

Source
pub struct Match {
Show 43 fields pub in_port: Option<u32>, pub in_phy_port: Option<u32>, pub metadata: Option<u64>, pub metadata_mask: Option<u64>, pub eth_src: Option<[u8; 6]>, pub eth_src_mask: Option<[u8; 6]>, pub eth_dst: Option<[u8; 6]>, pub eth_dst_mask: Option<[u8; 6]>, pub eth_type: Option<u16>, pub vlan_vid: Option<u16>, pub vlan_pcp: Option<u8>, pub ipv4_src: Option<Ipv4Addr>, pub ipv4_src_mask: Option<u8>, pub ipv4_dst: Option<Ipv4Addr>, pub ipv4_dst_mask: Option<u8>, pub ip_proto: Option<u8>, pub ip_dscp: Option<u8>, pub ip_ecn: Option<u8>, pub ipv6_src: Option<Ipv6Addr>, pub ipv6_src_mask: Option<u8>, pub ipv6_dst: Option<Ipv6Addr>, pub ipv6_dst_mask: Option<u8>, pub ipv6_flabel: Option<u32>, pub tcp_src: Option<u16>, pub tcp_dst: Option<u16>, pub tcp_flags: Option<u16>, pub udp_src: Option<u16>, pub udp_dst: Option<u16>, pub icmp_type: Option<u8>, pub icmp_code: Option<u8>, pub icmpv6_type: Option<u8>, pub icmpv6_code: Option<u8>, pub arp_op: Option<u16>, pub arp_spa: Option<Ipv4Addr>, pub arp_tpa: Option<Ipv4Addr>, pub arp_sha: Option<[u8; 6]>, pub arp_tha: Option<[u8; 6]>, pub tunnel_id: Option<u64>, pub ct_state: Option<u32>, pub ct_state_mask: Option<u32>, pub ct_zone: Option<u16>, pub ct_mark: Option<u32>, pub ct_mark_mask: Option<u32>,
}
Expand description

Match fields for flow matching.

Uses a builder pattern for ergonomic construction.

Fields§

§in_port: Option<u32>

Input port

§in_phy_port: Option<u32>

Input physical port

§metadata: Option<u64>

Metadata

§metadata_mask: Option<u64>

Metadata mask

§eth_src: Option<[u8; 6]>

Source MAC address

§eth_src_mask: Option<[u8; 6]>

Source MAC mask

§eth_dst: Option<[u8; 6]>

Destination MAC address

§eth_dst_mask: Option<[u8; 6]>

Destination MAC mask

§eth_type: Option<u16>

Ethernet type

§vlan_vid: Option<u16>

VLAN ID

§vlan_pcp: Option<u8>

VLAN PCP

§ipv4_src: Option<Ipv4Addr>

IPv4 source address

§ipv4_src_mask: Option<u8>

IPv4 source mask (prefix length)

§ipv4_dst: Option<Ipv4Addr>

IPv4 destination address

§ipv4_dst_mask: Option<u8>

IPv4 destination mask (prefix length)

§ip_proto: Option<u8>

IP protocol

§ip_dscp: Option<u8>

IP DSCP

§ip_ecn: Option<u8>

IP ECN

§ipv6_src: Option<Ipv6Addr>

IPv6 source address

§ipv6_src_mask: Option<u8>

IPv6 source mask (prefix length)

§ipv6_dst: Option<Ipv6Addr>

IPv6 destination address

§ipv6_dst_mask: Option<u8>

IPv6 destination mask (prefix length)

§ipv6_flabel: Option<u32>

IPv6 flow label

§tcp_src: Option<u16>

TCP source port

§tcp_dst: Option<u16>

TCP destination port

§tcp_flags: Option<u16>

TCP flags

§udp_src: Option<u16>

UDP source port

§udp_dst: Option<u16>

UDP destination port

§icmp_type: Option<u8>

ICMPv4 type

§icmp_code: Option<u8>

ICMPv4 code

§icmpv6_type: Option<u8>

ICMPv6 type

§icmpv6_code: Option<u8>

ICMPv6 code

§arp_op: Option<u16>

ARP opcode

§arp_spa: Option<Ipv4Addr>

ARP source IPv4

§arp_tpa: Option<Ipv4Addr>

ARP target IPv4

§arp_sha: Option<[u8; 6]>

ARP source MAC

§arp_tha: Option<[u8; 6]>

ARP target MAC

§tunnel_id: Option<u64>

Tunnel ID

§ct_state: Option<u32>

Connection tracking state (use ct_state:: constants)

§ct_state_mask: Option<u32>

Connection tracking state mask

§ct_zone: Option<u16>

Connection tracking zone

§ct_mark: Option<u32>

Connection tracking mark

§ct_mark_mask: Option<u32>

Connection tracking mark mask

Implementations§

Source§

impl Match

Source

pub fn new() -> Self

Create a new empty match (matches all packets).

Source

pub fn in_port(self, port: u32) -> Self

Match on input port.

Source

pub fn eth_src(self, addr: [u8; 6]) -> Self

Match on source MAC address.

Source

pub fn eth_dst(self, addr: [u8; 6]) -> Self

Match on destination MAC address.

Source

pub fn eth_type(self, etype: u16) -> Self

Match on Ethernet type.

Source

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

Match on VLAN ID.

Source

pub fn ipv4_src(self, addr: Ipv4Addr, prefix_len: u8) -> Self

Match on IPv4 source address with prefix length.

Source

pub fn ipv4_dst(self, addr: Ipv4Addr, prefix_len: u8) -> Self

Match on IPv4 destination address with prefix length.

Source

pub fn ipv6_src(self, addr: Ipv6Addr, prefix_len: u8) -> Self

Match on IPv6 source address with prefix length.

Source

pub fn ipv6_dst(self, addr: Ipv6Addr, prefix_len: u8) -> Self

Match on IPv6 destination address with prefix length.

Source

pub fn ip_proto(self, proto: u8) -> Self

Match on IP protocol.

Source

pub fn tcp_src(self, port: u16) -> Self

Match on TCP source port.

Source

pub fn tcp_dst(self, port: u16) -> Self

Match on TCP destination port.

Source

pub fn udp_src(self, port: u16) -> Self

Match on UDP source port.

Source

pub fn udp_dst(self, port: u16) -> Self

Match on UDP destination port.

Source

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

Match on tunnel ID.

Source

pub fn ct_state(self, state: u32) -> Self

Match on connection tracking state (Nicira extension).

Use constants from oxm::ct_state module, e.g.:

  • ct_state::TRK - packet has been tracked
  • ct_state::NEW - new connection
  • ct_state::EST - established connection
  • ct_state::REL - related connection
  • ct_state::INV - invalid connection
§Example
use rovs_openflow::oxm::ct_state;

// Match established connections
Match::new().ct_state(ct_state::TRK | ct_state::EST)
Source

pub fn ct_state_masked(self, state: u32, mask: u32) -> Self

Match on connection tracking state with explicit mask.

The mask specifies which bits of the state to match.

§Example
use rovs_openflow::oxm::ct_state;

// Match tracked + new, ignoring other flags
Match::new().ct_state_masked(
    ct_state::TRK | ct_state::NEW,
    ct_state::TRK | ct_state::NEW
)
Source

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

Match on connection tracking zone (Nicira extension).

Zones allow multiple independent connection tracking tables.

Source

pub fn ct_mark(self, mark: u32) -> Self

Match on connection tracking mark (Nicira extension).

The ct_mark is a 32-bit value that can be set by the ct action and matched on later.

Source

pub fn ct_mark_masked(self, mark: u32, mask: u32) -> Self

Match on connection tracking mark with mask (Nicira extension).

Source

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

Match on ARP opcode.

Common values: 1 = request, 2 = reply

Source

pub fn arp_spa(self, addr: impl Into<Ipv4Addr>) -> Self

Match on ARP source protocol address (sender IP).

Source

pub fn arp_tpa(self, addr: impl Into<Ipv4Addr>) -> Self

Match on ARP target protocol address (target IP).

Source

pub fn arp_sha(self, addr: [u8; 6]) -> Self

Match on ARP source hardware address (sender MAC).

Source

pub fn arp_tha(self, addr: [u8; 6]) -> Self

Match on ARP target hardware address (target MAC).

Source

pub fn icmp_type(self, icmp_type: u8) -> Self

Match on ICMPv4 type.

Common values: 0 = echo reply, 8 = echo request

Source

pub fn icmp_code(self, code: u8) -> Self

Match on ICMPv4 code.

Source

pub fn icmpv6_type(self, icmp_type: u8) -> Self

Match on ICMPv6 type.

Common values: 128 = echo request, 129 = echo reply, 133 = router solicitation, 134 = router advertisement, 135 = neighbor solicitation, 136 = neighbor advertisement

Source

pub fn icmpv6_code(self, code: u8) -> Self

Match on ICMPv6 code.

Source

pub fn is_empty(&self) -> bool

Check if this match is empty (matches all).

Source§

impl Match

Source

pub fn decode_oxm(oxm_data: &[u8]) -> Result<Self>

Decode OXM fields from raw bytes (without match header).

This is useful for parsing match fields from Packet-In messages where the match header has already been processed.

Source

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

Decode a match from OpenFlow wire format.

Returns the decoded match and the total number of bytes consumed (including padding to 8-byte boundary).

Source

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

Encode the match to OpenFlow wire format (OXM).

The match is encoded as:

  • Match header: type (2 bytes) + length (2 bytes)
  • OXM fields (variable)
  • Padding to 8-byte boundary

Fields are encoded in OpenFlow-specified order with prerequisites automatically satisfied by the builder methods.

Source

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

Encode just the OXM/NXM field TLVs without the match header.

This is used by protocols that embed raw OXM fields without the standard OpenFlow match header (e.g., Nicira flow monitor requests).

Trait Implementations§

Source§

impl Clone for Match

Source§

fn clone(&self) -> Match

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 Match

Source§

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

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

impl Default for Match

Source§

fn default() -> Match

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

impl Display for Match

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Match

§

impl RefUnwindSafe for Match

§

impl Send for Match

§

impl Sync for Match

§

impl Unpin for Match

§

impl UnsafeUnpin for Match

§

impl UnwindSafe for Match

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.