SatCat5
satcat5::net::Type Struct Reference

Detailed Description

Multipurpose filter for matching fields in network packets.

Filter for numeric values, such as IP address or port number, to allow each instance of net::Protocol to inform the net::Dispatch layer which packets it accepts.

Every instance of net::Protocol must define a multipurpose "Type" to inform the net::Dispatch layer which packets it accepts. The Type can hold any numeric value up to 32 bits. It may be an IP address, a port number, or any other numeric protocol or endpoint identifier. Each net::Protocol object is required to contain a net::Type that designates the type or identity of streams it can accept, or the corresponding field-values for outgoing frames.

The formatting depends on the associated Dispatch, but is usually one-to-one with EtherType, UDP port #, etc. for that network layer. The size is chosen to fit any of the above without duress. In most cases, an exact match is required. However, the two-argument Type constructor can be used in conjunction with the u16 constructor to explicitly request partial matching on the second argument only. Such matching is symmetric, i.e., (x) matches (*, x) and vice-versa.

Note: Dispatch implementations SHOULD provide public accessors for creating Type objects from EtherType, Port#, etc.

Definition at line 38 of file net_type.h.

#include <net_type.h>

Public Member Functions

constexpr Type (u16 val1, u16 val2)
 Construct a Type from a pair of values, concatenated.
 
constexpr Type (u32 val, u32 mask)
 Construct a Type with a custom bitwise filter-mask.
 
 Type (const Type &t)=default
 
Typeoperator= (const Type &t)=default
 
bool bound () const
 Is this Type actively filtering or is it TYPE_NONE?
 
bool match (const Type &other) const
 Check if this Type matches other.
 
constexpr Type (u8 val)
 Construct a Type from a single value.
 
constexpr Type (u16 val)
 Construct a Type from a single value.
 
constexpr Type (u32 val)
 Construct a Type from a single value.
 
u8 as_u8 () const
 Accessors for m_value.
 
u16 as_u16 () const
 Accessors for m_value.
 
u32 as_u32 () const
 Accessors for m_value.
 
void as_u8 (u8 &a) const
 Sets the given parameter to m_value.
 
void as_u16 (u16 &a) const
 Sets the given parameter to m_value.
 
void as_u32 (u32 &a) const
 Sets the given parameter to m_value.
 
void as_pair (u16 &a, u16 &b) const
 Sets the given parameter to m_value.
 

Private Attributes

u32 m_mask
 32-bit mask for m_value.
 
u32 m_value
 Underlying value to check for a match.
 

The documentation for this struct was generated from the following file: