bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::Field Class Reference

Inherits Data.

Public Member Functions

const ByteContainerget_bytes () const
 
int get_nbytes () const
 
int get_nbits () const
 Get the number of bits occupied by this field in the packet header. More...
 
void set_written_to (bool v)
 
bool get_written_to () const
 

Detailed Description

Field objects are used to represent P4 fields. Each Field instance belongs to a Header instance. When defining your own target, you will have to manipulate Field objects to set and access the target's intrinsic metadata. Most of the interesting methods for a target designer are inherited from Data.

Member Function Documentation

◆ get_bytes()

const ByteContainer& bm::Field::get_bytes ( ) const
inline

Return the byte representation of this field. Note that this returns a reference to a byte container, which is only valid as long as the Field instance is alive.

◆ get_nbits()

int bm::Field::get_nbits ( ) const
inline

Get the number of bits occupied by this field in the packet header.

◆ get_nbytes()

int bm::Field::get_nbytes ( ) const
inline

Get the number of bytes occupied by this field, not based on its layout in the packet header, but assuming a byte boundary alignment for the most significant bit. nbytes = (nbits + 7) / 8

◆ get_written_to()

bool bm::Field::get_written_to ( ) const
inline

Get the value of the written_to flag. See set_written_to() for more information.

◆ set_written_to()

void bm::Field::set_written_to ( bool  v)
inline

Set the value of the written_to flag for the field. This flag can be queried at any time using get_written_to() and is used to check whether the field has been modified since written_to was last set to false.


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