/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 | 3.94M | 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 | | |
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 | 72.3M | { |
127 | 72.3M | return m_NextLayer; |
128 | 72.3M | } |
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.21M | { |
133 | 1.21M | return m_PrevLayer; |
134 | 1.21M | } |
135 | | |
136 | | /// @return The protocol enum |
137 | | ProtocolType getProtocol() const |
138 | 51.9M | { |
139 | 51.9M | return m_Protocol; |
140 | 51.9M | } |
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 | 224k | { |
150 | 224k | return m_Data; |
151 | 224k | } |
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 | 2.46M | { |
156 | 2.46M | return m_DataLen; |
157 | 2.46M | } |
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 | 12.7k | { |
168 | 12.7k | return m_DataLen - getHeaderLen(); |
169 | 12.7k | } |
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 | 3.94M | { |
182 | 3.94M | return m_AllocationInfo.attachedPacket != nullptr; |
183 | 3.94M | } |
184 | | |
185 | | /// Copy the raw data of this layer to another array |
186 | | /// @param[out] toArr The destination byte array |
187 | | void copyData(uint8_t* toArr) const; |
188 | | |
189 | | // implement abstract methods |
190 | | |
191 | | uint8_t* getDataPtr(size_t offset = 0) const override |
192 | 103k | { |
193 | 103k | return static_cast<uint8_t*>(m_Data + offset); |
194 | 103k | } |
195 | | |
196 | | // abstract methods |
197 | | |
198 | | /// Each layer is responsible for parsing the next layer |
199 | | virtual void parseNextLayer() = 0; |
200 | | |
201 | | /// @return The header length in bytes |
202 | | virtual size_t getHeaderLen() const = 0; |
203 | | |
204 | | /// Each layer can compute field values automatically using this method. This is an abstract method |
205 | | virtual void computeCalculateFields() = 0; |
206 | | |
207 | | /// @return A string representation of the layer most important data (should look like the layer description in |
208 | | /// Wireshark) |
209 | | virtual std::string toString() const = 0; |
210 | | |
211 | | /// @return The OSI Model layer this protocol belongs to |
212 | | virtual OsiModelLayer getOsiModelLayer() const = 0; |
213 | | |
214 | | protected: |
215 | | uint8_t* m_Data; |
216 | | size_t m_DataLen; |
217 | | ProtocolType m_Protocol; |
218 | | Layer* m_NextLayer; |
219 | | Layer* m_PrevLayer; |
220 | | |
221 | | private: |
222 | | internal::LayerAllocationInfo m_AllocationInfo; |
223 | | |
224 | | protected: |
225 | 0 | Layer() : m_Data(nullptr), m_DataLen(0), m_Protocol(UnknownProtocol), m_NextLayer(nullptr), m_PrevLayer(nullptr) |
226 | 0 | {} |
227 | | |
228 | | Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol) |
229 | 3.81M | : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer), |
230 | 3.81M | m_AllocationInfo{ packet, false } |
231 | 3.81M | {} |
232 | | |
233 | | // Copy c'tor |
234 | | Layer(const Layer& other); |
235 | | Layer& operator=(const Layer& other); |
236 | | |
237 | | /// @brief Get a pointer to the Packet this layer is attached to (if any). |
238 | | /// @return A pointer to the Packet this layer is attached to, or nullptr if the layer is not attached. |
239 | | Packet* getAttachedPacket() |
240 | 3.37M | { |
241 | 3.37M | return m_AllocationInfo.attachedPacket; |
242 | 3.37M | } |
243 | | |
244 | | /// @brief Get a pointer to the Packet this layer is attached to (if any). |
245 | | /// @return A const pointer to the Packet this layer is attached to, or nullptr if the layer is not attached. |
246 | | Packet const* getAttachedPacket() const |
247 | 6.86k | { |
248 | 6.86k | return m_AllocationInfo.attachedPacket; |
249 | 6.86k | } |
250 | | |
251 | | void setNextLayer(Layer* nextLayer) |
252 | 2.94M | { |
253 | 2.94M | m_NextLayer = nextLayer; |
254 | 2.94M | } |
255 | | void setPrevLayer(Layer* prevLayer) |
256 | 0 | { |
257 | 0 | m_PrevLayer = prevLayer; |
258 | 0 | } |
259 | | |
260 | | virtual bool extendLayer(int offsetInLayer, size_t numOfBytesToExtend); |
261 | | virtual bool shortenLayer(int offsetInLayer, size_t numOfBytesToShorten); |
262 | | |
263 | | bool hasNextLayer() const |
264 | 5.52M | { |
265 | 5.52M | return m_NextLayer != nullptr; |
266 | 5.52M | } |
267 | | |
268 | | /// @brief Construct the next layer in the protocol stack. No validation is performed on the data. |
269 | | /// |
270 | | /// This overload infers the Packet from the current layer. |
271 | | /// |
272 | | /// @tparam T The type of the layer to construct |
273 | | /// @tparam Args The types of the arguments to pass to the layer constructor |
274 | | /// @param data The data to construct the layer from |
275 | | /// @param dataLen The length of the data |
276 | | /// @param extraArgs Extra arguments to be forwarded to the layer constructor |
277 | | /// @return The constructed layer |
278 | | template <typename T, typename... Args> |
279 | | Layer* constructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
280 | 178k | { |
281 | 178k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
282 | 178k | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 12.3k | { | 281 | 12.3k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 12.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 1.26k | { | 281 | 1.26k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 1.26k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 57.0k | { | 281 | 57.0k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 57.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&) Line | Count | Source | 280 | 10.2k | { | 281 | 10.2k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 10.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 5.59k | { | 281 | 5.59k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 5.59k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 46.0k | { | 281 | 46.0k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 46.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 20.0k | { | 281 | 20.0k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 20.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 6.65k | { | 281 | 6.65k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 6.65k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 5.07k | { | 281 | 5.07k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 5.07k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 1.30k | { | 281 | 1.30k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 1.30k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 3.33k | { | 281 | 3.33k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 3.33k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 320 | { | 281 | 320 | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 320 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 4.70k | { | 281 | 4.70k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 4.70k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 4.27k | { | 281 | 4.27k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 4.27k | } |
|
283 | | |
284 | | /// Construct the next layer in the protocol stack. No validation is performed on the data. |
285 | | /// @tparam T The type of the layer to construct |
286 | | /// @tparam Args The types of the arguments to pass to the layer constructor |
287 | | /// @param[in] data The data to construct the layer from |
288 | | /// @param[in] dataLen The length of the data |
289 | | /// @param[in] packet The packet the layer belongs to |
290 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
291 | | /// @return The constructed layer |
292 | | template <typename T, typename... Args> |
293 | | Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
294 | 2.43M | { |
295 | 2.43M | if (hasNextLayer()) |
296 | 0 | { |
297 | 0 | throw std::runtime_error("Next layer already exists"); |
298 | 0 | } |
299 | | |
300 | 2.43M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
301 | 2.43M | setNextLayer(newLayer); |
302 | 2.43M | return newLayer; |
303 | 2.43M | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 685k | { | 295 | 685k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 685k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 685k | setNextLayer(newLayer); | 302 | 685k | return newLayer; | 303 | 685k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 280k | { | 295 | 280k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 280k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 280k | setNextLayer(newLayer); | 302 | 280k | return newLayer; | 303 | 280k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 215k | { | 295 | 215k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 215k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 215k | setNextLayer(newLayer); | 302 | 215k | return newLayer; | 303 | 215k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 37.7k | { | 295 | 37.7k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 37.7k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 37.7k | setNextLayer(newLayer); | 302 | 37.7k | return newLayer; | 303 | 37.7k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.28k | { | 295 | 1.28k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.28k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.28k | setNextLayer(newLayer); | 302 | 1.28k | return newLayer; | 303 | 1.28k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 2.61k | { | 295 | 2.61k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 2.61k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 2.61k | setNextLayer(newLayer); | 302 | 2.61k | return newLayer; | 303 | 2.61k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.70k | { | 295 | 4.70k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.70k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.70k | setNextLayer(newLayer); | 302 | 4.70k | return newLayer; | 303 | 4.70k | } |
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 | 294 | 9.49k | { | 295 | 9.49k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 9.49k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 9.49k | setNextLayer(newLayer); | 302 | 9.49k | return newLayer; | 303 | 9.49k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 217k | { | 295 | 217k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 217k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 217k | setNextLayer(newLayer); | 302 | 217k | return newLayer; | 303 | 217k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 618k | { | 295 | 618k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 618k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 618k | setNextLayer(newLayer); | 302 | 618k | return newLayer; | 303 | 618k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 13.0k | { | 295 | 13.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 13.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 13.0k | setNextLayer(newLayer); | 302 | 13.0k | return newLayer; | 303 | 13.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 9.88k | { | 295 | 9.88k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 9.88k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 9.88k | setNextLayer(newLayer); | 302 | 9.88k | return newLayer; | 303 | 9.88k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 11.0k | { | 295 | 11.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 11.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 11.0k | setNextLayer(newLayer); | 302 | 11.0k | return newLayer; | 303 | 11.0k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.57k | { | 295 | 1.57k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.57k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.57k | setNextLayer(newLayer); | 302 | 1.57k | return newLayer; | 303 | 1.57k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 20 | { | 295 | 20 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 20 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 20 | setNextLayer(newLayer); | 302 | 20 | return newLayer; | 303 | 20 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.84k | { | 295 | 1.84k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.84k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.84k | setNextLayer(newLayer); | 302 | 1.84k | return newLayer; | 303 | 1.84k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 23 | { | 295 | 23 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 23 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 23 | setNextLayer(newLayer); | 302 | 23 | return newLayer; | 303 | 23 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 45 | { | 295 | 45 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 45 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 45 | setNextLayer(newLayer); | 302 | 45 | return newLayer; | 303 | 45 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 9.01k | { | 295 | 9.01k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 9.01k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 9.01k | setNextLayer(newLayer); | 302 | 9.01k | return newLayer; | 303 | 9.01k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 294 | 14.6k | { | 295 | 14.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 14.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 14.6k | setNextLayer(newLayer); | 302 | 14.6k | return newLayer; | 303 | 14.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 17.9k | { | 295 | 17.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 17.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 17.9k | setNextLayer(newLayer); | 302 | 17.9k | return newLayer; | 303 | 17.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 16.4k | { | 295 | 16.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 16.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 16.4k | setNextLayer(newLayer); | 302 | 16.4k | return newLayer; | 303 | 16.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 480 | { | 295 | 480 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 480 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 480 | setNextLayer(newLayer); | 302 | 480 | return newLayer; | 303 | 480 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 7.96k | { | 295 | 7.96k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 7.96k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 7.96k | setNextLayer(newLayer); | 302 | 7.96k | return newLayer; | 303 | 7.96k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 85.5k | { | 295 | 85.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 85.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 85.5k | setNextLayer(newLayer); | 302 | 85.5k | return newLayer; | 303 | 85.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 13.9k | { | 295 | 13.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 13.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 13.9k | setNextLayer(newLayer); | 302 | 13.9k | return newLayer; | 303 | 13.9k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.86k | { | 295 | 1.86k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.86k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.86k | setNextLayer(newLayer); | 302 | 1.86k | return newLayer; | 303 | 1.86k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.39k | { | 295 | 3.39k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.39k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.39k | setNextLayer(newLayer); | 302 | 3.39k | return newLayer; | 303 | 3.39k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 7.42k | { | 295 | 7.42k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 7.42k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 7.42k | setNextLayer(newLayer); | 302 | 7.42k | return newLayer; | 303 | 7.42k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 9.01k | { | 295 | 9.01k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 9.01k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 9.01k | setNextLayer(newLayer); | 302 | 9.01k | return newLayer; | 303 | 9.01k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.74k | { | 295 | 3.74k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.74k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.74k | setNextLayer(newLayer); | 302 | 3.74k | return newLayer; | 303 | 3.74k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.11k | { | 295 | 1.11k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.11k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.11k | setNextLayer(newLayer); | 302 | 1.11k | return newLayer; | 303 | 1.11k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 7.01k | { | 295 | 7.01k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 7.01k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 7.01k | setNextLayer(newLayer); | 302 | 7.01k | return newLayer; | 303 | 7.01k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.67k | { | 295 | 1.67k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.67k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.67k | setNextLayer(newLayer); | 302 | 1.67k | return newLayer; | 303 | 1.67k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.75k | { | 295 | 4.75k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.75k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.75k | setNextLayer(newLayer); | 302 | 4.75k | return newLayer; | 303 | 4.75k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.23k | { | 295 | 1.23k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.23k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.23k | setNextLayer(newLayer); | 302 | 1.23k | return newLayer; | 303 | 1.23k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.85k | { | 295 | 6.85k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.85k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.85k | setNextLayer(newLayer); | 302 | 6.85k | return newLayer; | 303 | 6.85k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 17.8k | { | 295 | 17.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 17.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 17.8k | setNextLayer(newLayer); | 302 | 17.8k | return newLayer; | 303 | 17.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.70k | { | 295 | 4.70k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.70k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.70k | setNextLayer(newLayer); | 302 | 4.70k | return newLayer; | 303 | 4.70k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 46.0k | { | 295 | 46.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 46.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 46.0k | setNextLayer(newLayer); | 302 | 46.0k | return newLayer; | 303 | 46.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 20.0k | { | 295 | 20.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 20.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 20.0k | setNextLayer(newLayer); | 302 | 20.0k | return newLayer; | 303 | 20.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.65k | { | 295 | 6.65k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.65k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.65k | setNextLayer(newLayer); | 302 | 6.65k | return newLayer; | 303 | 6.65k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.30k | { | 295 | 1.30k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.30k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.30k | setNextLayer(newLayer); | 302 | 1.30k | return newLayer; | 303 | 1.30k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.33k | { | 295 | 3.33k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.33k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.33k | setNextLayer(newLayer); | 302 | 3.33k | return newLayer; | 303 | 3.33k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 320 | { | 295 | 320 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 320 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 320 | setNextLayer(newLayer); | 302 | 320 | return newLayer; | 303 | 320 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.69k | { | 295 | 4.69k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.69k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.69k | setNextLayer(newLayer); | 302 | 4.69k | return newLayer; | 303 | 4.69k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.27k | { | 295 | 4.27k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.27k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.27k | setNextLayer(newLayer); | 302 | 4.27k | return newLayer; | 303 | 4.27k | } |
|
304 | | |
305 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
306 | | /// |
307 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
308 | | /// If the factory returns a nullptr, no next layer is set. |
309 | | /// |
310 | | /// The factory functor is expected to have the following signature: |
311 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
312 | | /// |
313 | | /// This overload infers the Packet from the current layer. |
314 | | /// |
315 | | /// @tparam TFactory The factory functor type. |
316 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
317 | | /// @param[in] factoryFn The factory functor to create the layer. |
318 | | /// @param[in] data The data to construct the layer from |
319 | | /// @param[in] dataLen The length of the data |
320 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
321 | | /// @return The return value of the factory functor. |
322 | | template <typename TFactory, typename... Args> |
323 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs) |
324 | 409k | { |
325 | 409k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), |
326 | 409k | std::forward<Args>(extraArgs)...); |
327 | 409k | } 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 | 324 | 23.8k | { | 325 | 23.8k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 23.8k | std::forward<Args>(extraArgs)...); | 327 | 23.8k | } |
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 | 324 | 55.5k | { | 325 | 55.5k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 55.5k | std::forward<Args>(extraArgs)...); | 327 | 55.5k | } |
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 | 324 | 314k | { | 325 | 314k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 314k | std::forward<Args>(extraArgs)...); | 327 | 314k | } |
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 | 324 | 13.5k | { | 325 | 13.5k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 13.5k | std::forward<Args>(extraArgs)...); | 327 | 13.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 | 324 | 5 | { | 325 | 5 | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 5 | std::forward<Args>(extraArgs)...); | 327 | 5 | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 2.12k | { | 325 | 2.12k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 2.12k | std::forward<Args>(extraArgs)...); | 327 | 2.12k | } |
|
328 | | |
329 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
330 | | /// |
331 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
332 | | /// If the factory returns a nullptr, no next layer is set. |
333 | | /// |
334 | | /// The factory functor is expected to have the following signature: |
335 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
336 | | /// |
337 | | /// @tparam TFactory The factory functor type. |
338 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
339 | | /// @param[in] factoryFn The factory functor to create the layer. |
340 | | /// @param[in] data The data to construct the layer from |
341 | | /// @param[in] dataLen The length of the data |
342 | | /// @param[in] packet The packet the layer belongs to |
343 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
344 | | /// @return The return value of the factory functor. |
345 | | template <typename TFactory, typename... Args> |
346 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet, |
347 | | Args&&... extraArgs) |
348 | 496k | { |
349 | 496k | if (hasNextLayer()) |
350 | 0 | { |
351 | 0 | throw std::runtime_error("Next layer already exists"); |
352 | 0 | } |
353 | | |
354 | | // cppcheck-suppress redundantInitialization |
355 | 496k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
356 | 496k | setNextLayer(newLayer); |
357 | 496k | return newLayer; |
358 | 496k | } 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 | 348 | 46.8k | { | 349 | 46.8k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 46.8k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 46.8k | setNextLayer(newLayer); | 357 | 46.8k | return newLayer; | 358 | 46.8k | } |
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 | 348 | 55.5k | { | 349 | 55.5k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 55.5k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 55.5k | setNextLayer(newLayer); | 357 | 55.5k | return newLayer; | 358 | 55.5k | } |
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 | 348 | 314k | { | 349 | 314k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 314k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 314k | setNextLayer(newLayer); | 357 | 314k | return newLayer; | 358 | 314k | } |
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 | 348 | 13.5k | { | 349 | 13.5k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 13.5k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 13.5k | setNextLayer(newLayer); | 357 | 13.5k | return newLayer; | 358 | 13.5k | } |
Unexecuted instantiation: 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*) 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 | 348 | 156 | { | 349 | 156 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 156 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 156 | setNextLayer(newLayer); | 357 | 156 | return newLayer; | 358 | 156 | } |
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 | 348 | 25 | { | 349 | 25 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 25 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 25 | setNextLayer(newLayer); | 357 | 25 | return newLayer; | 358 | 25 | } |
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 | 348 | 381 | { | 349 | 381 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 381 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 381 | setNextLayer(newLayer); | 357 | 381 | return newLayer; | 358 | 381 | } |
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 | 348 | 11.8k | { | 349 | 11.8k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 11.8k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 11.8k | setNextLayer(newLayer); | 357 | 11.8k | return newLayer; | 358 | 11.8k | } |
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 | 348 | 340 | { | 349 | 340 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 340 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 340 | setNextLayer(newLayer); | 357 | 340 | return newLayer; | 358 | 340 | } |
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 | 348 | 51.5k | { | 349 | 51.5k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 51.5k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 51.5k | setNextLayer(newLayer); | 357 | 51.5k | return newLayer; | 358 | 51.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 2.12k | { | 349 | 2.12k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 2.12k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 2.12k | setNextLayer(newLayer); | 357 | 2.12k | return newLayer; | 358 | 2.12k | } |
|
359 | | |
360 | | /// Try to construct the next layer in the protocol stack. |
361 | | /// |
362 | | /// This overload infers the Packet from the current layer. |
363 | | /// |
364 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
365 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
366 | | /// |
367 | | /// @tparam T The type of the layer to construct |
368 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
369 | | /// @param[in] data The data to construct the layer from |
370 | | /// @param[in] dataLen The length of the data |
371 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
372 | | /// @return The constructed layer or nullptr if the data is invalid |
373 | | template <typename T, typename... Args> |
374 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
375 | 0 | { |
376 | 0 | return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
377 | 0 | } |
378 | | |
379 | | /// Try to construct the next layer in the protocol stack. |
380 | | /// |
381 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
382 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
383 | | /// |
384 | | /// @tparam T The type of the layer to construct |
385 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
386 | | /// @param[in] data The data to construct the layer from |
387 | | /// @param[in] dataLen The length of the data |
388 | | /// @param[in] packet The packet the layer belongs to |
389 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
390 | | /// @return The constructed layer or nullptr if the data is invalid |
391 | | template <typename T, typename... Args> |
392 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
393 | 1.89M | { |
394 | 1.89M | if (T::isDataValid(data, dataLen)) |
395 | 1.89M | { |
396 | 1.89M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); |
397 | 1.89M | } |
398 | 7.52k | return nullptr; |
399 | 1.89M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 687k | { | 394 | 687k | if (T::isDataValid(data, dataLen)) | 395 | 685k | { | 396 | 685k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 685k | } | 398 | 2.53k | return nullptr; | 399 | 687k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 215k | { | 394 | 215k | if (T::isDataValid(data, dataLen)) | 395 | 215k | { | 396 | 215k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 215k | } | 398 | 54 | return nullptr; | 399 | 215k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.61k | { | 394 | 2.61k | if (T::isDataValid(data, dataLen)) | 395 | 2.61k | { | 396 | 2.61k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.61k | } | 398 | 0 | return nullptr; | 399 | 2.61k | } |
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 | 393 | 5.05k | { | 394 | 5.05k | if (T::isDataValid(data, dataLen)) | 395 | 4.40k | { | 396 | 4.40k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.40k | } | 398 | 649 | return nullptr; | 399 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 217k | { | 394 | 217k | if (T::isDataValid(data, dataLen)) | 395 | 217k | { | 396 | 217k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 217k | } | 398 | 66 | return nullptr; | 399 | 217k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 621k | { | 394 | 621k | if (T::isDataValid(data, dataLen)) | 395 | 618k | { | 396 | 618k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 618k | } | 398 | 2.61k | return nullptr; | 399 | 621k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 13.4k | { | 394 | 13.4k | if (T::isDataValid(data, dataLen)) | 395 | 13.0k | { | 396 | 13.0k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 13.0k | } | 398 | 453 | return nullptr; | 399 | 13.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 9.88k | { | 394 | 9.88k | if (T::isDataValid(data, dataLen)) | 395 | 9.88k | { | 396 | 9.88k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 9.88k | } | 398 | 0 | return nullptr; | 399 | 9.88k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 11.0k | { | 394 | 11.0k | if (T::isDataValid(data, dataLen)) | 395 | 11.0k | { | 396 | 11.0k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 11.0k | } | 398 | 0 | return nullptr; | 399 | 11.0k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.57k | { | 394 | 1.57k | if (T::isDataValid(data, dataLen)) | 395 | 1.57k | { | 396 | 1.57k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.57k | } | 398 | 0 | return nullptr; | 399 | 1.57k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 20 | { | 394 | 20 | if (T::isDataValid(data, dataLen)) | 395 | 20 | { | 396 | 20 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 20 | } | 398 | 0 | return nullptr; | 399 | 20 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.84k | { | 394 | 1.84k | if (T::isDataValid(data, dataLen)) | 395 | 1.84k | { | 396 | 1.84k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.84k | } | 398 | 0 | return nullptr; | 399 | 1.84k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 23 | { | 394 | 23 | if (T::isDataValid(data, dataLen)) | 395 | 23 | { | 396 | 23 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 23 | } | 398 | 0 | return nullptr; | 399 | 23 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 45 | { | 394 | 45 | if (T::isDataValid(data, dataLen)) | 395 | 45 | { | 396 | 45 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 45 | } | 398 | 0 | return nullptr; | 399 | 45 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 9.01k | { | 394 | 9.01k | if (T::isDataValid(data, dataLen)) | 395 | 9.01k | { | 396 | 9.01k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 9.01k | } | 398 | 0 | return nullptr; | 399 | 9.01k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 393 | 4.38k | { | 394 | 4.38k | if (T::isDataValid(data, dataLen)) | 395 | 4.38k | { | 396 | 4.38k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.38k | } | 398 | 0 | return nullptr; | 399 | 4.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 16.4k | { | 394 | 16.4k | if (T::isDataValid(data, dataLen)) | 395 | 16.4k | { | 396 | 16.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 16.4k | } | 398 | 0 | return nullptr; | 399 | 16.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 480 | { | 394 | 480 | if (T::isDataValid(data, dataLen)) | 395 | 480 | { | 396 | 480 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 480 | } | 398 | 0 | return nullptr; | 399 | 480 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 8.06k | { | 394 | 8.06k | if (T::isDataValid(data, dataLen)) | 395 | 7.96k | { | 396 | 7.96k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 7.96k | } | 398 | 100 | return nullptr; | 399 | 8.06k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 7.01k | { | 394 | 7.01k | if (T::isDataValid(data, dataLen)) | 395 | 6.85k | { | 396 | 6.85k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 6.85k | } | 398 | 156 | return nullptr; | 399 | 7.01k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 17.9k | { | 394 | 17.9k | if (T::isDataValid(data, dataLen)) | 395 | 17.8k | { | 396 | 17.8k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 17.8k | } | 398 | 144 | return nullptr; | 399 | 17.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.70k | { | 394 | 4.70k | if (T::isDataValid(data, dataLen)) | 395 | 4.70k | { | 396 | 4.70k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.70k | } | 398 | 0 | return nullptr; | 399 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 5.21k | { | 394 | 5.21k | if (T::isDataValid(data, dataLen)) | 395 | 4.69k | { | 396 | 4.69k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.69k | } | 398 | 518 | return nullptr; | 399 | 5.21k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 12.3k | { | 394 | 12.3k | if (T::isDataValid(data, dataLen)) | 395 | 12.3k | { | 396 | 12.3k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 12.3k | } | 398 | 0 | return nullptr; | 399 | 12.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 25.3k | { | 394 | 25.3k | if (T::isDataValid(data, dataLen)) | 395 | 25.3k | { | 396 | 25.3k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 25.3k | } | 398 | 0 | return nullptr; | 399 | 25.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 26 | { | 394 | 26 | if (T::isDataValid(data, dataLen)) | 395 | 26 | { | 396 | 26 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 26 | } | 398 | 0 | return nullptr; | 399 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 243 | { | 394 | 243 | if (T::isDataValid(data, dataLen)) | 395 | 0 | { | 396 | 0 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 0 | } | 398 | 243 | return nullptr; | 399 | 243 | } |
|
400 | | |
401 | | /// @brief Try to construct the next layer in the protocol stack with a fallback option. |
402 | | /// |
403 | | /// This overload infers the Packet from the current layer. |
404 | | /// |
405 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
406 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
407 | | /// |
408 | | /// @tparam T The type of the layer to construct |
409 | | /// @tparam TFallback The fallback layer type to construct if T fails |
410 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
411 | | /// @param[in] data The data to construct the layer from |
412 | | /// @param[in] dataLen The length of the data |
413 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
414 | | /// @return The constructed layer of type T or TFallback |
415 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
416 | | /// constructor. |
417 | | template <typename T, typename TFallback, typename... Args> |
418 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
419 | 1.20M | { |
420 | 1.20M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), |
421 | 1.20M | std::forward<Args>(extraArgs)...); |
422 | 1.20M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 687k | { | 420 | 687k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 687k | std::forward<Args>(extraArgs)...); | 422 | 687k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 211k | { | 420 | 211k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 211k | std::forward<Args>(extraArgs)...); | 422 | 211k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 2.61k | { | 420 | 2.61k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 2.61k | std::forward<Args>(extraArgs)...); | 422 | 2.61k | } |
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 | 419 | 5.05k | { | 420 | 5.05k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.05k | std::forward<Args>(extraArgs)...); | 422 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 5.22k | { | 420 | 5.22k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.22k | std::forward<Args>(extraArgs)...); | 422 | 5.22k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 190k | { | 420 | 190k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 190k | std::forward<Args>(extraArgs)...); | 422 | 190k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 3.82k | { | 420 | 3.82k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 3.82k | std::forward<Args>(extraArgs)...); | 422 | 3.82k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 7 | { | 420 | 7 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 7 | std::forward<Args>(extraArgs)...); | 422 | 7 | } |
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 | 419 | 40 | { | 420 | 40 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 40 | std::forward<Args>(extraArgs)...); | 422 | 40 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 16.4k | { | 420 | 16.4k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 16.4k | std::forward<Args>(extraArgs)...); | 422 | 16.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 480 | { | 420 | 480 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 480 | std::forward<Args>(extraArgs)...); | 422 | 480 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 8.06k | { | 420 | 8.06k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 8.06k | std::forward<Args>(extraArgs)...); | 422 | 8.06k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 7.01k | { | 420 | 7.01k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 7.01k | std::forward<Args>(extraArgs)...); | 422 | 7.01k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 17.9k | { | 420 | 17.9k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 17.9k | std::forward<Args>(extraArgs)...); | 422 | 17.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 4.70k | { | 420 | 4.70k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 4.70k | std::forward<Args>(extraArgs)...); | 422 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 5.21k | { | 420 | 5.21k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.21k | std::forward<Args>(extraArgs)...); | 422 | 5.21k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 12.3k | { | 420 | 12.3k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 12.3k | std::forward<Args>(extraArgs)...); | 422 | 12.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 25.3k | { | 420 | 25.3k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 25.3k | std::forward<Args>(extraArgs)...); | 422 | 25.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 26 | { | 420 | 26 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 26 | std::forward<Args>(extraArgs)...); | 422 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 243 | { | 420 | 243 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 243 | std::forward<Args>(extraArgs)...); | 422 | 243 | } |
|
423 | | |
424 | | /// Try to construct the next layer in the protocol stack with a fallback option. |
425 | | /// |
426 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
427 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
428 | | /// |
429 | | /// @tparam T The type of the layer to construct |
430 | | /// @tparam TFallback The fallback layer type to construct if T fails |
431 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
432 | | /// @param[in] data The data to construct the layer from |
433 | | /// @param[in] dataLen The length of the data |
434 | | /// @param[in] packet The packet the layer belongs to |
435 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
436 | | /// @return The constructed layer of type T or TFallback |
437 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
438 | | /// constructor. |
439 | | template <typename T, typename TFallback, typename... Args> |
440 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
441 | 1.89M | { |
442 | 1.89M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) |
443 | 1.89M | { |
444 | 1.89M | return m_NextLayer; |
445 | 1.89M | } |
446 | | |
447 | 7.52k | return constructNextLayer<TFallback>(data, dataLen, packet); |
448 | 1.89M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 687k | { | 442 | 687k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 685k | { | 444 | 685k | return m_NextLayer; | 445 | 685k | } | 446 | | | 447 | 2.53k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 687k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 215k | { | 442 | 215k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 215k | { | 444 | 215k | return m_NextLayer; | 445 | 215k | } | 446 | | | 447 | 54 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 215k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.61k | { | 442 | 2.61k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.61k | { | 444 | 2.61k | return m_NextLayer; | 445 | 2.61k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.61k | } |
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 | 441 | 5.05k | { | 442 | 5.05k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.40k | { | 444 | 4.40k | return m_NextLayer; | 445 | 4.40k | } | 446 | | | 447 | 649 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 217k | { | 442 | 217k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 217k | { | 444 | 217k | return m_NextLayer; | 445 | 217k | } | 446 | | | 447 | 66 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 217k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 621k | { | 442 | 621k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 618k | { | 444 | 618k | return m_NextLayer; | 445 | 618k | } | 446 | | | 447 | 2.61k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 621k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 13.4k | { | 442 | 13.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 13.0k | { | 444 | 13.0k | return m_NextLayer; | 445 | 13.0k | } | 446 | | | 447 | 453 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 13.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 9.88k | { | 442 | 9.88k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 9.88k | { | 444 | 9.88k | return m_NextLayer; | 445 | 9.88k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 9.88k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 11.0k | { | 442 | 11.0k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 11.0k | { | 444 | 11.0k | return m_NextLayer; | 445 | 11.0k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 11.0k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.57k | { | 442 | 1.57k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.57k | { | 444 | 1.57k | return m_NextLayer; | 445 | 1.57k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.57k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 20 | { | 442 | 20 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 20 | { | 444 | 20 | return m_NextLayer; | 445 | 20 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 20 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.84k | { | 442 | 1.84k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.84k | { | 444 | 1.84k | return m_NextLayer; | 445 | 1.84k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.84k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 23 | { | 442 | 23 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 23 | { | 444 | 23 | return m_NextLayer; | 445 | 23 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 23 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 45 | { | 442 | 45 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 45 | { | 444 | 45 | return m_NextLayer; | 445 | 45 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 45 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 9.01k | { | 442 | 9.01k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 9.01k | { | 444 | 9.01k | return m_NextLayer; | 445 | 9.01k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 9.01k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV3Layer, pcpp::PayloadLayer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 441 | 4.38k | { | 442 | 4.38k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.38k | { | 444 | 4.38k | return m_NextLayer; | 445 | 4.38k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 16.4k | { | 442 | 16.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 16.4k | { | 444 | 16.4k | return m_NextLayer; | 445 | 16.4k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 16.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 480 | { | 442 | 480 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 480 | { | 444 | 480 | return m_NextLayer; | 445 | 480 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 480 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 8.06k | { | 442 | 8.06k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 7.96k | { | 444 | 7.96k | return m_NextLayer; | 445 | 7.96k | } | 446 | | | 447 | 100 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 8.06k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 7.01k | { | 442 | 7.01k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 6.85k | { | 444 | 6.85k | return m_NextLayer; | 445 | 6.85k | } | 446 | | | 447 | 156 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 7.01k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 17.9k | { | 442 | 17.9k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 17.8k | { | 444 | 17.8k | return m_NextLayer; | 445 | 17.8k | } | 446 | | | 447 | 144 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 17.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.70k | { | 442 | 4.70k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.70k | { | 444 | 4.70k | return m_NextLayer; | 445 | 4.70k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 5.21k | { | 442 | 5.21k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.69k | { | 444 | 4.69k | return m_NextLayer; | 445 | 4.69k | } | 446 | | | 447 | 518 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.21k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 12.3k | { | 442 | 12.3k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 12.3k | { | 444 | 12.3k | return m_NextLayer; | 445 | 12.3k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 12.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 25.3k | { | 442 | 25.3k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 25.3k | { | 444 | 25.3k | return m_NextLayer; | 445 | 25.3k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 25.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 26 | { | 442 | 26 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 26 | { | 444 | 26 | return m_NextLayer; | 445 | 26 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 243 | { | 442 | 243 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 0 | { | 444 | 0 | return m_NextLayer; | 445 | 0 | } | 446 | | | 447 | 243 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 243 | } |
|
449 | | |
450 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
451 | | /// |
452 | | /// The method will attempt to construct the next layer using the provided factory function. |
453 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
454 | | /// construct a layer of type TFallback. |
455 | | /// |
456 | | /// The factory functor is expected to have the following signature: |
457 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
458 | | /// |
459 | | /// This overload infers the Packet from the current layer. |
460 | | /// |
461 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
462 | | /// @tparam TFactory The factory functor type. |
463 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
464 | | /// @param[in] factoryFn The factory functor to create the layer. |
465 | | /// @param[in] data The data to construct the layer from |
466 | | /// @param[in] dataLen The length of the data |
467 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
468 | | /// @return The return value of the factory functor. |
469 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
470 | | /// constructor. |
471 | | template <typename TFallback, typename TFactory, typename... Args> |
472 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
473 | | Args&&... extraArgs) |
474 | 87.1k | { |
475 | | // Note that the fallback is first to allow template argument deduction of the factory type. |
476 | 87.1k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( |
477 | 87.1k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
478 | 87.1k | } 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 | 474 | 22.9k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 22.9k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 22.9k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 22.9k | } |
Unexecuted instantiation: 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::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 | 474 | 151 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 151 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 151 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 151 | } |
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 | 474 | 25 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 25 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 25 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 25 | } |
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 | 474 | 381 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 381 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 381 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 381 | } |
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 | 474 | 11.8k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 11.8k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 11.8k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 11.8k | } |
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 | 474 | 340 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 340 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 340 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 340 | } |
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 | 474 | 51.5k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 51.5k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 51.5k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 51.5k | } |
|
479 | | |
480 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
481 | | /// |
482 | | /// The method will attempt to construct the next layer using the provided factory function. |
483 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
484 | | /// construct a layer of type TFallback. |
485 | | /// |
486 | | /// The factory functor is expected to have the following signature: |
487 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
488 | | /// |
489 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
490 | | /// @tparam TFactory The factory functor type. |
491 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
492 | | /// @param[in] factoryFn The factory functor to create the layer. |
493 | | /// @param[in] data The data to construct the layer from |
494 | | /// @param[in] dataLen The length of the data |
495 | | /// @param[in] packet The packet the layer belongs to |
496 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
497 | | /// @return The return value of the factory functor. |
498 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
499 | | /// constructor. |
500 | | template <typename TFallback, typename TFactory, typename... Args> |
501 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
502 | | Packet* packet, Args&&... extraArgs) |
503 | 87.1k | { |
504 | 87.1k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, |
505 | 87.1k | std::forward<Args>(extraArgs)...); |
506 | 87.1k | if (nextLayer != nullptr) |
507 | 33.6k | { |
508 | 33.6k | return nextLayer; |
509 | 33.6k | } |
510 | | |
511 | | // factory failed, construct fallback layer |
512 | 53.5k | return constructNextLayer<TFallback>(data, dataLen, packet); |
513 | 87.1k | } 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 | 503 | 22.9k | { | 504 | 22.9k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 22.9k | std::forward<Args>(extraArgs)...); | 506 | 22.9k | if (nextLayer != nullptr) | 507 | 21.9k | { | 508 | 21.9k | return nextLayer; | 509 | 21.9k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 977 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 22.9k | } |
Unexecuted instantiation: 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*) 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 | 503 | 151 | { | 504 | 151 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 151 | std::forward<Args>(extraArgs)...); | 506 | 151 | if (nextLayer != nullptr) | 507 | 65 | { | 508 | 65 | return nextLayer; | 509 | 65 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 86 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 151 | } |
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 | 503 | 25 | { | 504 | 25 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 25 | std::forward<Args>(extraArgs)...); | 506 | 25 | if (nextLayer != nullptr) | 507 | 25 | { | 508 | 25 | return nextLayer; | 509 | 25 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 25 | } |
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 | 503 | 381 | { | 504 | 381 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 381 | std::forward<Args>(extraArgs)...); | 506 | 381 | if (nextLayer != nullptr) | 507 | 381 | { | 508 | 381 | return nextLayer; | 509 | 381 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 381 | } |
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 | 503 | 11.8k | { | 504 | 11.8k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 11.8k | std::forward<Args>(extraArgs)...); | 506 | 11.8k | if (nextLayer != nullptr) | 507 | 10.3k | { | 508 | 10.3k | return nextLayer; | 509 | 10.3k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 1.50k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 11.8k | } |
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 | 503 | 340 | { | 504 | 340 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 340 | std::forward<Args>(extraArgs)...); | 506 | 340 | if (nextLayer != nullptr) | 507 | 340 | { | 508 | 340 | return nextLayer; | 509 | 340 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 340 | } |
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 | 503 | 51.5k | { | 504 | 51.5k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 51.5k | std::forward<Args>(extraArgs)...); | 506 | 51.5k | if (nextLayer != nullptr) | 507 | 553 | { | 508 | 553 | return nextLayer; | 509 | 553 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 50.9k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 51.5k | } |
|
514 | | |
515 | | /// @brief Check if the data is large enough to reinterpret as a type |
516 | | /// |
517 | | /// The data must be non-null and at least as large as the type |
518 | | /// |
519 | | /// @tparam T The type to reinterpret as |
520 | | /// @param data The data to check |
521 | | /// @param dataLen The length of the data |
522 | | /// @return True if the data is large enough to reinterpret as T, false otherwise |
523 | | template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen) |
524 | 1.48M | { |
525 | 1.48M | return data != nullptr && dataLen >= sizeof(T); |
526 | 1.48M | } bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 12.3k | { | 525 | 12.3k | return data != nullptr && dataLen >= sizeof(T); | 526 | 12.3k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 706k | { | 525 | 706k | return data != nullptr && dataLen >= sizeof(T); | 526 | 706k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 17.9k | { | 525 | 17.9k | return data != nullptr && dataLen >= sizeof(T); | 526 | 17.9k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 13.4k | { | 525 | 13.4k | return data != nullptr && dataLen >= sizeof(T); | 526 | 13.4k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 217k | { | 525 | 217k | return data != nullptr && dataLen >= sizeof(T); | 526 | 217k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 25.3k | { | 525 | 25.3k | return data != nullptr && dataLen >= sizeof(T); | 526 | 25.3k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 26 | { | 525 | 26 | return data != nullptr && dataLen >= sizeof(T); | 526 | 26 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.57k | { | 525 | 1.57k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.57k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 20 | { | 525 | 20 | return data != nullptr && dataLen >= sizeof(T); | 526 | 20 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.84k | { | 525 | 1.84k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.84k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 314k | { | 525 | 314k | return data != nullptr && dataLen >= sizeof(T); | 526 | 314k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 166k | { | 525 | 166k | return data != nullptr && dataLen >= sizeof(T); | 526 | 166k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 4.70k | { | 525 | 4.70k | return data != nullptr && dataLen >= sizeof(T); | 526 | 4.70k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 768 | { | 525 | 768 | return data != nullptr && dataLen >= sizeof(T); | 526 | 768 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.22k | { | 525 | 1.22k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.22k | } |
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) |
527 | | }; |
528 | | |
529 | | inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer) |
530 | 0 | { |
531 | 0 | os << layer.toString(); |
532 | 0 | return os; |
533 | 0 | } |
534 | | } // namespace pcpp |