Coverage Report

Created: 2026-10-17 07:09

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 "Serializers.h"
7
#include <ostream>
8
#include <string>
9
#include <stdexcept>
10
#include <utility>
11
12
/// @file
13
14
/// @namespace pcpp
15
/// @brief The main namespace for the PcapPlusPlus lib
16
namespace pcpp
17
{
18
19
  /// @class IDataContainer
20
  /// An interface (virtual abstract class) that indicates an object that holds a pointer to a buffer data. The Layer
21
  /// class is an example of such object, hence it inherits this interface
22
  class IDataContainer
23
  {
24
  public:
25
    /// Get a pointer to the data
26
    /// @param[in] offset Get a pointer in a certain offset. Default is 0 - get a pointer to start of data
27
    /// @return A pointer to the data
28
    virtual uint8_t* getDataPtr(size_t offset = 0) const = 0;
29
30
9.31M
    virtual ~IDataContainer() = default;
31
  };
32
33
  class Packet;
34
35
  namespace internal
36
  {
37
    /// @brief Holds information about a Layer's data and object ownership.
38
    struct LayerAllocationInfo
39
    {
40
      /// @brief Pointer to the Packet this layer is attached to (if any).
41
      ///
42
      /// If the layer is attached to a Packet, the layer's memory span (data) is considered managed by the
43
      /// Packet. The Packet is responsible for keeping the layer's memory span valid and updating it should it
44
      /// become necessary as long as the layer is attached to it.
45
      ///
46
      /// In an event the Packet is destroyed, all of its attached layers's memory views are considered invalid.
47
      /// Accessing layer data after the Packet is destroyed results in undefined behavior.
48
      ///
49
      /// If nullptr, the layer is not attached to any Packet and is considered unmanaged.
50
      /// It also means the layer's memory span is considered owned by the layer itself and will be freed when
51
      /// the layer is destroyed.
52
      Packet* attachedPacket = nullptr;
53
54
      /// @brief Controls if the layer object is considered owned by the attached Packet
55
      ///
56
      /// If 'true', the Layer object is considered owned by the attached Packet and will be freed by it on Packet
57
      /// destruction.
58
      ///
59
      /// If 'false', the Layer object is considered unmanaged and the user is responsible for freeing it.
60
      /// This is commonly the case for layers created on the stack and attached to a Packet.
61
      bool ownedByPacket = false;
62
63
      /// @brief Sets the state of attachment to a specified Packet
64
      /// @param packet Pointer to the Packet this layer is attached to (or nullptr if not attached to any Packet)
65
      /// @param managed True if the layer object's lifetime is to be managed by the Packet, false otherwise
66
      /// @param force If true, bypasses the check for existing attachment. Default is false.
67
      /// @throws std::runtime_error if the layer is already attached to a Packet and 'force' is false
68
      void attachPacket(Packet* packet, bool managed, bool force = false)
69
0
      {
70
0
        if (!force && attachedPacket != nullptr)
71
0
        {
72
0
          throw std::runtime_error("Layer is already attached to a Packet");
73
0
        }
74
75
0
        attachedPacket = packet;
76
0
        ownedByPacket = managed;
77
0
      }
78
79
      /// @brief Clears the attachment to any Packet, resetting to unmanaged state.
80
      void detach()
81
0
      {
82
0
        attachedPacket = nullptr;
83
0
        ownedByPacket = false;
84
0
      }
85
    };
86
  }  // namespace internal
87
88
  /// @class Layer
89
  /// Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that
90
  /// inherits Layer.
91
  /// The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields.
92
  /// For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size,
93
  /// compute fields that can be automatically computed, print protocol data to string, etc.
94
  /// Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is
95
  /// represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer
96
  /// has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is
97
  /// abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer
98
  /// to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the
99
  /// packet. Here is an example packet showing this concept:
100
  ///
101
  /// @code{.unparsed}
102
  /// ====================================================
103
  /// |Eth       |IPv4       |TCP       |Packet          |
104
  /// |Header    |Header     |Header    |Payload         |
105
  /// ====================================================
106
  ///
107
  /// |--------------------------------------------------|
108
  /// EthLayer data
109
  ///            |---------------------------------------|
110
  ///            IPv4Layer data
111
  ///                        |---------------------------|
112
  ///                        TcpLayer data
113
  ///                                   |----------------|
114
  ///                                   PayloadLayer data
115
  /// @endcode
116
  class Layer : public IDataContainer
117
  {
118
    friend class Packet;
119
120
  public:
121
    /// A destructor for this class. Frees the data if it was allocated by the layer constructor (see
122
    /// isAllocatedToPacket() for more info)
123
    ~Layer() override;
124
125
    /// @return A pointer to the next layer in the protocol stack or nullptr if the layer is the last one
126
    Layer* getNextLayer() const
127
176M
    {
128
176M
      return m_NextLayer;
129
176M
    }
130
131
    /// @return A pointer to the previous layer in the protocol stack or nullptr if the layer is the first one
132
    Layer* getPrevLayer() const
133
3.01M
    {
134
3.01M
      return m_PrevLayer;
135
3.01M
    }
136
137
    /// @return The protocol enum
138
    ProtocolType getProtocol() const
139
126M
    {
140
126M
      return m_Protocol;
141
126M
    }
142
143
    /// Check if the layer's protocol matches a protocol family
144
    /// @param protocolTypeFamily The protocol family to check
145
    /// @return True if the layer's protocol matches the protocol family, false otherwise
146
    bool isMemberOfProtocolFamily(ProtocolTypeFamily protocolTypeFamily) const;
147
148
    /// @return A pointer to the layer raw data. In most cases it'll be a pointer to the first byte of the header
149
    uint8_t* getData() const
150
512k
    {
151
512k
      return m_Data;
152
512k
    }
153
154
    /// @return The length in bytes of the data from the first byte of the header until the end of the packet
155
    size_t getDataLen() const
156
6.28M
    {
157
6.28M
      return m_DataLen;
158
6.28M
    }
159
160
    /// @return A pointer for the layer payload, meaning the first byte after the header
161
    uint8_t* getLayerPayload() const
162
0
    {
163
0
      return m_Data + getHeaderLen();
164
0
    }
165
166
    /// @return The size in bytes of the payload
167
    size_t getLayerPayloadSize() const
168
107k
    {
169
107k
      return m_DataLen - getHeaderLen();
170
107k
    }
171
172
    /// Raw data in layers can come from one of sources:
173
    /// 1. from an existing packet - this is the case when parsing packets received from files or the network. In
174
    /// this case the data was already allocated by someone else, and layer only holds the pointer to the relevant
175
    /// place inside this data
176
    /// 2. when creating packets, data is allocated when layer is created. In this case the layer is responsible for
177
    /// freeing it as well
178
    ///
179
    /// @return Returns true if the data was allocated by an external source (a packet) or false if it was allocated
180
    /// by the layer itself
181
    bool isAllocatedToPacket() const
182
9.31M
    {
183
9.31M
      return m_AllocationInfo.attachedPacket != nullptr;
184
9.31M
    }
185
186
    /// @brief Copy the raw data of this layer to another array
187
    ///
188
    /// @warning The method does not perform any bounds checking on the destination array. The caller MUST ensure
189
    /// that the destination array has enough space to hold the getDataLen() bytes.
190
    ///
191
    /// @warning Prefer the overload of copyData() that accepts a destination size to ensure safe copying of data.
192
    ///
193
    /// @param[out] toArr The destination byte array
194
    void copyData(uint8_t* toArr) const;
195
196
    /// @brief Copy the raw data of this layer to another array, with a specified maximum size.
197
    ///
198
    /// The method copies up to 'destSize' bytes of the layer's raw data into the provided destination array.
199
    /// If the layer's data length is greater than 'destSize', only the first 'destSize' bytes will be copied.
200
    ///
201
    /// To ensure sufficient space is available in the destination array, use getDataLen() to determine the actual
202
    /// length of the layer's data before calling this method.
203
    ///
204
    /// @param[out] dest The destination byte array
205
    /// @param[in] destSize The maximum number of bytes to copy
206
    /// @return The number of bytes copied to the destination array.
207
    size_t copyData(uint8_t* dest, size_t destSize) const;
208
209
    /// @struct SerializedFields
210
    /// Field descriptors for the fields serialized by Layer::serialize().
211
    struct SerializedFields
212
    {
213
      /// @return A vector containing all layer field descriptors.
214
      static std::vector<FieldDescriptor> all()
215
0
      {
216
0
        return { ProtocolName, ProtocolId, Length };
217
0
      }
218
219
      /// Field descriptor for the layer protocol name.
220
      static const FieldDescriptor ProtocolName;
221
222
      /// Field descriptor for the layer protocol ID.
223
      static const FieldDescriptor ProtocolId;
224
225
      /// Field descriptor for the layer length.
226
      static const FieldDescriptor Length;
227
228
      /// Maximum field ID used by the layer.
229
      static constexpr uint16_t MaxID = 1;
230
    };
231
232
    /// Serialize the layer using the provided serializer.
233
    /// @param[in] serializer The serializer to use.
234
    void serialize(ISerializer& serializer) const;
235
236
    // implement abstract methods
237
238
    uint8_t* getDataPtr(size_t offset = 0) const override
239
200k
    {
240
200k
      return static_cast<uint8_t*>(m_Data + offset);
241
200k
    }
242
243
    // abstract methods
244
245
    /// Each layer is responsible for parsing the next layer
246
    virtual void parseNextLayer() = 0;
247
248
    /// @return The header length in bytes
249
    virtual size_t getHeaderLen() const = 0;
250
251
    /// Each layer can compute field values automatically using this method. This is an abstract method
252
    virtual void computeCalculateFields() = 0;
253
254
    /// @return A string representation of the layer most important data (should look like the layer description in
255
    /// Wireshark)
256
    virtual std::string toString() const = 0;
257
258
    /// @return The OSI Model layer this protocol belongs to
259
    virtual OsiModelLayer getOsiModelLayer() const = 0;
260
261
  protected:
262
    uint8_t* m_Data;
263
    size_t m_DataLen;
264
    ProtocolType m_Protocol;
265
    Layer* m_NextLayer;
266
    Layer* m_PrevLayer;
267
268
  private:
269
    internal::LayerAllocationInfo m_AllocationInfo;
270
271
  protected:
272
0
    Layer() : m_Data(nullptr), m_DataLen(0), m_Protocol(UnknownProtocol), m_NextLayer(nullptr), m_PrevLayer(nullptr)
273
0
    {}
274
275
    Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol)
276
9.07M
        : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer),
