|
| MBufRawPacket () |
|
virtual | ~MBufRawPacket () |
|
| MBufRawPacket (const MBufRawPacket &other) |
|
bool | init (DpdkDevice *device) |
| Initialize an instance of this class from DpdkDevice. Initialization includes allocating an mbuf from the pool that resides in DpdkDevice. The user should call this method only once per instance. Calling it more than once will result with an error. More...
|
|
bool | initFromRawPacket (const RawPacket *rawPacket, DpdkDevice *device) |
| Initialize an instance of this class and copies the content of a RawPacket object. Initialization includes allocating an mbuf from the pool that resides in provided DpdkDevice, and copying the data from the input RawPacket object into this mBuf. The user should call this method only once per instance. Calling it more than once will result with an error. More...
|
|
rte_mbuf * | getMBuf () |
|
uint8_t | getObjectType () const override |
|
MBufRawPacket & | operator= (const MBufRawPacket &other) |
|
bool | setRawData (const uint8_t *pRawData, int rawDataLen, timespec timestamp, LinkLayerType layerType=LINKTYPE_ETHERNET, int frameLength=-1) |
|
void | clear () |
|
void | appendData (const uint8_t *dataToAppend, size_t dataToAppendLen) |
|
void | insertData (int atIndex, const uint8_t *dataToInsert, size_t dataToInsertLen) |
|
bool | removeData (int atIndex, size_t numOfBytesToRemove) |
|
bool | reallocateData (size_t newBufferLength) |
|
void | setFreeMbuf (bool val=true) |
|
| RawPacket (const uint8_t *pRawData, int rawDataLen, timeval timestamp, bool deleteRawDataAtDestructor, LinkLayerType layerType=LINKTYPE_ETHERNET) |
|
| RawPacket (const uint8_t *pRawData, int rawDataLen, timespec timestamp, bool deleteRawDataAtDestructor, LinkLayerType layerType=LINKTYPE_ETHERNET) |
|
| RawPacket () |
|
virtual | ~RawPacket () |
|
| RawPacket (const RawPacket &other) |
|
RawPacket & | operator= (const RawPacket &other) |
|
virtual bool | setRawData (const uint8_t *pRawData, int rawDataLen, timeval timestamp, LinkLayerType layerType=LINKTYPE_ETHERNET, int frameLength=-1) |
|
bool | initWithRawData (const uint8_t *pRawData, int rawDataLen, timespec timestamp, LinkLayerType layerType=LINKTYPE_ETHERNET) |
|
const uint8_t * | getRawData () const |
|
LinkLayerType | getLinkLayerType () const |
|
int | getRawDataLen () const |
|
int | getFrameLength () const |
|
timespec | getPacketTimeStamp () const |
|
virtual bool | setPacketTimeStamp (timeval timestamp) |
|
virtual bool | setPacketTimeStamp (timespec timestamp) |
|
bool | isPacketSet () const |
|
A class that inherits RawPacket and wraps DPDK's mbuf object (see some info about mbuf in DpdkDevice.h) but is compatible with PcapPlusPlus framework. Using MBufRawPacket is be almost similar to using RawPacket, the implementation differences are encapsulated in the class implementation. For example: user can create and manipulate a Packet object from MBufRawPacket the same way it is done with RawPacket; User can use PcapFileWriterDevice to save MBufRawPacket to pcap the same way it's used with RawPacket; etc.
The main difference is that RawPacket contains a pointer to the data itself and MBufRawPacket is holding a pointer to an mbuf object which contains a pointer to the data. This implies that MBufRawPacket without an mbuf allocated to it is not usable. Getting instances of MBufRawPacket can be done in one to the following ways:
- Receiving packets from DpdkDevice. In this case DpdkDevice takes care of getting the mbuf from DPDK and wrapping it with MBufRawPacket
- Creating MBufRawPacket from scratch (in order to send it with DpdkDevice, for example). In this case the user should call the init() method after constructing the object in order to allocate a new mbuf from DPDK port pool (encapsulated by DpdkDevice)
Limitations of this class:
- Currently chained mbufs are not supported. An mbuf has the capability to be linked to another mbuf and create a linked list of mbufs. This is good for Jumbo packets or other uses. MBufRawPacket doesn't support this capability so there is no way to access the mbufs linked to the mbuf wrapped by MBufRawPacket instance. I hope I'll be able to add this support in the future
bool pcpp::MBufRawPacket::setRawData |
( |
const uint8_t * |
pRawData, |
|
|
int |
rawDataLen, |
|
|
timespec |
timestamp, |
|
|
LinkLayerType |
layerType = LINKTYPE_ETHERNET , |
|
|
int |
frameLength = -1 |
|
) |
| |
|
virtual |
Set raw data to the mbuf by copying the data to it. In order to stay compatible with the ancestor method which takes control of the data pointer and frees it when RawPacket is destroyed, this method frees this pointer right away after data is copied to the mbuf. So when using this method please notice that after it's called pRawData memory is free, don't use this pointer again. In addition, if raw packet isn't initialized (mbuf is nullptr), this method will call the init() method
- Parameters
-
[in] | pRawData | A pointer to the new raw data |
[in] | rawDataLen | The new raw data length in bytes |
[in] | timestamp | The timestamp packet was received by the NIC |
[in] | layerType | The link layer type for this raw data. Default is Ethernet |
[in] | frameLength | When reading from pcap files, sometimes the captured length is different from the actual packet length. This parameter represents the packet length. This parameter is optional, if not set or set to -1 it is assumed both lengths are equal |
- Returns
- True if raw data was copied to the mbuf successfully, false if rawDataLen is larger than mbuf max size, if initialization failed or if copying the data to the mbuf failed. In all of these cases an error will be printed to log
Reimplemented from pcpp::RawPacket.