Coverage Report

Created: 2025-12-31 07:37

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 <string>
7
#include <stdexcept>
8
#include <utility>
9
10
/// @file
11
12
/// @namespace pcpp
13
/// @brief The main namespace for the PcapPlusPlus lib
14
namespace pcpp
15
{
16
17
  /// @class IDataContainer
18
  /// An interface (virtual abstract class) that indicates an object that holds a pointer to a buffer data. The Layer
19
  /// class is an example of such object, hence it inherits this interface
20
  class IDataContainer
21
  {
22
  public:
23
    /// Get a pointer to the data
24
    /// @param[in] offset Get a pointer in a certain offset. Default is 0 - get a pointer to start of data
25
    /// @return A pointer to the data
26
    virtual uint8_t* getDataPtr(size_t offset = 0) const = 0;
27
28
4.47M
    virtual ~IDataContainer() = default;
29
  };
30
31
  class Packet;
32
33
  /// @class Layer
34
  /// Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that
35
  /// inherits Layer.
36
  /// The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields.
37
  /// For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size,
38
  /// compute fields that can be automatically computed, print protocol data to string, etc.
39
  /// Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is
40
  /// represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer
41
  /// has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is
42
  /// abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer
43
  /// to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the
44
  /// packet. Here is an example packet showing this concept:
45
  ///
46
  /// @code{.unparsed}
47
  /// ====================================================
48
  /// |Eth       |IPv4       |TCP       |Packet          |
49
  /// |Header    |Header     |Header    |Payload         |
50
  /// ====================================================
51
  ///
52
  /// |--------------------------------------------------|
53
  /// EthLayer data
54
  ///            |---------------------------------------|
55
  ///            IPv4Layer data
56
  ///                        |---------------------------|
57
  ///                        TcpLayer data
58
  ///                                   |----------------|
59
  ///                                   PayloadLayer data
60
  /// @endcode
61
  class Layer : public IDataContainer
62
  {
63
    friend class Packet;
64
65
  public:
66
    /// A destructor for this class. Frees the data if it was allocated by the layer constructor (see
67
    /// isAllocatedToPacket() for more info)
68
    ~Layer() override;
69
70
    /// @return A pointer to the next layer in the protocol stack or nullptr if the layer is the last one
71
    Layer* getNextLayer() const
72
84.7M
    {
73
84.7M
      return m_NextLayer;
74
84.7M
    }
75
76
    /// @return A pointer to the previous layer in the protocol stack or nullptr if the layer is the first one
77
    Layer* getPrevLayer() const
78
2.09M
    {
79
2.09M
      return m_PrevLayer;
80
2.09M
    }
81
82
    /// @return The protocol enum
83
    ProtocolType getProtocol() const
84
60.4M
    {
85
60.4M
      return m_Protocol;
86
60.4M
    }
87
88
    /// Check if the layer's protocol matches a protocol family
89
    /// @param protocolTypeFamily The protocol family to check
90
    /// @return True if the layer's protocol matches the protocol family, false otherwise
91
    bool isMemberOfProtocolFamily(ProtocolTypeFamily protocolTypeFamily) const;
92
93
    /// @return A pointer to the layer raw data. In most cases it'll be a pointer to the first byte of the header
94
    uint8_t* getData() const
95
295k
    {
96
295k
      return m_Data;
97
295k
    }
98
99
    /// @return The length in bytes of the data from the first byte of the header until the end of the packet
100
    size_t getDataLen() const
101
3.23M
    {
102
3.23M
      return m_DataLen;
103
3.23M
    }
104
105
    /// @return A pointer for the layer payload, meaning the first byte after the header
106
    uint8_t* getLayerPayload() const
107
0
    {
108
0
      return m_Data + getHeaderLen();
109
0
    }
110
111
    /// @return The size in bytes of the payload
112
    size_t getLayerPayloadSize() const
113
58.9k
    {
114
58.9k
      return m_DataLen - getHeaderLen();
115
58.9k
    }
116
117
    /// Raw data in layers can come from one of sources:
118
    /// 1. from an existing packet - this is the case when parsing packets received from files or the network. In
119
    /// this case the data was already allocated by someone else, and layer only holds the pointer to the relevant
120
    /// place inside this data
121
    /// 2. when creating packets, data is allocated when layer is created. In this case the layer is responsible for
122
    /// freeing it as well
123
    ///
124
    /// @return Returns true if the data was allocated by an external source (a packet) or false if it was allocated
125
    /// by the layer itself
126
    bool isAllocatedToPacket() const
127
4.47M
    {
128
4.47M
      return m_Packet != nullptr;
129
4.47M
    }
130
131
    /// Copy the raw data of this layer to another array
132
    /// @param[out] toArr The destination byte array
133
    void copyData(uint8_t* toArr) const;
134
135
    // implement abstract methods
136
137
    uint8_t* getDataPtr(size_t offset = 0) const override
138
115k
    {
139
115k
      return static_cast<uint8_t*>(m_Data + offset);
140
115k
    }
141
142
    // abstract methods
143
144
    /// Each layer is responsible for parsing the next layer
145
    virtual void parseNextLayer() = 0;
146
147
    /// @return The header length in bytes
148
    virtual size_t getHeaderLen() const = 0;
149
150
    /// Each layer can compute field values automatically using this method. This is an abstract method
151
    virtual void computeCalculateFields() = 0;
152
153
    /// @return A string representation of the layer most important data (should look like the layer description in
154
    /// Wireshark)
155
    virtual std::string toString() const = 0;
156
157
    /// @return The OSI Model layer this protocol belongs to
158
    virtual OsiModelLayer getOsiModelLayer() const = 0;
159
160
  protected:
161
    uint8_t* m_Data;
162
    size_t m_DataLen;
163
    Packet* m_Packet;
164
    ProtocolType m_Protocol;
165
    Layer* m_NextLayer;
166
    Layer* m_PrevLayer;
167
    bool m_IsAllocatedInPacket;
168
169
    Layer()
170
        : m_Data(nullptr), m_DataLen(0), m_Packet(nullptr), m_Protocol(UnknownProtocol), m_NextLayer(nullptr),
171
          m_PrevLayer(nullptr), m_IsAllocatedInPacket(false)
172
0
    {}
173
174
    Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol)
175
4.35M
        : m_Data(data), m_DataLen(dataLen), m_Packet(packet), m_Protocol(protocol), m_NextLayer(nullptr),
176
4.35M
          m_PrevLayer(prevLayer), m_IsAllocatedInPacket(false)
177
4.35M
    {}
178
179
    // Copy c'tor
180
    Layer(const Layer& other);
181
    Layer& operator=(const Layer& other);
182
183
    void setNextLayer(Layer* nextLayer)
184
1.96M
    {
185
1.96M
      m_NextLayer = nextLayer;
186
1.96M
    }
187
    void setPrevLayer(Layer* prevLayer)
188
0
    {
189
0
      m_PrevLayer = prevLayer;
190
0
    }
191
192
    virtual bool extendLayer(int offsetInLayer, size_t numOfBytesToExtend);
193
    virtual bool shortenLayer(int offsetInLayer, size_t numOfBytesToShorten);
194
195
    bool hasNextLayer() const
196
3.41M
    {
197
3.41M
      return m_NextLayer != nullptr;
198
3.41M
    }
199
200
    /// Construct the next layer in the protocol stack. No validation is performed on the data.
201
    /// @tparam T The type of the layer to construct
202
    /// @tparam Args The types of the arguments to pass to the layer constructor
203
    /// @param[in] data The data to construct the layer from
204
    /// @param[in] dataLen The length of the data
205
    /// @param[in] packet The packet the layer belongs to
206
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
207
    /// @return The constructed layer
208
    template <typename T, typename... Args>
209
    Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
210
1.80M
    {
211
1.80M
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
1.80M
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
1.80M
      setNextLayer(newLayer);
218
1.80M
      return newLayer;
219
1.80M
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
112k
    {
211
112k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
112k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
112k
      setNextLayer(newLayer);
218
112k
      return newLayer;
219
112k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
287k
    {
211
287k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
287k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
287k
      setNextLayer(newLayer);
218
287k
      return newLayer;
219
287k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
385k
    {
211
385k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
385k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
385k
      setNextLayer(newLayer);
218
385k
      return newLayer;
219
385k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
37.7k
    {
211
37.7k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
37.7k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
37.7k
      setNextLayer(newLayer);
218
37.7k
      return newLayer;
219
37.7k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
583k
    {
211
583k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
583k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
583k
      setNextLayer(newLayer);
218
583k
      return newLayer;
219
583k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
56.5k
    {
211
56.5k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
56.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
56.5k
      setNextLayer(newLayer);
218
56.5k
      return newLayer;
219
56.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
3.78k
    {
211
3.78k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.78k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.78k
      setNextLayer(newLayer);
218
3.78k
      return newLayer;
219
3.78k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
62.5k
    {
211
62.5k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
62.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
62.5k
      setNextLayer(newLayer);
218
62.5k
      return newLayer;
219
62.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
3.45k
    {
211
3.45k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.45k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.45k
      setNextLayer(newLayer);
218
3.45k
      return newLayer;
219
3.45k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
7.00k
    {
211
7.00k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
7.00k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
7.00k
      setNextLayer(newLayer);
218
7.00k
      return newLayer;
219
7.00k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
3.80k
    {
211
3.80k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.80k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.80k
      setNextLayer(newLayer);
218
3.80k
      return newLayer;
219
3.80k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
2.28k
    {
211
2.28k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
2.28k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
2.28k
      setNextLayer(newLayer);
218
2.28k
      return newLayer;
219
2.28k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
5.22k
    {
211
5.22k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
5.22k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
5.22k
      setNextLayer(newLayer);
218
5.22k
      return newLayer;
219
5.22k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
1.00k
    {
211
1.00k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
1.00k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
1.00k
      setNextLayer(newLayer);
218
1.00k
      return newLayer;
219
1.00k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
3.95k
    {
211
3.95k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.95k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.95k
      setNextLayer(newLayer);
218
3.95k
      return newLayer;
219
3.95k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
210
3.34k
    {
211
3.34k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.34k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.34k
      setNextLayer(newLayer);
218
3.34k
      return newLayer;
219
3.34k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
6.86k
    {
211
6.86k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
6.86k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
6.86k
      setNextLayer(newLayer);
218
6.86k
      return newLayer;
219
6.86k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
12.2k
    {
211
12.2k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
12.2k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
12.2k
      setNextLayer(newLayer);
218
12.2k
      return newLayer;
219
12.2k
    }
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
210
23.9k
    {
211
23.9k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
23.9k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
23.9k
      setNextLayer(newLayer);
218
23.9k
      return newLayer;
219
23.9k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
41.5k
    {
211
41.5k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
41.5k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
41.5k
      setNextLayer(newLayer);
218
41.5k
      return newLayer;
219
41.5k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
5.32k
    {
211
5.32k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
5.32k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
5.32k
      setNextLayer(newLayer);
218
5.32k
      return newLayer;
219
5.32k
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
3.00k
    {
211
3.00k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
3.00k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
3.00k
      setNextLayer(newLayer);
218
3.00k
      return newLayer;
219
3.00k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
5.32k
    {
211
5.32k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
5.32k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
5.32k
      setNextLayer(newLayer);
218
5.32k
      return newLayer;
219
5.32k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
12
    {
211
12
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
12
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
12
      setNextLayer(newLayer);
218
12
      return newLayer;
219
12
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
101
    {
211
101
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
101
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
101
      setNextLayer(newLayer);
218
101
      return newLayer;
219
101
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
2.72k
    {
211
2.72k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
2.72k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
2.72k
      setNextLayer(newLayer);
218
2.72k
      return newLayer;
219
2.72k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
140k
    {
211
140k
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
140k
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
140k
      setNextLayer(newLayer);
218
140k
      return newLayer;
219
140k
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
15
    {
211
15
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
15
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
15
      setNextLayer(newLayer);
218
15
      return newLayer;
219
15
    }
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
210
10
    {
211
10
      if (hasNextLayer())
212
0
      {
213
0
        throw std::runtime_error("Next layer already exists");
214
0
      }
215
216
10
      Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...);
217
10
      setNextLayer(newLayer);
218
10
      return newLayer;
219
10
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
220
221
    /// Try to construct the next layer in the protocol stack with a fallback option.
222
    ///
223
    /// The method checks if the data is valid for the layer type T before constructing it by calling
224
    /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback.
225
    ///
226
    /// @tparam T The type of the layer to construct
227
    /// @tparam TFallback The fallback layer type to construct if T fails
228
    /// @tparam Args The types of the extra arguments to pass to the layer constructor of T
229
    /// @param[in] data The data to construct the layer from
230
    /// @param[in] dataLen The length of the data
231
    /// @param[in] packet The packet the layer belongs to
232
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T
233
    /// @return The constructed layer of type T or TFallback
234
    template <typename T, typename TFallback, typename... Args>
235
    Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
236
1.60M
    {
237
1.60M
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
1.58M
      {
239
1.58M
        return m_NextLayer;
240
1.58M
      }
241
242
17.4k
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
1.60M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
287k
    {
237
287k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
287k
      {
239
287k
        return m_NextLayer;
240
287k
      }
241
242
203
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
287k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
397k
    {
237
397k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
385k
      {
239
385k
        return m_NextLayer;
240
385k
      }
241
242
12.6k
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
397k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
39.5k
    {
237
39.5k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
37.7k
      {
239
37.7k
        return m_NextLayer;
240
37.7k
      }
241
242
1.72k
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
39.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
585k
    {
237
585k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
583k
      {
239
583k
        return m_NextLayer;
240
583k
      }
241
242
1.95k
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
585k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
56.8k
    {
237
56.8k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
56.5k
      {
239
56.5k
        return m_NextLayer;
240
56.5k
      }
241
242
320
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
56.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
3.78k
    {
237
3.78k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
3.78k
      {
239
3.78k
        return m_NextLayer;
240
3.78k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
3.78k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
62.6k
    {
237
62.6k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
62.5k
      {
239
62.5k
        return m_NextLayer;
240
62.5k
      }
241
242
60
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
62.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
3.45k
    {
237
3.45k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
3.45k
      {
239
3.45k
        return m_NextLayer;
240
3.45k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
3.45k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
7.00k
    {
237
7.00k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
7.00k
      {
239
7.00k
        return m_NextLayer;
240
7.00k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
7.00k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
3.80k
    {
237
3.80k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
3.80k
      {
239
3.80k
        return m_NextLayer;
240
3.80k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
3.80k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
2.28k
    {
237
2.28k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
2.28k
      {
239
2.28k
        return m_NextLayer;
240
2.28k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
2.28k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
5.58k
    {
237
5.58k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
5.22k
      {
239
5.22k
        return m_NextLayer;
240
5.22k
      }
241
242
366
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
5.58k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
1.02k
    {
237
1.02k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
1.00k
      {
239
1.00k
        return m_NextLayer;
240
1.00k
      }
241
242
15
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
1.02k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
3.95k
    {
237
3.95k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
3.95k
      {
239
3.95k
        return m_NextLayer;
240
3.95k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
3.95k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV3Layer, pcpp::PayloadLayer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
236
3.34k
    {
237
3.34k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
3.34k
      {
239
3.34k
        return m_NextLayer;
240
3.34k
      }
241
242
0
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
3.34k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
2.77k
    {
237
2.77k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
2.72k
      {
239
2.72k
        return m_NextLayer;
240
2.72k
      }
241
242
51
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
2.77k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
140k
    {
237
140k
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
140k
      {
239
140k
        return m_NextLayer;
240
140k
      }
241
242
69
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
140k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
18
    {
237
18
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
15
      {
239
15
        return m_NextLayer;
240
15
      }
241
242
3
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
18
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
13
    {
237
13
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
10
      {
239
10
        return m_NextLayer;
240
10
      }
241
242
3
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
13
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
236
72
    {
237
72
      if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...))
238
0
      {
239
0
        return m_NextLayer;
240
0
      }
241
242
72
      return constructNextLayer<TFallback>(data, dataLen, packet);
243
72
    }
244
245
    /// @brief Check if the data is large enough to reinterpret as a type
246
    ///
247
    /// The data must be non-null and at least as large as the type
248
    ///
249
    /// @tparam T The type to reinterpret as
250
    /// @param data The data to check
251
    /// @param dataLen The length of the data
252
    /// @return True if the data is large enough to reinterpret as T, false otherwise
253
    template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen)
254
1.27M
    {
255
1.27M
      return data != nullptr && dataLen >= sizeof(T);
256
1.27M
    }
bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long)
Line
Count
Source
254
2.77k
    {
255
2.77k
      return data != nullptr && dataLen >= sizeof(T);
256
2.77k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long)
Line
Count
Source
254
848k
    {
255
848k
      return data != nullptr && dataLen >= sizeof(T);
256
848k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long)
Line
Count
Source
254
7.29k
    {
255
7.29k
      return data != nullptr && dataLen >= sizeof(T);
256
7.29k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long)
Line
Count
Source
254
155k
    {
255
155k
      return data != nullptr && dataLen >= sizeof(T);
256
155k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long)
Line
Count
Source
254
140k
    {
255
140k
      return data != nullptr && dataLen >= sizeof(T);
256
140k
    }
Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long)
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long)
Line
Count
Source
254
10.4k
    {
255
10.4k
      return data != nullptr && dataLen >= sizeof(T);
256
10.4k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long)
Line
Count
Source
254
3.80k
    {
255
3.80k
      return data != nullptr && dataLen >= sizeof(T);
256
3.80k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long)
Line
Count
Source
254
2.28k
    {
255
2.28k
      return data != nullptr && dataLen >= sizeof(T);
256
2.28k
    }
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long)
Line
Count
Source
254
107k
    {
255
107k
      return data != nullptr && dataLen >= sizeof(T);
256
107k
    }
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)
257
258
  private:
259
    /// Try to construct the next layer in the protocol stack.
260
    ///
261
    /// The method checks if the data is valid for the layer type T before constructing it by calling
262
    /// T::isDataValid(data, dataLen). If the data is invalid, a nullptr is returned.
263
    ///
264
    /// @tparam T The type of the layer to construct
265
    /// @tparam Args The types of the extra arguments to pass to the layer constructor
266
    /// @param[in] data The data to construct the layer from
267
    /// @param[in] dataLen The length of the data
268
    /// @param[in] packet The packet the layer belongs to
269
    /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor
270
    /// @return The constructed layer or nullptr if the data is invalid
271
    template <typename T, typename... Args>
272
    Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs)
273
1.60M
    {
274
1.60M
      if (T::isDataValid(data, dataLen))
275
1.58M
      {
276
1.58M
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
1.58M
      }
278
17.4k
      return nullptr;
279
1.60M
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
287k
    {
274
287k
      if (T::isDataValid(data, dataLen))
275
287k
      {
276
287k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
287k
      }
278
203
      return nullptr;
279
287k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
397k
    {
274
397k
      if (T::isDataValid(data, dataLen))
275
385k
      {
276
385k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
385k
      }
278
12.6k
      return nullptr;
279
397k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
39.5k
    {
274
39.5k
      if (T::isDataValid(data, dataLen))
275
37.7k
      {
276
37.7k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
37.7k
      }
278
1.72k
      return nullptr;
279
39.5k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
585k
    {
274
585k
      if (T::isDataValid(data, dataLen))
275
583k
      {
276
583k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
583k
      }
278
1.95k
      return nullptr;
279
585k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
56.8k
    {
274
56.8k
      if (T::isDataValid(data, dataLen))
275
56.5k
      {
276
56.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
56.5k
      }
278
320
      return nullptr;
279
56.8k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
3.78k
    {
274
3.78k
      if (T::isDataValid(data, dataLen))
275
3.78k
      {
276
3.78k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
3.78k
      }
278
0
      return nullptr;
279
3.78k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
62.6k
    {
274
62.6k
      if (T::isDataValid(data, dataLen))
275
62.5k
      {
276
62.5k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
62.5k
      }
278
60
      return nullptr;
279
62.6k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
3.45k
    {
274
3.45k
      if (T::isDataValid(data, dataLen))
275
3.45k
      {
276
3.45k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
3.45k
      }
278
0
      return nullptr;
279
3.45k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
7.00k
    {
274
7.00k
      if (T::isDataValid(data, dataLen))
275
7.00k
      {
276
7.00k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
7.00k
      }
278
0
      return nullptr;
279
7.00k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
3.80k
    {
274
3.80k
      if (T::isDataValid(data, dataLen))
275
3.80k
      {
276
3.80k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
3.80k
      }
278
0
      return nullptr;
279
3.80k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
2.28k
    {
274
2.28k
      if (T::isDataValid(data, dataLen))
275
2.28k
      {
276
2.28k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
2.28k
      }
278
0
      return nullptr;
279
2.28k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
5.58k
    {
274
5.58k
      if (T::isDataValid(data, dataLen))
275
5.22k
      {
276
5.22k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
5.22k
      }
278
366
      return nullptr;
279
5.58k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
1.02k
    {
274
1.02k
      if (T::isDataValid(data, dataLen))
275
1.00k
      {
276
1.00k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
1.00k
      }
278
15
      return nullptr;
279
1.02k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
3.95k
    {
274
3.95k
      if (T::isDataValid(data, dataLen))
275
3.95k
      {
276
3.95k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
3.95k
      }
278
0
      return nullptr;
279
3.95k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&)
Line
Count
Source
273
3.34k
    {
274
3.34k
      if (T::isDataValid(data, dataLen))
275
3.34k
      {
276
3.34k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
3.34k
      }
278
0
      return nullptr;
279
3.34k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
2.77k
    {
274
2.77k
      if (T::isDataValid(data, dataLen))
275
2.72k
      {
276
2.72k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
2.72k
      }
278
51
      return nullptr;
279
2.77k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
140k
    {
274
140k
      if (T::isDataValid(data, dataLen))
275
140k
      {
276
140k
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
140k
      }
278
69
      return nullptr;
279
140k
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
18
    {
274
18
      if (T::isDataValid(data, dataLen))
275
15
      {
276
15
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
15
      }
278
3
      return nullptr;
279
18
    }
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
13
    {
274
13
      if (T::isDataValid(data, dataLen))
275
10
      {
276
10
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
10
      }
278
3
      return nullptr;
279
13
    }
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*)
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*)
Line
Count
Source
273
72
    {
274
72
      if (T::isDataValid(data, dataLen))
275
0
      {
276
0
        return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...);
277
0
      }
278
72
      return nullptr;
279
72
    }
280
  };
281
282
  inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer)
283
0
  {
284
0
    os << layer.toString();
285
0
    return os;
286
0
  }
287
}  // namespace pcpp