277
9.07M
          m_AllocationInfo{ packet, false }
278
9.07M
    {}
279
280
    // Copy c'tor
281
    Layer(const Layer& other);
282
    Layer& operator=(const Layer& other);
283
284
    /// @brief Get a pointer to the Packet this layer is attached to (if any).
285
    /// @return A pointer to the Packet this layer is attached to, or nullptr if the layer is not attached.
286
    Packet* getAttachedPacket()
287
8.44M
    {
288
8.44M
      return m_AllocationInfo.attachedPacket;
289
8.44M
    }
290
291
    /// @brief Get a pointer to the Packet this layer is attached to (if any).
292
    /// @return A const pointer to the Packet this layer is attached to, or nullptr if the layer is not attached.
293
    Packet const* getAttachedPacket() const
294
6.27k
    {
295
6.27k
      return m_AllocationInfo.attachedPacket;
296
6.27k
    }
297
298
    void setNextLayer(Layer* nextLayer)
299
7.29M
    {
300
7.29M
      m_NextLayer = nextLayer;
301
7.29M
    }
302
    void setPrevLayer(Layer* prevLayer)
303
0
    {
304
0
      m_PrevLayer = prevLayer;
305
0
    }
306
307
    // ------ Memory Control Methods -----
308
    // Used by derived classes to request buffer size changes.
309
310
    /// @brief Requests the layer to allocate a new data buffer of the specified length.
311
    ///
312
    /// If the layer is not attached to a Packet, it will allocate a new buffer of the specified length.
313
    /// If the layer is attached to a Packet, it will throw a std::logic_error, as that case is not yet supported.
314
    ///
315
    /// The primary use case for this method is initial allocation of the data buffer in derived classes.
316
    ///
317
    /// @param[in] dataLen The length of the new data buffer.
318
    /// @param[in] zeroInit If true, the new buffer will be zero-initialized.
319
    /// @throws std::runtime_error if the layer already has allocated data.
320
    /// @throws std::logic_error if the layer is attached to a Packet (not yet supported).
321
    void allocData(size_t dataLen, bool zeroInit = true);
322
323
    virtual bool extendLayer(int offsetInLayer, size_t numOfBytesToExtend);
324
    virtual bool shortenLayer(int offsetInLayer, size_t numOfBytesToShorten);
325
326
    bool hasNextLayer() const
327
12.7M
    {
328
12.7M
      return m_NextLayer != nullptr;
329
12.7M
    }
