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§
Sourcetype Scalar
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.
Sourcetype Aux
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.
Sourcetype NextNodes: NextNodes
type NextNodes: NextNodes
Type defining the next nodes of this node
Typically an enum using the vpp_plugin_macros::NextNodes derive macro.
Sourcetype RuntimeData: Send + Copy
type RuntimeData: Send + Copy
Type defining the runtime data of this node
This data is per-node instance and per-thread.
Sourcetype Errors: ErrorCounters
type Errors: ErrorCounters
Type defining the error counters of this node
Typically an enum using the vpp_plugin_macros::ErrorCounters derive macro.
Sourcetype FeatureData: Send
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§
Sourceunsafe fn function(
&self,
vm: &mut MainRef,
node: &mut NodeRuntimeRef<Self>,
frame: &mut FrameRef<Self>,
) -> u16
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.