Coverage Report

Created: 2026-09-01 08:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Packet++/header/Layer.h
Line
Count
Source
1
#pragma once
2
3
#include <stdint.h>
4
#include <stdio.h>
5
#include "ProtocolType.h"
6
#include <ostream>
7
#include <string>
8
#include <stdexcept>
9
#include <utility>
10
11
/// @file
12
13
/// @namespace pcpp
14
/// @brief The main namespace for the PcapPlusPlus lib
15
namespace pcpp
16
{
17
18
  /// @class IDataContainer
19
  /// An interface (virtual abstract class) that indicates an object that holds a pointer to a buffer data. The Layer
20
  /// class is an example of such object, hence it inherits this interface
21
  class IDataContainer
22
  {
23
  public:
24
    /// Get a pointer to the data
25
    /// @param[in] offset Get a pointer in a certain offset. Default is 0 - get a pointer to start of data
26
    /// @return A pointer to the data
27
    virtual uint8_t* getDataPtr(size_t offset = 0) const = 0;
28
29
5.52M
    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.4M
    {
139
75.4M
      return m_Protocol;
140
75.4M
    }
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
325k
    {
150
325k
      return m_Data;
151
325k
    }
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.42M
    {
156
4.42M
      return m_DataLen;
157
4.42M
    }
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
95.9k
    {
168
95.9k
      return m_DataLen - getHeaderLen();
169
95.9k
    }
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.52M
    {
182
5.52M
      return m_AllocationInfo.attachedPacket != nullptr;
183
5.52M
    }
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.39M
        : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer),
249
5.39M
          m_AllocationInfo{ packet, false }
250
5.39M
    {}
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.20M
    {
260
5.20M
      return m_AllocationInfo.attachedPacket;
261
5.20M
    }
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.37M
    {
272
4.37M
      m_NextLayer = nextLayer;
273
4.37M
    }
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.57M
    {
300
7.57M
      return m_NextLayer != nullptr;
301
7.57M
    }
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
412k
    {
316
412k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
412k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
82.1k
    {
316
82.1k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
82.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
119k
    {
316
119k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
119k
    }
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
56.2k
    {
316
56.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
56.2k
    }
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.5k
    {
316
22.5k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
22.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
16.0k
    {
316
16.0k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
16.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
830
    {
316
830
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
830
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
56.7k
    {
316
56.7k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
56.7k
    }
318
319
    /// Construct the next layer in the protocol stack. No validation is performed on the data.
320
    /// @tparam T The type of the layer to construct
321
    /// @tparam Args The types of the arguments to pass to the layer constructor
322
    /// @param[in] data The data to construct the layer from
323
    /// @param[in] dataLen The length of the data
324
    /// @param[in] packet The packet the layer belongs to
325
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
326
    /// @return The constructed layer
327
    template <typename T, typename... Args>
328
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
329
3.52M
    {
330
3.52M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.52M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.52M
      setNextLayer(newLayer);
337
3.52M
      return newLayer;
338
3.52M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.01M
    {
330
1.01M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.01M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.01M
      setNextLayer(newLayer);
337
1.01M
      return newLayer;
338
1.01M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
328k
    {
330
328k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
328k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
328k
      setNextLayer(newLayer);
337
328k
      return newLayer;
338
328k
    }
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
281k
    {
330
281k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
281k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
281k
      setNextLayer(newLayer);
337
281k
      return newLayer;
338
281k
    }
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
99.6k
    {
330
99.6k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
99.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
99.6k
      setNextLayer(newLayer);
337
99.6k
      return newLayer;
338
99.6k
    }
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
400k
    {
330
400k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
400k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
400k
      setNextLayer(newLayer);
337
400k
      return newLayer;
338
400k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
550k
    {
330
550k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
550k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
550k
      setNextLayer(newLayer);
337
550k
      return newLayer;
338
550k
    }
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.2k
    {
330
11.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
11.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
11.2k
      setNextLayer(newLayer);
337
11.2k
      return newLayer;
338
11.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
107k
    {
330
107k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
107k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
107k
      setNextLayer(newLayer);
337
107k
      return newLayer;
338
107k
    }
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.91k
    {
330
4.91k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
4.91k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
4.91k
      setNextLayer(newLayer);
337
4.91k
      return newLayer;
338
4.91k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
60.0k
    {
330
60.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
60.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
60.0k
      setNextLayer(newLayer);
337
60.0k
      return newLayer;
338
60.0k
    }
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.72k
    {
330
6.72k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
6.72k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
6.72k
      setNextLayer(newLayer);
337
6.72k
      return newLayer;
338
6.72k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
6.84k
    {
330
6.84k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
6.84k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
6.84k
      setNextLayer(newLayer);
337
6.84k
      return newLayer;
338
6.84k
    }
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.7k
    {
330
68.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
68.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
68.7k
      setNextLayer(newLayer);
337
68.7k
      return newLayer;
338
68.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
12.1k
    {
330
12.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
12.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
12.1k
      setNextLayer(newLayer);
337
12.1k
      return newLayer;
338
12.1k
    }
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.51k
    {
330
3.51k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.51k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.51k
      setNextLayer(newLayer);
337
3.51k
      return newLayer;
338
3.51k
    }
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
42
    {
330
42
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
42
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
42
      setNextLayer(newLayer);
337
42
      return newLayer;
338
42
    }
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
15.1k
    {
330
15.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
15.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
15.1k
      setNextLayer(newLayer);
337
15.1k
      return newLayer;
338
15.1k
    }
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
56.2k
    {
330
56.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
56.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
56.2k
      setNextLayer(newLayer);
337
56.2k
      return newLayer;
338
56.2k
    }
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.5k
    {
330
22.5k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
22.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
22.5k
      setNextLayer(newLayer);
337
22.5k
      return newLayer;
338
22.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
16.0k
    {
330
16.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
16.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
16.0k
      setNextLayer(newLayer);
337
16.0k
      return newLayer;
338
16.0k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
830
    {
330
830
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
830
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
830
      setNextLayer(newLayer);
337
830
      return newLayer;
338
830
    }
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
56.7k
    {
330
56.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
56.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
56.7k
      setNextLayer(newLayer);
337
56.7k
      return newLayer;
338
56.7k
    }
339
340
    /// @brief Construct the next layer in the protocol stack using a factory functor.
341
    ///
342
    /// No validation is performed on the data, outside of what the factory functor may perform.
343
    /// If the factory returns a nullptr, no next layer is set.
344
    ///
345
    /// The factory functor is expected to have the following signature:
346
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
347
    ///
348
    /// This overload infers the Packet from the current layer.
349
    ///
350
    /// @tparam TFactory The factory functor type.
351
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
352
    /// @param[in] factoryFn The factory functor to create the layer.
353
    /// @param[in] data The data to construct the layer from
354
    /// @param[in] dataLen The length of the data
355
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
356
    /// @return The return value of the factory functor.
357
    template <typename TFactory, typename... Args>
358
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs)
359
482k
    {
360
482k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
482k
                                                     std::forward<Args>(extraArgs)...);
362
482k
    }
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
138k
    {
360
138k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
138k
                                                     std::forward<Args>(extraArgs)...);
362
138k
    }
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.2k
    {
360
63.2k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
63.2k
                                                     std::forward<Args>(extraArgs)...);
362
63.2k
    }
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
235k
    {
360
235k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
235k
                                                     std::forward<Args>(extraArgs)...);
362
235k
    }
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.6k
    {
360
18.6k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
18.6k
                                                     std::forward<Args>(extraArgs)...);
362
18.6k
    }
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
800k
    {
384
800k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
800k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
800k
      setNextLayer(newLayer);
392
800k
      return newLayer;
393
800k
    }
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
192k
    {
384
192k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
192k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
192k
      setNextLayer(newLayer);
392
192k
      return newLayer;
393
192k
    }
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.2k
    {
384
63.2k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
63.2k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
63.2k
      setNextLayer(newLayer);
392
63.2k
      return newLayer;
393
63.2k
    }
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
235k
    {
384
235k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
235k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
235k
      setNextLayer(newLayer);
392
235k
      return newLayer;
393
235k
    }
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.6k
    {
384
18.6k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
18.6k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
18.6k
      setNextLayer(newLayer);
392
18.6k
      return newLayer;
393
18.6k
    }
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.7k
    {
384
64.7k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
64.7k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
64.7k
      setNextLayer(newLayer);
392
64.7k
      return newLayer;
393
64.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, 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
819
    {
384
819
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
819
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
819
      setNextLayer(newLayer);
392
819
      return newLayer;
393
819
    }
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
100k
    {
384
100k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
100k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
100k
      setNextLayer(newLayer);
392
100k
      return newLayer;
393
100k
    }
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
48.1k
    {
384
48.1k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
48.1k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
48.1k
      setNextLayer(newLayer);
392
48.1k
      return newLayer;
393
48.1k
    }
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.80M
    {
429
2.80M
      if (T::isDataValid(data, dataLen))
430
2.76M
      {
431
2.76M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.76M
      }
433
42.3k
      return nullptr;
434
2.80M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
1.03M
    {
429
1.03M
      if (T::isDataValid(data, dataLen))
430
1.01M
      {
431
1.01M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
1.01M
      }
433
19.0k
      return nullptr;
434
1.03M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
187k
    {
429
187k
      if (T::isDataValid(data, dataLen))
430
182k
      {
431
182k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
182k
      }
433
4.81k
      return nullptr;
434
187k
    }
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
99.6k
    {
429
99.6k
      if (T::isDataValid(data, dataLen))
430
99.6k
      {
431
99.6k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
99.6k
      }
433
15
      return nullptr;
434
99.6k
    }
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
400k
      {
431
400k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
400k
      }
433
1.73k
      return nullptr;
434
401k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
562k
    {
429
562k
      if (T::isDataValid(data, dataLen))
430
550k
      {
431
550k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
550k
      }
433
11.5k
      return nullptr;
434
562k
    }
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.22k
      return nullptr;
434
46.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
11.2k
    {
429
11.2k
      if (T::isDataValid(data, dataLen))
430
11.2k
      {
431
11.2k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
11.2k
      }
433
0
      return nullptr;
434
11.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
107k
    {
429
107k
      if (T::isDataValid(data, dataLen))
430
107k
      {
431
107k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
107k
      }
433
60
      return nullptr;
434
107k
    }
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.1k
    {
429
60.1k
      if (T::isDataValid(data, dataLen))
430
60.0k
      {
431
60.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
60.0k
      }
433
97
      return nullptr;
434
60.1k
    }
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.10k
    {
429
7.10k
      if (T::isDataValid(data, dataLen))
430
6.72k
      {
431
6.72k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
6.72k
      }
433
380
      return nullptr;
434
7.10k
    }
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.4k
    {
429
15.4k
      if (T::isDataValid(data, dataLen))
430
15.1k
      {
431
15.1k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
15.1k
      }
433
238
      return nullptr;
434
15.4k
    }
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.09k
    {
429
3.09k
      if (T::isDataValid(data, dataLen))
430
3.03k
      {
431
3.03k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
3.03k
      }
433
57
      return nullptr;
434
3.09k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
199k
    {
429
199k
      if (T::isDataValid(data, dataLen))
430
199k
      {
431
199k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
199k
      }
433
198
      return nullptr;
434
199k
    }
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.03M
    {
455
1.03M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
1.03M
                                                             std::forward<Args>(extraArgs)...);
457
1.03M
    }
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
99.6k
    {
455
99.6k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
99.6k
                                                             std::forward<Args>(extraArgs)...);
457
99.6k
    }
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
36.9k
    {
455
36.9k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
36.9k
                                                             std::forward<Args>(extraArgs)...);
457
36.9k
    }
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.27k
    {
455
7.27k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
7.27k
                                                             std::forward<Args>(extraArgs)...);
457
7.27k
    }
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.1k
    {
455
60.1k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
60.1k
                                                             std::forward<Args>(extraArgs)...);
457
60.1k
    }
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.10k
    {
455
7.10k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
7.10k
                                                             std::forward<Args>(extraArgs)...);
457
7.10k
    }
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.4k
    {
455
15.4k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
15.4k
                                                             std::forward<Args>(extraArgs)...);
457
15.4k
    }
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.09k
    {
455
3.09k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
3.09k
                                                             std::forward<Args>(extraArgs)...);
457
3.09k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
199k
    {
455
199k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
199k
                                                             std::forward<Args>(extraArgs)...);
457
199k
    }
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.80M
    {
477
2.80M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.76M
      {
479
2.76M
        return m_NextLayer;
480
2.76M
      }
481
482
42.3k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.80M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
1.03M
    {
477
1.03M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
1.01M
      {
479
1.01M
        return m_NextLayer;
480
1.01M
      }
481
482
19.0k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
1.03M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
187k
    {
477
187k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
182k
      {
479
182k
        return m_NextLayer;
480
182k
      }
481
482
4.81k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
187k
    }
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
99.6k
    {
477
99.6k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
99.6k
      {
479
99.6k
        return m_NextLayer;
480
99.6k
      }
481
482
15
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
99.6k
    }
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
400k
      {
479
400k
        return m_NextLayer;
480
400k
      }
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
562k
    {
477
562k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
550k
      {
479
550k
        return m_NextLayer;
480
550k
      }
481
482
11.5k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
562k
    }
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.22k
      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.2k
    {
477
11.2k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
11.2k
      {
479
11.2k
        return m_NextLayer;
480
11.2k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
11.2k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
107k
    {
477
107k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
107k
      {
479
107k
        return m_NextLayer;
480
107k
      }
481
482
60
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
107k
    }
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.1k
    {
477
60.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
60.0k
      {
479
60.0k
        return m_NextLayer;
480
60.0k
      }
481
482
97
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
60.1k
    }
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.10k
    {
477
7.10k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
6.72k
      {
479
6.72k
        return m_NextLayer;
480
6.72k
      }
481
482
380
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
7.10k
    }
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.4k
    {
477
15.4k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
15.1k
      {
479
15.1k
        return m_NextLayer;
480
15.1k
      }
481
482
238
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
15.4k
    }
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.09k
    {
477
3.09k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
3.03k
      {
479
3.03k
        return m_NextLayer;
480
3.03k
      }
481
482
57
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
3.09k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
199k
    {
477
199k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
199k
      {
479
199k
        return m_NextLayer;
480
199k
      }
481
482
198
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
199k
    }
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
317k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
317k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
317k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
317k
    }
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
53.9k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
53.9k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
53.9k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
53.9k
    }
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.7k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
64.7k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
64.7k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
64.7k
    }
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.2k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
44.2k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
44.2k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
44.2k
    }
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
819
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
819
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
819
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
819
    }
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
100k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
100k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
100k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
100k
    }
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
48.1k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
48.1k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
48.1k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
48.1k
    }
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
317k
    {
539
317k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
317k
                                                               std::forward<Args>(extraArgs)...);
541
317k
      if (nextLayer != nullptr)
542
244k
      {
543
244k
        return nextLayer;
544
244k
      }
545
546
      // factory failed, construct fallback layer
547
72.9k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
317k
    }
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
53.9k
    {
539
53.9k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
53.9k
                                                               std::forward<Args>(extraArgs)...);
541
53.9k
      if (nextLayer != nullptr)
542
49.6k
      {
543
49.6k
        return nextLayer;
544
49.6k
      }
545
546
      // factory failed, construct fallback layer
547
4.29k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
53.9k
    }
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.7k
    {
539
64.7k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
64.7k
                                                               std::forward<Args>(extraArgs)...);
541
64.7k
      if (nextLayer != nullptr)
542
63.9k
      {
543
63.9k
        return nextLayer;
544
63.9k
      }
545
546
      // factory failed, construct fallback layer
547
854
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
64.7k
    }
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.2k
    {
539
44.2k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
44.2k
                                                               std::forward<Args>(extraArgs)...);
541
44.2k
      if (nextLayer != nullptr)
542
29.5k
      {
543
29.5k
        return nextLayer;
544
29.5k
      }
545
546
      // factory failed, construct fallback layer
547
14.6k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
44.2k
    }
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
819
    {
539
819
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
819
                                                               std::forward<Args>(extraArgs)...);
