bmv2
Designing your own switch target with bmv2
|
Public Member Functions | |
PacketBuffer (size_t size, const char *data, size_t data_size) | |
This acts as a recipient for the packet data. A PacketBuffer instance will belong to a Packet instance and the same PacketBuffer is used to hold 1) the unparsed packet when the packet is first received 2) the packet payload (i.e. data that was not extracted) while the packet is being processed by the match-action tables 3) the deparsed packet ready to be transmitted. As a target switch programmer, you will only encounter PacketBuffer when creating a new Packet instance:
|
inline |
Construct a PacketBuffer instance with capacity size
, and copy the bytes [data; data + data_size)
to the new buffer. The data
is actually copied to the end of the buffer. This is because while we never need to append data at the end of a packet, the header size of the outgoing packet may be larger than the header size of the incoming packet. By copying the initial data
at the end of the buffer, we preserve space at the beginning of the buffer for potential new headers.
The capacity size
of the PacketBuffer needs to be at least as big as data_size
. If new headers are going to be added to the pakcet during processing, size
needs to be at least as big as the size of the outgoing packet.