Skip to main content

Node

Trait Node 

Source
pub trait Node {
    type Vector;
    type Scalar;
    type Aux;
    type NextNodes: NextNodes;
    type RuntimeData: Send + Copy;
    type TraceData: Send + Copy;
    type Errors: ErrorCounters;
    type FeatureData: Send;

    // Required method
    unsafe fn function(
        &self,
        vm: &mut MainRef,
        node: &mut NodeRuntimeRef<Self>,
        frame: &mut FrameRef<Self>,
    ) -> u16;
}
Expand description

Trait for defining a VPP node

Required Associated Types§

Source

type Vector

Type of vector data sent to the node

Source

type Scalar

Type of scalar data sent to the node

The scalar data is shared between all vector elements in a frame.

This is rarely used and can be set to () if not needed.

Source

type Aux

Type of auxiliary data sent to the node

The auxiliary data is per-vector.

This is rarely used and can be set to () if not needed.

Source

type NextNodes: NextNodes

Type defining the next nodes of this node

Typically an enum using the vpp_plugin_macros::NextNodes derive macro.

Source

type RuntimeData: Send + Copy

Type defining the runtime data of this node

This data is per-node instance and per-thread.

Source

type TraceData: Send + Copy

Type defining the trace data of this node

Source

type Errors: ErrorCounters

Type defining the error counters of this node

Typically an enum using the vpp_plugin_macros::ErrorCounters derive macro.

Source

type FeatureData: Send

Type defining the feature data of this node

This is available when the node is used as a feature node invoked from a feature arc.

If the node is not used as a feature node, this type is not used and so can be set to ().

Required Methods§

Source

unsafe fn function( &self, vm: &mut MainRef, node: &mut NodeRuntimeRef<Self>, frame: &mut FrameRef<Self>, ) -> u16

The packet processing function of the node

Returns the number of packets processed from the frame.

§Safety
  • The caller must ensure that precondition assumptions for the state of the buffers in the frame are met, e.g. that the packets are valid and have the expected headers. For example, if the node is expected to be invoked during the ip4-input feature arc, the caller must ensure that all packets in the frame are valid IPv4 packets and the current data offset is pointing to the start of the IPv4 header. In addition, any assumptions about how much of the packet has been linearised must also be upheld.
  • The node’s precondition assumptions may also inherit from those of next nodes the node sends the buffers to.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§