Coverage Report

Created: 2026-09-03 08:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Packet++/header/Layer.h
Line
Count
Source
1
#pragma once
2
3
#include <stdint.h>
4
#include <stdio.h>
5
#include "ProtocolType.h"
6
#include <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
4.79M
    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
91.0M
    {
127
91.0M
      return m_NextLayer;
128
91.0M
    }
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
1.81M
    {
133
1.81M
      return m_PrevLayer;
134
1.81M
    }
135
136
    /// @return The protocol enum
137
    ProtocolType getProtocol() const
138
65.4M
    {
139
65.4M
      return m_Protocol;
140
65.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
280k
    {
150
280k
      return m_Data;
151
280k
    }
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.01M
    {
156
4.01M
      return m_DataLen;
157
4.01M
    }
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
84.5k
    {
168
84.5k
      return m_DataLen - getHeaderLen();
169
84.5k
    }
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
4.79M
    {
182
4.79M
      return m_AllocationInfo.attachedPacket != nullptr;
183
4.79M
    }
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
97.0k
    {
212
97.0k
      return static_cast<uint8_t*>(m_Data + offset);
213
97.0k
    }
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
4.68M
        : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer),
249
4.68M
          m_AllocationInfo{ packet, false }
250
4.68M
    {}
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
4.53M
    {
260
4.53M
      return m_AllocationInfo.attachedPacket;
261
4.53M
    }
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.46k
    {
267
2.46k
      return m_AllocationInfo.attachedPacket;
268
2.46k
    }
269
270
    void setNextLayer(Layer* nextLayer)
