|
| Packet * | getAttachedPacket () |
| | Get a pointer to the Packet this layer is attached to (if any). More...
|
| |
| Packet const * | getAttachedPacket () const |
| | Get a pointer to the Packet this layer is attached to (if any). More...
|
| |
| template<typename T , typename... Args> |
| Layer * | constructNextLayer (uint8_t *data, size_t dataLen, Args &&... extraArgs) |
| | Construct the next layer in the protocol stack. No validation is performed on the data. More...
|
| |
| template<typename T , typename... Args> |
| Layer * | constructNextLayer (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| |
| template<typename TFactory , typename... Args> |
| Layer * | constructNextLayerFromFactory (TFactory factoryFn, uint8_t *data, size_t dataLen, Args &&... extraArgs) |
| | Construct the next layer in the protocol stack using a factory functor. More...
|
| |
| template<typename TFactory , typename... Args> |
| Layer * | constructNextLayerFromFactory (TFactory factoryFn, uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| | Construct the next layer in the protocol stack using a factory functor. More...
|
| |
| template<typename T , typename... Args> |
| Layer * | tryConstructNextLayer (uint8_t *data, size_t dataLen, Args &&... extraArgs) |
| |
| template<typename T , typename... Args> |
| Layer * | tryConstructNextLayer (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| |
| template<typename T , typename TFallback , typename... Args> |
| Layer * | tryConstructNextLayerWithFallback (uint8_t *data, size_t dataLen, Args &&... extraArgs) |
| | Try to construct the next layer in the protocol stack with a fallback option. More...
|
| |
| template<typename T , typename TFallback , typename... Args> |
| Layer * | tryConstructNextLayerWithFallback (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| |
| template<typename TFallback , typename TFactory , typename... Args> |
| Layer * | tryConstructNextLayerFromFactoryWithFallback (TFactory factoryFn, uint8_t *data, size_t dataLen, Args &&... extraArgs) |
| | Try to construct the next layer in the protocol stack using a factory functor with a fallback option. More...
|
| |
| template<typename TFallback , typename TFactory , typename... Args> |
| Layer * | tryConstructNextLayerFromFactoryWithFallback (TFactory factoryFn, uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| | Try to construct the next layer in the protocol stack using a factory functor with a fallback option. More...
|
| |
Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that inherits Layer. The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields. For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size, compute fields that can be automatically computed, print protocol data to string, etc. Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the packet. Here is an example packet showing this concept:
====================================================
|Eth |IPv4 |TCP |Packet |
|Header |Header |Header |Payload |
====================================================
|--------------------------------------------------|
EthLayer data
|---------------------------------------|
IPv4Layer data
|---------------------------|
TcpLayer data
|----------------|
PayloadLayer data
template<typename TFactory , typename... Args>
| Layer* pcpp::Layer::constructNextLayerFromFactory |
( |
TFactory |
factoryFn, |
|
|
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Construct the next layer in the protocol stack using a factory functor.
No validation is performed on the data, outside of what the factory functor may perform. If the factory returns a nullptr, no next layer is set.
The factory functor is expected to have the following signature: Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
This overload infers the Packet from the current layer.
- Template Parameters
-
| TFactory | The factory functor type. |
| ...Args | Parameter pack for extra arguments to pass to the factory functor. |
- Parameters
-
| [in] | factoryFn | The factory functor to create the layer. |
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | extraArgs | Extra arguments to be forwarded to the factory. |
- Returns
- The return value of the factory functor.
template<typename TFactory , typename... Args>
| Layer* pcpp::Layer::constructNextLayerFromFactory |
( |
TFactory |
factoryFn, |
|
|
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Packet * |
packet, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Construct the next layer in the protocol stack using a factory functor.
No validation is performed on the data, outside of what the factory functor may perform. If the factory returns a nullptr, no next layer is set.
The factory functor is expected to have the following signature: Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
- Template Parameters
-
| TFactory | The factory functor type. |
| ...Args | Parameter pack for extra arguments to pass to the factory functor. |
- Parameters
-
| [in] | factoryFn | The factory functor to create the layer. |
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | packet | The packet the layer belongs to |
| [in] | extraArgs | Extra arguments to be forwarded to the factory. |
- Returns
- The return value of the factory functor.
template<typename T , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayer |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack.
This overload infers the Packet from the current layer.
The method checks if the data is valid for the layer type T before constructing it by calling T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
- Template Parameters
-
| T | The type of the layer to construct |
| Args | The types of the extra arguments to pass to the layer constructor |
- Parameters
-
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | extraArgs | Extra arguments to be forwarded to the layer constructor |
- Returns
- The constructed layer or nullptr if the data is invalid
template<typename T , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayer |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Packet * |
packet, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack.
The method checks if the data is valid for the layer type T before constructing it by calling T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
- Template Parameters
-
| T | The type of the layer to construct |
| Args | The types of the extra arguments to pass to the layer constructor |
- Parameters
-
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | packet | The packet the layer belongs to |
| [in] | extraArgs | Extra arguments to be forwarded to the layer constructor |
- Returns
- The constructed layer or nullptr if the data is invalid
template<typename TFallback , typename TFactory , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback |
( |
TFactory |
factoryFn, |
|
|
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
The method will attempt to construct the next layer using the provided factory function. If the factory function returns nullptr, indicating failure to create the layer, the method will then construct a layer of type TFallback.
The factory functor is expected to have the following signature: Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
This overload infers the Packet from the current layer.
- Template Parameters
-
| TFallback | The fallback layer type to construct if the factory fails. |
| TFactory | The factory functor type. |
| ...Args | Parameter pack for extra arguments to pass to the factory functor. |
- Parameters
-
| [in] | factoryFn | The factory functor to create the layer. |
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | extraArgs | Extra arguments to be forwarded to the factory. |
- Returns
- The return value of the factory functor.
template<typename TFallback , typename TFactory , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback |
( |
TFactory |
factoryFn, |
|
|
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Packet * |
packet, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
The method will attempt to construct the next layer using the provided factory function. If the factory function returns nullptr, indicating failure to create the layer, the method will then construct a layer of type TFallback.
The factory functor is expected to have the following signature: Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
- Template Parameters
-
| TFallback | The fallback layer type to construct if the factory fails. |
| TFactory | The factory functor type. |
| ...Args | Parameter pack for extra arguments to pass to the factory functor. |
- Parameters
-
| [in] | factoryFn | The factory functor to create the layer. |
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | packet | The packet the layer belongs to |
| [in] | extraArgs | Extra arguments to be forwarded to the factory. |
- Returns
- The return value of the factory functor.
template<typename T , typename TFallback , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayerWithFallback |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack with a fallback option.
This overload infers the Packet from the current layer.
The method checks if the data is valid for the layer type T before constructing it by calling T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
- Template Parameters
-
| T | The type of the layer to construct |
| TFallback | The fallback layer type to construct if T fails |
| Args | The types of the extra arguments to pass to the layer constructor of T |
- Parameters
-
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | extraArgs | Extra arguments to be forwarded to the layer constructor of T |
- Returns
- The constructed layer of type T or TFallback
template<typename T , typename TFallback , typename... Args>
| Layer* pcpp::Layer::tryConstructNextLayerWithFallback |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Packet * |
packet, |
|
|
Args &&... |
extraArgs |
|
) |
| |
|
inlineprotected |
Try to construct the next layer in the protocol stack with a fallback option.
The method checks if the data is valid for the layer type T before constructing it by calling T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
- Template Parameters
-
| T | The type of the layer to construct |
| TFallback | The fallback layer type to construct if T fails |
| Args | The types of the extra arguments to pass to the layer constructor of T |
- Parameters
-
| [in] | data | The data to construct the layer from |
| [in] | dataLen | The length of the data |
| [in] | packet | The packet the layer belongs to |
| [in] | extraArgs | Extra arguments to be forwarded to the layer constructor of T |
- Returns
- The constructed layer of type T or TFallback