Coverage Report

Created: 2026-07-16 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Packet++/header/Layer.h
Line
Count
Source
1
#pragma once
2
3
#include <stdint.h>
4
#include <stdio.h>
5
#include "ProtocolType.h"
6
#include <ostream>
7
#include <string>
8
#include <stdexcept>
9
#include <utility>
10
11
/// @file
12
13
/// @namespace pcpp
14
/// @brief The main namespace for the PcapPlusPlus lib
15
namespace pcpp
16
{
17
18
  /// @class IDataContainer
19
  /// An interface (virtual abstract class) that indicates an object that holds a pointer to a buffer data. The Layer
20
  /// class is an example of such object, hence it inherits this interface
21
  class IDataContainer
22
  {
23
  public:
24
    /// Get a pointer to the data
25
    /// @param[in] offset Get a pointer in a certain offset. Default is 0 - get a pointer to start of data
26
    /// @return A pointer to the data
27
    virtual uint8_t* getDataPtr(size_t offset = 0) const = 0;
28
29
9.16M
    virtual ~IDataContainer() = default;
30
  };
31
32
  class Packet;
33
34
  namespace internal
35
  {
36
    /// @brief Holds information about a Layer's data and object ownership.
37
    struct LayerAllocationInfo
38
    {
39
      /// @brief Pointer to the Packet this layer is attached to (if any).
40
      ///
41
      /// If the layer is attached to a Packet, the layer's memory span (data) is considered managed by the
42
      /// Packet. The Packet is responsible for keeping the layer's memory span valid and updating it should it
43
      /// become necessary as long as the layer is attached to it.
44
      ///
45
      /// In an event the Packet is destroyed, all of its attached layers's memory views are considered invalid.
46
      /// Accessing layer data after the Packet is destroyed results in undefined behavior.
47
      ///
48
      /// If nullptr, the layer is not attached to any Packet and is considered unmanaged.
49
      /// It also means the layer's memory span is considered owned by the layer itself and will be freed when
50
      /// the layer is destroyed.
51
      Packet* attachedPacket = nullptr;
52
53
      /// @brief Controls if the layer object is considered owned by the attached Packet
54
      ///
55
      /// If 'true', the Layer object is considered owned by the attached Packet and will be freed by it on Packet
56
      /// destruction.
57
      ///
58
      /// If 'false', the Layer object is considered unmanaged and the user is responsible for freeing it.
59
      /// This is commonly the case for layers created on the stack and attached to a Packet.
60
      bool ownedByPacket = false;
61
62
      /// @brief Sets the state of attachment to a specified Packet
63
      /// @param packet Pointer to the Packet this layer is attached to (or nullptr if not attached to any Packet)
64
      /// @param managed True if the layer object's lifetime is to be managed by the Packet, false otherwise
65
      /// @param force If true, bypasses the check for existing attachment. Default is false.
66
      /// @throws std::runtime_error if the layer is already attached to a Packet and 'force' is false
67
      void attachPacket(Packet* packet, bool managed, bool force = false)
68
0
      {
69
0
        if (!force && attachedPacket != nullptr)
70
0
        {
71
0
          throw std::runtime_error("Layer is already attached to a Packet");
72
0
        }
73
0
74
0
        attachedPacket = packet;
75
0
        ownedByPacket = managed;
76
0
      }
77
78
      /// @brief Clears the attachment to any Packet, resetting to unmanaged state.
79
      void detach()
80
0
      {
81
0
        attachedPacket = nullptr;
82
0
        ownedByPacket = false;
83
0
      }
84
    };
85
  }  // namespace internal
86
87
  /// @class Layer
88
  /// Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that
89
  /// inherits Layer.
90
  /// The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields.
91
  /// For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size,
92
  /// compute fields that can be automatically computed, print protocol data to string, etc.
93
  /// Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is
94
  /// represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer
95
  /// has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is
96
  /// abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer
97
  /// to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the
98
  /// packet. Here is an example packet showing this concept:
99
  ///
100
  /// @code{.unparsed}
101
  /// ====================================================
102
  /// |Eth       |IPv4       |TCP       |Packet          |
103
  /// |Header    |Header     |Header    |Payload         |
104
  /// ====================================================
105
  ///
106
  /// |--------------------------------------------------|
107
  /// EthLayer data
108
  ///            |---------------------------------------|
109
  ///            IPv4Layer data
110
  ///                        |---------------------------|
111
  ///                        TcpLayer data
112
  ///                                   |----------------|
113
  ///                                   PayloadLayer data
114
  /// @endcode
115
  class Layer : public IDataContainer
116
  {
117
    friend class Packet;
118
119
  public:
120
    /// A destructor for this class. Frees the data if it was allocated by the layer constructor (see
121
    /// isAllocatedToPacket() for more info)
122
    ~Layer() override;
123
124
    /// @return A pointer to the next layer in the protocol stack or nullptr if the layer is the last one
125
    Layer* getNextLayer() const
126
171M
    {
127
171M
      return m_NextLayer;
128
171M
    }
129
130
    /// @return A pointer to the previous layer in the protocol stack or nullptr if the layer is the first one
131
    Layer* getPrevLayer() const
132
3.26M
    {
133
3.26M
      return m_PrevLayer;
134
3.26M
    }
135
136
    /// @return The protocol enum
137
    ProtocolType getProtocol() const
138
123M
    {
139
123M
      return m_Protocol;
140
123M
    }
141
142
    /// Check if the layer's protocol matches a protocol family
143
    /// @param protocolTypeFamily The protocol family to check
144
    /// @return True if the layer's protocol matches the protocol family, false otherwise
145
    bool isMemberOfProtocolFamily(ProtocolTypeFamily protocolTypeFamily) const;
146
147
    /// @return A pointer to the layer raw data. In most cases it'll be a pointer to the first byte of the header
148
    uint8_t* getData() const
149
540k
    {
150
540k
      return m_Data;
151
540k
    }
152
153
    /// @return The length in bytes of the data from the first byte of the header until the end of the packet
154
    size_t getDataLen() const
155
5.91M
    {
156
5.91M
      return m_DataLen;
157
5.91M
    }
158
159
    /// @return A pointer for the layer payload, meaning the first byte after the header
160
    uint8_t* getLayerPayload() const
161
0
    {
162
0
      return m_Data + getHeaderLen();
163
0
    }
164
165
    /// @return The size in bytes of the payload
166
    size_t getLayerPayloadSize() const
167
93.8k
    {
168
93.8k
      return m_DataLen - getHeaderLen();
169
93.8k
    }
170
171
    /// Raw data in layers can come from one of sources:
172
    /// 1. from an existing packet - this is the case when parsing packets received from files or the network. In
173
    /// this case the data was already allocated by someone else, and layer only holds the pointer to the relevant
174
    /// place inside this data
175
    /// 2. when creating packets, data is allocated when layer is created. In this case the layer is responsible for
176
    /// freeing it as well
177
    ///
178
    /// @return Returns true if the data was allocated by an external source (a packet) or false if it was allocated
179
    /// by the layer itself
180
    bool isAllocatedToPacket() const
181
9.16M
    {
182
9.16M
      return m_AllocationInfo.attachedPacket != nullptr;
183
9.16M
    }
184
185
    /// @brief Copy the raw data of this layer to another array
186
    ///
187
    /// @warning The method does not perform any bounds checking on the destination array. The caller MUST ensure
188
    /// that the destination array has enough space to hold the getDataLen() bytes.
189
    ///
190
    /// @warning Prefer the overload of copyData() that accepts a destination size to ensure safe copying of data.
191
    ///
192
    /// @param[out] toArr The destination byte array
193
    void copyData(uint8_t* toArr) const;
194
195
    /// @brief Copy the raw data of this layer to another array, with a specified maximum size.
196
    ///
197
    /// The method copies up to 'destSize' bytes of the layer's raw data into the provided destination array.
198
    /// If the layer's data length is greater than 'destSize', only the first 'destSize' bytes will be copied.
199
    ///
200
    /// To ensure sufficient space is available in the destination array, use getDataLen() to determine the actual
201
    /// length of the layer's data before calling this method.
202
    ///
203
    /// @param[out] dest The destination byte array
204
    /// @param[in] destSize The maximum number of bytes to copy
205
    /// @return The number of bytes copied to the destination array.
206
    size_t copyData(uint8_t* dest, size_t destSize) const;
207
208
    // implement abstract methods
209
210
    uint8_t* getDataPtr(size_t offset = 0) const override
211
210k
    {
212
210k
      return static_cast<uint8_t*>(m_Data + offset);
213
210k
    }
214
215
    // abstract methods
216
217
    /// Each layer is responsible for parsing the next layer
218
    virtual void parseNextLayer() = 0;
219
220
    /// @return The header length in bytes
221
    virtual size_t getHeaderLen() const = 0;
222
223
    /// Each layer can compute field values automatically using this method. This is an abstract method
224
    virtual void computeCalculateFields() = 0;
225
226
    /// @return A string representation of the layer most important data (should look like the layer description in
227
    /// Wireshark)
228
    virtual std::string toString() const = 0;
229
230
    /// @return The OSI Model layer this protocol belongs to
231
    virtual OsiModelLayer getOsiModelLayer() const = 0;
232
233
  protected:
234
    uint8_t* m_Data;
235
    size_t m_DataLen;
236
    ProtocolType m_Protocol;
237
    Layer* m_NextLayer;
238
    Layer* m_PrevLayer;
239
240
  private:
241
    internal::LayerAllocationInfo m_AllocationInfo;
242
243
  protected:
244
    Layer() : m_Data(nullptr), m_DataLen(0), m_Protocol(UnknownProtocol), m_NextLayer(nullptr), m_PrevLayer(nullptr)
245
0
    {}
246
247
    Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol)
248
8.90M
        : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer),
