Coverage Report

Created: 2026-08-31 07:52

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