/src/PcapPlusPlus/Packet++/header/Layer.h
Line | Count | Source |
1 | | #pragma once |
2 | | |
3 | | #include <stdint.h> |
4 | | #include <stdio.h> |
5 | | #include "ProtocolType.h" |
6 | | #include <ostream> |
7 | | #include <string> |
8 | | #include <stdexcept> |
9 | | #include <utility> |
10 | | |
11 | | /// @file |
12 | | |
13 | | /// @namespace pcpp |
14 | | /// @brief The main namespace for the PcapPlusPlus lib |
15 | | namespace pcpp |
16 | | { |
17 | | |
18 | | /// @class IDataContainer |
19 | | /// An interface (virtual abstract class) that indicates an object that holds a pointer to a buffer data. The Layer |
20 | | /// class is an example of such object, hence it inherits this interface |
21 | | class IDataContainer |
22 | | { |
23 | | public: |
24 | | /// Get a pointer to the data |
25 | | /// @param[in] offset Get a pointer in a certain offset. Default is 0 - get a pointer to start of data |
26 | | /// @return A pointer to the data |
27 | | virtual uint8_t* getDataPtr(size_t offset = 0) const = 0; |
28 | | |
29 | 9.38M | virtual ~IDataContainer() = default; |
30 | | }; |
31 | | |
32 | | class Packet; |
33 | | |
34 | | namespace internal |
35 | | { |
36 | | /// @brief Holds information about a Layer's data and object ownership. |
37 | | struct LayerAllocationInfo |
38 | | { |
39 | | /// @brief Pointer to the Packet this layer is attached to (if any). |
40 | | /// |
41 | | /// If the layer is attached to a Packet, the layer's memory span (data) is considered managed by the |
42 | | /// Packet. The Packet is responsible for keeping the layer's memory span valid and updating it should it |
43 | | /// become necessary as long as the layer is attached to it. |
44 | | /// |
45 | | /// In an event the Packet is destroyed, all of its attached layers's memory views are considered invalid. |
46 | | /// Accessing layer data after the Packet is destroyed results in undefined behavior. |
47 | | /// |
48 | | /// If nullptr, the layer is not attached to any Packet and is considered unmanaged. |
49 | | /// It also means the layer's memory span is considered owned by the layer itself and will be freed when |
50 | | /// the layer is destroyed. |
51 | | Packet* attachedPacket = nullptr; |
52 | | |
53 | | /// @brief Controls if the layer object is considered owned by the attached Packet |
54 | | /// |
55 | | /// If 'true', the Layer object is considered owned by the attached Packet and will be freed by it on Packet |
56 | | /// destruction. |
57 | | /// |
58 | | /// If 'false', the Layer object is considered unmanaged and the user is responsible for freeing it. |
59 | | /// This is commonly the case for layers created on the stack and attached to a Packet. |
60 | | bool ownedByPacket = false; |
61 | | |
62 | | /// @brief Sets the state of attachment to a specified Packet |
63 | | /// @param packet Pointer to the Packet this layer is attached to (or nullptr if not attached to any Packet) |
64 | | /// @param managed True if the layer object's lifetime is to be managed by the Packet, false otherwise |
65 | | /// @param force If true, bypasses the check for existing attachment. Default is false. |
66 | | /// @throws std::runtime_error if the layer is already attached to a Packet and 'force' is false |
67 | | void attachPacket(Packet* packet, bool managed, bool force = false) |
68 | 0 | { |
69 | 0 | if (!force && attachedPacket != nullptr) |
70 | 0 | { |
71 | 0 | throw std::runtime_error("Layer is already attached to a Packet"); |
72 | 0 | } |
73 | 0 |
|
74 | 0 | attachedPacket = packet; |
75 | 0 | ownedByPacket = managed; |
76 | 0 | } |
77 | | |
78 | | /// @brief Clears the attachment to any Packet, resetting to unmanaged state. |
79 | | void detach() |
80 | 0 | { |
81 | 0 | attachedPacket = nullptr; |
82 | 0 | ownedByPacket = false; |
83 | 0 | } |
84 | | }; |
85 | | } // namespace internal |
86 | | |
87 | | /// @class Layer |
88 | | /// Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that |
89 | | /// inherits Layer. |
90 | | /// The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields. |
91 | | /// For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size, |
92 | | /// compute fields that can be automatically computed, print protocol data to string, etc. |
93 | | /// Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is |
94 | | /// represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer |
95 | | /// has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is |
96 | | /// abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer |
97 | | /// to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the |
98 | | /// packet. Here is an example packet showing this concept: |
99 | | /// |
100 | | /// @code{.unparsed} |
101 | | /// ==================================================== |
102 | | /// |Eth |IPv4 |TCP |Packet | |
103 | | /// |Header |Header |Header |Payload | |
104 | | /// ==================================================== |
105 | | /// |
106 | | /// |--------------------------------------------------| |
107 | | /// EthLayer data |
108 | | /// |---------------------------------------| |
109 | | /// IPv4Layer data |
110 | | /// |---------------------------| |
111 | | /// TcpLayer data |
112 | | /// |----------------| |
113 | | /// PayloadLayer data |
114 | | /// @endcode |
115 | | class Layer : public IDataContainer |
116 | | { |
117 | | friend class Packet; |
118 | | |
119 | | public: |
120 | | /// A destructor for this class. Frees the data if it was allocated by the layer constructor (see |
121 | | /// isAllocatedToPacket() for more info) |
122 | | ~Layer() override; |
123 | | |
124 | | /// @return A pointer to the next layer in the protocol stack or nullptr if the layer is the last one |
125 | | Layer* getNextLayer() const |
126 | 175M | { |
127 | 175M | return m_NextLayer; |
128 | 175M | } |
129 | | |
130 | | /// @return A pointer to the previous layer in the protocol stack or nullptr if the layer is the first one |
131 | | Layer* getPrevLayer() const |
132 | 3.47M | { |
133 | 3.47M | return m_PrevLayer; |
134 | 3.47M | } |
135 | | |
136 | | /// @return The protocol enum |
137 | | ProtocolType getProtocol() const |
138 | 125M | { |
139 | 125M | return m_Protocol; |
140 | 125M | } |
141 | | |
142 | | /// Check if the layer's protocol matches a protocol family |
143 | | /// @param protocolTypeFamily The protocol family to check |
144 | | /// @return True if the layer's protocol matches the protocol family, false otherwise |
145 | | bool isMemberOfProtocolFamily(ProtocolTypeFamily protocolTypeFamily) const; |
146 | | |
147 | | /// @return A pointer to the layer raw data. In most cases it'll be a pointer to the first byte of the header |
148 | | uint8_t* getData() const |
149 | 553k | { |
150 | 553k | return m_Data; |
151 | 553k | } |
152 | | |
153 | | /// @return The length in bytes of the data from the first byte of the header until the end of the packet |
154 | | size_t getDataLen() const |
155 | 5.60M | { |
156 | 5.60M | return m_DataLen; |
157 | 5.60M | } |
158 | | |
159 | | /// @return A pointer for the layer payload, meaning the first byte after the header |
160 | | uint8_t* getLayerPayload() const |
161 | 0 | { |
162 | 0 | return m_Data + getHeaderLen(); |
163 | 0 | } |
164 | | |
165 | | /// @return The size in bytes of the payload |
166 | | size_t getLayerPayloadSize() const |
167 | 74.2k | { |
168 | 74.2k | return m_DataLen - getHeaderLen(); |
169 | 74.2k | } |
170 | | |
171 | | /// Raw data in layers can come from one of sources: |
172 | | /// 1. from an existing packet - this is the case when parsing packets received from files or the network. In |
173 | | /// this case the data was already allocated by someone else, and layer only holds the pointer to the relevant |
174 | | /// place inside this data |
175 | | /// 2. when creating packets, data is allocated when layer is created. In this case the layer is responsible for |
176 | | /// freeing it as well |
177 | | /// |
178 | | /// @return Returns true if the data was allocated by an external source (a packet) or false if it was allocated |
179 | | /// by the layer itself |
180 | | bool isAllocatedToPacket() const |
181 | 9.38M | { |
182 | 9.38M | return m_AllocationInfo.attachedPacket != nullptr; |
183 | 9.38M | } |
184 | | |
185 | | /// Copy the raw data of this layer to another array |
186 | | /// @param[out] toArr The destination byte array |
187 | | void copyData(uint8_t* toArr) const; |
188 | | |
189 | | // implement abstract methods |
190 | | |
191 | | uint8_t* getDataPtr(size_t offset = 0) const override |
192 | 227k | { |
193 | 227k | return static_cast<uint8_t*>(m_Data + offset); |
194 | 227k | } |
195 | | |
196 | | // abstract methods |
197 | | |
198 | | /// Each layer is responsible for parsing the next layer |
199 | | virtual void parseNextLayer() = 0; |
200 | | |
201 | | /// @return The header length in bytes |
202 | | virtual size_t getHeaderLen() const = 0; |
203 | | |
204 | | /// Each layer can compute field values automatically using this method. This is an abstract method |
205 | | virtual void computeCalculateFields() = 0; |
206 | | |
207 | | /// @return A string representation of the layer most important data (should look like the layer description in |
208 | | /// Wireshark) |
209 | | virtual std::string toString() const = 0; |
210 | | |
211 | | /// @return The OSI Model layer this protocol belongs to |
212 | | virtual OsiModelLayer getOsiModelLayer() const = 0; |
213 | | |
214 | | protected: |
215 | | uint8_t* m_Data; |
216 | | size_t m_DataLen; |
217 | | ProtocolType m_Protocol; |
218 | | Layer* m_NextLayer; |
219 | | Layer* m_PrevLayer; |
220 | | |
221 | | private: |
222 | | internal::LayerAllocationInfo m_AllocationInfo; |
223 | | |
224 | | protected: |
225 | | Layer() : m_Data(nullptr), m_DataLen(0), m_Protocol(UnknownProtocol), m_NextLayer(nullptr), m_PrevLayer(nullptr) |
226 | 0 | {} |
227 | | |
228 | | Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol) |
229 | 9.11M | : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer), |
230 | 9.11M | m_AllocationInfo{ packet, false } |
231 | 9.11M | {} |
232 | | |
233 | | // Copy c'tor |
234 | | Layer(const Layer& other); |
235 | | Layer& operator=(const Layer& other); |
236 | | |
237 | | /// @brief Get a pointer to the Packet this layer is attached to (if any). |
238 | | /// @return A pointer to the Packet this layer is attached to, or nullptr if the layer is not attached. |
239 | | Packet* getAttachedPacket() |
240 | 8.60M | { |
241 | 8.60M | return m_AllocationInfo.attachedPacket; |
242 | 8.60M | } |
243 | | |
244 | | /// @brief Get a pointer to the Packet this layer is attached to (if any). |
245 | | /// @return A const pointer to the Packet this layer is attached to, or nullptr if the layer is not attached. |
246 | | Packet const* getAttachedPacket() const |
247 | 10.3k | { |
248 | 10.3k | return m_AllocationInfo.attachedPacket; |
249 | 10.3k | } |
250 | | |
251 | | void setNextLayer(Layer* nextLayer) |
252 | 7.21M | { |
253 | 7.21M | m_NextLayer = nextLayer; |
254 | 7.21M | } |
255 | | void setPrevLayer(Layer* prevLayer) |
256 | 0 | { |
257 | 0 | m_PrevLayer = prevLayer; |
258 | 0 | } |
259 | | |
260 | | virtual bool extendLayer(int offsetInLayer, size_t numOfBytesToExtend); |
261 | | virtual bool shortenLayer(int offsetInLayer, size_t numOfBytesToShorten); |
262 | | |
263 | | bool hasNextLayer() const |
264 | 12.9M | { |
265 | 12.9M | return m_NextLayer != nullptr; |
266 | 12.9M | } |
267 | | |
268 | | /// @brief Construct the next layer in the protocol stack. No validation is performed on the data. |
269 | | /// |
270 | | /// This overload infers the Packet from the current layer. |
271 | | /// |
272 | | /// @tparam T The type of the layer to construct |
273 | | /// @tparam Args The types of the arguments to pass to the layer constructor |
274 | | /// @param data The data to construct the layer from |
275 | | /// @param dataLen The length of the data |
276 | | /// @param extraArgs Extra arguments to be forwarded to the layer constructor |
277 | | /// @return The constructed layer |
278 | | template <typename T, typename... Args> |
279 | | Layer* constructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
280 | 631k | { |
281 | 631k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
282 | 631k | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 65.7k | { | 281 | 65.7k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 65.7k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 103k | { | 281 | 103k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 103k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 151k | { | 281 | 151k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 151k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&) Line | Count | Source | 280 | 14.2k | { | 281 | 14.2k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 14.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 9.01k | { | 281 | 9.01k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 9.01k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 113k | { | 281 | 113k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 113k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 32.8k | { | 281 | 32.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 32.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 41.9k | { | 281 | 41.9k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 41.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 7.48k | { | 281 | 7.48k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 7.48k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 22.8k | { | 281 | 22.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 22.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 20.4k | { | 281 | 20.4k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 20.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 1.00k | { | 281 | 1.00k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 1.00k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 6.20k | { | 281 | 6.20k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 6.20k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 40.8k | { | 281 | 40.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 40.8k | } |
|
283 | | |
284 | | /// Construct the next layer in the protocol stack. No validation is performed on the data. |
285 | | /// @tparam T The type of the layer to construct |
286 | | /// @tparam Args The types of the arguments to pass to the layer constructor |
287 | | /// @param[in] data The data to construct the layer from |
288 | | /// @param[in] dataLen The length of the data |
289 | | /// @param[in] packet The packet the layer belongs to |
290 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
291 | | /// @return The constructed layer |
292 | | template <typename T, typename... Args> |
293 | | Layer* constructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
294 | 5.88M | { |
295 | 5.88M | if (hasNextLayer()) |
296 | 0 | { |
297 | 0 | throw std::runtime_error("Next layer already exists"); |
298 | 0 | } |
299 | | |
300 | 5.88M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
301 | 5.88M | setNextLayer(newLayer); |
302 | 5.88M | return newLayer; |
303 | 5.88M | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.67M | { | 295 | 1.67M | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.67M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.67M | setNextLayer(newLayer); | 302 | 1.67M | return newLayer; | 303 | 1.67M | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 606k | { | 295 | 606k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 606k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 606k | setNextLayer(newLayer); | 302 | 606k | return newLayer; | 303 | 606k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 396k | { | 295 | 396k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 396k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 396k | setNextLayer(newLayer); | 302 | 396k | return newLayer; | 303 | 396k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 237k | { | 295 | 237k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 237k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 237k | setNextLayer(newLayer); | 302 | 237k | return newLayer; | 303 | 237k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 106k | { | 295 | 106k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 106k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 106k | setNextLayer(newLayer); | 302 | 106k | return newLayer; | 303 | 106k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 68.1k | { | 295 | 68.1k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 68.1k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 68.1k | setNextLayer(newLayer); | 302 | 68.1k | return newLayer; | 303 | 68.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.20k | { | 295 | 6.20k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.20k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.20k | setNextLayer(newLayer); | 302 | 6.20k | return newLayer; | 303 | 6.20k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 13.2k | { | 295 | 13.2k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 13.2k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 13.2k | setNextLayer(newLayer); | 302 | 13.2k | return newLayer; | 303 | 13.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 597k | { | 295 | 597k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 597k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 597k | setNextLayer(newLayer); | 302 | 597k | return newLayer; | 303 | 597k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.18M | { | 295 | 1.18M | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.18M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.18M | setNextLayer(newLayer); | 302 | 1.18M | return newLayer; | 303 | 1.18M | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 58.6k | { | 295 | 58.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 58.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 58.6k | setNextLayer(newLayer); | 302 | 58.6k | return newLayer; | 303 | 58.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 18.1k | { | 295 | 18.1k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 18.1k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 18.1k | setNextLayer(newLayer); | 302 | 18.1k | return newLayer; | 303 | 18.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 84.7k | { | 295 | 84.7k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 84.7k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 84.7k | setNextLayer(newLayer); | 302 | 84.7k | return newLayer; | 303 | 84.7k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.79k | { | 295 | 4.79k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.79k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.79k | setNextLayer(newLayer); | 302 | 4.79k | return newLayer; | 303 | 4.79k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 10.4k | { | 295 | 10.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 10.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 10.4k | setNextLayer(newLayer); | 302 | 10.4k | return newLayer; | 303 | 10.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 2.18k | { | 295 | 2.18k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 2.18k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 2.18k | setNextLayer(newLayer); | 302 | 2.18k | return newLayer; | 303 | 2.18k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.15k | { | 295 | 4.15k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.15k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.15k | setNextLayer(newLayer); | 302 | 4.15k | return newLayer; | 303 | 4.15k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.64k | { | 295 | 4.64k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.64k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.64k | setNextLayer(newLayer); | 302 | 4.64k | return newLayer; | 303 | 4.64k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 5.66k | { | 295 | 5.66k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 5.66k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 5.66k | setNextLayer(newLayer); | 302 | 5.66k | return newLayer; | 303 | 5.66k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 15.8k | { | 295 | 15.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 15.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 15.8k | setNextLayer(newLayer); | 302 | 15.8k | return newLayer; | 303 | 15.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 294 | 22.8k | { | 295 | 22.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 22.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 22.8k | setNextLayer(newLayer); | 302 | 22.8k | return newLayer; | 303 | 22.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 27.3k | { | 295 | 27.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 27.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 27.3k | setNextLayer(newLayer); | 302 | 27.3k | return newLayer; | 303 | 27.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 63.8k | { | 295 | 63.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 63.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 63.8k | setNextLayer(newLayer); | 302 | 63.8k | return newLayer; | 303 | 63.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.04k | { | 295 | 1.04k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.04k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.04k | setNextLayer(newLayer); | 302 | 1.04k | return newLayer; | 303 | 1.04k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 16.0k | { | 295 | 16.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 16.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 16.0k | setNextLayer(newLayer); | 302 | 16.0k | return newLayer; | 303 | 16.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 93.5k | { | 295 | 93.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 93.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 93.5k | setNextLayer(newLayer); | 302 | 93.5k | return newLayer; | 303 | 93.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 27.1k | { | 295 | 27.1k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 27.1k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 27.1k | setNextLayer(newLayer); | 302 | 27.1k | return newLayer; | 303 | 27.1k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.25k | { | 295 | 3.25k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.25k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.25k | setNextLayer(newLayer); | 302 | 3.25k | return newLayer; | 303 | 3.25k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 25.9k | { | 295 | 25.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 25.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 25.9k | setNextLayer(newLayer); | 302 | 25.9k | return newLayer; | 303 | 25.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 52.9k | { | 295 | 52.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 52.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 52.9k | setNextLayer(newLayer); | 302 | 52.9k | return newLayer; | 303 | 52.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 19.5k | { | 295 | 19.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 19.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 19.5k | setNextLayer(newLayer); | 302 | 19.5k | return newLayer; | 303 | 19.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.78k | { | 295 | 3.78k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.78k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.78k | setNextLayer(newLayer); | 302 | 3.78k | return newLayer; | 303 | 3.78k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.96k | { | 295 | 3.96k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.96k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.96k | setNextLayer(newLayer); | 302 | 3.96k | return newLayer; | 303 | 3.96k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 36.0k | { | 295 | 36.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 36.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 36.0k | setNextLayer(newLayer); | 302 | 36.0k | return newLayer; | 303 | 36.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.18k | { | 295 | 3.18k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.18k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.18k | setNextLayer(newLayer); | 302 | 3.18k | return newLayer; | 303 | 3.18k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.56k | { | 295 | 6.56k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.56k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.56k | setNextLayer(newLayer); | 302 | 6.56k | return newLayer; | 303 | 6.56k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 915 | { | 295 | 915 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 915 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 915 | setNextLayer(newLayer); | 302 | 915 | return newLayer; | 303 | 915 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 32.2k | { | 295 | 32.2k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 32.2k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 32.2k | setNextLayer(newLayer); | 302 | 32.2k | return newLayer; | 303 | 32.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 35.4k | { | 295 | 35.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 35.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 35.4k | setNextLayer(newLayer); | 302 | 35.4k | return newLayer; | 303 | 35.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.20k | { | 295 | 6.20k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.20k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.20k | setNextLayer(newLayer); | 302 | 6.20k | return newLayer; | 303 | 6.20k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 113k | { | 295 | 113k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 113k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 113k | setNextLayer(newLayer); | 302 | 113k | return newLayer; | 303 | 113k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 32.8k | { | 295 | 32.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 32.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 32.8k | setNextLayer(newLayer); | 302 | 32.8k | return newLayer; | 303 | 32.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 41.9k | { | 295 | 41.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 41.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 41.9k | setNextLayer(newLayer); | 302 | 41.9k | return newLayer; | 303 | 41.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 22.8k | { | 295 | 22.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 22.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 22.8k | setNextLayer(newLayer); | 302 | 22.8k | return newLayer; | 303 | 22.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 20.4k | { | 295 | 20.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 20.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 20.4k | setNextLayer(newLayer); | 302 | 20.4k | return newLayer; | 303 | 20.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.08k | { | 295 | 1.08k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.08k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.08k | setNextLayer(newLayer); | 302 | 1.08k | return newLayer; | 303 | 1.08k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 22.6k | { | 295 | 22.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 22.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 22.6k | setNextLayer(newLayer); | 302 | 22.6k | return newLayer; | 303 | 22.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 40.8k | { | 295 | 40.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 40.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 40.8k | setNextLayer(newLayer); | 302 | 40.8k | return newLayer; | 303 | 40.8k | } |
|
304 | | |
305 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
306 | | /// |
307 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
308 | | /// If the factory returns a nullptr, no next layer is set. |
309 | | /// |
310 | | /// The factory functor is expected to have the following signature: |
311 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
312 | | /// |
313 | | /// This overload infers the Packet from the current layer. |
314 | | /// |
315 | | /// @tparam TFactory The factory functor type. |
316 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
317 | | /// @param[in] factoryFn The factory functor to create the layer. |
318 | | /// @param[in] data The data to construct the layer from |
319 | | /// @param[in] dataLen The length of the data |
320 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
321 | | /// @return The return value of the factory functor. |
322 | | template <typename TFactory, typename... Args> |
323 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Args&&... extraArgs) |
324 | 913k | { |
325 | 913k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), |
326 | 913k | std::forward<Args>(extraArgs)...); |
327 | 913k | } pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 165k | { | 325 | 165k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 165k | std::forward<Args>(extraArgs)...); | 327 | 165k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 118k | { | 325 | 118k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 118k | std::forward<Args>(extraArgs)...); | 327 | 118k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 568k | { | 325 | 568k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 568k | std::forward<Args>(extraArgs)...); | 327 | 568k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 32.0k | { | 325 | 32.0k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 32.0k | std::forward<Args>(extraArgs)...); | 327 | 32.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 23.2k | { | 325 | 23.2k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 23.2k | std::forward<Args>(extraArgs)...); | 327 | 23.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 5.24k | { | 325 | 5.24k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 5.24k | std::forward<Args>(extraArgs)...); | 327 | 5.24k | } |
|
328 | | |
329 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
330 | | /// |
331 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
332 | | /// If the factory returns a nullptr, no next layer is set. |
333 | | /// |
334 | | /// The factory functor is expected to have the following signature: |
335 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
336 | | /// |
337 | | /// @tparam TFactory The factory functor type. |
338 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
339 | | /// @param[in] factoryFn The factory functor to create the layer. |
340 | | /// @param[in] data The data to construct the layer from |
341 | | /// @param[in] dataLen The length of the data |
342 | | /// @param[in] packet The packet the layer belongs to |
343 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
344 | | /// @return The return value of the factory functor. |
345 | | template <typename TFactory, typename... Args> |
346 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet, |
347 | | Args&&... extraArgs) |
348 | 1.26M | { |
349 | 1.26M | if (hasNextLayer()) |
350 | 0 | { |
351 | 0 | throw std::runtime_error("Next layer already exists"); |
352 | 0 | } |
353 | | |
354 | | // cppcheck-suppress redundantInitialization |
355 | 1.26M | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
356 | 1.26M | setNextLayer(newLayer); |
357 | 1.26M | return newLayer; |
358 | 1.26M | } pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 241k | { | 349 | 241k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 241k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 241k | setNextLayer(newLayer); | 357 | 241k | return newLayer; | 358 | 241k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::Layer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 118k | { | 349 | 118k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 118k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 118k | setNextLayer(newLayer); | 357 | 118k | return newLayer; | 358 | 118k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSLLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 568k | { | 349 | 568k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 568k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 568k | setNextLayer(newLayer); | 357 | 568k | return newLayer; | 358 | 568k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SSHLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 32.0k | { | 349 | 32.0k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 32.0k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 32.0k | setNextLayer(newLayer); | 357 | 32.0k | return newLayer; | 358 | 32.0k | } |
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 | 348 | 57.6k | { | 349 | 57.6k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 57.6k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 57.6k | setNextLayer(newLayer); | 357 | 57.6k | return newLayer; | 358 | 57.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 60.7k | { | 349 | 60.7k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 60.7k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 60.7k | setNextLayer(newLayer); | 357 | 60.7k | return newLayer; | 358 | 60.7k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 110 | { | 349 | 110 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 110 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 110 | setNextLayer(newLayer); | 357 | 110 | return newLayer; | 358 | 110 | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 1.04k | { | 349 | 1.04k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 1.04k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 1.04k | setNextLayer(newLayer); | 357 | 1.04k | return newLayer; | 358 | 1.04k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, pcpp::Packet*, unsigned short&, unsigned short&) Line | Count | Source | 348 | 74.8k | { | 349 | 74.8k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 74.8k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 74.8k | setNextLayer(newLayer); | 357 | 74.8k | return newLayer; | 358 | 74.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 3.16k | { | 349 | 3.16k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 3.16k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 3.16k | setNextLayer(newLayer); | 357 | 3.16k | return newLayer; | 358 | 3.16k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 105k | { | 349 | 105k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 105k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 105k | setNextLayer(newLayer); | 357 | 105k | return newLayer; | 358 | 105k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 5.24k | { | 349 | 5.24k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 5.24k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 5.24k | setNextLayer(newLayer); | 357 | 5.24k | return newLayer; | 358 | 5.24k | } |
|
359 | | |
360 | | /// Try to construct the next layer in the protocol stack. |
361 | | /// |
362 | | /// This overload infers the Packet from the current layer. |
363 | | /// |
364 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
365 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
366 | | /// |
367 | | /// @tparam T The type of the layer to construct |
368 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
369 | | /// @param[in] data The data to construct the layer from |
370 | | /// @param[in] dataLen The length of the data |
371 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
372 | | /// @return The constructed layer or nullptr if the data is invalid |
373 | | template <typename T, typename... Args> |
374 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
375 | 0 | { |
376 | 0 | return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
377 | 0 | } |
378 | | |
379 | | /// Try to construct the next layer in the protocol stack. |
380 | | /// |
381 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
382 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
383 | | /// |
384 | | /// @tparam T The type of the layer to construct |
385 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
386 | | /// @param[in] data The data to construct the layer from |
387 | | /// @param[in] dataLen The length of the data |
388 | | /// @param[in] packet The packet the layer belongs to |
389 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
390 | | /// @return The constructed layer or nullptr if the data is invalid |
391 | | template <typename T, typename... Args> |
392 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
393 | 4.57M | { |
394 | 4.57M | if (T::isDataValid(data, dataLen)) |
395 | 4.52M | { |
396 | 4.52M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); |
397 | 4.52M | } |
398 | 51.6k | return nullptr; |
399 | 4.57M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.69M | { | 394 | 1.69M | if (T::isDataValid(data, dataLen)) | 395 | 1.67M | { | 396 | 1.67M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.67M | } | 398 | 18.5k | return nullptr; | 399 | 1.69M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 400k | { | 394 | 400k | if (T::isDataValid(data, dataLen)) | 395 | 396k | { | 396 | 396k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 396k | } | 398 | 4.02k | return nullptr; | 399 | 400k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 68.7k | { | 394 | 68.7k | if (T::isDataValid(data, dataLen)) | 395 | 68.1k | { | 396 | 68.1k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 68.1k | } | 398 | 616 | return nullptr; | 399 | 68.7k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 7.38k | { | 394 | 7.38k | if (T::isDataValid(data, dataLen)) | 395 | 5.78k | { | 396 | 5.78k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 5.78k | } | 398 | 1.59k | return nullptr; | 399 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 600k | { | 394 | 600k | if (T::isDataValid(data, dataLen)) | 395 | 597k | { | 396 | 597k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 597k | } | 398 | 2.54k | return nullptr; | 399 | 600k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.20M | { | 394 | 1.20M | if (T::isDataValid(data, dataLen)) | 395 | 1.18M | { | 396 | 1.18M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.18M | } | 398 | 14.8k | return nullptr; | 399 | 1.20M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 59.9k | { | 394 | 59.9k | if (T::isDataValid(data, dataLen)) | 395 | 58.6k | { | 396 | 58.6k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 58.6k | } | 398 | 1.24k | return nullptr; | 399 | 59.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 18.1k | { | 394 | 18.1k | if (T::isDataValid(data, dataLen)) | 395 | 18.1k | { | 396 | 18.1k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 18.1k | } | 398 | 0 | return nullptr; | 399 | 18.1k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 84.7k | { | 394 | 84.7k | if (T::isDataValid(data, dataLen)) | 395 | 84.7k | { | 396 | 84.7k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 84.7k | } | 398 | 0 | return nullptr; | 399 | 84.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.79k | { | 394 | 4.79k | if (T::isDataValid(data, dataLen)) | 395 | 4.79k | { | 396 | 4.79k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.79k | } | 398 | 0 | return nullptr; | 399 | 4.79k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 10.4k | { | 394 | 10.4k | if (T::isDataValid(data, dataLen)) | 395 | 10.4k | { | 396 | 10.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 10.4k | } | 398 | 0 | return nullptr; | 399 | 10.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.18k | { | 394 | 2.18k | if (T::isDataValid(data, dataLen)) | 395 | 2.18k | { | 396 | 2.18k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.18k | } | 398 | 0 | return nullptr; | 399 | 2.18k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.15k | { | 394 | 4.15k | if (T::isDataValid(data, dataLen)) | 395 | 4.15k | { | 396 | 4.15k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.15k | } | 398 | 0 | return nullptr; | 399 | 4.15k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.78k | { | 394 | 4.78k | if (T::isDataValid(data, dataLen)) | 395 | 4.64k | { | 396 | 4.64k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.64k | } | 398 | 138 | return nullptr; | 399 | 4.78k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 5.66k | { | 394 | 5.66k | if (T::isDataValid(data, dataLen)) | 395 | 5.66k | { | 396 | 5.66k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 5.66k | } | 398 | 0 | return nullptr; | 399 | 5.66k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 15.8k | { | 394 | 15.8k | if (T::isDataValid(data, dataLen)) | 395 | 15.8k | { | 396 | 15.8k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 15.8k | } | 398 | 0 | return nullptr; | 399 | 15.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 393 | 8.57k | { | 394 | 8.57k | if (T::isDataValid(data, dataLen)) | 395 | 8.57k | { | 396 | 8.57k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 8.57k | } | 398 | 0 | return nullptr; | 399 | 8.57k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 63.9k | { | 394 | 63.9k | if (T::isDataValid(data, dataLen)) | 395 | 63.8k | { | 396 | 63.8k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 63.8k | } | 398 | 128 | return nullptr; | 399 | 63.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.04k | { | 394 | 1.04k | if (T::isDataValid(data, dataLen)) | 395 | 1.04k | { | 396 | 1.04k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.04k | } | 398 | 0 | return nullptr; | 399 | 1.04k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 17.0k | { | 394 | 17.0k | if (T::isDataValid(data, dataLen)) | 395 | 16.0k | { | 396 | 16.0k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 16.0k | } | 398 | 1.00k | return nullptr; | 399 | 17.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 35.9k | { | 394 | 35.9k | if (T::isDataValid(data, dataLen)) | 395 | 32.2k | { | 396 | 32.2k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 32.2k | } | 398 | 3.71k | return nullptr; | 399 | 35.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 35.8k | { | 394 | 35.8k | if (T::isDataValid(data, dataLen)) | 395 | 35.4k | { | 396 | 35.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 35.4k | } | 398 | 366 | return nullptr; | 399 | 35.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 6.20k | { | 394 | 6.20k | if (T::isDataValid(data, dataLen)) | 395 | 6.20k | { | 396 | 6.20k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 6.20k | } | 398 | 0 | return nullptr; | 399 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 24.7k | { | 394 | 24.7k | if (T::isDataValid(data, dataLen)) | 395 | 22.6k | { | 396 | 22.6k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 22.6k | } | 398 | 2.11k | return nullptr; | 399 | 24.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 18.3k | { | 394 | 18.3k | if (T::isDataValid(data, dataLen)) | 395 | 18.3k | { | 396 | 18.3k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 18.3k | } | 398 | 15 | return nullptr; | 399 | 18.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 172k | { | 394 | 172k | if (T::isDataValid(data, dataLen)) | 395 | 171k | { | 396 | 171k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 171k | } | 398 | 261 | return nullptr; | 399 | 172k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.74k | { | 394 | 2.74k | if (T::isDataValid(data, dataLen)) | 395 | 2.74k | { | 396 | 2.74k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.74k | } | 398 | 0 | return nullptr; | 399 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 519 | { | 394 | 519 | if (T::isDataValid(data, dataLen)) | 395 | 87 | { | 396 | 87 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 87 | } | 398 | 432 | return nullptr; | 399 | 519 | } |
|
400 | | |
401 | | /// @brief Try to construct the next layer in the protocol stack with a fallback option. |
402 | | /// |
403 | | /// This overload infers the Packet from the current layer. |
404 | | /// |
405 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
406 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
407 | | /// |
408 | | /// @tparam T The type of the layer to construct |
409 | | /// @tparam TFallback The fallback layer type to construct if T fails |
410 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
411 | | /// @param[in] data The data to construct the layer from |
412 | | /// @param[in] dataLen The length of the data |
413 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
414 | | /// @return The constructed layer of type T or TFallback |
415 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
416 | | /// constructor. |
417 | | template <typename T, typename TFallback, typename... Args> |
418 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
419 | 2.90M | { |
420 | 2.90M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), |
421 | 2.90M | std::forward<Args>(extraArgs)...); |
422 | 2.90M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 1.69M | { | 420 | 1.69M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 1.69M | std::forward<Args>(extraArgs)...); | 422 | 1.69M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 393k | { | 420 | 393k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 393k | std::forward<Args>(extraArgs)...); | 422 | 393k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 68.7k | { | 420 | 68.7k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 68.7k | std::forward<Args>(extraArgs)...); | 422 | 68.7k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 7.38k | { | 420 | 7.38k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 7.38k | std::forward<Args>(extraArgs)...); | 422 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 42.7k | { | 420 | 42.7k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 42.7k | std::forward<Args>(extraArgs)...); | 422 | 42.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 303k | { | 420 | 303k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 303k | std::forward<Args>(extraArgs)...); | 422 | 303k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 9.93k | { | 420 | 9.93k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 9.93k | std::forward<Args>(extraArgs)...); | 422 | 9.93k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 5.64k | { | 420 | 5.64k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.64k | std::forward<Args>(extraArgs)...); | 422 | 5.64k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 3.43k | { | 420 | 3.43k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 3.43k | std::forward<Args>(extraArgs)...); | 422 | 3.43k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 63.9k | { | 420 | 63.9k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 63.9k | std::forward<Args>(extraArgs)...); | 422 | 63.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 1.04k | { | 420 | 1.04k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 1.04k | std::forward<Args>(extraArgs)...); | 422 | 1.04k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 17.0k | { | 420 | 17.0k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 17.0k | std::forward<Args>(extraArgs)...); | 422 | 17.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 35.9k | { | 420 | 35.9k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 35.9k | std::forward<Args>(extraArgs)...); | 422 | 35.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 35.8k | { | 420 | 35.8k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 35.8k | std::forward<Args>(extraArgs)...); | 422 | 35.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 6.20k | { | 420 | 6.20k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 6.20k | std::forward<Args>(extraArgs)...); | 422 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 24.7k | { | 420 | 24.7k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 24.7k | std::forward<Args>(extraArgs)...); | 422 | 24.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 18.3k | { | 420 | 18.3k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 18.3k | std::forward<Args>(extraArgs)...); | 422 | 18.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 172k | { | 420 | 172k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 172k | std::forward<Args>(extraArgs)...); | 422 | 172k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 2.74k | { | 420 | 2.74k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 2.74k | std::forward<Args>(extraArgs)...); | 422 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 519 | { | 420 | 519 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 519 | std::forward<Args>(extraArgs)...); | 422 | 519 | } |
|
423 | | |
424 | | /// Try to construct the next layer in the protocol stack with a fallback option. |
425 | | /// |
426 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
427 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
428 | | /// |
429 | | /// @tparam T The type of the layer to construct |
430 | | /// @tparam TFallback The fallback layer type to construct if T fails |
431 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
432 | | /// @param[in] data The data to construct the layer from |
433 | | /// @param[in] dataLen The length of the data |
434 | | /// @param[in] packet The packet the layer belongs to |
435 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
436 | | /// @return The constructed layer of type T or TFallback |
437 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
438 | | /// constructor. |
439 | | template <typename T, typename TFallback, typename... Args> |
440 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
441 | 4.57M | { |
442 | 4.57M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) |
443 | 4.52M | { |
444 | 4.52M | return m_NextLayer; |
445 | 4.52M | } |
446 | | |
447 | 51.6k | return constructNextLayer<TFallback>(data, dataLen, packet); |
448 | 4.57M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.69M | { | 442 | 1.69M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.67M | { | 444 | 1.67M | return m_NextLayer; | 445 | 1.67M | } | 446 | | | 447 | 18.5k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.69M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 400k | { | 442 | 400k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 396k | { | 444 | 396k | return m_NextLayer; | 445 | 396k | } | 446 | | | 447 | 4.02k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 400k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 68.7k | { | 442 | 68.7k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 68.1k | { | 444 | 68.1k | return m_NextLayer; | 445 | 68.1k | } | 446 | | | 447 | 616 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 68.7k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 7.38k | { | 442 | 7.38k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 5.78k | { | 444 | 5.78k | return m_NextLayer; | 445 | 5.78k | } | 446 | | | 447 | 1.59k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 600k | { | 442 | 600k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 597k | { | 444 | 597k | return m_NextLayer; | 445 | 597k | } | 446 | | | 447 | 2.54k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 600k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.20M | { | 442 | 1.20M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.18M | { | 444 | 1.18M | return m_NextLayer; | 445 | 1.18M | } | 446 | | | 447 | 14.8k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.20M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 59.9k | { | 442 | 59.9k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 58.6k | { | 444 | 58.6k | return m_NextLayer; | 445 | 58.6k | } | 446 | | | 447 | 1.24k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 59.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 18.1k | { | 442 | 18.1k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 18.1k | { | 444 | 18.1k | return m_NextLayer; | 445 | 18.1k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 18.1k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 84.7k | { | 442 | 84.7k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 84.7k | { | 444 | 84.7k | return m_NextLayer; | 445 | 84.7k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 84.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.79k | { | 442 | 4.79k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.79k | { | 444 | 4.79k | return m_NextLayer; | 445 | 4.79k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.79k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 10.4k | { | 442 | 10.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 10.4k | { | 444 | 10.4k | return m_NextLayer; | 445 | 10.4k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 10.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.18k | { | 442 | 2.18k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.18k | { | 444 | 2.18k | return m_NextLayer; | 445 | 2.18k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.18k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.15k | { | 442 | 4.15k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.15k | { | 444 | 4.15k | return m_NextLayer; | 445 | 4.15k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.15k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.78k | { | 442 | 4.78k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.64k | { | 444 | 4.64k | return m_NextLayer; | 445 | 4.64k | } | 446 | | | 447 | 138 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.78k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 5.66k | { | 442 | 5.66k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 5.66k | { | 444 | 5.66k | return m_NextLayer; | 445 | 5.66k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.66k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 15.8k | { | 442 | 15.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 15.8k | { | 444 | 15.8k | return m_NextLayer; | 445 | 15.8k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 15.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV3Layer, pcpp::PayloadLayer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 441 | 8.57k | { | 442 | 8.57k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 8.57k | { | 444 | 8.57k | return m_NextLayer; | 445 | 8.57k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 8.57k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 63.9k | { | 442 | 63.9k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 63.8k | { | 444 | 63.8k | return m_NextLayer; | 445 | 63.8k | } | 446 | | | 447 | 128 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 63.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.04k | { | 442 | 1.04k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.04k | { | 444 | 1.04k | return m_NextLayer; | 445 | 1.04k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.04k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 17.0k | { | 442 | 17.0k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 16.0k | { | 444 | 16.0k | return m_NextLayer; | 445 | 16.0k | } | 446 | | | 447 | 1.00k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 17.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 35.9k | { | 442 | 35.9k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 32.2k | { | 444 | 32.2k | return m_NextLayer; | 445 | 32.2k | } | 446 | | | 447 | 3.71k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 35.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 35.8k | { | 442 | 35.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 35.4k | { | 444 | 35.4k | return m_NextLayer; | 445 | 35.4k | } | 446 | | | 447 | 366 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 35.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 6.20k | { | 442 | 6.20k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 6.20k | { | 444 | 6.20k | return m_NextLayer; | 445 | 6.20k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 24.7k | { | 442 | 24.7k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 22.6k | { | 444 | 22.6k | return m_NextLayer; | 445 | 22.6k | } | 446 | | | 447 | 2.11k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 24.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 18.3k | { | 442 | 18.3k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 18.3k | { | 444 | 18.3k | return m_NextLayer; | 445 | 18.3k | } | 446 | | | 447 | 15 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 18.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 172k | { | 442 | 172k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 171k | { | 444 | 171k | return m_NextLayer; | 445 | 171k | } | 446 | | | 447 | 261 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 172k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.74k | { | 442 | 2.74k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.74k | { | 444 | 2.74k | return m_NextLayer; | 445 | 2.74k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 519 | { | 442 | 519 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 87 | { | 444 | 87 | return m_NextLayer; | 445 | 87 | } | 446 | | | 447 | 432 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 519 | } |
|
449 | | |
450 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
451 | | /// |
452 | | /// The method will attempt to construct the next layer using the provided factory function. |
453 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
454 | | /// construct a layer of type TFallback. |
455 | | /// |
456 | | /// The factory functor is expected to have the following signature: |
457 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
458 | | /// |
459 | | /// This overload infers the Packet from the current layer. |
460 | | /// |
461 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
462 | | /// @tparam TFactory The factory functor type. |
463 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
464 | | /// @param[in] factoryFn The factory functor to create the layer. |
465 | | /// @param[in] data The data to construct the layer from |
466 | | /// @param[in] dataLen The length of the data |
467 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
468 | | /// @return The return value of the factory functor. |
469 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
470 | | /// constructor. |
471 | | template <typename TFallback, typename TFactory, typename... Args> |
472 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
473 | | Args&&... extraArgs) |
474 | 356k | { |
475 | | // Note that the fallback is first to allow template argument deduction of the factory type. |
476 | 356k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( |
477 | 356k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
478 | 356k | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 75.9k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 75.9k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 75.9k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 75.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 | 474 | 57.6k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 57.6k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 57.6k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 57.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 37.5k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 37.5k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 37.5k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 37.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 | 474 | 110 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 110 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 110 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 110 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 1.04k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 1.04k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 1.04k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 1.04k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, unsigned short&, unsigned short&) Line | Count | Source | 474 | 74.8k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 74.8k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 74.8k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 74.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 3.16k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 3.16k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 3.16k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 3.16k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 105k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 105k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 105k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 105k | } |
|
479 | | |
480 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
481 | | /// |
482 | | /// The method will attempt to construct the next layer using the provided factory function. |
483 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
484 | | /// construct a layer of type TFallback. |
485 | | /// |
486 | | /// The factory functor is expected to have the following signature: |
487 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
488 | | /// |
489 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
490 | | /// @tparam TFactory The factory functor type. |
491 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
492 | | /// @param[in] factoryFn The factory functor to create the layer. |
493 | | /// @param[in] data The data to construct the layer from |
494 | | /// @param[in] dataLen The length of the data |
495 | | /// @param[in] packet The packet the layer belongs to |
496 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
497 | | /// @return The return value of the factory functor. |
498 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
499 | | /// constructor. |
500 | | template <typename TFallback, typename TFactory, typename... Args> |
501 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
502 | | Packet* packet, Args&&... extraArgs) |
503 | 356k | { |
504 | 356k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, |
505 | 356k | std::forward<Args>(extraArgs)...); |
506 | 356k | if (nextLayer != nullptr) |
507 | 237k | { |
508 | 237k | return nextLayer; |
509 | 237k | } |
510 | | |
511 | | // factory failed, construct fallback layer |
512 | 118k | return constructNextLayer<TFallback>(data, dataLen, packet); |
513 | 356k | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::BgpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 75.9k | { | 504 | 75.9k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 75.9k | std::forward<Args>(extraArgs)...); | 506 | 75.9k | if (nextLayer != nullptr) | 507 | 72.5k | { | 508 | 72.5k | return nextLayer; | 509 | 72.5k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 3.40k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 75.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 | 503 | 57.6k | { | 504 | 57.6k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 57.6k | std::forward<Args>(extraArgs)...); | 506 | 57.6k | if (nextLayer != nullptr) | 507 | 57.4k | { | 508 | 57.4k | return nextLayer; | 509 | 57.4k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 264 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 57.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 37.5k | { | 504 | 37.5k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 37.5k | std::forward<Args>(extraArgs)...); | 506 | 37.5k | if (nextLayer != nullptr) | 507 | 32.5k | { | 508 | 32.5k | return nextLayer; | 509 | 32.5k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 5.06k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 37.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 | 503 | 110 | { | 504 | 110 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 110 | std::forward<Args>(extraArgs)...); | 506 | 110 | if (nextLayer != nullptr) | 507 | 110 | { | 508 | 110 | return nextLayer; | 509 | 110 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 110 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::MySqlLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 1.04k | { | 504 | 1.04k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 1.04k | std::forward<Args>(extraArgs)...); | 506 | 1.04k | if (nextLayer != nullptr) | 507 | 1.04k | { | 508 | 1.04k | return nextLayer; | 509 | 1.04k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 1.04k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned short&, unsigned short&>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*, unsigned short, unsigned short), unsigned char*, unsigned long, pcpp::Packet*, unsigned short&, unsigned short&) Line | Count | Source | 503 | 74.8k | { | 504 | 74.8k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 74.8k | std::forward<Args>(extraArgs)...); | 506 | 74.8k | if (nextLayer != nullptr) | 507 | 69.4k | { | 508 | 69.4k | return nextLayer; | 509 | 69.4k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 5.32k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 74.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 3.16k | { | 504 | 3.16k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 3.16k | std::forward<Args>(extraArgs)...); | 506 | 3.16k | if (nextLayer != nullptr) | 507 | 3.16k | { | 508 | 3.16k | return nextLayer; | 509 | 3.16k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 3.16k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::SipLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 105k | { | 504 | 105k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 105k | std::forward<Args>(extraArgs)...); | 506 | 105k | if (nextLayer != nullptr) | 507 | 1.49k | { | 508 | 1.49k | return nextLayer; | 509 | 1.49k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 104k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 105k | } |
|
514 | | |
515 | | /// @brief Check if the data is large enough to reinterpret as a type |
516 | | /// |
517 | | /// The data must be non-null and at least as large as the type |
518 | | /// |
519 | | /// @tparam T The type to reinterpret as |
520 | | /// @param data The data to check |
521 | | /// @param dataLen The length of the data |
522 | | /// @return True if the data is large enough to reinterpret as T, false otherwise |
523 | | template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen) |
524 | 3.30M | { |
525 | 3.30M | return data != nullptr && dataLen >= sizeof(T); |
526 | 3.30M | } bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 18.3k | { | 525 | 18.3k | return data != nullptr && dataLen >= sizeof(T); | 526 | 18.3k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.71M | { | 525 | 1.71M | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.71M | } |
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 35.8k | { | 525 | 35.8k | return data != nullptr && dataLen >= sizeof(T); | 526 | 35.8k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 24.3k | { | 525 | 24.3k | return data != nullptr && dataLen >= sizeof(T); | 526 | 24.3k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 403k | { | 525 | 403k | return data != nullptr && dataLen >= sizeof(T); | 526 | 403k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 172k | { | 525 | 172k | return data != nullptr && dataLen >= sizeof(T); | 526 | 172k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 2.74k | { | 525 | 2.74k | return data != nullptr && dataLen >= sizeof(T); | 526 | 2.74k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 15.2k | { | 525 | 15.2k | return data != nullptr && dataLen >= sizeof(T); | 526 | 15.2k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 2.18k | { | 525 | 2.18k | return data != nullptr && dataLen >= sizeof(T); | 526 | 2.18k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 4.15k | { | 525 | 4.15k | return data != nullptr && dataLen >= sizeof(T); | 526 | 4.15k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 568k | { | 525 | 568k | return data != nullptr && dataLen >= sizeof(T); | 526 | 568k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 335k | { | 525 | 335k | return data != nullptr && dataLen >= sizeof(T); | 526 | 335k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 6.20k | { | 525 | 6.20k | return data != nullptr && dataLen >= sizeof(T); | 526 | 6.20k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.97k | { | 525 | 1.97k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.97k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.98k | { | 525 | 1.98k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.98k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::rstp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.08k | { | 525 | 1.08k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.08k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::mstp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 68 | { | 525 | 68 | return data != nullptr && dataLen >= sizeof(T); | 526 | 68 | } |
|
527 | | }; |
528 | | |
529 | | inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer) |
530 | 0 | { |
531 | 0 | os << layer.toString(); |
532 | 0 | return os; |
533 | 0 | } |
534 | | } // namespace pcpp |