541
819
      if (nextLayer != nullptr)
542
819
      {
543
819
        return nextLayer;
544
819
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
819
    }
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
100k
    {
539
100k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
100k
                                                               std::forward<Args>(extraArgs)...);
541
100k
      if (nextLayer != nullptr)
542
95.3k
      {
543
95.3k
        return nextLayer;
544
95.3k
      }
545
546
      // factory failed, construct fallback layer
547
5.54k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
100k
    }
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
48.1k
    {
539
48.1k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
48.1k
                                                               std::forward<Args>(extraArgs)...);
541
48.1k
      if (nextLayer != nullptr)
542
566
      {
543
566
        return nextLayer;
544
566
      }
545
546
      // factory failed, construct fallback layer
547
47.5k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
48.1k
    }
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.84M
    {
560
1.84M
      return data != nullptr && dataLen >= sizeof(T);
561
1.84M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
3.09k
    {
560
3.09k
      return data != nullptr && dataLen >= sizeof(T);
561
3.09k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
1.03M
    {
560
1.03M
      return data != nullptr && dataLen >= sizeof(T);
561
1.03M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
15.4k
    {
560
15.4k
      return data != nullptr && dataLen >= sizeof(T);
561
15.4k
    }
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
199k
    {
560
199k
      return data != nullptr && dataLen >= sizeof(T);
561
199k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
11.3k
    {
560
11.3k
      return data != nullptr && dataLen >= sizeof(T);
561
11.3k
    }
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
235k
    {
560
235k
      return data != nullptr && dataLen >= sizeof(T);
561
235k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
137k
    {
560
137k
      return data != nullptr && dataLen >= sizeof(T);
561
137k
    }
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