330
331
    /// @brief Construct the next layer in the protocol stack. No validation is performed on the data.
332
    ///
333
    /// This overload infers the Packet from the current layer.
334
    ///
335
    /// @tparam T The type of the layer to construct
336
    /// @tparam Args The types of the arguments to pass to the layer constructor
337
    /// @param data The data to construct the layer from
338
    /// @param dataLen The length of the data
339
    /// @param extraArgs Extra arguments to be forwarded to the layer constructor
340
    /// @return The constructed layer
341
    template <typename T, typename... Args>
342
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs)
343
500k
    {
344
500k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
500k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
196k
    {
344
196k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
196k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&)
Line
Count
Source
343
8.26k
    {
344
8.26k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
8.26k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
88.1k
    {
344
88.1k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
88.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
31.2k
    {
344
31.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
31.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long)
Line
Count
Source
343
61.5k
    {
344
61.5k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
61.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long)
Line
Count
Source
343
8.60k
    {
344
8.60k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
8.60k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long)
Line
Count
Source
343
21.8k
    {
344
21.8k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
21.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
18.3k
    {
344
18.3k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
18.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
990
    {
344
990
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
990
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long)
Line
Count
Source
343
65.1k
    {
344
65.1k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
345
65.1k
    }
346
347
    /// Construct the next layer in the protocol stack. No validation is performed on the data.
348
    /// @tparam T The type of the layer to construct
349
    /// @tparam Args The types of the arguments to pass to the layer constructor
350
    /// @param[in] data The data to construct the layer from
351
    /// @param[in] dataLen The length of the data
352
    /// @param[in] packet The packet the layer belongs to
353
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
354
    /// @return The constructed layer
355
    template <typename T, typename... Args>
356
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
357
5.94M
    {
358
5.94M
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
5.94M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
5.94M
      setNextLayer(newLayer);
365
5.94M
      return newLayer;
366
5.94M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
1.63M
    {
358
1.63M
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
1.63M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
1.63M
      setNextLayer(newLayer);
365
1.63M
      return newLayer;
366
1.63M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
557k
    {
358
557k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
557k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
557k
      setNextLayer(newLayer);
365
557k
      return newLayer;
366
557k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
306k
    {
358
306k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
306k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
306k
      setNextLayer(newLayer);
365
306k
      return newLayer;
366
306k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
22.5k
    {
358
22.5k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
22.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
22.5k
      setNextLayer(newLayer);
365
22.5k
      return newLayer;
366
22.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
315k
    {
358
315k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
315k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
315k
      setNextLayer(newLayer);
365
315k
      return newLayer;
366
315k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
77.5k
    {
358
77.5k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
77.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
77.5k
      setNextLayer(newLayer);
365
77.5k
      return newLayer;
366
77.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
6.38k
    {
358
6.38k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
6.38k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
6.38k
      setNextLayer(newLayer);
365
6.38k
      return newLayer;
366
6.38k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
352k
    {
358
352k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
352k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
352k
      setNextLayer(newLayer);
365
352k
      return newLayer;
366
352k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
16.4k
    {
358
16.4k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
16.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
16.4k
      setNextLayer(newLayer);
365
16.4k
      return newLayer;
366
16.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
1.05k
    {
358
1.05k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
1.05k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
1.05k
      setNextLayer(newLayer);
365
1.05k
      return newLayer;
366
1.05k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
601k
    {
358
601k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
601k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
601k
      setNextLayer(newLayer);
365
601k
      return newLayer;
366
601k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
1.05M
    {
358
1.05M
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
1.05M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
1.05M
      setNextLayer(newLayer);
365
1.05M
      return newLayer;
366
1.05M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
61.3k
    {
358
61.3k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
61.3k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
61.3k
      setNextLayer(newLayer);
365
61.3k
      return newLayer;
366
61.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
23.4k
    {
358
23.4k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
23.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
23.4k
      setNextLayer(newLayer);
365
23.4k
      return newLayer;
366
23.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
113k
    {
358
113k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
113k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
113k
      setNextLayer(newLayer);
365
113k
      return newLayer;
366
113k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
6.11k
    {
358
6.11k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
6.11k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
6.11k
      setNextLayer(newLayer);
365
6.11k
      return newLayer;
366
6.11k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
11.5k
    {
358
11.5k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
11.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
11.5k
      setNextLayer(newLayer);
365
11.5k
      return newLayer;
366
11.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
1.44k
    {
358
1.44k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
1.44k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
1.44k
      setNextLayer(newLayer);
365
1.44k
      return newLayer;
366
1.44k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
3.80k
    {
358
3.80k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
3.80k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
3.80k
      setNextLayer(newLayer);
365
3.80k
      return newLayer;
366
3.80k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
5.54k
    {
358
5.54k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
5.54k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
5.54k
      setNextLayer(newLayer);
365
5.54k
      return newLayer;
366
5.54k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
5.36k
    {
358
5.36k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
5.36k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
5.36k
      setNextLayer(newLayer);
365
5.36k
      return newLayer;
366
5.36k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
9.26k
    {
358
9.26k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
9.26k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
9.26k
      setNextLayer(newLayer);
365
9.26k
      return newLayer;
366
9.26k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
357
13.8k
    {
358
13.8k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
13.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
13.8k
      setNextLayer(newLayer);
365
13.8k
      return newLayer;
366
13.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
80.6k
    {
358
80.6k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
80.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
80.6k
      setNextLayer(newLayer);
365
80.6k
      return newLayer;
366
80.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
23.6k
    {
358
23.6k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
23.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
23.6k
      setNextLayer(newLayer);
365
23.6k
      return newLayer;
366
23.6k
    }
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
357
2.89k
    {
358
2.89k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
2.89k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
2.89k
      setNextLayer(newLayer);
365
2.89k
      return newLayer;
366
2.89k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
14.8k
    {
358
14.8k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
14.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
14.8k
      setNextLayer(newLayer);
365
14.8k
      return newLayer;
366
14.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
63.2k
    {
358
63.2k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
63.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
63.2k
      setNextLayer(newLayer);
365
63.2k
      return newLayer;
366
63.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
21.6k
    {
358
21.6k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
21.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
21.6k
      setNextLayer(newLayer);
365
21.6k
      return newLayer;
366
21.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
7.03k
    {
358
7.03k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
7.03k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
7.03k
      setNextLayer(newLayer);
365
7.03k
      return newLayer;
366
7.03k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
4.84k
    {
358
4.84k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
4.84k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
4.84k
      setNextLayer(newLayer);
365
4.84k
      return newLayer;
366
4.84k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
31.2k
    {
358
31.2k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
31.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
31.2k
      setNextLayer(newLayer);
365
31.2k
      return newLayer;
366
31.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
4.12k
    {
358
4.12k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
4.12k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
4.12k
      setNextLayer(newLayer);
365
4.12k
      return newLayer;
366
4.12k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
10.4k
    {
358
10.4k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
10.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
10.4k
      setNextLayer(newLayer);
365
10.4k
      return newLayer;
366
10.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
16.9k
    {
358
16.9k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
16.9k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
16.9k
      setNextLayer(newLayer);
365
16.9k
      return newLayer;
366
16.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
2.34k
    {
358
2.34k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
2.34k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
2.34k
      setNextLayer(newLayer);
365
2.34k
      return newLayer;
366
2.34k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
28.0k
    {
358
28.0k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
28.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
28.0k
      setNextLayer(newLayer);
365
28.0k
      return newLayer;
366
28.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
34.0k
    {
358
34.0k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
34.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
34.0k
      setNextLayer(newLayer);
365
34.0k
      return newLayer;
366
34.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
6.90k
    {
358
6.90k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
6.90k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
6.90k
      setNextLayer(newLayer);
365
6.90k
      return newLayer;
366
6.90k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
88.1k
    {
358
88.1k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
88.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
88.1k
      setNextLayer(newLayer);
365
88.1k
      return newLayer;
366
88.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
31.2k
    {
358
31.2k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
31.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
31.2k
      setNextLayer(newLayer);
365
31.2k
      return newLayer;
366
31.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
61.5k
    {
358
61.5k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
61.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
61.5k
      setNextLayer(newLayer);
365
61.5k
      return newLayer;
366
61.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
21.8k
    {
358
21.8k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
21.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
21.8k
      setNextLayer(newLayer);
365
21.8k
      return newLayer;
366
21.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
18.3k
    {
358
18.3k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
18.3k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
18.3k
      setNextLayer(newLayer);
365
18.3k
      return newLayer;
366
18.3k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
6.64k
    {
358
6.64k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
6.64k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
6.64k
      setNextLayer(newLayer);
365
6.64k
      return newLayer;
366
6.64k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
16.7k
    {
358
16.7k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
16.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
16.7k
      setNextLayer(newLayer);
365
16.7k
      return newLayer;
366
16.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
89.5k
    {
358
89.5k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
89.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
89.5k
      setNextLayer(newLayer);
365
89.5k
      return newLayer;
366
89.5k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
357
65.1k
    {
358
65.1k
      if (hasNextLayer())
359
0
      {
360
0
        throw std::runtime_error("Next layer already exists");
361
0
      }
362
363
65.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
364
65.1k
      setNextLayer(newLayer);
365
65.1k
      return newLayer;
366
65.1k
    }
367
368
    /// @brief Construct the next layer in the protocol stack using a factory functor.
369
    ///
370
    /// No validation is performed on the data, outside of what the factory functor may perform.
371
    /// If the factory returns a nullptr, no next layer is set.
372
    ///
373
    /// The factory functor is expected to have the following signature:
374
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
375
    ///
376
    /// This overload infers the Packet from the current layer.
377
    ///
378
    /// @tparam TFactory The factory functor type.
379
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
380
    /// @param[in] factoryFn The factory functor to create the layer.
381
    /// @param[in] data The data to construct the layer from
382
    /// @param[in] dataLen The length of the data
383
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
384
    /// @return The return value of the factory functor.
385
    template <typename TFactory, typename... Args>
386
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs)
387
883k
    {
388
883k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
883k
                                                     std::forward<Args>(extraArgs)...);
390
883k
    }
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
387
118k
    {
388
118k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
118k
                                                     std::forward<Args>(extraArgs)...);
390
118k
    }
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
387
5.26k
    {
388
5.26k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
5.26k
                                                     std::forward<Args>(extraArgs)...);
390
5.26k
    }
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
387
548k
    {
388
548k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
548k
                                                     std::forward<Args>(extraArgs)...);
390
548k
    }
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
387
32.9k
    {
388
32.9k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
32.9k
                                                     std::forward<Args>(extraArgs)...);
390
32.9k
    }
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
387
151k
    {
388
151k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
151k
                                                     std::forward<Args>(extraArgs)...);
390
151k
    }
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
387
26.9k
    {
388
26.9k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
389
26.9k
                                                     std::forward<Args>(extraArgs)...);
390
26.9k
    }
391
392
    /// @brief Construct the next layer in the protocol stack using a factory functor.
393
    ///
394
    /// No validation is performed on the data, outside of what the factory functor may perform.
395
    /// If the factory returns a nullptr, no next layer is set.
396
    ///
397
    /// The factory functor is expected to have the following signature:
398
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
399
    ///
400
    /// @tparam TFactory The factory functor type.
401
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
402
    /// @param[in] factoryFn The factory functor to create the layer.
403
    /// @param[in] data The data to construct the layer from
404
    /// @param[in] dataLen The length of the data
405
    /// @param[in] packet The packet the layer belongs to
406
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
407
    /// @return The return value of the factory functor.
408
    template <typename TFactory, typename... Args>
409
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet,
410
                                         Args&&... extraArgs)
411
1.28M
    {
412
1.28M
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
1.28M
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
1.28M
      setNextLayer(newLayer);
420
1.28M
      return newLayer;
421
1.28M
    }
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
411
118k
    {
412
118k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
118k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
118k
      setNextLayer(newLayer);
420
118k
      return newLayer;
421
118k
    }
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
411
5.26k
    {
412
5.26k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
5.26k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
5.26k
      setNextLayer(newLayer);
420
5.26k
      return newLayer;
421
5.26k
    }
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
411
548k
    {
412
548k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
548k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
548k
      setNextLayer(newLayer);
420
548k
      return newLayer;
421
548k
    }
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
411
226k
    {
412
226k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
226k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
226k
      setNextLayer(newLayer);
420
226k
      return newLayer;
421
226k
    }
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
411
32.9k
    {
412
32.9k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
32.9k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
32.9k
      setNextLayer(newLayer);
420
32.9k
      return newLayer;
421
32.9k
    }
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
411
57.0k
    {
412
57.0k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
57.0k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
57.0k
      setNextLayer(newLayer);
420
57.0k
      return newLayer;
421
57.0k
    }
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
411
68.7k
    {
412
68.7k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
68.7k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
68.7k
      setNextLayer(newLayer);
420
68.7k
      return newLayer;
421
68.7k
    }
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
411
639
    {
412
639
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
639
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
639
      setNextLayer(newLayer);
420
639
      return newLayer;
421
639
    }
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
411
19.9k
    {
412
19.9k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
19.9k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
19.9k
      setNextLayer(newLayer);
420
19.9k
      return newLayer;
421
19.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
411
3.22k
    {
412
3.22k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
3.22k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
3.22k
      setNextLayer(newLayer);
420
3.22k
      return newLayer;
421
3.22k
    }
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
411
101k
    {
412
101k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
101k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
101k
      setNextLayer(newLayer);
420
101k
      return newLayer;
421
101k
    }
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
411
3.94k
    {
412
3.94k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
3.94k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
3.94k
      setNextLayer(newLayer);
420
3.94k
      return newLayer;
421
3.94k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
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
411
95.4k
    {
412
95.4k
      if (hasNextLayer())
413
0
      {
414
0
        throw std::runtime_error("Next layer already exists");
415
0
      }
416
417
      // cppcheck-suppress redundantInitialization
418
95.4k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
419
95.4k
      setNextLayer(newLayer);
420
95.4k
      return newLayer;
421
95.4k
    }
422
423
    /// Try to construct the next layer in the protocol stack.
424
    ///
425
    /// This overload infers the Packet from the current layer.
426
    ///
427
    /// The method checks if the data is valid for the layer type T before constructing it by calling
428
    /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
429
    ///
430
    /// @tparam T The type of the layer to construct
431
    /// @tparam Args The types of the extra arguments to pass to the layer constructor
432
    /// @param[in] data The data to construct the layer from
433
    /// @param[in] dataLen The length of the data
434
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
435
    /// @return The constructed layer or nullptr if the data is invalid
436
    template <typename T, typename... Args>
437
    Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs)
438
0
    {
439
0
      return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
440
0
    }
441
442
    /// Try to construct the next layer in the protocol stack.
443
    ///
444
    /// The method checks if the data is valid for the layer type T before constructing it by calling
445
    /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned.
446
    ///
447
    /// @tparam T The type of the layer to construct
448
    /// @tparam Args The types of the extra arguments to pass to the layer constructor
449
    /// @param[in] data The data to construct the layer from
450
    /// @param[in] dataLen The length of the data
451
    /// @param[in] packet The packet the layer belongs to
452
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
453
    /// @return The constructed layer or nullptr if the data is invalid
454
    template <typename T, typename... Args>
455
    Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
456
4.87M
    {
457
4.87M
      if (T::isDataValid(data, dataLen))
458
4.81M
      {
459
4.81M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
4.81M
      }
461
51.2k
      return nullptr;
462
4.87M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
1.65M
    {
457
1.65M
      if (T::isDataValid(data, dataLen))
458
1.63M
      {
459
1.63M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
1.63M
      }
461
21.1k
      return nullptr;
462
1.65M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
312k
    {
457
312k
      if (T::isDataValid(data, dataLen))
458
306k
      {
459
306k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
306k
      }
461
5.04k
      return nullptr;
462
312k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
22.7k
    {
457
22.7k
      if (T::isDataValid(data, dataLen))
458
22.5k
      {
459
22.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
22.5k
      }
461
172
      return nullptr;
462
22.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
315k
    {
457
315k
      if (T::isDataValid(data, dataLen))
458
315k
      {
459
315k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
315k
      }
461
280
      return nullptr;
462
315k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
77.7k
    {
457
77.7k
      if (T::isDataValid(data, dataLen))
458
77.5k
      {
459
77.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
77.5k
      }
461
128
      return nullptr;
462
77.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
6.38k
    {
457
6.38k
      if (T::isDataValid(data, dataLen))
458
6.38k
      {
459
6.38k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
6.38k
      }
461
0
      return nullptr;
462
6.38k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
352k
    {
457
352k
      if (T::isDataValid(data, dataLen))
458
352k
      {
459
352k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
352k
      }
461
9
      return nullptr;
462
352k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
18.0k
    {
457
18.0k
      if (T::isDataValid(data, dataLen))
458
16.4k
      {
459
16.4k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
16.4k
      }
461
1.56k
      return nullptr;
462
18.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
342
    {
457
342
      if (T::isDataValid(data, dataLen))
458
63
      {
459
63
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
63
      }
461
279
      return nullptr;
462
342
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
603k
    {
457
603k
      if (T::isDataValid(data, dataLen))
458
601k
      {
459
601k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
601k
      }
461
1.67k
      return nullptr;
462
603k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
1.06M
    {
457
1.06M
      if (T::isDataValid(data, dataLen))
458
1.05M
      {
459
1.05M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
1.05M
      }
461
11.3k
      return nullptr;
462
1.06M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
62.2k
    {
457
62.2k
      if (T::isDataValid(data, dataLen))
458
61.3k
      {
459
61.3k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
61.3k
      }
461
972
      return nullptr;
462
62.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
23.4k
    {
457
23.4k
      if (T::isDataValid(data, dataLen))
458
23.4k
      {
459
23.4k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
23.4k
      }
461
0
      return nullptr;
462
23.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
113k
    {
457
113k
      if (T::isDataValid(data, dataLen))
458
113k
      {
459
113k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
113k
      }
461
0
      return nullptr;
462
113k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
6.11k
    {
457
6.11k
      if (T::isDataValid(data, dataLen))
458
6.11k
      {
459
6.11k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
6.11k
      }
461
0
      return nullptr;
462
6.11k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
11.5k
    {
457
11.5k
      if (T::isDataValid(data, dataLen))
458
11.5k
      {
459
11.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
11.5k
      }
461
0
      return nullptr;
462
11.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
1.44k
    {
457
1.44k
      if (T::isDataValid(data, dataLen))
458
1.44k
      {
459
1.44k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
1.44k
      }
461
0
      return nullptr;
462
1.44k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
3.80k
    {
457
3.80k
      if (T::isDataValid(data, dataLen))
458
3.80k
      {
459
3.80k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
3.80k
      }
461
0
      return nullptr;
462
3.80k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
5.69k
    {
457
5.69k
      if (T::isDataValid(data, dataLen))
458
5.54k
      {
459
5.54k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
5.54k
      }
461
144
      return nullptr;
462
5.69k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
5.36k
    {
457
5.36k
      if (T::isDataValid(data, dataLen))
458
5.36k
      {
459
5.36k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
5.36k
      }
461
0
      return nullptr;
462
5.36k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
9.26k
    {
457
9.26k
      if (T::isDataValid(data, dataLen))
458
9.26k
      {
459
9.26k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
9.26k
      }
461
0
      return nullptr;
462
9.26k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
456
5.54k
    {
457
5.54k
      if (T::isDataValid(data, dataLen))
458
5.54k
      {
459
5.54k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
5.54k
      }
461
0
      return nullptr;
462
5.54k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
31.1k
    {
457
31.1k
      if (T::isDataValid(data, dataLen))
458
28.0k
      {
459
28.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
28.0k
      }
461
3.08k
      return nullptr;
462
31.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
34.5k
    {
457
34.5k
      if (T::isDataValid(data, dataLen))
458
34.0k
      {
459
34.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
34.0k
      }
461
594
      return nullptr;
462
34.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
6.90k
    {
457
6.90k
      if (T::isDataValid(data, dataLen))
458
6.90k
      {
459
6.90k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
6.90k
      }
461
0
      return nullptr;
462
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
6.90k
    {
457
6.90k
      if (T::isDataValid(data, dataLen))
458
6.64k
      {
459
6.64k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
6.64k
      }
461
259
      return nullptr;
462
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
19.0k
    {
457
19.0k
      if (T::isDataValid(data, dataLen))
458
16.7k
      {
459
16.7k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
16.7k
      }
461
2.26k
      return nullptr;
462
19.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
456
89.9k
    {
457
89.9k
      if (T::isDataValid(data, dataLen))
458
89.5k
      {
459
89.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
89.5k
      }
461
392
      return nullptr;
462
89.9k
    }
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
456
10.1k
    {
457
10.1k
      if (T::isDataValid(data, dataLen))
458
8.31k
      {
459
8.31k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
460
8.31k
      }
461
1.79k
      return nullptr;
462
10.1k
    }
463
464
    /// @brief Try to construct the next layer in the protocol stack with a fallback option.
465
    ///
466
    /// This overload infers the Packet from the current layer.
467
    ///
468
    /// The method checks if the data is valid for the layer type T before constructing it by calling
469
    /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
470
    ///
471
    /// @tparam T The type of the layer to construct
472
    /// @tparam TFallback The fallback layer type to construct if T fails
473
    /// @tparam Args The types of the extra arguments to pass to the layer constructor of T
474
    /// @param[in] data The data to construct the layer from
475
    /// @param[in] dataLen The length of the data
476
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T
477
    /// @return The constructed layer of type T or TFallback
478
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
479
    /// constructor.
480
    template <typename T, typename TFallback, typename... Args>
481
    Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs)
482
3.22M
    {
483
3.22M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
3.22M
                                                             std::forward<Args>(extraArgs)...);
485
3.22M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
1.65M
    {
483
1.65M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
1.65M
                                                             std::forward<Args>(extraArgs)...);
485
1.65M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
305k
    {
483
305k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
305k
                                                             std::forward<Args>(extraArgs)...);
485
305k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
22.7k
    {
483
22.7k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
22.7k
                                                             std::forward<Args>(extraArgs)...);
485
22.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
315k
    {
483
315k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
315k
                                                             std::forward<Args>(extraArgs)...);
485
315k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
77.7k
    {
483
77.7k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
77.7k
                                                             std::forward<Args>(extraArgs)...);
485
77.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
6.38k
    {
483
6.38k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
6.38k
                                                             std::forward<Args>(extraArgs)...);
485
6.38k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
352k
    {
483
352k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
352k
                                                             std::forward<Args>(extraArgs)...);
485
352k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
18.0k
    {
483
18.0k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
18.0k
                                                             std::forward<Args>(extraArgs)...);
485
18.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
342
    {
483
342
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
342
                                                             std::forward<Args>(extraArgs)...);
485
342
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
40.0k
    {
483
40.0k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
40.0k
                                                             std::forward<Args>(extraArgs)...);
485
40.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
223k
    {
483
223k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
223k
                                                             std::forward<Args>(extraArgs)...);
485
223k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
6.76k
    {
483
6.76k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
6.76k
                                                             std::forward<Args>(extraArgs)...);
485
6.76k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
5.90k
    {
483
5.90k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
5.90k
                                                             std::forward<Args>(extraArgs)...);
485
5.90k
    }
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
482
2.89k
    {
483
2.89k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
2.89k
                                                             std::forward<Args>(extraArgs)...);
485
2.89k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
31.1k
    {
483
31.1k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
31.1k
                                                             std::forward<Args>(extraArgs)...);
485
31.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
34.5k
    {
483
34.5k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
34.5k
                                                             std::forward<Args>(extraArgs)...);
485
34.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
6.90k
    {
483
6.90k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
6.90k
                                                             std::forward<Args>(extraArgs)...);
485
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
6.90k
    {
483
6.90k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
6.90k
                                                             std::forward<Args>(extraArgs)...);
485
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
19.0k
    {
483
19.0k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
19.0k
                                                             std::forward<Args>(extraArgs)...);
485
19.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
482
89.9k
    {
483
89.9k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
89.9k
                                                             std::forward<Args>(extraArgs)...);
485
89.9k
    }
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
482
10.1k
    {
483
10.1k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
484
10.1k
                                                             std::forward<Args>(extraArgs)...);
485
10.1k
    }
486
487
    /// Try to construct the next layer in the protocol stack with a fallback option.
488
    ///
489
    /// The method checks if the data is valid for the layer type T before constructing it by calling
490
    /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
491
    ///
492
    /// @tparam T The type of the layer to construct
493
    /// @tparam TFallback The fallback layer type to construct if T fails
494
    /// @tparam Args The types of the extra arguments to pass to the layer constructor of T
495
    /// @param[in] data The data to construct the layer from
496
    /// @param[in] dataLen The length of the data
497
    /// @param[in] packet The packet the layer belongs to
498
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T
499
    /// @return The constructed layer of type T or TFallback
500
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
501
    /// constructor.
502
    template <typename T, typename TFallback, typename... Args>
503
    Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
504
4.87M
    {
505
4.87M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
4.81M
      {
507
4.81M
        return m_NextLayer;
508
4.81M
      }
509
510
51.2k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
4.87M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
1.65M
    {
505
1.65M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
1.63M
      {
507
1.63M
        return m_NextLayer;
508
1.63M
      }
509
510
21.1k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
1.65M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
312k
    {
505
312k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
306k
      {
507
306k
        return m_NextLayer;
508
306k
      }
509
510
5.04k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
312k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
22.7k
    {
505
22.7k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
22.5k
      {
507
22.5k
        return m_NextLayer;
508
22.5k
      }
509
510
172
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
22.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
315k
    {
505
315k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
315k
      {
507
315k
        return m_NextLayer;
508
315k
      }
509
510
280
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
315k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
77.7k
    {
505
77.7k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
77.5k
      {
507
77.5k
        return m_NextLayer;
508
77.5k
      }
509
510
128
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
77.7k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
6.38k
    {
505
6.38k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
6.38k
      {
507
6.38k
        return m_NextLayer;
508
6.38k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
6.38k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
352k
    {
505
352k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
352k
      {
507
352k
        return m_NextLayer;
508
352k
      }
509
510
9
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
352k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
18.0k
    {
505
18.0k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
16.4k
      {
507
16.4k
        return m_NextLayer;
508
16.4k
      }
509
510
1.56k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
18.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
342
    {
505
342
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
63
      {
507
63
        return m_NextLayer;
508
63
      }
509
510
279
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
342
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
603k
    {
505
603k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
601k
      {
507
601k
        return m_NextLayer;
508
601k
      }
509
510
1.67k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
603k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
1.06M
    {
505
1.06M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
1.05M
      {
507
1.05M
        return m_NextLayer;
508
1.05M
      }
509
510
11.3k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
1.06M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
62.2k
    {
505
62.2k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
61.3k
      {
507
61.3k
        return m_NextLayer;
508
61.3k
      }
509
510
972
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
62.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
23.4k
    {
505
23.4k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
23.4k
      {
507
23.4k
        return m_NextLayer;
508
23.4k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
23.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
113k
    {
505
113k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
113k
      {
507
113k
        return m_NextLayer;
508
113k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
113k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
6.11k
    {
505
6.11k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
6.11k
      {
507
6.11k
        return m_NextLayer;
508
6.11k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
6.11k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
11.5k
    {
505
11.5k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
11.5k
      {
507
11.5k
        return m_NextLayer;
508
11.5k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
11.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
1.44k
    {
505
1.44k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
1.44k
      {
507
1.44k
        return m_NextLayer;
508
1.44k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
1.44k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
3.80k
    {
505
3.80k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
3.80k
      {
507
3.80k
        return m_NextLayer;
508
3.80k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
3.80k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
5.69k
    {
505
5.69k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
5.54k
      {
507
5.54k
        return m_NextLayer;
508
5.54k
      }
509
510
144
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
5.69k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
5.36k
    {
505
5.36k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
5.36k
      {
507
5.36k
        return m_NextLayer;
508
5.36k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
5.36k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
9.26k
    {
505
9.26k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
9.26k
      {
507
9.26k
        return m_NextLayer;
508
9.26k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
9.26k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV3Layer, pcpp::PayloadLayer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
504
5.54k
    {
505
5.54k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
5.54k
      {
507
5.54k
        return m_NextLayer;
508
5.54k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
5.54k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
31.1k
    {
505
31.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
28.0k
      {
507
28.0k
        return m_NextLayer;
508
28.0k
      }
509
510
3.08k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
31.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
34.5k
    {
505
34.5k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
34.0k
      {
507
34.0k
        return m_NextLayer;
508
34.0k
      }
509
510
594
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
34.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
6.90k
    {
505
6.90k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
6.90k
      {
507
6.90k
        return m_NextLayer;
508
6.90k
      }
509
510
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
6.90k
    {
505
6.90k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
6.64k
      {
507
6.64k
        return m_NextLayer;
508
6.64k
      }
509
510
259
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
6.90k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
19.0k
    {
505
19.0k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
16.7k
      {
507
16.7k
        return m_NextLayer;
508
16.7k
      }
509
510
2.26k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
19.0k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
504
89.9k
    {
505
89.9k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
89.5k
      {
507
89.5k
        return m_NextLayer;
508
89.5k
      }
509
510
392
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
89.9k
    }
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
504
10.1k
    {
505
10.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
506
8.31k
      {
507
8.31k
        return m_NextLayer;
508
8.31k
      }
509
510
1.79k
      return constructNextLayer<TFallback>(data, dataLen, packet);
511
10.1k
    }
512
513
    /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
514
    ///
515
    /// The method will attempt to construct the next layer using the provided factory function.
516
    /// If the factory function returns nullptr, indicating failure to create the layer, the method will then
517
    /// construct a layer of type TFallback.
518
    ///
519
    /// The factory functor is expected to have the following signature:
520
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
521
    ///
522
    /// This overload infers the Packet from the current layer.
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] extraArgs Extra arguments to be forwarded to the factory.
531
    /// @return The return value of the factory functor.
532
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
533
    /// constructor.
534
    template <typename TFallback, typename TFactory, typename... Args>
535
    Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen,
536
                                                        Args&&... extraArgs)
537
398k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
398k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
398k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
398k
    }
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
537
74.7k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
74.7k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
74.7k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
74.7k
    }
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
537
57.0k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
57.0k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
57.0k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
57.0k
    }
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
537
41.8k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
41.8k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
41.8k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
41.8k
    }
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
537
639
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
639
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
639
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
639
    }
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
537
19.9k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
19.9k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
19.9k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
19.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
537
3.22k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
3.22k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
3.22k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
3.22k
    }
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
537
101k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
101k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
101k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
101k
    }
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
537
3.94k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
3.94k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
3.94k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
3.94k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
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
537
95.4k
    {
538
      // Note that the fallback is first to allow template argument deduction of the factory type.
539
95.4k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
540
95.4k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
541
95.4k
    }
542
543
    /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option.
544
    ///
545
    /// The method will attempt to construct the next layer using the provided factory function.
546
    /// If the factory function returns nullptr, indicating failure to create the layer, the method will then
547
    /// construct a layer of type TFallback.
548
    ///
549
    /// The factory functor is expected to have the following signature:
550
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
551
    ///
552
    /// @tparam TFallback The fallback layer type to construct if the factory fails.
553
    /// @tparam TFactory The factory functor type.
554
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
555
    /// @param[in] factoryFn The factory functor to create the layer.
556
    /// @param[in] data The data to construct the layer from
557
    /// @param[in] dataLen The length of the data
558
    /// @param[in] packet The packet the layer belongs to
559
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
560
    /// @return The return value of the factory functor.
561
    /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback
562
    /// constructor.
563
    template <typename TFallback, typename TFactory, typename... Args>
564
    Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen,
565
                                                        Packet* packet, Args&&... extraArgs)
566
398k
    {
567
398k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
398k
                                                               std::forward<Args>(extraArgs)...);
569
398k
      if (nextLayer != nullptr)
570
291k
      {
571
291k
        return nextLayer;
572
291k
      }
573
574
      // factory failed, construct fallback layer
575
106k
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
398k
    }
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
566
74.7k
    {
567
74.7k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
74.7k
                                                               std::forward<Args>(extraArgs)...);
569
74.7k
      if (nextLayer != nullptr)
570
70.5k
      {
571
70.5k
        return nextLayer;
572
70.5k
      }
573
574
      // factory failed, construct fallback layer
575
4.16k
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
74.7k
    }
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
566
57.0k
    {
567
57.0k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
57.0k
                                                               std::forward<Args>(extraArgs)...);
569
57.0k
      if (nextLayer != nullptr)
570
56.6k
      {
571
56.6k
        return nextLayer;
572
56.6k
      }
573
574
      // factory failed, construct fallback layer
575
382
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
57.0k
    }
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
566
41.8k
    {
567
41.8k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
41.8k
                                                               std::forward<Args>(extraArgs)...);
569
41.8k
      if (nextLayer != nullptr)
570
32.8k
      {
571
32.8k
        return nextLayer;
572
32.8k
      }
573
574
      // factory failed, construct fallback layer
575
8.95k
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
41.8k
    }
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
566
639
    {
567
639
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
639
                                                               std::forward<Args>(extraArgs)...);
569
639
      if (nextLayer != nullptr)
570
639
      {
571
639
        return nextLayer;
572
639
      }
573
574
      // factory failed, construct fallback layer
575
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
639
    }
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
566
19.9k
    {
567
19.9k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
19.9k
                                                               std::forward<Args>(extraArgs)...);
569
19.9k
      if (nextLayer != nullptr)
570
19.9k
      {
571
19.9k
        return nextLayer;
572
19.9k
      }
573
574
      // factory failed, construct fallback layer
575
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
19.9k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::QuicV1Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
566
3.22k
    {
567
3.22k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
3.22k
                                                               std::forward<Args>(extraArgs)...);
569
3.22k
      if (nextLayer != nullptr)
570
2.93k
      {
571
2.93k
        return nextLayer;
572
2.93k
      }
573
574
      // factory failed, construct fallback layer
575
287
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
3.22k
    }
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
566
101k
    {
567
101k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
101k
                                                               std::forward<Args>(extraArgs)...);
569
101k
      if (nextLayer != nullptr)
570
97.3k
      {
571
97.3k
        return nextLayer;
572
97.3k
      }
573
574
      // factory failed, construct fallback layer
575
4.42k
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
101k
    }
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
566
3.94k
    {
567
3.94k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
3.94k
                                                               std::forward<Args>(extraArgs)...);
569
3.94k
      if (nextLayer != nullptr)
570
3.92k
      {
571
3.92k
        return nextLayer;
572
3.92k
      }
573
574
      // factory failed, construct fallback layer
575
18
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
3.94k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::GvcpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
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
566
95.4k
    {
567
95.4k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
568
95.4k
                                                               std::forward<Args>(extraArgs)...);
569
95.4k
      if (nextLayer != nullptr)
570
6.90k
      {
571
6.90k
        return nextLayer;
572
6.90k
      }
573
574
      // factory failed, construct fallback layer
575
88.5k
      return constructNextLayer<TFallback>(data, dataLen, packet);
576
95.4k
    }
577
578
    /// @brief Check if the data is large enough to reinterpret as a type
579
    ///
580
    /// The data must be non-null and at least as large as the type
581
    ///
582
    /// @tparam T The type to reinterpret as
583
    /// @param data The data to check
584
    /// @param dataLen The length of the data
585
    /// @return True if the data is large enough to reinterpret as T, false otherwise
586
    template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen)
587
3.61M
    {
588
3.61M
      return data != nullptr && dataLen >= sizeof(T);
589
3.61M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long)
Line
Count
Source
587
22.7k
    {
588
22.7k
      return data != nullptr && dataLen >= sizeof(T);
589
22.7k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long)
Line
Count
Source
587
1.69M
    {
588
1.69M
      return data != nullptr && dataLen >= sizeof(T);
589
1.69M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
34.5k
    {
588
34.5k
      return data != nullptr && dataLen >= sizeof(T);
589
34.5k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
14.8k
    {
588
14.8k
      return data != nullptr && dataLen >= sizeof(T);
589
14.8k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long)
Line
Count
Source
587
314k
    {
588
314k
      return data != nullptr && dataLen >= sizeof(T);
589
314k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
315k
    {
588
315k
      return data != nullptr && dataLen >= sizeof(T);
589
315k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
352k
    {
588
352k
      return data != nullptr && dataLen >= sizeof(T);
589
352k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
17.6k
    {
588
17.6k
      return data != nullptr && dataLen >= sizeof(T);
589
17.6k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
1.44k
    {
588
1.44k
      return data != nullptr && dataLen >= sizeof(T);
589
1.44k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
3.80k
    {
588
3.80k
      return data != nullptr && dataLen >= sizeof(T);
589
3.80k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
587
1.60k
    {
588
1.60k
      return data != nullptr && dataLen >= sizeof(T);
589
1.60k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
587
2.38k
    {
588
2.38k
      return data != nullptr && dataLen >= sizeof(T);
589
2.38k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::rstp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
587
1.08k
    {
588
1.08k
      return data != nullptr && dataLen >= sizeof(T);
589
1.08k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::mstp_conf_bpdu>(unsigned char const*, unsigned long)
Line
Count
Source
587
68
    {
588
68
      return data != nullptr && dataLen >= sizeof(T);
589
68
    }
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long)
Line
Count
Source
587
278k
    {
588
278k
      return data != nullptr && dataLen >= sizeof(T);
589
278k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
587
6.90k
    {
588
6.90k
      return data != nullptr && dataLen >= sizeof(T);
589
6.90k
    }
Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::GvcpRequestLayer::gvcp_request_header>(unsigned char const*, unsigned long)
Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::GvcpAcknowledgeLayer::gvcp_ack_header>(unsigned char const*, unsigned long)
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long)
Line
Count
Source
587
548k
    {
588
548k
      return data != nullptr && dataLen >= sizeof(T);
589
548k
    }
590
591
    /// Serializes the layer's data into a provided serializer object.
592
    /// This is used for generating serialized representations (like JSON) of the packet layers.
593
    /// This method should be overridden by derived layers to provide specific serialization logic.
594
    ///
595
    /// @param[in] serializer The object scope serializer to which the layer details should be written.
596
    virtual void serializeLayer(ObjectScope& serializer) const
597
0
    {}
598
  };
599
600
  inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer)
601
0
  {
602
0
    os << layer.toString();
603
0
    return os;
604
0
  }
605
}  // namespace pcpp