249
8.90M
          m_AllocationInfo{ packet, false }
250
8.90M
    {}
251
252
    // Copy c'tor
253
    Layer(const Layer& other);
254
    Layer& operator=(const Layer& other);
255
256
    /// @brief Get a pointer to the Packet this layer is attached to (if any).
257
    /// @return A pointer to the Packet this layer is attached to, or nullptr if the layer is not attached.
258
    Packet* getAttachedPacket()
259
8.35M
    {
260
8.35M
      return m_AllocationInfo.attachedPacket;
261
8.35M
    }
262
263
    /// @brief Get a pointer to the Packet this layer is attached to (if any).
264
    /// @return A const pointer to the Packet this layer is attached to, or nullptr if the layer is not attached.
265
    Packet const* getAttachedPacket() const
266
11.1k
    {
267
11.1k
      return m_AllocationInfo.attachedPacket;
268
11.1k
    }
269
270
    void setNextLayer(Layer* nextLayer)
271
7.05M
    {
272
7.05M
      m_NextLayer = nextLayer;
273
7.05M
    }
274
    void setPrevLayer(Layer* prevLayer)
275
0
    {
276
0
      m_PrevLayer = prevLayer;
277
0
    }
278
279
    // ------ Memory Control Methods -----
280
    // Used by derived classes to request buffer size changes.
281
282
    /// @brief Requests the layer to allocate a new data buffer of the specified length.
283
    ///
284
    /// If the layer is not attached to a Packet, it will allocate a new buffer of the specified length.
285
    /// If the layer is attached to a Packet, it will throw a std::logic_error, as that case is not yet supported.
286
    ///
287
    /// The primary use case for this method is initial allocation of the data buffer in derived classes.
288
    ///
289
    /// @param[in] dataLen The length of the new data buffer.
290
    /// @param[in] zeroInit If true, the new buffer will be zero-initialized.
291
    /// @throws std::runtime_error if the layer already has allocated data.
292
    /// @throws std::logic_error if the layer is attached to a Packet (not yet supported).
293
    void allocData(size_t dataLen, bool zeroInit = true);
294
295
    virtual bool extendLayer(int offsetInLayer, size_t numOfBytesToExtend);
296
    virtual bool shortenLayer(int offsetInLayer, size_t numOfBytesToShorten);
297
298
    bool hasNextLayer() const
