bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::Header Class Reference
Inheritance diagram for bm::Header:
Inheritance graph
[legend]

Public Member Functions

int get_nbytes_packet () const
 
bool is_valid () const
 Returns true if this header is marked valid. More...
 
bool is_metadata () const
 Returns true if this header represents metadata. More...
 
void mark_valid ()
 Marks the header as valid. More...
 
void mark_invalid ()
 Marks the header as not-valid. More...
 
void reset ()
 Sets all the fields in the header to value 0. More...
 
void set_written_to (bool written_to_value)
 
Fieldget_field (int field_offset)
 
const Fieldget_field (int field_offset) const
 
header_type_id_t get_header_type_id () const
 
bool is_VL_header () const
 
size_type size () const noexcept
 Returns the number of fields in the header. More...
 
iterator begin ()
 NC. More...
 
const_iterator begin () const
 NC. More...
 
iterator end ()
 NC. More...
 
const_iterator end () const
 NC. More...
 
reference operator[] (size_type n)
 
const_reference operator[] (size_type n) const
 
const std::string & get_field_name (int field_offset) const
 Returns a reference to the name of the field at the given offset. More...
 
const std::string get_field_full_name (int field_offset) const
 
- Public Member Functions inherited from bm::NamedP4Object
const std::string & get_name () const
 Get the name of the P4 instance. More...
 
p4object_id_t get_id () const
 Get the compiler-provided id. More...
 
 NamedP4Object (const NamedP4Object &other)=delete
 Deleted copy constructor. More...
 
NamedP4Objectoperator= (const NamedP4Object &other)=delete
 Deleted copy assignment operator. More...
 
 NamedP4Object (NamedP4Object &&other)=default
 Default move constructor. More...
 
NamedP4Objectoperator= (NamedP4Object &&other)=default
 Default assignment operator. More...
 

Detailed Description

Used to represent P4 header instances. It includes a vector of Field objects.

Member Function Documentation

◆ begin() [1/2]

iterator bm::Header::begin ( )
inline

NC.

◆ begin() [2/2]

const_iterator bm::Header::begin ( ) const
inline

NC.

◆ end() [1/2]

iterator bm::Header::end ( )
inline

NC.

◆ end() [2/2]

const_iterator bm::Header::end ( ) const
inline

NC.

◆ get_field() [1/2]

Field& bm::Header::get_field ( int  field_offset)
inline

Returns a reference to the Field at the specified offset, with bounds checking. If pos not within the range of the container, an exception of type std::out_of_range is thrown.

◆ get_field() [2/2]

const Field& bm::Header::get_field ( int  field_offset) const
inline

Returns a reference to the Field at the specified offset, with bounds checking. If pos not within the range of the container, an exception of type std::out_of_range is thrown.

◆ get_field_full_name()

const std::string bm::Header::get_field_full_name ( int  field_offset) const

Returns the full name of the field at the given offset as a new string. The name is of the form <hdr_name>.<f_name>.

◆ get_field_name()

const std::string& bm::Header::get_field_name ( int  field_offset) const

Returns a reference to the name of the field at the given offset.

◆ get_header_type_id()

header_type_id_t bm::Header::get_header_type_id ( ) const
inline

Returns an integral id which represents the header type of the header. This id can be used to compare whether 2 Header instances have the same header type.

◆ get_nbytes_packet()

int bm::Header::get_nbytes_packet ( ) const
inline

Returns the number of byte occupied by this header when it is deserialized in the packet

◆ is_metadata()

bool bm::Header::is_metadata ( ) const
inline

Returns true if this header represents metadata.

◆ is_valid()

bool bm::Header::is_valid ( ) const
inline

Returns true if this header is marked valid.

◆ is_VL_header()

bool bm::Header::is_VL_header ( ) const
inline

Returns true if this header is an instance of a Variable-Length header type, i.e. contains a field whose length is determined when the header is extracted from the packet data.

◆ mark_invalid()

void bm::Header::mark_invalid ( )

Marks the header as not-valid.

◆ mark_valid()

void bm::Header::mark_valid ( )

Marks the header as valid.

◆ operator[]() [1/2]

reference bm::Header::operator[] ( size_type  n)
inline

Access the character at position n. Will assert if n is greater or equal than the number of fields in the header.

◆ operator[]() [2/2]

const_reference bm::Header::operator[] ( size_type  n) const
inline

Access the character at position n. Will assert if n is greater or equal than the number of fields in the header.

◆ reset()

void bm::Header::reset ( )

Sets all the fields in the header to value 0.

◆ set_written_to()

void bm::Header::set_written_to ( bool  written_to_value)

Set the written_to flag maintained by each field. This flag can be queried at any time by the target, using the Field interface, and can be used to check whether the field has been modified since written_to was last set to false.

◆ size()

size_type bm::Header::size ( ) const
inlinenoexcept

Returns the number of fields in the header.


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