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