299
12.6M
    {
300
12.6M
      return m_NextLayer != nullptr;
301
12.6M
    }
302
303
    /// @brief Construct the next layer in the protocol stack. No validation is performed on the data.
304
    ///
305
    /// This overload infers the Packet from the current layer.
306
    ///
307
    /// @tparam T The type of the layer to construct
308
    /// @tparam Args The types of the arguments to pass to the layer constructor
309
    /// @param data The data to construct the layer from
310
    /// @param dataLen The length of the data
311
    /// @param extraArgs Extra arguments to be forwarded to the layer constructor
312
    /// @return The constructed layer
313
    template <typename T, typename... Args>
314
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs)
315
671k
    {
316
671k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
671k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
76.5k
    {
316
76.5k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
76.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
87.6k
    {
316
87.6k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
87.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
184k
    {
316
184k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
184k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&)
Line
Count
Source
315
15.2k
    {
316
15.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
15.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
7.71k
    {
316
7.71k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
7.71k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
97.3k
    {
316
97.3k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
97.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
33.7k
    {
316
33.7k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
33.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
47.1k
    {
316
47.1k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
47.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
7.90k
    {
316
7.90k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
7.90k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
22.0k
    {
316
22.0k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
22.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
22.4k
    {
316
22.4k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
22.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
1.15k
    {
316
1.15k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
1.15k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
6.87k
    {
316
6.87k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
6.87k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
60.7k
    {
316
60.7k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
60.7k
    }
318
319
    /// Construct the next layer in the protocol stack. No validation is performed on the data.
320
    /// @tparam T The type of the layer to construct
321
    /// @tparam Args The types of the arguments to pass to the layer constructor
322
    /// @param[in] data The data to construct the layer from
323
    /// @param[in] dataLen The length of the data
324
    /// @param[in] packet The packet the layer belongs to
325
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
326
    /// @return The constructed layer
327
    template <typename T, typename... Args>
328
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
329
5.75M
    {
330
5.75M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.75M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.75M
      setNextLayer(newLayer);
337
5.75M
      return newLayer;
338
5.75M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.64M
    {
330
1.64M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.64M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.64M
      setNextLayer(newLayer);
337
1.64M
      return newLayer;
338
1.64M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
582k
    {
330
582k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
582k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
582k
      setNextLayer(newLayer);
337
582k
      return newLayer;
338
582k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
356k
    {
330
356k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
356k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
356k
      setNextLayer(newLayer);
337
356k
      return newLayer;
338
356k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
255k
    {
330
255k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
255k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
255k
      setNextLayer(newLayer);
337
255k
      return newLayer;
338
255k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
89.9k
    {
330
89.9k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
89.9k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
89.9k
      setNextLayer(newLayer);
337
89.9k
      return newLayer;
338
89.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
73.0k
    {
330
73.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
73.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
73.0k
      setNextLayer(newLayer);
337
73.0k
      return newLayer;
338
73.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
6.87k
    {
330
6.87k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
6.87k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
6.87k
      setNextLayer(newLayer);
337
6.87k
      return newLayer;
338
6.87k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
14.4k
    {
330
14.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
14.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
14.4k
      setNextLayer(newLayer);
337
14.4k
      return newLayer;
338
14.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
581k
    {
330
581k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
581k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
581k
      setNextLayer(newLayer);
337
581k
      return newLayer;
338
581k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.13M
    {
330
1.13M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.13M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.13M
      setNextLayer(newLayer);
337
1.13M
      return newLayer;
338
1.13M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
56.0k
    {
330
56.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
56.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
56.0k
      setNextLayer(newLayer);
337
56.0k
      return newLayer;
338
56.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
26.4k
    {
330
26.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
26.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
26.4k
      setNextLayer(newLayer);
337
26.4k
      return newLayer;
338
26.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
93.9k
    {
330
93.9k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
93.9k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
93.9k
      setNextLayer(newLayer);
337
93.9k
      return newLayer;
338
93.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5.31k
    {
330
5.31k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.31k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.31k
      setNextLayer(newLayer);
337
5.31k
      return newLayer;
338
5.31k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
10.2k
    {
330
10.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
10.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
10.2k
      setNextLayer(newLayer);
337
10.2k
      return newLayer;
338
10.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.45k
    {
330
1.45k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.45k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.45k
      setNextLayer(newLayer);
337
1.45k
      return newLayer;
338
1.45k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
3.73k
    {
330
3.73k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.73k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.73k
      setNextLayer(newLayer);
337
3.73k
      return newLayer;
338
3.73k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
4.36k
    {
330
4.36k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
4.36k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
4.36k
      setNextLayer(newLayer);
337
4.36k
      return newLayer;
338
4.36k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5.32k
    {
330
5.32k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.32k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.32k
      setNextLayer(newLayer);
337
5.32k
      return newLayer;
338
5.32k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
16.0k
    {
330
16.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
16.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
16.0k
      setNextLayer(newLayer);
337
16.0k
      return newLayer;
338
16.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
329
24.4k
    {
330
24.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
24.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
24.4k
      setNextLayer(newLayer);
337
24.4k
      return newLayer;
338
24.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
22.3k
    {
330
22.3k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
22.3k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
22.3k
      setNextLayer(newLayer);
337
22.3k
      return newLayer;
338
22.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
71.5k
    {
330
71.5k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
71.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
71.5k
      setNextLayer(newLayer);
337
71.5k
      return newLayer;
338
71.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
2.76k
    {
330
2.76k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
2.76k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
2.76k
      setNextLayer(newLayer);
337
2.76k
      return newLayer;
338
2.76k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
16.3k
    {
330
16.3k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
16.3k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
16.3k
      setNextLayer(newLayer);
337
16.3k
      return newLayer;
338
16.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
83.6k
    {
330
83.6k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
83.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
83.6k
      setNextLayer(newLayer);
337
83.6k
      return newLayer;
338
83.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
26.1k
    {
330
26.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
26.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
26.1k
      setNextLayer(newLayer);
337
26.1k
      return newLayer;
338
26.1k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.48k
    {
330
1.48k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.48k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.48k
      setNextLayer(newLayer);
337
1.48k
      return newLayer;
338
1.48k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
22.6k
    {
330
22.6k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
22.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
22.6k
      setNextLayer(newLayer);
337
22.6k
      return newLayer;
338
22.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
58.8k
    {
330
58.8k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
58.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
58.8k
      setNextLayer(newLayer);
337
58.8k
      return newLayer;
338
58.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
21.0k
    {
330
21.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
21.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
21.0k
      setNextLayer(newLayer);
337
21.0k
      return newLayer;
338
21.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5.62k
    {
330
5.62k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.62k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.62k
      setNextLayer(newLayer);
337
5.62k
      return newLayer;
338
5.62k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
4.60k
    {
330
4.60k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
4.60k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
4.60k
      setNextLayer(newLayer);
337
4.60k
      return newLayer;
338
4.60k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
34.2k
    {
330
34.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
34.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
34.2k
      setNextLayer(newLayer);
337
34.2k
      return newLayer;
338
34.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
3.52k
    {
330
3.52k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.52k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.52k
      setNextLayer(newLayer);
337
3.52k
      return newLayer;
338
3.52k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
8.27k
    {
330
8.27k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
8.27k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
8.27k
      setNextLayer(newLayer);
337
8.27k
      return newLayer;
338
8.27k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.81k
    {
330
1.81k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.81k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.81k
      setNextLayer(newLayer);
337
1.81k
      return newLayer;
338
1.81k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
30.7k
    {
330
30.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
30.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
30.7k
      setNextLayer(newLayer);
337
30.7k
      return newLayer;
338
30.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
31.4k
    {
330
31.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
31.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
31.4k
      setNextLayer(newLayer);
337
31.4k
      return newLayer;
338
31.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
6.87k
    {
330
6.87k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
6.87k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
6.87k
      setNextLayer(newLayer);
337
6.87k
      return newLayer;
338
6.87k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
97.3k
    {
330
97.3k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
97.3k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
97.3k
      setNextLayer(newLayer);
337
97.3k
      return newLayer;
338
97.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
33.7k
    {
330
33.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
33.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
33.7k
      setNextLayer(newLayer);
337
33.7k
      return newLayer;
338
33.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
47.1k
    {
330
47.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
47.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
47.1k
      setNextLayer(newLayer);
337
47.1k
      return newLayer;
338
47.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
22.0k
    {
330
22.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
22.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
22.0k
      setNextLayer(newLayer);
337
22.0k
      return newLayer;
338
22.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
22.4k
    {
330
22.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
22.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
22.4k
      setNextLayer(newLayer);
337
22.4k
      return newLayer;
338
22.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.21k
    {
330
1.21k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.21k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.21k
      setNextLayer(newLayer);
337
1.21k
      return newLayer;
338
1.21k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
20.9k
    {
330
20.9k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
20.9k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
20.9k
      setNextLayer(newLayer);
337
20.9k
      return newLayer;
338
20.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
60.7k
    {
330
60.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
60.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
60.7k
      setNextLayer(newLayer);
337
60.7k
      return newLayer;
338
60.7k
    }
339
340
    /// @brief Construct the next layer in the protocol stack using a factory functor.
341
    ///
342
    /// No validation is performed on the data, outside of what the factory functor may perform.
343
    /// If the factory returns a nullptr, no next layer is set.
344
    ///
345
    /// The factory functor is expected to have the following signature:
346
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
347
    ///
348
    /// This overload infers the Packet from the current layer.
349
    ///
350
    /// @tparam TFactory The factory functor type.
351
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
352
    /// @param[in] factoryFn The factory functor to create the layer.
353
    /// @param[in] data The data to construct the layer from
354
    /// @param[in] dataLen The length of the data
355
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
356
    /// @return The return value of the factory functor.
357
    template <typename TFactory, typename... Args>
358
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs)
359
882k
    {
360
882k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
882k
                                                     std::forward<Args>(extraArgs)...);
362
882k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
164k
    {
360
164k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
164k
                                                     std::forward<Args>(extraArgs)...);
362
164k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
114k
    {
360
114k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
114k
                                                     std::forward<Args>(extraArgs)...);
362
114k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
544k
    {
360
544k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
544k
                                                     std::forward<Args>(extraArgs)...);
362
544k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
31.7k
    {
360
31.7k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
31.7k
                                                     std::forward<Args>(extraArgs)...);
362
31.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
20.7k
    {
360
20.7k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
20.7k
                                                     std::forward<Args>(extraArgs)...);
362
20.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
359
5.46k
    {
360
5.46k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
5.46k
                                                     std::forward<Args>(extraArgs)...);
362
5.46k
    }
363
364
    /// @brief Construct the next layer in the protocol stack using a factory functor.
365
    ///
366
    /// No validation is performed on the data, outside of what the factory functor may perform.
367
    /// If the factory returns a nullptr, no next layer is set.
368
    ///
369
    /// The factory functor is expected to have the following signature:
370
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
371
    ///
372
    /// @tparam TFactory The factory functor type.
373
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
374
    /// @param[in] factoryFn The factory functor to create the layer.
375
    /// @param[in] data The data to construct the layer from
376
    /// @param[in] dataLen The length of the data
377
    /// @param[in] packet The packet the layer belongs to
378
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
379
    /// @return The return value of the factory functor.
380
    template <typename TFactory, typename... Args>
381
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet,
382
                                         Args&&... extraArgs)
383
1.24M
    {
384
1.24M
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
1.24M
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
1.24M
      setNextLayer(newLayer);
392
1.24M
      return newLayer;
393
1.24M
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
244k
    {
384
244k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
244k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
244k
      setNextLayer(newLayer);
392
244k
      return newLayer;
393
244k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
114k
    {
384
114k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
114k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
114k
      setNextLayer(newLayer);
392
114k
      return newLayer;
393
114k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
544k
    {
384
544k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
544k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
544k
      setNextLayer(newLayer);
392
544k
      return newLayer;
393
544k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
31.7k
    {
384
31.7k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
31.7k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
31.7k
      setNextLayer(newLayer);
392
31.7k
      return newLayer;
393
31.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
49.2k
    {
384
49.2k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
49.2k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
49.2k
      setNextLayer(newLayer);
392
49.2k
      return newLayer;
393
49.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
59.5k
    {
384
59.5k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
59.5k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
59.5k
      setNextLayer(newLayer);
392
59.5k
      return newLayer;
393
59.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
85
    {
384
85
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
85
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
85
      setNextLayer(newLayer);
392
85
      return newLayer;
393
85
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
4.44k
    {
384
4.44k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
4.44k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
4.44k
      setNextLayer(newLayer);
392
4.44k
      return newLayer;
393
4.44k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, pcpp::Packet*, unsigned short&, unsigned short&)
Line
Count
Source
383
94.9k
    {
384
94.9k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
94.9k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
94.9k
      setNextLayer(newLayer);
392
94.9k
      return newLayer;
393
94.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
3.25k
    {
384
3.25k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
3.25k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
3.25k
      setNextLayer(newLayer);
392
3.25k
      return newLayer;
393
3.25k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
90.9k
    {
384
90.9k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
90.9k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
90.9k
      setNextLayer(newLayer);
392
90.9k
      return newLayer;
393
90.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
383
5.46k
    {
384
5.46k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
5.46k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
5.46k
      setNextLayer(newLayer);
392
5.46k
      return newLayer;
393
5.46k
    }
394
395
    /// Try to construct the next layer in the protocol stack.
396
    ///
397
    /// This overload infers the Packet from the current layer.
398
    ///
399
    /// The method checks if the data is valid for the layer type T before constructing it by calling
400
    /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
401
    ///
402
    /// @tparam T The type of the layer to construct
403
    /// @tparam Args The types of the extra arguments to pass to the layer constructor
404
    /// @param[in] data The data to construct the layer from
405
    /// @param[in] dataLen The length of the data
406
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
407
    /// @return The constructed layer or nullptr if the data is invalid
408
    template <typename T, typename... Args>
409
    Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs)
410
0
    {
411
0
      return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
412
0
    }
413
414
    /// Try to construct the next layer in the protocol stack.
415
    ///
416
    /// The method checks if the data is valid for the layer type T before constructing it by calling
417
    /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
418
    ///
419
    /// @tparam T The type of the layer to construct
420
    /// @tparam Args The types of the extra arguments to pass to the layer constructor
421
    /// @param[in] data The data to construct the layer from
422
    /// @param[in] dataLen The length of the data
423
    /// @param[in] packet The packet the layer belongs to
424
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
425
    /// @return The constructed layer or nullptr if the data is invalid
426
    template <typename T, typename... Args>
427
    Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
428
4.45M
    {
429
4.45M
      if (T::isDataValid(data, dataLen))
430
4.41M
      {
431
4.41M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
4.41M
      }
433
47.4k
      return nullptr;
434
4.45M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
1.66M
    {
429
1.66M
      if (T::isDataValid(data, dataLen))
430
1.64M
      {
431
1.64M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
1.64M
      }
433
17.9k
      return nullptr;
434
1.66M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
360k
    {
429
360k
      if (T::isDataValid(data, dataLen))
430
356k
      {
431
356k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
356k
      }
433
3.31k
      return nullptr;
434
360k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
73.4k
    {
429
73.4k
      if (T::isDataValid(data, dataLen))
430
73.0k
      {
431
73.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
73.0k
      }
433
392
      return nullptr;
434
73.4k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
7.94k
    {
429
7.94k
      if (T::isDataValid(data, dataLen))
430
6.54k
      {
431
6.54k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
6.54k
      }
433
1.40k
      return nullptr;
434
7.94k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
584k
    {
429
584k
      if (T::isDataValid(data, dataLen))
430
581k
      {
431
581k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
581k
      }
433
2.54k
      return nullptr;
434
584k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
1.15M
    {
429
1.15M
      if (T::isDataValid(data, dataLen))
430
1.13M
      {
431
1.13M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
1.13M
      }
433
13.1k
      return nullptr;
434
1.15M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
57.0k
    {
429
57.0k
      if (T::isDataValid(data, dataLen))
430
56.0k
      {
431
56.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
56.0k
      }
433
1.01k
      return nullptr;
434
57.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
26.4k
    {
429
26.4k
      if (T::isDataValid(data, dataLen))
430
26.4k
      {
431
26.4k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
26.4k
      }
433
0
      return nullptr;
434
26.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
93.9k
    {
429
93.9k
      if (T::isDataValid(data, dataLen))
430
93.9k
      {
431
93.9k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
93.9k
      }
433
0
      return nullptr;
434
93.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
5.31k
    {
429
5.31k
      if (T::isDataValid(data, dataLen))
430
5.31k
      {
431
5.31k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
5.31k
      }
433
0
      return nullptr;
434
5.31k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
10.2k
    {
429
10.2k
      if (T::isDataValid(data, dataLen))
430
10.2k
      {
431
10.2k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
10.2k
      }
433
0
      return nullptr;
434
10.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
1.45k
    {
429
1.45k
      if (T::isDataValid(data, dataLen))
430
1.45k
      {
431
1.45k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
1.45k
      }
433
0
      return nullptr;
434
1.45k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
3.73k
    {
429
3.73k
      if (T::isDataValid(data, dataLen))
430
3.73k
      {
431
3.73k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
3.73k
      }
433
0
      return nullptr;
434
3.73k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
4.50k
    {
429
4.50k
      if (T::isDataValid(data, dataLen))
430
4.36k
      {
431
4.36k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
4.36k
      }
433
138
      return nullptr;
434
4.50k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
5.32k
    {
429
5.32k
      if (T::isDataValid(data, dataLen))
430
5.32k
      {
431
5.32k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
5.32k
      }
433
0
      return nullptr;
434
5.32k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
16.0k
    {
429
16.0k
      if (T::isDataValid(data, dataLen))
430
16.0k
      {
431
16.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
16.0k
      }
433
0
      return nullptr;
434
16.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
428
9.18k
    {
429
9.18k
      if (T::isDataValid(data, dataLen))
430
9.18k
      {
431
9.18k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
9.18k
      }
433
0
      return nullptr;
434
9.18k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
71.6k
    {
429
71.6k
      if (T::isDataValid(data, dataLen))
430
71.5k
      {
431
71.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
71.5k
      }
433
128
      return nullptr;
434
71.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.76k
    {
429
2.76k
      if (T::isDataValid(data, dataLen))
430
2.76k
      {
431
2.76k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.76k
      }
433
0
      return nullptr;
434
2.76k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
17.3k
    {
429
17.3k
      if (T::isDataValid(data, dataLen))
430
16.3k
      {
431
16.3k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
16.3k
      }
433
1.02k
      return nullptr;
434
17.3k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
34.1k
    {
429
34.1k
      if (T::isDataValid(data, dataLen))
430
30.7k
      {
431
30.7k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
30.7k
      }
433
3.45k
      return nullptr;
434
34.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
31.8k
    {
429
31.8k
      if (T::isDataValid(data, dataLen))
430
31.4k
      {
431
31.4k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
31.4k
      }
433
336
      return nullptr;
434
31.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
6.87k
    {
429
6.87k
      if (T::isDataValid(data, dataLen))
430
6.87k
      {
431
6.87k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
6.87k
      }
433
0
      return nullptr;
434
6.87k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
22.9k
    {
429
22.9k
      if (T::isDataValid(data, dataLen))
430
20.9k
      {
431
20.9k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
20.9k
      }
433
2.04k
      return nullptr;
434
22.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
14.6k
    {
429
14.6k
      if (T::isDataValid(data, dataLen))
430
14.6k
      {
431
14.6k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
14.6k
      }
433
21
      return nullptr;
434
14.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
179k
    {
429
179k
      if (T::isDataValid(data, dataLen))
430
179k
      {
431
179k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
179k
      }
433
258
      return nullptr;
434
179k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.27k
    {
429
2.27k
      if (T::isDataValid(data, dataLen))
430
2.27k
      {
431
2.27k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.27k
      }
433
0
      return nullptr;
434
2.27k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
348
    {
429
348
      if (T::isDataValid(data, dataLen))
430
63
      {
431
63
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
63
      }
433
285
      return nullptr;
434
348
    }
435
436
    /// @brief Try to construct the next layer in the protocol stack with a fallback option.
437
    ///
438
    /// This overload infers the Packet from the current layer.
439
    ///
440
    /// The method checks if the data is valid for the layer type T before constructing it by calling
441
    /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
442
    ///
443
    /// @tparam T The type of the layer to construct
444
    /// @tparam TFallback The fallback layer type to construct if T fails
445
    /// @tparam Args The types of the extra arguments to pass to the layer constructor of T
446
    /// @param[in] data The data to construct the layer from
447
    /// @param[in] dataLen The length of the data
448
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T
449
    /// @return The constructed layer of type T or TFallback
450
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
451
    /// constructor.
452
    template <typename T, typename TFallback, typename... Args>
453
    Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs)
454
2.80M
    {
455
2.80M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
2.80M
                                                             std::forward<Args>(extraArgs)...);
457
2.80M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
1.66M
    {
455
1.66M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
1.66M
                                                             std::forward<Args>(extraArgs)...);
457
1.66M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
353k
    {
455
353k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
353k
                                                             std::forward<Args>(extraArgs)...);
457
353k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
73.4k
    {
455
73.4k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
73.4k
                                                             std::forward<Args>(extraArgs)...);
457
73.4k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
7.94k
    {
455
7.94k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
7.94k
                                                             std::forward<Args>(extraArgs)...);
457
7.94k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
39.6k
    {
455
39.6k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
39.6k
                                                             std::forward<Args>(extraArgs)...);
457
39.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
267k
    {
455
267k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
267k
                                                             std::forward<Args>(extraArgs)...);
457
267k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
9.75k
    {
455
9.75k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
9.75k
                                                             std::forward<Args>(extraArgs)...);
457
9.75k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
5.48k
    {
455
5.48k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
5.48k
                                                             std::forward<Args>(extraArgs)...);
457
5.48k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
3.16k
    {
455
3.16k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
3.16k
                                                             std::forward<Args>(extraArgs)...);
457
3.16k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
71.6k
    {
455
71.6k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
71.6k
                                                             std::forward<Args>(extraArgs)...);
457
71.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
2.76k
    {
455
2.76k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
2.76k
                                                             std::forward<Args>(extraArgs)...);
457
2.76k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
17.3k
    {
455
17.3k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
17.3k
                                                             std::forward<Args>(extraArgs)...);
457
17.3k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
34.1k
    {
455
34.1k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
34.1k
                                                             std::forward<Args>(extraArgs)...);
457
34.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
31.8k
    {
455
31.8k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
31.8k
                                                             std::forward<Args>(extraArgs)...);
457
31.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
6.87k
    {
455
6.87k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
6.87k
                                                             std::forward<Args>(extraArgs)...);
457
6.87k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
22.9k
    {
455
22.9k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
22.9k
                                                             std::forward<Args>(extraArgs)...);
457
22.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
14.6k
    {
455
14.6k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
14.6k
                                                             std::forward<Args>(extraArgs)...);
457
14.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
179k
    {
455
179k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
179k
                                                             std::forward<Args>(extraArgs)...);
457
179k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
2.27k
    {
455
2.27k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
2.27k
                                                             std::forward<Args>(extraArgs)...);
457
2.27k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
348
    {
455
348
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
348
                                                             std::forward<Args>(extraArgs)...);
457
348
    }
458
459
    /// Try to construct the next layer in the protocol stack with a fallback option.
460
    ///
461
    /// The method checks if the data is valid for the layer type T before constructing it by calling
462
    /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
463
    ///
464
    /// @tparam T The type of the layer to construct
465
    /// @tparam TFallback The fallback layer type to construct if T fails
466
    /// @tparam Args The types of the extra arguments to pass to the layer constructor of T
467
    /// @param[in] data The data to construct the layer from
468
    /// @param[in] dataLen The length of the data
469
    /// @param[in] packet The packet the layer belongs to
470
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T
471
    /// @return The constructed layer of type T or TFallback
472
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
473
    /// constructor.
474
    template <typename T, typename TFallback, typename... Args>
475
    Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
476
4.45M
    {
477
4.45M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
4.41M
      {
479
4.41M
        return m_NextLayer;
480
4.41M
      }
481
482
47.4k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
4.45M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
1.66M
    {
477
1.66M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
1.64M
      {
479
1.64M
        return m_NextLayer;
480
1.64M
      }
481
482
17.9k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
1.66M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
360k
    {
477
360k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
356k
      {
479
356k
        return m_NextLayer;
480
356k
      }
481
482
3.31k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
360k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
73.4k
    {
477
73.4k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
73.0k
      {
479
73.0k
        return m_NextLayer;
480
73.0k
      }
481
482
392
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
73.4k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
7.94k
    {
477
7.94k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
6.54k
      {
479
6.54k
        return m_NextLayer;
480
6.54k
      }
481
482
1.40k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
7.94k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
584k
    {
477
584k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
581k
      {
479
581k
        return m_NextLayer;
480
581k
      }
481
482
2.54k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
584k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
1.15M
    {
477
1.15M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
1.13M
      {
479
1.13M
        return m_NextLayer;
480
1.13M
      }
481
482
13.1k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
1.15M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
57.0k
    {
477
57.0k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
56.0k
      {
479
56.0k
        return m_NextLayer;
480
56.0k
      }
481
482
1.01k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
57.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
26.4k
    {
477
26.4k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
26.4k
      {
479
26.4k
        return m_NextLayer;
480
26.4k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
26.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
93.9k
    {
477
93.9k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
93.9k
      {
479
93.9k
        return m_NextLayer;
480
93.9k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
93.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
5.31k
    {
477
5.31k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
5.31k
      {
479
5.31k
        return m_NextLayer;
480
5.31k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
5.31k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
10.2k
    {
477
10.2k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
10.2k
      {
479
10.2k
        return m_NextLayer;
480
10.2k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
10.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
1.45k
    {
477
1.45k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
1.45k
      {
479
1.45k
        return m_NextLayer;
480
1.45k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
1.45k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
3.73k
    {
477
3.73k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
3.73k
      {
479
3.73k
        return m_NextLayer;
480
3.73k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
3.73k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
4.50k
    {
477
4.50k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
4.36k
      {
479
4.36k
        return m_NextLayer;
480
4.36k
      }
481
482
138
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
4.50k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
5.32k
    {
477
5.32k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
5.32k
      {
479
5.32k
        return m_NextLayer;
480
5.32k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
5.32k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
16.0k
    {
477
16.0k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
16.0k
      {
479
16.0k
        return m_NextLayer;
480
16.0k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
16.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV3Layer, pcpp::PayloadLayer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
476
9.18k
    {
477
9.18k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
9.18k
      {
479
9.18k
        return m_NextLayer;
480
9.18k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
9.18k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
71.6k
    {
477
71.6k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
71.5k
      {
479
71.5k
        return m_NextLayer;
480
71.5k
      }
481
482
128
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
71.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.76k
    {
477
2.76k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.76k
      {
479
2.76k
        return m_NextLayer;
480
2.76k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.76k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
17.3k
    {
477
17.3k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
16.3k
      {
479
16.3k
        return m_NextLayer;
480
16.3k
      }
481
482
1.02k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
17.3k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
34.1k
    {
477
34.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
30.7k
      {
479
30.7k
        return m_NextLayer;
480
30.7k
      }
481
482
3.45k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
34.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
31.8k
    {
477
31.8k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
31.4k
      {
479
31.4k
        return m_NextLayer;
480
31.4k
      }
481
482
336
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
31.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
6.87k
    {
477
6.87k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
6.87k
      {
479
6.87k
        return m_NextLayer;
480
6.87k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
6.87k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
22.9k
    {
477
22.9k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
20.9k
      {
479
20.9k
        return m_NextLayer;
480
20.9k
      }
481
482
2.04k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
22.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
14.6k
    {
477
14.6k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
14.6k
      {
479
14.6k
        return m_NextLayer;
480
14.6k
      }
481
482
21
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
14.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
179k
    {
477
179k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
179k
      {
479
179k
        return m_NextLayer;
480
179k
      }
481
482
258
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
179k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.27k
    {
477
2.27k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.27k
      {
479
2.27k
        return m_NextLayer;
480
2.27k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.27k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
348
    {
477
348
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
63
      {
479
63
        return m_NextLayer;
480
63
      }
481
482
285
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
348
    }
484
485
    /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
486
    ///
487
    /// The method will attempt to construct the next layer using the provided factory function.
488
    /// If the factory function returns nullptr, indicating failure to create the layer, the method will then
489
    /// construct a layer of type TFallback.
490
    ///
491
    /// The factory functor is expected to have the following signature:
492
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
493
    ///
494
    /// This overload infers the Packet from the current layer.
495
    ///
496
    /// @tparam TFallback The fallback layer type to construct if the factory fails.
497
    /// @tparam TFactory The factory functor type.
498
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
499
    /// @param[in] factoryFn The factory functor to create the layer.
500
    /// @param[in] data The data to construct the layer from
501
    /// @param[in] dataLen The length of the data
502
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
503
    /// @return The return value of the factory functor.
504
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
505
    /// constructor.
506
    template <typename TFallback, typename TFactory, typename... Args>
507
    Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen,
508
                                                        Args&&... extraArgs)
509
360k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
360k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
360k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
360k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
79.1k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
79.1k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
79.1k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
79.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
49.2k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
49.2k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
49.2k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
49.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
38.7k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
38.7k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
38.7k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
38.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
85
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
85
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
85
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
85
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
4.44k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
4.44k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
4.44k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
4.44k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, unsigned short&, unsigned short&)
Line
Count
Source
509
94.9k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
94.9k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
94.9k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
94.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
3.25k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
3.25k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
3.25k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
3.25k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
90.9k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
90.9k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
90.9k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
90.9k
    }
514
515
    /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
516
    ///
517
    /// The method will attempt to construct the next layer using the provided factory function.
518
    /// If the factory function returns nullptr, indicating failure to create the layer, the method will then
519
    /// construct a layer of type TFallback.
520
    ///
521
    /// The factory functor is expected to have the following signature:
522
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
523
    ///
524
    /// @tparam TFallback The fallback layer type to construct if the factory fails.
525
    /// @tparam TFactory The factory functor type.
526
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
527
    /// @param[in] factoryFn The factory functor to create the layer.
528
    /// @param[in] data The data to construct the layer from
529
    /// @param[in] dataLen The length of the data
530
    /// @param[in] packet The packet the layer belongs to
531
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
532
    /// @return The return value of the factory functor.
533
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
534
    /// constructor.
535
    template <typename TFallback, typename TFactory, typename... Args>
536
    Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen,
537
                                                        Packet* packet, Args&&... extraArgs)
538
360k
    {
539
360k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
360k
                                                               std::forward<Args>(extraArgs)...);
541
360k
      if (nextLayer != nullptr)
542
253k
      {
543
253k
        return nextLayer;
544
253k
      }
545
546
      // factory failed, construct fallback layer
547
107k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
360k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
79.1k
    {
539
79.1k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
79.1k
                                                               std::forward<Args>(extraArgs)...);
541
79.1k
      if (nextLayer != nullptr)
542
73.6k
      {
543
73.6k
        return nextLayer;
544
73.6k
      }
545
546
      // factory failed, construct fallback layer
547
5.48k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
79.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
49.2k
    {
539
49.2k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
49.2k
                                                               std::forward<Args>(extraArgs)...);
541
49.2k
      if (nextLayer != nullptr)
542
49.1k
      {
543
49.1k
        return nextLayer;
544
49.1k
      }
545
546
      // factory failed, construct fallback layer
547
150
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
49.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
38.7k
    {
539
38.7k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
38.7k
                                                               std::forward<Args>(extraArgs)...);
541
38.7k
      if (nextLayer != nullptr)
542
30.1k
      {
543
30.1k
        return nextLayer;
544
30.1k
      }
545
546
      // factory failed, construct fallback layer
547
8.68k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
38.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
85
    {
539
85
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
85
                                                               std::forward<Args>(extraArgs)...);
541
85
      if (nextLayer != nullptr)
542
85
      {
543
85
        return nextLayer;
544
85
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
85
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
4.44k
    {
539
4.44k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
4.44k
                                                               std::forward<Args>(extraArgs)...);
541
4.44k
      if (nextLayer != nullptr)
542
4.44k
      {
543
4.44k
        return nextLayer;
544
4.44k
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
4.44k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, pcpp::Packet*, unsigned short&, unsigned short&)
Line
Count
Source
538
94.9k
    {
539
94.9k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
94.9k
                                                               std::forward<Args>(extraArgs)...);
541
94.9k
      if (nextLayer != nullptr)
542
90.3k
      {
543
90.3k
        return nextLayer;
544
90.3k
      }
545
546
      // factory failed, construct fallback layer
547
4.60k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
94.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
3.25k
    {
539
3.25k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
3.25k
                                                               std::forward<Args>(extraArgs)...);
541
3.25k
      if (nextLayer != nullptr)
542
3.25k
      {
543
3.25k
        return nextLayer;
544
3.25k
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
3.25k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
90.9k
    {
539
90.9k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
90.9k
                                                               std::forward<Args>(extraArgs)...);
541
90.9k
      if (nextLayer != nullptr)
542
1.98k
      {
543
1.98k
        return nextLayer;
544
1.98k
      }
545
546
      // factory failed, construct fallback layer
547
88.9k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
90.9k
    }
549
550
    /// @brief Check if the data is large enough to reinterpret as a type
551
    ///
552
    /// The data must be non-null and at least as large as the type
553
    ///
554
    /// @tparam T The type to reinterpret as
555
    /// @param data The data to check
556
    /// @param dataLen The length of the data
557
    /// @return True if the data is large enough to reinterpret as T, false otherwise
558
    template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen)
559
3.19M
    {
560
3.19M
      return data != nullptr && dataLen >= sizeof(T);
561
3.19M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
14.6k
    {
560
14.6k
      return data != nullptr && dataLen >= sizeof(T);
561
14.6k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
1.70M
    {
560
1.70M
      return data != nullptr && dataLen >= sizeof(T);
561
1.70M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
31.8k
    {
560
31.8k
      return data != nullptr && dataLen >= sizeof(T);
561
31.8k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
25.1k
    {
560
25.1k
      return data != nullptr && dataLen >= sizeof(T);
561
25.1k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
363k
    {
560
363k
      return data != nullptr && dataLen >= sizeof(T);
561
363k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
179k
    {
560
179k
      return data != nullptr && dataLen >= sizeof(T);
561
179k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
2.27k
    {
560
2.27k
      return data != nullptr && dataLen >= sizeof(T);
561
2.27k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
15.6k
    {
560
15.6k
      return data != nullptr && dataLen >= sizeof(T);
561
15.6k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
1.45k
    {
560
1.45k
      return data != nullptr && dataLen >= sizeof(T);
561
1.45k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
3.73k
    {
560
3.73k
      return data != nullptr && dataLen >= sizeof(T);
561
3.73k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long)
Line
Count
Source
559
544k
    {
560
544k
      return data != nullptr && dataLen >= sizeof(T);
561
544k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
300k
    {
560
300k
      return data != nullptr && dataLen >= sizeof(T);
561
300k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
6.87k
    {
560
6.87k
      return data != nullptr && dataLen >= sizeof(T);
561
6.87k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
559
1.97k
    {
560
1.97k
      return data != nullptr && dataLen >= sizeof(T);
561
1.97k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
559
2.16k
    {
560
2.16k
      return data != nullptr && dataLen >= sizeof(T);
561
2.16k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::rstp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
559
1.11k
    {
560
1.11k
      return data != nullptr && dataLen >= sizeof(T);
561
1.11k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::mstp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
559
68
    {
560
68
      return data != nullptr && dataLen >= sizeof(T);
561
68
    }
562
  };
563
564
  inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer)
565
0
  {
566
0
    os << layer.toString();
567
0
    return os;
568
0
  }
569
}  // namespace pcpp