271
3.79M
    {
272
3.79M
      m_NextLayer = nextLayer;
273
3.79M
    }
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
6.58M
    {
300
6.58M
      return m_NextLayer != nullptr;
301
6.58M
    }
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
353k
    {
316
353k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
353k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
67.5k
    {
316
67.5k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
67.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
103k
    {
316
103k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
103k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&)
Line
Count
Source
315
3.51k
    {
316
3.51k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
3.51k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
1.63k
    {
316
1.63k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
1.63k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
48.7k
    {
316
48.7k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
48.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
11.1k
    {
316
11.1k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
11.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
34.2k
    {
316
34.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
34.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
8
    {
316
8
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
8
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long)
Line
Count
Source
315
20.2k
    {
316
20.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
20.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
12.2k
    {
316
12.2k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
12.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
745
    {
316
745
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
745
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long)
Line
Count
Source
315
49.8k
    {
316
49.8k
      return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
317
49.8k
    }
318
319
    /// Construct the next layer in the protocol stack. No validation is performed on the data.
320
    /// @tparam T The type of the layer to construct
321
    /// @tparam Args The types of the arguments to pass to the layer constructor
322
    /// @param[in] data The data to construct the layer from
323
    /// @param[in] dataLen The length of the data
324
    /// @param[in] packet The packet the layer belongs to
325
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
326
    /// @return The constructed layer
327
    template <typename T, typename... Args>
328
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
329
3.04M
    {
330
3.04M
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.04M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.04M
      setNextLayer(newLayer);
337
3.04M
      return newLayer;
338
3.04M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
887k
    {
330
887k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
887k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
887k
      setNextLayer(newLayer);
337
887k
      return newLayer;
338
887k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
278k
    {
330
278k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
278k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
278k
      setNextLayer(newLayer);
337
278k
      return newLayer;
338
278k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
153k
    {
330
153k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
153k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
153k
      setNextLayer(newLayer);
337
153k
      return newLayer;
338
153k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
237k
    {
330
237k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
237k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
237k
      setNextLayer(newLayer);
337
237k
      return newLayer;
338
237k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
7.92k
    {
330
7.92k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
7.92k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
7.92k
      setNextLayer(newLayer);
337
7.92k
      return newLayer;
338
7.92k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
87.0k
    {
330
87.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
87.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
87.0k
      setNextLayer(newLayer);
337
87.0k
      return newLayer;
338
87.0k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
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
8
    {
330
8
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
8
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
8
      setNextLayer(newLayer);
337
8
      return newLayer;
338
8
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
353k
    {
330
353k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
353k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
353k
      setNextLayer(newLayer);
337
353k
      return newLayer;
338
353k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
472k
    {
330
472k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
472k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
472k
      setNextLayer(newLayer);
337
472k
      return newLayer;
338
472k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
40.5k
    {
330
40.5k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
40.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
40.5k
      setNextLayer(newLayer);
337
40.5k
      return newLayer;
338
40.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
10.1k
    {
330
10.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
10.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
10.1k
      setNextLayer(newLayer);
337
10.1k
      return newLayer;
338
10.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
94.4k
    {
330
94.4k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
94.4k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
94.4k
      setNextLayer(newLayer);
337
94.4k
      return newLayer;
338
94.4k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
3.11k
    {
330
3.11k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.11k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.11k
      setNextLayer(newLayer);
337
3.11k
      return newLayer;
338
3.11k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
7.30k
    {
330
7.30k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
7.30k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
7.30k
      setNextLayer(newLayer);
337
7.30k
      return newLayer;
338
7.30k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
2.21k
    {
330
2.21k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
2.21k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
2.21k
      setNextLayer(newLayer);
337
2.21k
      return newLayer;
338
2.21k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
2.02k
    {
330
2.02k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
2.02k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
2.02k
      setNextLayer(newLayer);
337
2.02k
      return newLayer;
338
2.02k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
4.36k
    {
330
4.36k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
4.36k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
4.36k
      setNextLayer(newLayer);
337
4.36k
      return newLayer;
338
4.36k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5.26k
    {
330
5.26k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.26k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.26k
      setNextLayer(newLayer);
337
5.26k
      return newLayer;
338
5.26k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
2.84k
    {
330
2.84k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
2.84k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
2.84k
      setNextLayer(newLayer);
337
2.84k
      return newLayer;
338
2.84k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
329
5.98k
    {
330
5.98k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.98k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.98k
      setNextLayer(newLayer);
337
5.98k
      return newLayer;
338
5.98k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
4.15k
    {
330
4.15k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
4.15k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
4.15k
      setNextLayer(newLayer);
337
4.15k
      return newLayer;
338
4.15k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
48.8k
    {
330
48.8k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
48.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
48.8k
      setNextLayer(newLayer);
337
48.8k
      return newLayer;
338
48.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
1.23k
    {
330
1.23k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
1.23k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
1.23k
      setNextLayer(newLayer);
337
1.23k
      return newLayer;
338
1.23k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
3.88k
    {
330
3.88k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.88k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.88k
      setNextLayer(newLayer);
337
3.88k
      return newLayer;
338
3.88k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5.35k
    {
330
5.35k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5.35k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5.35k
      setNextLayer(newLayer);
337
5.35k
      return newLayer;
338
5.35k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
9.73k
    {
330
9.73k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
9.73k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
9.73k
      setNextLayer(newLayer);
337
9.73k
      return newLayer;
338
9.73k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
13.8k
    {
330
13.8k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
13.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
13.8k
      setNextLayer(newLayer);
337
13.8k
      return newLayer;
338
13.8k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
55.6k
    {
330
55.6k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
55.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
55.6k
      setNextLayer(newLayer);
337
55.6k
      return newLayer;
338
55.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
10.2k
    {
330
10.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
10.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
10.2k
      setNextLayer(newLayer);
337
10.2k
      return newLayer;
338
10.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
216
    {
330
216
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
216
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
216
      setNextLayer(newLayer);
337
216
      return newLayer;
338
216
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
3.19k
    {
330
3.19k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
3.19k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
3.19k
      setNextLayer(newLayer);
337
3.19k
      return newLayer;
338
3.19k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
17.6k
    {
330
17.6k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
17.6k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
17.6k
      setNextLayer(newLayer);
337
17.6k
      return newLayer;
338
17.6k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
185
    {
330
185
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
185
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
185
      setNextLayer(newLayer);
337
185
      return newLayer;
338
185
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
161
    {
330
161
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
161
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
161
      setNextLayer(newLayer);
337
161
      return newLayer;
338
161
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
5
    {
330
5
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
5
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
5
      setNextLayer(newLayer);
337
5
      return newLayer;
338
5
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
16.5k
    {
330
16.5k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
16.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
16.5k
      setNextLayer(newLayer);
337
16.5k
      return newLayer;
338
16.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
14.0k
    {
330
14.0k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
14.0k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
14.0k
      setNextLayer(newLayer);
337
14.0k
      return newLayer;
338
14.0k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
48.7k
    {
330
48.7k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
48.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
48.7k
      setNextLayer(newLayer);
337
48.7k
      return newLayer;
338
48.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
11.1k
    {
330
11.1k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
11.1k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
11.1k
      setNextLayer(newLayer);
337
11.1k
      return newLayer;
338
11.1k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
34.2k
    {
330
34.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
34.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
34.2k
      setNextLayer(newLayer);
337
34.2k
      return newLayer;
338
34.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
20.2k
    {
330
20.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
20.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
20.2k
      setNextLayer(newLayer);
337
20.2k
      return newLayer;
338
20.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
12.2k
    {
330
12.2k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
12.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
12.2k
      setNextLayer(newLayer);
337
12.2k
      return newLayer;
338
12.2k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
745
    {
330
745
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
745
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
745
      setNextLayer(newLayer);
337
745
      return newLayer;
338
745
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
9.04k
    {
330
9.04k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
9.04k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
9.04k
      setNextLayer(newLayer);
337
9.04k
      return newLayer;
338
9.04k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
329
49.8k
    {
330
49.8k
      if (hasNextLayer())
331
0
      {
332
0
        throw std::runtime_error("Next layer already exists");
333
0
      }
334
335
49.8k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
336
49.8k
      setNextLayer(newLayer);
337
49.8k
      return newLayer;
338
49.8k
    }
339
340
    /// @brief Construct the next layer in the protocol stack using a factory functor.
341
    ///
342
    /// No validation is performed on the data, outside of what the factory functor may perform.
343
    /// If the factory returns a nullptr, no next layer is set.
344
    ///
345
    /// The factory functor is expected to have the following signature:
346
    /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...);
347
    ///
348
    /// This overload infers the Packet from the current layer.
349
    ///
350
    /// @tparam TFactory The factory functor type.
351
    /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor.
352
    /// @param[in] factoryFn The factory functor to create the layer.
353
    /// @param[in] data The data to construct the layer from
354
    /// @param[in] dataLen The length of the data
355
    /// @param[in] extraArgs Extra arguments to be forwarded to the factory.
356
    /// @return The return value of the factory functor.
357
    template <typename TFactory, typename... Args>
358
    Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs)
359
422k
    {
360
422k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
422k
                                                     std::forward<Args>(extraArgs)...);
362
422k
    }
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
123k
    {
360
123k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
123k
                                                     std::forward<Args>(extraArgs)...);
362
123k
    }
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
54.0k
    {
360
54.0k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
54.0k
                                                     std::forward<Args>(extraArgs)...);
362
54.0k
    }
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
203k
    {
360
203k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
203k
                                                     std::forward<Args>(extraArgs)...);
362
203k
    }
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
17.5k
    {
360
17.5k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
17.5k
                                                     std::forward<Args>(extraArgs)...);
362
17.5k
    }
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
23.6k
    {
360
23.6k
      return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(),
361
23.6k
                                                     std::forward<Args>(extraArgs)...);
362
23.6k
    }
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
704k
    {
384
704k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
704k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
704k
      setNextLayer(newLayer);
392
704k
      return newLayer;
393
704k
    }
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
170k
    {
384
170k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
170k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
170k
      setNextLayer(newLayer);
392
170k
      return newLayer;
393
170k
    }
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
54.0k
    {
384
54.0k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
54.0k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
54.0k
      setNextLayer(newLayer);
392
54.0k
      return newLayer;
393
54.0k
    }
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
203k
    {
384
203k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
203k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
203k
      setNextLayer(newLayer);
392
203k
      return newLayer;
393
203k
    }
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
17.5k
    {
384
17.5k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
17.5k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
17.5k
      setNextLayer(newLayer);
392
17.5k
      return newLayer;
393
17.5k
    }
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.1k
    {
384
64.1k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
64.1k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
64.1k
      setNextLayer(newLayer);
392
64.1k
      return newLayer;
393
64.1k
    }
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
61.2k
    {
384
61.2k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
61.2k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
61.2k
      setNextLayer(newLayer);
392
61.2k
      return newLayer;
393
61.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
160
    {
384
160
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
160
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
160
      setNextLayer(newLayer);
392
160
      return newLayer;
393
160
    }
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
1.79k
    {
384
1.79k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
1.79k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
1.79k
      setNextLayer(newLayer);
392
1.79k
      return newLayer;
393
1.79k
    }
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
88.3k
    {
384
88.3k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
88.3k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
88.3k
      setNextLayer(newLayer);
392
88.3k
      return newLayer;
393
88.3k
    }
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.24k
    {
384
2.24k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
2.24k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
2.24k
      setNextLayer(newLayer);
392
2.24k
      return newLayer;
393
2.24k
    }
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
41.1k
    {
384
41.1k
      if (hasNextLayer())
385
0
      {
386
0
        throw std::runtime_error("Next layer already exists");
387
0
      }
388
389
      // cppcheck-suppress redundantInitialization
390
41.1k
      Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
391
41.1k
      setNextLayer(newLayer);
392
41.1k
      return newLayer;
393
41.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.43M
    {
429
2.43M
      if (T::isDataValid(data, dataLen))
430
2.40M
      {
431
2.40M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.40M
      }
433
36.3k
      return nullptr;
434
2.43M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
903k
    {
429
903k
      if (T::isDataValid(data, dataLen))
430
887k
      {
431
887k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
887k
      }
433
16.7k
      return nullptr;
434
903k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
157k
    {
429
157k
      if (T::isDataValid(data, dataLen))
430
153k
      {
431
153k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
153k
      }
433
4.42k
      return nullptr;
434
157k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
7.92k
    {
429
7.92k
      if (T::isDataValid(data, dataLen))
430
7.92k
      {
431
7.92k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
7.92k
      }
433
9
      return nullptr;
434
7.92k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
87.0k
    {
429
87.0k
      if (T::isDataValid(data, dataLen))
430
87.0k
      {
431
87.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
87.0k
      }
433
6
      return nullptr;
434
87.0k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
8
    {
429
8
      if (T::isDataValid(data, dataLen))
430
0
      {
431
0
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
0
      }
433
8
      return nullptr;
434
8
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
355k
    {
429
355k
      if (T::isDataValid(data, dataLen))
430
353k
      {
431
353k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
353k
      }
433
1.65k
      return nullptr;
434
355k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
483k
    {
429
483k
      if (T::isDataValid(data, dataLen))
430
472k
      {
431
472k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
472k
      }
433
10.1k
      return nullptr;
434
483k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
41.1k
    {
429
41.1k
      if (T::isDataValid(data, dataLen))
430
40.5k
      {
431
40.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
40.5k
      }
433
679
      return nullptr;
434
41.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
10.1k
    {
429
10.1k
      if (T::isDataValid(data, dataLen))
430
10.1k
      {
431
10.1k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
10.1k
      }
433
0
      return nullptr;
434
10.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
94.4k
    {
429
94.4k
      if (T::isDataValid(data, dataLen))
430
94.4k
      {
431
94.4k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
94.4k
      }
433
0
      return nullptr;
434
94.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
3.11k
    {
429
3.11k
      if (T::isDataValid(data, dataLen))
430
3.11k
      {
431
3.11k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
3.11k
      }
433
0
      return nullptr;
434
3.11k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
7.30k
    {
429
7.30k
      if (T::isDataValid(data, dataLen))
430
7.30k
      {
431
7.30k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
7.30k
      }
433
0
      return nullptr;
434
7.30k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.21k
    {
429
2.21k
      if (T::isDataValid(data, dataLen))
430
2.21k
      {
431
2.21k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.21k
      }
433
0
      return nullptr;
434
2.21k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.02k
    {
429
2.02k
      if (T::isDataValid(data, dataLen))
430
2.02k
      {
431
2.02k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.02k
      }
433
0
      return nullptr;
434
2.02k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
4.49k
    {
429
4.49k
      if (T::isDataValid(data, dataLen))
430
4.36k
      {
431
4.36k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
4.36k
      }
433
138
      return nullptr;
434
4.49k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
5.26k
    {
429
5.26k
      if (T::isDataValid(data, dataLen))
430
5.26k
      {
431
5.26k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
5.26k
      }
433
0
      return nullptr;
434
5.26k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.84k
    {
429
2.84k
      if (T::isDataValid(data, dataLen))
430
2.84k
      {
431
2.84k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.84k
      }
433
0
      return nullptr;
434
2.84k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
428
2.47k
    {
429
2.47k
      if (T::isDataValid(data, dataLen))
430
2.47k
      {
431
2.47k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.47k
      }
433
0
      return nullptr;
434
2.47k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
48.8k
    {
429
48.8k
      if (T::isDataValid(data, dataLen))
430
48.8k
      {
431
48.8k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
48.8k
      }
433
8
      return nullptr;
434
48.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
1.23k
    {
429
1.23k
      if (T::isDataValid(data, dataLen))
430
1.23k
      {
431
1.23k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
1.23k
      }
433
0
      return nullptr;
434
1.23k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
4.13k
    {
429
4.13k
      if (T::isDataValid(data, dataLen))
430
3.88k
      {
431
3.88k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
3.88k
      }
433
257
      return nullptr;
434
4.13k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
17.6k
    {
429
17.6k
      if (T::isDataValid(data, dataLen))
430
16.5k
      {
431
16.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
16.5k
      }
433
1.16k
      return nullptr;
434
17.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
14.2k
    {
429
14.2k
      if (T::isDataValid(data, dataLen))
430
14.0k
      {
431
14.0k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
14.0k
      }
433
198
      return nullptr;
434
14.2k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
9.78k
    {
429
9.78k
      if (T::isDataValid(data, dataLen))
430
9.04k
      {
431
9.04k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
9.04k
      }
433
736
      return nullptr;
434
9.78k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
2.53k
    {
429
2.53k
      if (T::isDataValid(data, dataLen))
430
2.52k
      {
431
2.52k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
2.52k
      }
433
18
      return nullptr;
434
2.53k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
428
169k
    {
429
169k
      if (T::isDataValid(data, dataLen))
430
169k
      {
431
169k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
432
169k
      }
433
129
      return nullptr;
434
169k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
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.56M
    {
455
1.56M
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
1.56M
                                                             std::forward<Args>(extraArgs)...);
457
1.56M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
902k
    {
455
902k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
902k
                                                             std::forward<Args>(extraArgs)...);
457
902k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
157k
    {
455
157k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
157k
                                                             std::forward<Args>(extraArgs)...);
457
157k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
7.92k
    {
455
7.92k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
7.92k
                                                             std::forward<Args>(extraArgs)...);
457
7.92k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
87.0k
    {
455
87.0k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
87.0k
                                                             std::forward<Args>(extraArgs)...);
457
87.0k
    }
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
8
    {
455
8
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
8
                                                             std::forward<Args>(extraArgs)...);
457
8
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
32.8k
    {
455
32.8k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
32.8k
                                                             std::forward<Args>(extraArgs)...);
457
32.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
91.3k
    {
455
91.3k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
91.3k
                                                             std::forward<Args>(extraArgs)...);
457
91.3k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
6.87k
    {
455
6.87k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
6.87k
                                                             std::forward<Args>(extraArgs)...);
457
6.87k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
5.47k
    {
455
5.47k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
5.47k
                                                             std::forward<Args>(extraArgs)...);
457
5.47k
    }
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.12k
    {
455
3.12k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
3.12k
                                                             std::forward<Args>(extraArgs)...);
457
3.12k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
48.8k
    {
455
48.8k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
48.8k
                                                             std::forward<Args>(extraArgs)...);
457
48.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
1.23k
    {
455
1.23k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
1.23k
                                                             std::forward<Args>(extraArgs)...);
457
1.23k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
4.13k
    {
455
4.13k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
4.13k
                                                             std::forward<Args>(extraArgs)...);
457
4.13k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
17.6k
    {
455
17.6k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
17.6k
                                                             std::forward<Args>(extraArgs)...);
457
17.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
14.2k
    {
455
14.2k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
14.2k
                                                             std::forward<Args>(extraArgs)...);
457
14.2k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
9.78k
    {
455
9.78k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
9.78k
                                                             std::forward<Args>(extraArgs)...);
457
9.78k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
2.53k
    {
455
2.53k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
2.53k
                                                             std::forward<Args>(extraArgs)...);
457
2.53k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
Line
Count
Source
454
169k
    {
455
169k
      return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(),
456
169k
                                                             std::forward<Args>(extraArgs)...);
457
169k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long)
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.43M
    {
477
2.43M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.40M
      {
479
2.40M
        return m_NextLayer;
480
2.40M
      }
481
482
36.3k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.43M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
903k
    {
477
903k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
887k
      {
479
887k
        return m_NextLayer;
480
887k
      }
481
482
16.7k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
903k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
157k
    {
477
157k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
153k
      {
479
153k
        return m_NextLayer;
480
153k
      }
481
482
4.42k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
157k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
7.92k
    {
477
7.92k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
7.92k
      {
479
7.92k
        return m_NextLayer;
480
7.92k
      }
481
482
9
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
7.92k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
87.0k
    {
477
87.0k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
87.0k
      {
479
87.0k
        return m_NextLayer;
480
87.0k
      }
481
482
6
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
87.0k
    }
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
8
    {
477
8
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
0
      {
479
0
        return m_NextLayer;
480
0
      }
481
482
8
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
8
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
355k
    {
477
355k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
353k
      {
479
353k
        return m_NextLayer;
480
353k
      }
481
482
1.65k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
355k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
483k
    {
477
483k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
472k
      {
479
472k
        return m_NextLayer;
480
472k
      }
481
482
10.1k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
483k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
41.1k
    {
477
41.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
40.5k
      {
479
40.5k
        return m_NextLayer;
480
40.5k
      }
481
482
679
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
41.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
10.1k
    {
477
10.1k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
10.1k
      {
479
10.1k
        return m_NextLayer;
480
10.1k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
10.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
94.4k
    {
477
94.4k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
94.4k
      {
479
94.4k
        return m_NextLayer;
480
94.4k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
94.4k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
3.11k
    {
477
3.11k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
3.11k
      {
479
3.11k
        return m_NextLayer;
480
3.11k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
3.11k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
7.30k
    {
477
7.30k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
7.30k
      {
479
7.30k
        return m_NextLayer;
480
7.30k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
7.30k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.21k
    {
477
2.21k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.21k
      {
479
2.21k
        return m_NextLayer;
480
2.21k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.21k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.02k
    {
477
2.02k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.02k
      {
479
2.02k
        return m_NextLayer;
480
2.02k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.02k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
4.49k
    {
477
4.49k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
4.36k
      {
479
4.36k
        return m_NextLayer;
480
4.36k
      }
481
482
138
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
4.49k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
5.26k
    {
477
5.26k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
5.26k
      {
479
5.26k
        return m_NextLayer;
480
5.26k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
5.26k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.84k
    {
477
2.84k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.84k
      {
479
2.84k
        return m_NextLayer;
480
2.84k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.84k
    }
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.47k
    {
477
2.47k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.47k
      {
479
2.47k
        return m_NextLayer;
480
2.47k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.47k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
48.8k
    {
477
48.8k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
48.8k
      {
479
48.8k
        return m_NextLayer;
480
48.8k
      }
481
482
8
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
48.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
1.23k
    {
477
1.23k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
1.23k
      {
479
1.23k
        return m_NextLayer;
480
1.23k
      }
481
482
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
1.23k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
4.13k
    {
477
4.13k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
3.88k
      {
479
3.88k
        return m_NextLayer;
480
3.88k
      }
481
482
257
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
4.13k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
17.6k
    {
477
17.6k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
16.5k
      {
479
16.5k
        return m_NextLayer;
480
16.5k
      }
481
482
1.16k
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
17.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
14.2k
    {
477
14.2k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
14.0k
      {
479
14.0k
        return m_NextLayer;
480
14.0k
      }
481
482
198
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
14.2k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
9.78k
    {
477
9.78k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
9.04k
      {
479
9.04k
        return m_NextLayer;
480
9.04k
      }
481
482
736
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
9.78k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
2.53k
    {
477
2.53k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
2.52k
      {
479
2.52k
        return m_NextLayer;
480
2.52k
      }
481
482
18
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
2.53k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
476
169k
    {
477
169k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
478
169k
      {
479
169k
        return m_NextLayer;
480
169k
      }
481
482
129
      return constructNextLayer<TFallback>(data, dataLen, packet);
483
169k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
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
282k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
282k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
282k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
282k
    }
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
47.1k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
47.1k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
47.1k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
47.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long)
Line
Count
Source
509
64.1k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
64.1k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
64.1k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
64.1k
    }
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
37.6k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
37.6k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
37.6k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
37.6k
    }
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
160
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
160
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
160
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
160
    }
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
1.79k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
1.79k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
1.79k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
1.79k
    }
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
88.3k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
88.3k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
88.3k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
88.3k
    }
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.24k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
2.24k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
2.24k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
2.24k
    }
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
41.1k
    {
510
      // Note that the fallback is first to allow template argument deduction of the factory type.
511
41.1k
      return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>(
512
41.1k
          factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...);
513
41.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
282k
    {
539
282k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
282k
                                                               std::forward<Args>(extraArgs)...);
541
282k
      if (nextLayer != nullptr)
542
223k
      {
543
223k
        return nextLayer;
544
223k
      }
545
546
      // factory failed, construct fallback layer
547
59.1k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
282k
    }
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
47.1k
    {
539
47.1k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
47.1k
                                                               std::forward<Args>(extraArgs)...);
541
47.1k
      if (nextLayer != nullptr)
542
43.6k
      {
543
43.6k
        return nextLayer;
544
43.6k
      }
545
546
      // factory failed, construct fallback layer
547
3.43k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
47.1k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
538
64.1k
    {
539
64.1k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
64.1k
                                                               std::forward<Args>(extraArgs)...);
541
64.1k
      if (nextLayer != nullptr)
542
63.8k
      {
543
63.8k
        return nextLayer;
544
63.8k
      }
545
546
      // factory failed, construct fallback layer
547
291
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
64.1k
    }
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
37.6k
    {
539
37.6k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
37.6k
                                                               std::forward<Args>(extraArgs)...);
541
37.6k
      if (nextLayer != nullptr)
542
27.2k
      {
543
27.2k
        return nextLayer;
544
27.2k
      }
545
546
      // factory failed, construct fallback layer
547
10.4k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
37.6k
    }
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
160
    {
539
160
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
160
                                                               std::forward<Args>(extraArgs)...);
541
160
      if (nextLayer != nullptr)
542
160
      {
543
160
        return nextLayer;
544
160
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
160
    }
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
1.79k
    {
539
1.79k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
1.79k
                                                               std::forward<Args>(extraArgs)...);
541
1.79k
      if (nextLayer != nullptr)
542
1.79k
      {
543
1.79k
        return nextLayer;
544
1.79k
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
1.79k
    }
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
88.3k
    {
539
88.3k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
88.3k
                                                               std::forward<Args>(extraArgs)...);
541
88.3k
      if (nextLayer != nullptr)
542
84.2k
      {
543
84.2k
        return nextLayer;
544
84.2k
      }
545
546
      // factory failed, construct fallback layer
547
4.08k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
88.3k
    }
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.24k
    {
539
2.24k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
2.24k
                                                               std::forward<Args>(extraArgs)...);
541
2.24k
      if (nextLayer != nullptr)
542
2.24k
      {
543
2.24k
        return nextLayer;
544
2.24k
      }
545
546
      // factory failed, construct fallback layer
547
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
2.24k
    }
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
41.1k
    {
539
41.1k
      auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet,
540
41.1k
                                                               std::forward<Args>(extraArgs)...);
541
41.1k
      if (nextLayer != nullptr)
542
317
      {
543
317
        return nextLayer;
544
317
      }
545
546
      // factory failed, construct fallback layer
547
40.8k
      return constructNextLayer<TFallback>(data, dataLen, packet);
548
41.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.59M
    {
560
1.59M
      return data != nullptr && dataLen >= sizeof(T);
561
1.59M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
2.53k
    {
560
2.53k
      return data != nullptr && dataLen >= sizeof(T);
561
2.53k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
905k
    {
560
905k
      return data != nullptr && dataLen >= sizeof(T);
561
905k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
14.2k
    {
560
14.2k
      return data != nullptr && dataLen >= sizeof(T);
561
14.2k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
5.31k
    {
560
5.31k
      return data != nullptr && dataLen >= sizeof(T);
561
5.31k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
158k
    {
560
158k
      return data != nullptr && dataLen >= sizeof(T);
561
158k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
7.92k
    {
560
7.92k
      return data != nullptr && dataLen >= sizeof(T);
561
7.92k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
169k
    {
560
169k
      return data != nullptr && dataLen >= sizeof(T);
561
169k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
10.4k
    {
560
10.4k
      return data != nullptr && dataLen >= sizeof(T);
561
10.4k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
2.21k
    {
560
2.21k
      return data != nullptr && dataLen >= sizeof(T);
561
2.21k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long)
Line
Count
Source
559
2.02k
    {
560
2.02k
      return data != nullptr && dataLen >= sizeof(T);
561
2.02k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long)
Line
Count
Source
559
203k
    {
560
203k
      return data != nullptr && dataLen >= sizeof(T);
561
203k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long)
Line
Count
Source
559
116k
    {
560
116k
      return data != nullptr && dataLen >= sizeof(T);
561
116k
    }
Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long)
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