/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 | 8.63M | 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 | 161M | { |
127 | 161M | return m_NextLayer; |
128 | 161M | } |
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.13M | { |
133 | 3.13M | return m_PrevLayer; |
134 | 3.13M | } |
135 | | |
136 | | /// @return The protocol enum |
137 | | ProtocolType getProtocol() const |
138 | 115M | { |
139 | 115M | return m_Protocol; |
140 | 115M | } |
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 | 513k | { |
150 | 513k | return m_Data; |
151 | 513k | } |
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.69M | { |
156 | 5.69M | return m_DataLen; |
157 | 5.69M | } |
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 | 78.4k | { |
168 | 78.4k | return m_DataLen - getHeaderLen(); |
169 | 78.4k | } |
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 | 8.63M | { |
182 | 8.63M | return m_AllocationInfo.attachedPacket != nullptr; |
183 | 8.63M | } |
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 | 203k | { |
193 | 203k | return static_cast<uint8_t*>(m_Data + offset); |
194 | 203k | } |
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 | 8.38M | : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer), |
230 | 8.38M | m_AllocationInfo{ packet, false } |
231 | 8.38M | {} |
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 | 7.85M | { |
241 | 7.85M | return m_AllocationInfo.attachedPacket; |
242 | 7.85M | } |
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 | 9.81k | { |
248 | 9.81k | return m_AllocationInfo.attachedPacket; |
249 | 9.81k | } |
250 | | |
251 | | void setNextLayer(Layer* nextLayer) |
252 | 6.61M | { |
253 | 6.61M | m_NextLayer = nextLayer; |
254 | 6.61M | } |
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 | 11.9M | { |
265 | 11.9M | return m_NextLayer != nullptr; |
266 | 11.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 | 510k | { |
281 | 510k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
282 | 510k | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 69.3k | { | 281 | 69.3k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 69.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 5.72k | { | 281 | 5.72k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 5.72k | } |
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 | 13.8k | { | 281 | 13.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 13.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 7.22k | { | 281 | 7.22k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 7.22k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 97.1k | { | 281 | 97.1k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 97.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 30.3k | { | 281 | 30.3k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 30.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 39.4k | { | 281 | 39.4k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 39.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 5.07k | { | 281 | 5.07k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 5.07k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 19.6k | { | 281 | 19.6k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 19.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 17.8k | { | 281 | 17.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 17.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 1.13k | { | 281 | 1.13k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 1.13k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 4.70k | { | 281 | 4.70k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 4.70k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 47.7k | { | 281 | 47.7k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 47.7k | } |
|
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.37M | { |
295 | 5.37M | if (hasNextLayer()) |
296 | 0 | { |
297 | 0 | throw std::runtime_error("Next layer already exists"); |
298 | 0 | } |
299 | | |
300 | 5.37M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
301 | 5.37M | setNextLayer(newLayer); |
302 | 5.37M | return newLayer; |
303 | 5.37M | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.56M | { | 295 | 1.56M | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.56M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.56M | setNextLayer(newLayer); | 302 | 1.56M | return newLayer; | 303 | 1.56M | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 541k | { | 295 | 541k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 541k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 541k | setNextLayer(newLayer); | 302 | 541k | return newLayer; | 303 | 541k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 365k | { | 295 | 365k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 365k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 365k | setNextLayer(newLayer); | 302 | 365k | return newLayer; | 303 | 365k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 234k | { | 295 | 234k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 234k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 234k | setNextLayer(newLayer); | 302 | 234k | return newLayer; | 303 | 234k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 5.75k | { | 295 | 5.75k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 5.75k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 5.75k | setNextLayer(newLayer); | 302 | 5.75k | return newLayer; | 303 | 5.75k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 67.8k | { | 295 | 67.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 67.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 67.8k | setNextLayer(newLayer); | 302 | 67.8k | return newLayer; | 303 | 67.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.70k | { | 295 | 4.70k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.70k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.70k | setNextLayer(newLayer); | 302 | 4.70k | return newLayer; | 303 | 4.70k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 9.49k | { | 295 | 9.49k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 9.49k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 9.49k | setNextLayer(newLayer); | 302 | 9.49k | return newLayer; | 303 | 9.49k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 535k | { | 295 | 535k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 535k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 535k | setNextLayer(newLayer); | 302 | 535k | return newLayer; | 303 | 535k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.13M | { | 295 | 1.13M | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.13M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.13M | setNextLayer(newLayer); | 302 | 1.13M | return newLayer; | 303 | 1.13M | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 53.3k | { | 295 | 53.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 53.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 53.3k | setNextLayer(newLayer); | 302 | 53.3k | return newLayer; | 303 | 53.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 19.4k | { | 295 | 19.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 19.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 19.4k | setNextLayer(newLayer); | 302 | 19.4k | return newLayer; | 303 | 19.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 83.4k | { | 295 | 83.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 83.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 83.4k | setNextLayer(newLayer); | 302 | 83.4k | return newLayer; | 303 | 83.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 2.90k | { | 295 | 2.90k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 2.90k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 2.90k | setNextLayer(newLayer); | 302 | 2.90k | return newLayer; | 303 | 2.90k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 8.89k | { | 295 | 8.89k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 8.89k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 8.89k | setNextLayer(newLayer); | 302 | 8.89k | return newLayer; | 303 | 8.89k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.44k | { | 295 | 1.44k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.44k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.44k | setNextLayer(newLayer); | 302 | 1.44k | return newLayer; | 303 | 1.44k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.03k | { | 295 | 4.03k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.03k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.03k | setNextLayer(newLayer); | 302 | 4.03k | return newLayer; | 303 | 4.03k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.38k | { | 295 | 4.38k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.38k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.38k | setNextLayer(newLayer); | 302 | 4.38k | return newLayer; | 303 | 4.38k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 5.32k | { | 295 | 5.32k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 5.32k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 5.32k | setNextLayer(newLayer); | 302 | 5.32k | return newLayer; | 303 | 5.32k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 12.5k | { | 295 | 12.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 12.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 12.5k | setNextLayer(newLayer); | 302 | 12.5k | return newLayer; | 303 | 12.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 294 | 21.6k | { | 295 | 21.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 21.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 21.6k | setNextLayer(newLayer); | 302 | 21.6k | return newLayer; | 303 | 21.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 22.9k | { | 295 | 22.9k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 22.9k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 22.9k | setNextLayer(newLayer); | 302 | 22.9k | return newLayer; | 303 | 22.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 58.5k | { | 295 | 58.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 58.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 58.5k | setNextLayer(newLayer); | 302 | 58.5k | return newLayer; | 303 | 58.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.51k | { | 295 | 1.51k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.51k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.51k | setNextLayer(newLayer); | 302 | 1.51k | return newLayer; | 303 | 1.51k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 11.4k | { | 295 | 11.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 11.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 11.4k | setNextLayer(newLayer); | 302 | 11.4k | return newLayer; | 303 | 11.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 91.1k | { | 295 | 91.1k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 91.1k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 91.1k | setNextLayer(newLayer); | 302 | 91.1k | return newLayer; | 303 | 91.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 24.7k | { | 295 | 24.7k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 24.7k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 24.7k | setNextLayer(newLayer); | 302 | 24.7k | return newLayer; | 303 | 24.7k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.86k | { | 295 | 1.86k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.86k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.86k | setNextLayer(newLayer); | 302 | 1.86k | return newLayer; | 303 | 1.86k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 21.3k | { | 295 | 21.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 21.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 21.3k | setNextLayer(newLayer); | 302 | 21.3k | return newLayer; | 303 | 21.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 59.0k | { | 295 | 59.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 59.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 59.0k | setNextLayer(newLayer); | 302 | 59.0k | return newLayer; | 303 | 59.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 18.3k | { | 295 | 18.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 18.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 18.3k | setNextLayer(newLayer); | 302 | 18.3k | return newLayer; | 303 | 18.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.74k | { | 295 | 3.74k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.74k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.74k | setNextLayer(newLayer); | 302 | 3.74k | return newLayer; | 303 | 3.74k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.07k | { | 295 | 4.07k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.07k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.07k | setNextLayer(newLayer); | 302 | 4.07k | return newLayer; | 303 | 4.07k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 30.6k | { | 295 | 30.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 30.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 30.6k | setNextLayer(newLayer); | 302 | 30.6k | return newLayer; | 303 | 30.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.82k | { | 295 | 1.82k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.82k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.82k | setNextLayer(newLayer); | 302 | 1.82k | return newLayer; | 303 | 1.82k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.86k | { | 295 | 4.86k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.86k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.86k | setNextLayer(newLayer); | 302 | 4.86k | return newLayer; | 303 | 4.86k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.23k | { | 295 | 1.23k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.23k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.23k | setNextLayer(newLayer); | 302 | 1.23k | return newLayer; | 303 | 1.23k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 28.5k | { | 295 | 28.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 28.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 28.5k | setNextLayer(newLayer); | 302 | 28.5k | return newLayer; | 303 | 28.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 32.4k | { | 295 | 32.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 32.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 32.4k | setNextLayer(newLayer); | 302 | 32.4k | return newLayer; | 303 | 32.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.70k | { | 295 | 4.70k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.70k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.70k | setNextLayer(newLayer); | 302 | 4.70k | return newLayer; | 303 | 4.70k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 97.1k | { | 295 | 97.1k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 97.1k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 97.1k | setNextLayer(newLayer); | 302 | 97.1k | return newLayer; | 303 | 97.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 30.3k | { | 295 | 30.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 30.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 30.3k | setNextLayer(newLayer); | 302 | 30.3k | return newLayer; | 303 | 30.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 39.4k | { | 295 | 39.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 39.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 39.4k | setNextLayer(newLayer); | 302 | 39.4k | return newLayer; | 303 | 39.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 19.6k | { | 295 | 19.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 19.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 19.6k | setNextLayer(newLayer); | 302 | 19.6k | return newLayer; | 303 | 19.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 17.8k | { | 295 | 17.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 17.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 17.8k | setNextLayer(newLayer); | 302 | 17.8k | return newLayer; | 303 | 17.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.13k | { | 295 | 1.13k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.13k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.13k | setNextLayer(newLayer); | 302 | 1.13k | return newLayer; | 303 | 1.13k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 20.0k | { | 295 | 20.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 20.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 20.0k | setNextLayer(newLayer); | 302 | 20.0k | return newLayer; | 303 | 20.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 47.7k | { | 295 | 47.7k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 47.7k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 47.7k | setNextLayer(newLayer); | 302 | 47.7k | return newLayer; | 303 | 47.7k | } |
|
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 | 855k | { |
325 | 855k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), |
326 | 855k | std::forward<Args>(extraArgs)...); |
327 | 855k | } 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 | 159k | { | 325 | 159k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 159k | std::forward<Args>(extraArgs)...); | 327 | 159k | } |
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 | 105k | { | 325 | 105k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 105k | std::forward<Args>(extraArgs)...); | 327 | 105k | } |
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 | 535k | { | 325 | 535k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 535k | std::forward<Args>(extraArgs)...); | 327 | 535k | } |
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 | 30.6k | { | 325 | 30.6k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 30.6k | std::forward<Args>(extraArgs)...); | 327 | 30.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) Line | Count | Source | 324 | 21.9k | { | 325 | 21.9k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 21.9k | std::forward<Args>(extraArgs)...); | 327 | 21.9k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 2.12k | { | 325 | 2.12k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 2.12k | std::forward<Args>(extraArgs)...); | 327 | 2.12k | } |
|
328 | | |
329 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
330 | | /// |
331 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
332 | | /// If the factory returns a nullptr, no next layer is set. |
333 | | /// |
334 | | /// The factory functor is expected to have the following signature: |
335 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
336 | | /// |
337 | | /// @tparam TFactory The factory functor type. |
338 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
339 | | /// @param[in] factoryFn The factory functor to create the layer. |
340 | | /// @param[in] data The data to construct the layer from |
341 | | /// @param[in] dataLen The length of the data |
342 | | /// @param[in] packet The packet the layer belongs to |
343 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
344 | | /// @return The return value of the factory functor. |
345 | | template <typename TFactory, typename... Args> |
346 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet, |
347 | | Args&&... extraArgs) |
348 | 1.18M | { |
349 | 1.18M | if (hasNextLayer()) |
350 | 0 | { |
351 | 0 | throw std::runtime_error("Next layer already exists"); |
352 | 0 | } |
353 | | |
354 | | // cppcheck-suppress redundantInitialization |
355 | 1.18M | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
356 | 1.18M | setNextLayer(newLayer); |
357 | 1.18M | return newLayer; |
358 | 1.18M | } 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 | 231k | { | 349 | 231k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 231k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 231k | setNextLayer(newLayer); | 357 | 231k | return newLayer; | 358 | 231k | } |
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 | 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::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 | 535k | { | 349 | 535k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 535k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 535k | setNextLayer(newLayer); | 357 | 535k | return newLayer; | 358 | 535k | } |
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 | 30.6k | { | 349 | 30.6k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 30.6k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 30.6k | setNextLayer(newLayer); | 357 | 30.6k | return newLayer; | 358 | 30.6k | } |
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 | 48.4k | { | 349 | 48.4k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 48.4k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 48.4k | setNextLayer(newLayer); | 357 | 48.4k | return newLayer; | 358 | 48.4k | } |
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 | 59.2k | { | 349 | 59.2k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 59.2k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 59.2k | setNextLayer(newLayer); | 357 | 59.2k | return newLayer; | 358 | 59.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::PostgresLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 30 | { | 349 | 30 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 30 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 30 | setNextLayer(newLayer); | 357 | 30 | return newLayer; | 358 | 30 | } |
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.44k | { | 349 | 1.44k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 1.44k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 1.44k | setNextLayer(newLayer); | 357 | 1.44k | return newLayer; | 358 | 1.44k | } |
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 | 80.3k | { | 349 | 80.3k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 80.3k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 80.3k | setNextLayer(newLayer); | 357 | 80.3k | return newLayer; | 358 | 80.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 2.16k | { | 349 | 2.16k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 2.16k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 2.16k | setNextLayer(newLayer); | 357 | 2.16k | return newLayer; | 358 | 2.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 | 88.1k | { | 349 | 88.1k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 88.1k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 88.1k | setNextLayer(newLayer); | 357 | 88.1k | return newLayer; | 358 | 88.1k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 2.12k | { | 349 | 2.12k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 2.12k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 2.12k | setNextLayer(newLayer); | 357 | 2.12k | return newLayer; | 358 | 2.12k | } |
|
359 | | |
360 | | /// Try to construct the next layer in the protocol stack. |
361 | | /// |
362 | | /// This overload infers the Packet from the current layer. |
363 | | /// |
364 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
365 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
366 | | /// |
367 | | /// @tparam T The type of the layer to construct |
368 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
369 | | /// @param[in] data The data to construct the layer from |
370 | | /// @param[in] dataLen The length of the data |
371 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
372 | | /// @return The constructed layer or nullptr if the data is invalid |
373 | | template <typename T, typename... Args> |
374 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
375 | 0 | { |
376 | 0 | return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
377 | 0 | } |
378 | | |
379 | | /// Try to construct the next layer in the protocol stack. |
380 | | /// |
381 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
382 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
383 | | /// |
384 | | /// @tparam T The type of the layer to construct |
385 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
386 | | /// @param[in] data The data to construct the layer from |
387 | | /// @param[in] dataLen The length of the data |
388 | | /// @param[in] packet The packet the layer belongs to |
389 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
390 | | /// @return The constructed layer or nullptr if the data is invalid |
391 | | template <typename T, typename... Args> |
392 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
393 | 4.25M | { |
394 | 4.25M | if (T::isDataValid(data, dataLen)) |
395 | 4.21M | { |
396 | 4.21M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); |
397 | 4.21M | } |
398 | 43.1k | return nullptr; |
399 | 4.25M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.57M | { | 394 | 1.57M | if (T::isDataValid(data, dataLen)) | 395 | 1.56M | { | 396 | 1.56M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.56M | } | 398 | 17.2k | return nullptr; | 399 | 1.57M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 368k | { | 394 | 368k | if (T::isDataValid(data, dataLen)) | 395 | 365k | { | 396 | 365k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 365k | } | 398 | 3.07k | return nullptr; | 399 | 368k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 67.8k | { | 394 | 67.8k | if (T::isDataValid(data, dataLen)) | 395 | 67.8k | { | 396 | 67.8k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 67.8k | } | 398 | 0 | return nullptr; | 399 | 67.8k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 5.05k | { | 394 | 5.05k | if (T::isDataValid(data, dataLen)) | 395 | 4.40k | { | 396 | 4.40k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.40k | } | 398 | 649 | return nullptr; | 399 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 537k | { | 394 | 537k | if (T::isDataValid(data, dataLen)) | 395 | 535k | { | 396 | 535k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 535k | } | 398 | 2.86k | return nullptr; | 399 | 537k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.14M | { | 394 | 1.14M | if (T::isDataValid(data, dataLen)) | 395 | 1.13M | { | 396 | 1.13M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.13M | } | 398 | 13.3k | return nullptr; | 399 | 1.14M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 54.4k | { | 394 | 54.4k | if (T::isDataValid(data, dataLen)) | 395 | 53.3k | { | 396 | 53.3k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 53.3k | } | 398 | 1.10k | return nullptr; | 399 | 54.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 19.4k | { | 394 | 19.4k | if (T::isDataValid(data, dataLen)) | 395 | 19.4k | { | 396 | 19.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 19.4k | } | 398 | 0 | return nullptr; | 399 | 19.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 83.4k | { | 394 | 83.4k | if (T::isDataValid(data, dataLen)) | 395 | 83.4k | { | 396 | 83.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 83.4k | } | 398 | 0 | return nullptr; | 399 | 83.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.90k | { | 394 | 2.90k | if (T::isDataValid(data, dataLen)) | 395 | 2.90k | { | 396 | 2.90k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.90k | } | 398 | 0 | return nullptr; | 399 | 2.90k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 8.89k | { | 394 | 8.89k | if (T::isDataValid(data, dataLen)) | 395 | 8.89k | { | 396 | 8.89k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 8.89k | } | 398 | 0 | return nullptr; | 399 | 8.89k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.44k | { | 394 | 1.44k | if (T::isDataValid(data, dataLen)) | 395 | 1.44k | { | 396 | 1.44k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.44k | } | 398 | 0 | return nullptr; | 399 | 1.44k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.03k | { | 394 | 4.03k | if (T::isDataValid(data, dataLen)) | 395 | 4.03k | { | 396 | 4.03k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.03k | } | 398 | 0 | return nullptr; | 399 | 4.03k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.52k | { | 394 | 4.52k | if (T::isDataValid(data, dataLen)) | 395 | 4.38k | { | 396 | 4.38k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.38k | } | 398 | 138 | return nullptr; | 399 | 4.52k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 5.32k | { | 394 | 5.32k | if (T::isDataValid(data, dataLen)) | 395 | 5.32k | { | 396 | 5.32k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 5.32k | } | 398 | 0 | return nullptr; | 399 | 5.32k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 12.5k | { | 394 | 12.5k | if (T::isDataValid(data, dataLen)) | 395 | 12.5k | { | 396 | 12.5k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 12.5k | } | 398 | 0 | return nullptr; | 399 | 12.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 393 | 7.81k | { | 394 | 7.81k | if (T::isDataValid(data, dataLen)) | 395 | 7.81k | { | 396 | 7.81k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 7.81k | } | 398 | 0 | return nullptr; | 399 | 7.81k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 58.5k | { | 394 | 58.5k | if (T::isDataValid(data, dataLen)) | 395 | 58.5k | { | 396 | 58.5k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 58.5k | } | 398 | 0 | return nullptr; | 399 | 58.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.51k | { | 394 | 1.51k | if (T::isDataValid(data, dataLen)) | 395 | 1.51k | { | 396 | 1.51k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.51k | } | 398 | 0 | return nullptr; | 399 | 1.51k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 11.7k | { | 394 | 11.7k | if (T::isDataValid(data, dataLen)) | 395 | 11.4k | { | 396 | 11.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 11.4k | } | 398 | 357 | return nullptr; | 399 | 11.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 30.6k | { | 394 | 30.6k | if (T::isDataValid(data, dataLen)) | 395 | 28.5k | { | 396 | 28.5k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 28.5k | } | 398 | 2.11k | return nullptr; | 399 | 30.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 32.8k | { | 394 | 32.8k | if (T::isDataValid(data, dataLen)) | 395 | 32.4k | { | 396 | 32.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 32.4k | } | 398 | 342 | return nullptr; | 399 | 32.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 4.70k | { | 394 | 4.70k | if (T::isDataValid(data, dataLen)) | 395 | 4.70k | { | 396 | 4.70k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 4.70k | } | 398 | 0 | return nullptr; | 399 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 21.6k | { | 394 | 21.6k | if (T::isDataValid(data, dataLen)) | 395 | 20.0k | { | 396 | 20.0k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 20.0k | } | 398 | 1.51k | return nullptr; | 399 | 21.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 15.7k | { | 394 | 15.7k | if (T::isDataValid(data, dataLen)) | 395 | 15.6k | { | 396 | 15.6k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 15.6k | } | 398 | 24 | return nullptr; | 399 | 15.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 165k | { | 394 | 165k | if (T::isDataValid(data, dataLen)) | 395 | 165k | { | 396 | 165k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 165k | } | 398 | 129 | return nullptr; | 399 | 165k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 26 | { | 394 | 26 | if (T::isDataValid(data, dataLen)) | 395 | 26 | { | 396 | 26 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 26 | } | 398 | 0 | return nullptr; | 399 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 243 | { | 394 | 243 | if (T::isDataValid(data, dataLen)) | 395 | 0 | { | 396 | 0 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 0 | } | 398 | 243 | return nullptr; | 399 | 243 | } |
|
400 | | |
401 | | /// @brief Try to construct the next layer in the protocol stack with a fallback option. |
402 | | /// |
403 | | /// This overload infers the Packet from the current layer. |
404 | | /// |
405 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
406 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
407 | | /// |
408 | | /// @tparam T The type of the layer to construct |
409 | | /// @tparam TFallback The fallback layer type to construct if T fails |
410 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
411 | | /// @param[in] data The data to construct the layer from |
412 | | /// @param[in] dataLen The length of the data |
413 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
414 | | /// @return The constructed layer of type T or TFallback |
415 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
416 | | /// constructor. |
417 | | template <typename T, typename TFallback, typename... Args> |
418 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
419 | 2.69M | { |
420 | 2.69M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), |
421 | 2.69M | std::forward<Args>(extraArgs)...); |
422 | 2.69M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 1.57M | { | 420 | 1.57M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 1.57M | std::forward<Args>(extraArgs)...); | 422 | 1.57M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 364k | { | 420 | 364k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 364k | std::forward<Args>(extraArgs)...); | 422 | 364k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 67.8k | { | 420 | 67.8k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 67.8k | std::forward<Args>(extraArgs)...); | 422 | 67.8k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 5.05k | { | 420 | 5.05k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.05k | std::forward<Args>(extraArgs)...); | 422 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 37.4k | { | 420 | 37.4k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 37.4k | std::forward<Args>(extraArgs)...); | 422 | 37.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 281k | { | 420 | 281k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 281k | std::forward<Args>(extraArgs)...); | 422 | 281k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 10.3k | { | 420 | 10.3k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 10.3k | std::forward<Args>(extraArgs)...); | 422 | 10.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 5.39k | { | 420 | 5.39k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 5.39k | std::forward<Args>(extraArgs)...); | 422 | 5.39k | } |
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.16k | { | 420 | 3.16k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 3.16k | std::forward<Args>(extraArgs)...); | 422 | 3.16k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 58.5k | { | 420 | 58.5k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 58.5k | std::forward<Args>(extraArgs)...); | 422 | 58.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 1.51k | { | 420 | 1.51k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 1.51k | std::forward<Args>(extraArgs)...); | 422 | 1.51k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 11.7k | { | 420 | 11.7k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 11.7k | std::forward<Args>(extraArgs)...); | 422 | 11.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 30.6k | { | 420 | 30.6k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 30.6k | std::forward<Args>(extraArgs)...); | 422 | 30.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 32.8k | { | 420 | 32.8k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 32.8k | std::forward<Args>(extraArgs)...); | 422 | 32.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 4.70k | { | 420 | 4.70k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 4.70k | std::forward<Args>(extraArgs)...); | 422 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 21.6k | { | 420 | 21.6k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 21.6k | std::forward<Args>(extraArgs)...); | 422 | 21.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 15.7k | { | 420 | 15.7k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 15.7k | std::forward<Args>(extraArgs)...); | 422 | 15.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 165k | { | 420 | 165k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 165k | std::forward<Args>(extraArgs)...); | 422 | 165k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 26 | { | 420 | 26 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 26 | std::forward<Args>(extraArgs)...); | 422 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 243 | { | 420 | 243 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 243 | std::forward<Args>(extraArgs)...); | 422 | 243 | } |
|
423 | | |
424 | | /// Try to construct the next layer in the protocol stack with a fallback option. |
425 | | /// |
426 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
427 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
428 | | /// |
429 | | /// @tparam T The type of the layer to construct |
430 | | /// @tparam TFallback The fallback layer type to construct if T fails |
431 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
432 | | /// @param[in] data The data to construct the layer from |
433 | | /// @param[in] dataLen The length of the data |
434 | | /// @param[in] packet The packet the layer belongs to |
435 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
436 | | /// @return The constructed layer of type T or TFallback |
437 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
438 | | /// constructor. |
439 | | template <typename T, typename TFallback, typename... Args> |
440 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
441 | 4.25M | { |
442 | 4.25M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) |
443 | 4.21M | { |
444 | 4.21M | return m_NextLayer; |
445 | 4.21M | } |
446 | | |
447 | 43.1k | return constructNextLayer<TFallback>(data, dataLen, packet); |
448 | 4.25M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.57M | { | 442 | 1.57M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.56M | { | 444 | 1.56M | return m_NextLayer; | 445 | 1.56M | } | 446 | | | 447 | 17.2k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.57M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 368k | { | 442 | 368k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 365k | { | 444 | 365k | return m_NextLayer; | 445 | 365k | } | 446 | | | 447 | 3.07k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 368k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 67.8k | { | 442 | 67.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 67.8k | { | 444 | 67.8k | return m_NextLayer; | 445 | 67.8k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 67.8k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 5.05k | { | 442 | 5.05k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.40k | { | 444 | 4.40k | return m_NextLayer; | 445 | 4.40k | } | 446 | | | 447 | 649 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.05k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 537k | { | 442 | 537k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 535k | { | 444 | 535k | return m_NextLayer; | 445 | 535k | } | 446 | | | 447 | 2.86k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 537k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.14M | { | 442 | 1.14M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.13M | { | 444 | 1.13M | return m_NextLayer; | 445 | 1.13M | } | 446 | | | 447 | 13.3k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.14M | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 54.4k | { | 442 | 54.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 53.3k | { | 444 | 53.3k | return m_NextLayer; | 445 | 53.3k | } | 446 | | | 447 | 1.10k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 54.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 19.4k | { | 442 | 19.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 19.4k | { | 444 | 19.4k | return m_NextLayer; | 445 | 19.4k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 19.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 83.4k | { | 442 | 83.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 83.4k | { | 444 | 83.4k | return m_NextLayer; | 445 | 83.4k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 83.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.90k | { | 442 | 2.90k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.90k | { | 444 | 2.90k | return m_NextLayer; | 445 | 2.90k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.90k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 8.89k | { | 442 | 8.89k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 8.89k | { | 444 | 8.89k | return m_NextLayer; | 445 | 8.89k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 8.89k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.44k | { | 442 | 1.44k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.44k | { | 444 | 1.44k | return m_NextLayer; | 445 | 1.44k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.44k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.03k | { | 442 | 4.03k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.03k | { | 444 | 4.03k | return m_NextLayer; | 445 | 4.03k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.03k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.52k | { | 442 | 4.52k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.38k | { | 444 | 4.38k | return m_NextLayer; | 445 | 4.38k | } | 446 | | | 447 | 138 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.52k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 5.32k | { | 442 | 5.32k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 5.32k | { | 444 | 5.32k | return m_NextLayer; | 445 | 5.32k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.32k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 12.5k | { | 442 | 12.5k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 12.5k | { | 444 | 12.5k | return m_NextLayer; | 445 | 12.5k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 12.5k | } |
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 | 7.81k | { | 442 | 7.81k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 7.81k | { | 444 | 7.81k | return m_NextLayer; | 445 | 7.81k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 7.81k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 58.5k | { | 442 | 58.5k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 58.5k | { | 444 | 58.5k | return m_NextLayer; | 445 | 58.5k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 58.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.51k | { | 442 | 1.51k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.51k | { | 444 | 1.51k | return m_NextLayer; | 445 | 1.51k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.51k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 11.7k | { | 442 | 11.7k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 11.4k | { | 444 | 11.4k | return m_NextLayer; | 445 | 11.4k | } | 446 | | | 447 | 357 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 11.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 30.6k | { | 442 | 30.6k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 28.5k | { | 444 | 28.5k | return m_NextLayer; | 445 | 28.5k | } | 446 | | | 447 | 2.11k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 30.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 32.8k | { | 442 | 32.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 32.4k | { | 444 | 32.4k | return m_NextLayer; | 445 | 32.4k | } | 446 | | | 447 | 342 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 32.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 4.70k | { | 442 | 4.70k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 4.70k | { | 444 | 4.70k | return m_NextLayer; | 445 | 4.70k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 4.70k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 21.6k | { | 442 | 21.6k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 20.0k | { | 444 | 20.0k | return m_NextLayer; | 445 | 20.0k | } | 446 | | | 447 | 1.51k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 21.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 15.7k | { | 442 | 15.7k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 15.6k | { | 444 | 15.6k | return m_NextLayer; | 445 | 15.6k | } | 446 | | | 447 | 24 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 15.7k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 165k | { | 442 | 165k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 165k | { | 444 | 165k | return m_NextLayer; | 445 | 165k | } | 446 | | | 447 | 129 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 165k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 26 | { | 442 | 26 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 26 | { | 444 | 26 | return m_NextLayer; | 445 | 26 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 26 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 243 | { | 442 | 243 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 0 | { | 444 | 0 | return m_NextLayer; | 445 | 0 | } | 446 | | | 447 | 243 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 243 | } |
|
449 | | |
450 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
451 | | /// |
452 | | /// The method will attempt to construct the next layer using the provided factory function. |
453 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
454 | | /// construct a layer of type TFallback. |
455 | | /// |
456 | | /// The factory functor is expected to have the following signature: |
457 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
458 | | /// |
459 | | /// This overload infers the Packet from the current layer. |
460 | | /// |
461 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
462 | | /// @tparam TFactory The factory functor type. |
463 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
464 | | /// @param[in] factoryFn The factory functor to create the layer. |
465 | | /// @param[in] data The data to construct the layer from |
466 | | /// @param[in] dataLen The length of the data |
467 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
468 | | /// @return The return value of the factory functor. |
469 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
470 | | /// constructor. |
471 | | template <typename TFallback, typename TFactory, typename... Args> |
472 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
473 | | Args&&... extraArgs) |
474 | 329k | { |
475 | | // Note that the fallback is first to allow template argument deduction of the factory type. |
476 | 329k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( |
477 | 329k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
478 | 329k | } 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 | 71.5k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 71.5k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 71.5k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 71.5k | } |
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 | 48.4k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 48.4k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 48.4k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 48.4k | } |
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.2k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 37.2k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 37.2k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 37.2k | } |
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 | 30 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 30 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 30 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 30 | } |
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.44k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 1.44k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 1.44k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 1.44k | } |
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 | 80.3k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 80.3k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 80.3k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 80.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 2.16k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 2.16k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 2.16k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 2.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 | 88.1k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 88.1k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 88.1k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 88.1k | } |
|
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 | 329k | { |
504 | 329k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, |
505 | 329k | std::forward<Args>(extraArgs)...); |
506 | 329k | if (nextLayer != nullptr) |
507 | 225k | { |
508 | 225k | return nextLayer; |
509 | 225k | } |
510 | | |
511 | | // factory failed, construct fallback layer |
512 | 103k | return constructNextLayer<TFallback>(data, dataLen, packet); |
513 | 329k | } 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 | 71.5k | { | 504 | 71.5k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 71.5k | std::forward<Args>(extraArgs)...); | 506 | 71.5k | if (nextLayer != nullptr) | 507 | 66.5k | { | 508 | 66.5k | return nextLayer; | 509 | 66.5k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 4.98k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 71.5k | } |
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 | 48.4k | { | 504 | 48.4k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 48.4k | std::forward<Args>(extraArgs)...); | 506 | 48.4k | if (nextLayer != nullptr) | 507 | 48.3k | { | 508 | 48.3k | return nextLayer; | 509 | 48.3k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 150 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 48.4k | } |
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.2k | { | 504 | 37.2k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 37.2k | std::forward<Args>(extraArgs)...); | 506 | 37.2k | if (nextLayer != nullptr) | 507 | 30.6k | { | 508 | 30.6k | return nextLayer; | 509 | 30.6k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 6.59k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 37.2k | } |
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 | 30 | { | 504 | 30 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 30 | std::forward<Args>(extraArgs)...); | 506 | 30 | if (nextLayer != nullptr) | 507 | 30 | { | 508 | 30 | return nextLayer; | 509 | 30 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 30 | } |
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.44k | { | 504 | 1.44k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 1.44k | std::forward<Args>(extraArgs)...); | 506 | 1.44k | if (nextLayer != nullptr) | 507 | 1.44k | { | 508 | 1.44k | return nextLayer; | 509 | 1.44k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 1.44k | } |
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 | 80.3k | { | 504 | 80.3k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 80.3k | std::forward<Args>(extraArgs)...); | 506 | 80.3k | if (nextLayer != nullptr) | 507 | 75.8k | { | 508 | 75.8k | return nextLayer; | 509 | 75.8k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 4.46k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 80.3k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::WireGuardLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 2.16k | { | 504 | 2.16k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 2.16k | std::forward<Args>(extraArgs)...); | 506 | 2.16k | if (nextLayer != nullptr) | 507 | 2.16k | { | 508 | 2.16k | return nextLayer; | 509 | 2.16k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 2.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 | 88.1k | { | 504 | 88.1k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 88.1k | std::forward<Args>(extraArgs)...); | 506 | 88.1k | if (nextLayer != nullptr) | 507 | 693 | { | 508 | 693 | return nextLayer; | 509 | 693 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 87.4k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 88.1k | } |
|
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.05M | { |
525 | 3.05M | return data != nullptr && dataLen >= sizeof(T); |
526 | 3.05M | } bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 15.7k | { | 525 | 15.7k | return data != nullptr && dataLen >= sizeof(T); | 526 | 15.7k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.59M | { | 525 | 1.59M | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.59M | } |
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 32.8k | { | 525 | 32.8k | return data != nullptr && dataLen >= sizeof(T); | 526 | 32.8k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 20.3k | { | 525 | 20.3k | return data != nullptr && dataLen >= sizeof(T); | 526 | 20.3k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 370k | { | 525 | 370k | return data != nullptr && dataLen >= sizeof(T); | 526 | 370k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 165k | { | 525 | 165k | return data != nullptr && dataLen >= sizeof(T); | 526 | 165k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 26 | { | 525 | 26 | return data != nullptr && dataLen >= sizeof(T); | 526 | 26 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 11.8k | { | 525 | 11.8k | return data != nullptr && dataLen >= sizeof(T); | 526 | 11.8k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.44k | { | 525 | 1.44k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.44k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 4.03k | { | 525 | 4.03k | return data != nullptr && dataLen >= sizeof(T); | 526 | 4.03k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 535k | { | 525 | 535k | return data != nullptr && dataLen >= sizeof(T); | 526 | 535k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 294k | { | 525 | 294k | return data != nullptr && dataLen >= sizeof(T); | 526 | 294k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 4.70k | { | 525 | 4.70k | return data != nullptr && dataLen >= sizeof(T); | 526 | 4.70k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 768 | { | 525 | 768 | return data != nullptr && dataLen >= sizeof(T); | 526 | 768 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.22k | { | 525 | 1.22k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.22k | } |
Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::rstp_conf_bpdu>(unsigned char const*, unsigned long) Unexecuted instantiation: bool pcpp::Layer::canReinterpretAs<pcpp::mstp_conf_bpdu>(unsigned char const*, unsigned long) |
527 | | }; |
528 | | |
529 | | inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer) |
530 | 0 | { |
531 | 0 | os << layer.toString(); |
532 | 0 | return os; |
533 | 0 | } |
534 | | } // namespace pcpp |