/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 | 4.93M | virtual ~IDataContainer() = default; |
30 | | }; |
31 | | |
32 | | class Packet; |
33 | | |
34 | | namespace internal |
35 | | { |
36 | | /// @brief Holds information about a Layer's data and object ownership. |
37 | | struct LayerAllocationInfo |
38 | | { |
39 | | /// @brief Pointer to the Packet this layer is attached to (if any). |
40 | | /// |
41 | | /// If the layer is attached to a Packet, the layer's memory span (data) is considered managed by the |
42 | | /// Packet. The Packet is responsible for keeping the layer's memory span valid and updating it should it |
43 | | /// become necessary as long as the layer is attached to it. |
44 | | /// |
45 | | /// In an event the Packet is destroyed, all of its attached layers's memory views are considered invalid. |
46 | | /// Accessing layer data after the Packet is destroyed results in undefined behavior. |
47 | | /// |
48 | | /// If nullptr, the layer is not attached to any Packet and is considered unmanaged. |
49 | | /// It also means the layer's memory span is considered owned by the layer itself and will be freed when |
50 | | /// the layer is destroyed. |
51 | | Packet* attachedPacket = nullptr; |
52 | | |
53 | | /// @brief Controls if the layer object is considered owned by the attached Packet |
54 | | /// |
55 | | /// If 'true', the Layer object is considered owned by the attached Packet and will be freed by it on Packet |
56 | | /// destruction. |
57 | | /// |
58 | | /// If 'false', the Layer object is considered unmanaged and the user is responsible for freeing it. |
59 | | /// This is commonly the case for layers created on the stack and attached to a Packet. |
60 | | bool ownedByPacket = false; |
61 | | |
62 | | /// @brief Sets the state of attachment to a specified Packet |
63 | | /// @param packet Pointer to the Packet this layer is attached to (or nullptr if not attached to any Packet) |
64 | | /// @param managed True if the layer object's lifetime is to be managed by the Packet, false otherwise |
65 | | /// @param force If true, bypasses the check for existing attachment. Default is false. |
66 | | /// @throws std::runtime_error if the layer is already attached to a Packet and 'force' is false |
67 | | void attachPacket(Packet* packet, bool managed, bool force = false) |
68 | 0 | { |
69 | 0 | if (!force && attachedPacket != nullptr) |
70 | 0 | { |
71 | 0 | throw std::runtime_error("Layer is already attached to a Packet"); |
72 | 0 | } |
73 | | |
74 | 0 | attachedPacket = packet; |
75 | 0 | ownedByPacket = managed; |
76 | 0 | } |
77 | | |
78 | | /// @brief Clears the attachment to any Packet, resetting to unmanaged state. |
79 | | void detach() |
80 | 0 | { |
81 | 0 | attachedPacket = nullptr; |
82 | 0 | ownedByPacket = false; |
83 | 0 | } |
84 | | }; |
85 | | } // namespace internal |
86 | | |
87 | | /// @class Layer |
88 | | /// Layer is the base class for all protocol layers. Each protocol supported in PcapPlusPlus has a class that |
89 | | /// inherits Layer. |
90 | | /// The protocol layer class expose all properties and methods relevant for viewing and editing protocol fields. |
91 | | /// For example: a pointer to a structured header (e.g tcphdr, iphdr, etc.), protocol header size, payload size, |
92 | | /// compute fields that can be automatically computed, print protocol data to string, etc. |
93 | | /// Each protocol instance is obviously part of a protocol stack (which construct a packet). This protocol stack is |
94 | | /// represented in PcapPlusPlus in a linked list, and each layer is an element in this list. That's why each layer |
95 | | /// has properties to the next and previous layer in the protocol stack. The Layer class, as a base class, is |
96 | | /// abstract and the user can't create an instance of it (it has a private constructor). Each layer holds a pointer |
97 | | /// to the relevant place in the packet. The layer sees all the data from this pointer forward until the end of the |
98 | | /// packet. Here is an example packet showing this concept: |
99 | | /// |
100 | | /// @code{.unparsed} |
101 | | /// ==================================================== |
102 | | /// |Eth |IPv4 |TCP |Packet | |
103 | | /// |Header |Header |Header |Payload | |
104 | | /// ==================================================== |
105 | | /// |
106 | | /// |--------------------------------------------------| |
107 | | /// EthLayer data |
108 | | /// |---------------------------------------| |
109 | | /// IPv4Layer data |
110 | | /// |---------------------------| |
111 | | /// TcpLayer data |
112 | | /// |----------------| |
113 | | /// PayloadLayer data |
114 | | /// @endcode |
115 | | class Layer : public IDataContainer |
116 | | { |
117 | | friend class Packet; |
118 | | |
119 | | public: |
120 | | /// A destructor for this class. Frees the data if it was allocated by the layer constructor (see |
121 | | /// isAllocatedToPacket() for more info) |
122 | | ~Layer() override; |
123 | | |
124 | | /// @return A pointer to the next layer in the protocol stack or nullptr if the layer is the last one |
125 | | Layer* getNextLayer() const |
126 | 91.2M | { |
127 | 91.2M | return m_NextLayer; |
128 | 91.2M | } |
129 | | |
130 | | /// @return A pointer to the previous layer in the protocol stack or nullptr if the layer is the first one |
131 | | Layer* getPrevLayer() const |
132 | 1.55M | { |
133 | 1.55M | return m_PrevLayer; |
134 | 1.55M | } |
135 | | |
136 | | /// @return The protocol enum |
137 | | ProtocolType getProtocol() const |
138 | 65.5M | { |
139 | 65.5M | return m_Protocol; |
140 | 65.5M | } |
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 | 274k | { |
150 | 274k | return m_Data; |
151 | 274k | } |
152 | | |
153 | | /// @return The length in bytes of the data from the first byte of the header until the end of the packet |
154 | | size_t getDataLen() const |
155 | 2.64M | { |
156 | 2.64M | return m_DataLen; |
157 | 2.64M | } |
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 | 15.0k | { |
168 | 15.0k | return m_DataLen - getHeaderLen(); |
169 | 15.0k | } |
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 | 4.93M | { |
182 | 4.93M | return m_AllocationInfo.attachedPacket != nullptr; |
183 | 4.93M | } |
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 | 123k | { |
193 | 123k | return static_cast<uint8_t*>(m_Data + offset); |
194 | 123k | } |
195 | | |
196 | | // abstract methods |
197 | | |
198 | | /// Each layer is responsible for parsing the next layer |
199 | | virtual void parseNextLayer() = 0; |
200 | | |
201 | | /// @return The header length in bytes |
202 | | virtual size_t getHeaderLen() const = 0; |
203 | | |
204 | | /// Each layer can compute field values automatically using this method. This is an abstract method |
205 | | virtual void computeCalculateFields() = 0; |
206 | | |
207 | | /// @return A string representation of the layer most important data (should look like the layer description in |
208 | | /// Wireshark) |
209 | | virtual std::string toString() const = 0; |
210 | | |
211 | | /// @return The OSI Model layer this protocol belongs to |
212 | | virtual OsiModelLayer getOsiModelLayer() const = 0; |
213 | | |
214 | | protected: |
215 | | uint8_t* m_Data; |
216 | | size_t m_DataLen; |
217 | | ProtocolType m_Protocol; |
218 | | Layer* m_NextLayer; |
219 | | Layer* m_PrevLayer; |
220 | | |
221 | | private: |
222 | | internal::LayerAllocationInfo m_AllocationInfo; |
223 | | |
224 | | protected: |
225 | 0 | Layer() : m_Data(nullptr), m_DataLen(0), m_Protocol(UnknownProtocol), m_NextLayer(nullptr), m_PrevLayer(nullptr) |
226 | 0 | {} |
227 | | |
228 | | Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ProtocolType protocol = UnknownProtocol) |
229 | 4.77M | : m_Data(data), m_DataLen(dataLen), m_Protocol(protocol), m_NextLayer(nullptr), m_PrevLayer(prevLayer), |
230 | 4.77M | m_AllocationInfo{ packet, false } |
231 | 4.77M | {} |
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 | 4.29M | { |
241 | 4.29M | return m_AllocationInfo.attachedPacket; |
242 | 4.29M | } |
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 | 7.24k | { |
248 | 7.24k | return m_AllocationInfo.attachedPacket; |
249 | 7.24k | } |
250 | | |
251 | | void setNextLayer(Layer* nextLayer) |
252 | 3.73M | { |
253 | 3.73M | m_NextLayer = nextLayer; |
254 | 3.73M | } |
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 | 6.89M | { |
265 | 6.89M | return m_NextLayer != nullptr; |
266 | 6.89M | } |
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 | 324k | { |
281 | 324k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
282 | 324k | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 17.2k | { | 281 | 17.2k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 17.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 99.2k | { | 281 | 99.2k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 99.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 64.0k | { | 281 | 64.0k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 64.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::IPAddress::AddressType&&) Line | Count | Source | 280 | 10.4k | { | 281 | 10.4k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 10.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 7.32k | { | 281 | 7.32k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 7.32k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 61.2k | { | 281 | 61.2k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 61.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 22.8k | { | 281 | 22.8k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 22.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 13.4k | { | 281 | 13.4k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 13.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 7.48k | { | 281 | 7.48k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 7.48k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 4.11k | { | 281 | 4.11k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 4.11k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 6.80k | { | 281 | 6.80k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 6.80k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 555 | { | 281 | 555 | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 555 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 6.20k | { | 281 | 6.20k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 6.20k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long) Line | Count | Source | 280 | 3.20k | { | 281 | 3.20k | return constructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 282 | 3.20k | } |
|
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 | 3.10M | { |
295 | 3.10M | if (hasNextLayer()) |
296 | 0 | { |
297 | 0 | throw std::runtime_error("Next layer already exists"); |
298 | 0 | } |
299 | | |
300 | 3.10M | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
301 | 3.10M | setNextLayer(newLayer); |
302 | 3.10M | return newLayer; |
303 | 3.10M | } pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 849k | { | 295 | 849k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 849k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 849k | setNextLayer(newLayer); | 302 | 849k | return newLayer; | 303 | 849k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 356k | { | 295 | 356k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 356k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 356k | setNextLayer(newLayer); | 302 | 356k | return newLayer; | 303 | 356k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 250k | { | 295 | 250k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 250k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 250k | setNextLayer(newLayer); | 302 | 250k | return newLayer; | 303 | 250k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 57.0k | { | 295 | 57.0k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 57.0k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 57.0k | setNextLayer(newLayer); | 302 | 57.0k | return newLayer; | 303 | 57.0k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 102k | { | 295 | 102k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 102k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 102k | setNextLayer(newLayer); | 302 | 102k | return newLayer; | 303 | 102k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 8.44k | { | 295 | 8.44k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 8.44k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 8.44k | setNextLayer(newLayer); | 302 | 8.44k | return newLayer; | 303 | 8.44k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.20k | { | 295 | 6.20k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.20k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.20k | setNextLayer(newLayer); | 302 | 6.20k | return newLayer; | 303 | 6.20k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 13.2k | { | 295 | 13.2k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 13.2k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 13.2k | setNextLayer(newLayer); | 302 | 13.2k | return newLayer; | 303 | 13.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 282k | { | 295 | 282k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 282k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 282k | setNextLayer(newLayer); | 302 | 282k | return newLayer; | 303 | 282k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 716k | { | 295 | 716k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 716k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 716k | setNextLayer(newLayer); | 302 | 716k | return newLayer; | 303 | 716k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 19.2k | { | 295 | 19.2k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 19.2k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 19.2k | setNextLayer(newLayer); | 302 | 19.2k | return newLayer; | 303 | 19.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 8.42k | { | 295 | 8.42k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 8.42k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 8.42k | setNextLayer(newLayer); | 302 | 8.42k | return newLayer; | 303 | 8.42k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GREv1Layer>(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::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.88k | { | 295 | 1.88k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.88k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.88k | setNextLayer(newLayer); | 302 | 1.88k | return newLayer; | 303 | 1.88k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.14k | { | 295 | 3.14k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.14k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.14k | setNextLayer(newLayer); | 302 | 3.14k | return newLayer; | 303 | 3.14k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 36 | { | 295 | 36 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 36 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 36 | setNextLayer(newLayer); | 302 | 36 | return newLayer; | 303 | 36 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 2.13k | { | 295 | 2.13k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 2.13k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 2.13k | setNextLayer(newLayer); | 302 | 2.13k | return newLayer; | 303 | 2.13k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 28 | { | 295 | 28 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 28 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 28 | setNextLayer(newLayer); | 302 | 28 | return newLayer; | 303 | 28 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 55 | { | 295 | 55 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 55 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 55 | setNextLayer(newLayer); | 302 | 55 | return newLayer; | 303 | 55 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 12.4k | { | 295 | 12.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 12.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 12.4k | setNextLayer(newLayer); | 302 | 12.4k | return newLayer; | 303 | 12.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 294 | 15.4k | { | 295 | 15.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 15.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 15.4k | setNextLayer(newLayer); | 302 | 15.4k | return newLayer; | 303 | 15.4k | } |
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 | 26.4k | { | 295 | 26.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 26.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 26.4k | setNextLayer(newLayer); | 302 | 26.4k | return newLayer; | 303 | 26.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 440 | { | 295 | 440 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 440 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 440 | setNextLayer(newLayer); | 302 | 440 | return newLayer; | 303 | 440 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 12.3k | { | 295 | 12.3k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 12.3k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 12.3k | setNextLayer(newLayer); | 302 | 12.3k | return newLayer; | 303 | 12.3k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 88.4k | { | 295 | 88.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 88.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 88.4k | setNextLayer(newLayer); | 302 | 88.4k | return newLayer; | 303 | 88.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::HttpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 15.5k | { | 295 | 15.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 15.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 15.5k | setNextLayer(newLayer); | 302 | 15.5k | return newLayer; | 303 | 15.5k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SipResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.25k | { | 295 | 3.25k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.25k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.25k | setNextLayer(newLayer); | 302 | 3.25k | return newLayer; | 303 | 3.25k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsOverTcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 7.74k | { | 295 | 7.74k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 7.74k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 7.74k | setNextLayer(newLayer); | 302 | 7.74k | return newLayer; | 303 | 7.74k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TelnetLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.25k | { | 295 | 6.25k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.25k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.25k | setNextLayer(newLayer); | 302 | 6.25k | return newLayer; | 303 | 6.25k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 10.5k | { | 295 | 10.5k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 10.5k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 10.5k | setNextLayer(newLayer); | 302 | 10.5k | return newLayer; | 303 | 10.5k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.78k | { | 295 | 3.78k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.78k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.78k | setNextLayer(newLayer); | 302 | 3.78k | return newLayer; | 303 | 3.78k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::FtpDataLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 1.34k | { | 295 | 1.34k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 1.34k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 1.34k | setNextLayer(newLayer); | 302 | 1.34k | return newLayer; | 303 | 1.34k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::TpktLayer>(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::SmtpResponseLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.09k | { | 295 | 3.09k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.09k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.09k | setNextLayer(newLayer); | 302 | 3.09k | return newLayer; | 303 | 3.09k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SmtpRequestLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.49k | { | 295 | 6.49k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.49k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.49k | setNextLayer(newLayer); | 302 | 6.49k | return newLayer; | 303 | 6.49k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::ModbusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 915 | { | 295 | 915 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 915 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 915 | setNextLayer(newLayer); | 302 | 915 | return newLayer; | 303 | 915 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 10.6k | { | 295 | 10.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 10.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 10.6k | setNextLayer(newLayer); | 302 | 10.6k | return newLayer; | 303 | 10.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 20.6k | { | 295 | 20.6k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 20.6k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 20.6k | setNextLayer(newLayer); | 302 | 20.6k | return newLayer; | 303 | 20.6k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.20k | { | 295 | 6.20k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.20k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.20k | setNextLayer(newLayer); | 302 | 6.20k | return newLayer; | 303 | 6.20k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DnsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 61.2k | { | 295 | 61.2k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 61.2k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 61.2k | setNextLayer(newLayer); | 302 | 61.2k | return newLayer; | 303 | 61.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::RadiusLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 22.8k | { | 295 | 22.8k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 22.8k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 22.8k | setNextLayer(newLayer); | 302 | 22.8k | return newLayer; | 303 | 22.8k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::GtpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 13.4k | { | 295 | 13.4k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 13.4k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 13.4k | setNextLayer(newLayer); | 302 | 13.4k | return newLayer; | 303 | 13.4k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::DhcpV6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 4.11k | { | 295 | 4.11k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 4.11k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 4.11k | setNextLayer(newLayer); | 302 | 4.11k | return newLayer; | 303 | 4.11k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::NtpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 6.80k | { | 295 | 6.80k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 6.80k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 6.80k | setNextLayer(newLayer); | 302 | 6.80k | return newLayer; | 303 | 6.80k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 642 | { | 295 | 642 | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 642 | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 642 | setNextLayer(newLayer); | 302 | 642 | return newLayer; | 303 | 642 | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 7.17k | { | 295 | 7.17k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 7.17k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 7.17k | setNextLayer(newLayer); | 302 | 7.17k | return newLayer; | 303 | 7.17k | } |
pcpp::Layer* pcpp::Layer::constructNextLayer<pcpp::SdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 294 | 3.20k | { | 295 | 3.20k | if (hasNextLayer()) | 296 | 0 | { | 297 | 0 | throw std::runtime_error("Next layer already exists"); | 298 | 0 | } | 299 | | | 300 | 3.20k | Layer* newLayer = new T(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 301 | 3.20k | setNextLayer(newLayer); | 302 | 3.20k | return newLayer; | 303 | 3.20k | } |
|
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 | 493k | { |
325 | 493k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), |
326 | 493k | std::forward<Args>(extraArgs)...); |
327 | 493k | } 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 | 31.6k | { | 325 | 31.6k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 31.6k | std::forward<Args>(extraArgs)...); | 327 | 31.6k | } |
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 | 67.8k | { | 325 | 67.8k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 67.8k | std::forward<Args>(extraArgs)...); | 327 | 67.8k | } |
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 | 372k | { | 325 | 372k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 372k | std::forward<Args>(extraArgs)...); | 327 | 372k | } |
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 | 15.9k | { | 325 | 15.9k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 15.9k | std::forward<Args>(extraArgs)...); | 327 | 15.9k | } |
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 | 60 | { | 325 | 60 | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 60 | std::forward<Args>(extraArgs)...); | 327 | 60 | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 324 | 5.24k | { | 325 | 5.24k | return constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, getAttachedPacket(), | 326 | 5.24k | std::forward<Args>(extraArgs)...); | 327 | 5.24k | } |
|
328 | | |
329 | | /// @brief Construct the next layer in the protocol stack using a factory functor. |
330 | | /// |
331 | | /// No validation is performed on the data, outside of what the factory functor may perform. |
332 | | /// If the factory returns a nullptr, no next layer is set. |
333 | | /// |
334 | | /// The factory functor is expected to have the following signature: |
335 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
336 | | /// |
337 | | /// @tparam TFactory The factory functor type. |
338 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
339 | | /// @param[in] factoryFn The factory functor to create the layer. |
340 | | /// @param[in] data The data to construct the layer from |
341 | | /// @param[in] dataLen The length of the data |
342 | | /// @param[in] packet The packet the layer belongs to |
343 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
344 | | /// @return The return value of the factory functor. |
345 | | template <typename TFactory, typename... Args> |
346 | | Layer* constructNextLayerFromFactory(TFactory factoryFn, uint8_t* data, size_t dataLen, Packet* packet, |
347 | | Args&&... extraArgs) |
348 | 607k | { |
349 | 607k | if (hasNextLayer()) |
350 | 0 | { |
351 | 0 | throw std::runtime_error("Next layer already exists"); |
352 | 0 | } |
353 | | |
354 | | // cppcheck-suppress redundantInitialization |
355 | 607k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); |
356 | 607k | setNextLayer(newLayer); |
357 | 607k | return newLayer; |
358 | 607k | } 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 | 61.3k | { | 349 | 61.3k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 61.3k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 61.3k | setNextLayer(newLayer); | 357 | 61.3k | return newLayer; | 358 | 61.3k | } |
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 | 67.8k | { | 349 | 67.8k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 67.8k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 67.8k | setNextLayer(newLayer); | 357 | 67.8k | return newLayer; | 358 | 67.8k | } |
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 | 372k | { | 349 | 372k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 372k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 372k | setNextLayer(newLayer); | 357 | 372k | return newLayer; | 358 | 372k | } |
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 | 15.9k | { | 349 | 15.9k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 15.9k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 15.9k | setNextLayer(newLayer); | 357 | 15.9k | return newLayer; | 358 | 15.9k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 1.02k | { | 349 | 1.02k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 1.02k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 1.02k | setNextLayer(newLayer); | 357 | 1.02k | return newLayer; | 358 | 1.02k | } |
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 | 90 | { | 349 | 90 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 90 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 90 | setNextLayer(newLayer); | 357 | 90 | return newLayer; | 358 | 90 | } |
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 | 291 | { | 349 | 291 | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 291 | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 291 | setNextLayer(newLayer); | 357 | 291 | return newLayer; | 358 | 291 | } |
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 | 12.7k | { | 349 | 12.7k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 12.7k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 12.7k | setNextLayer(newLayer); | 357 | 12.7k | return newLayer; | 358 | 12.7k | } |
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 | 1.54k | { | 349 | 1.54k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 1.54k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 1.54k | setNextLayer(newLayer); | 357 | 1.54k | return newLayer; | 358 | 1.54k | } |
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 | 69.2k | { | 349 | 69.2k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 69.2k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 69.2k | setNextLayer(newLayer); | 357 | 69.2k | return newLayer; | 358 | 69.2k | } |
pcpp::Layer* pcpp::Layer::constructNextLayerFromFactory<pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::StpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 348 | 5.24k | { | 349 | 5.24k | if (hasNextLayer()) | 350 | 0 | { | 351 | 0 | throw std::runtime_error("Next layer already exists"); | 352 | 0 | } | 353 | | | 354 | | // cppcheck-suppress redundantInitialization | 355 | 5.24k | Layer* newLayer = factoryFn(data, dataLen, this, packet, std::forward<Args>(extraArgs)...); | 356 | 5.24k | setNextLayer(newLayer); | 357 | 5.24k | return newLayer; | 358 | 5.24k | } |
|
359 | | |
360 | | /// Try to construct the next layer in the protocol stack. |
361 | | /// |
362 | | /// This overload infers the Packet from the current layer. |
363 | | /// |
364 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
365 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
366 | | /// |
367 | | /// @tparam T The type of the layer to construct |
368 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
369 | | /// @param[in] data The data to construct the layer from |
370 | | /// @param[in] dataLen The length of the data |
371 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
372 | | /// @return The constructed layer or nullptr if the data is invalid |
373 | | template <typename T, typename... Args> |
374 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
375 | 0 | { |
376 | 0 | return tryConstructNextLayer<T>(data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
377 | 0 | } |
378 | | |
379 | | /// Try to construct the next layer in the protocol stack. |
380 | | /// |
381 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
382 | | /// T::isDataValid(data, dataLen). If the data is invalid, no layer is constructed and a nullptr is returned. |
383 | | /// |
384 | | /// @tparam T The type of the layer to construct |
385 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor |
386 | | /// @param[in] data The data to construct the layer from |
387 | | /// @param[in] dataLen The length of the data |
388 | | /// @param[in] packet The packet the layer belongs to |
389 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor |
390 | | /// @return The constructed layer or nullptr if the data is invalid |
391 | | template <typename T, typename... Args> |
392 | | Layer* tryConstructNextLayer(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
393 | 2.34M | { |
394 | 2.34M | if (T::isDataValid(data, dataLen)) |
395 | 2.32M | { |
396 | 2.32M | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); |
397 | 2.32M | } |
398 | 14.9k | return nullptr; |
399 | 2.34M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv4Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 853k | { | 394 | 853k | if (T::isDataValid(data, dataLen)) | 395 | 849k | { | 396 | 849k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 849k | } | 398 | 3.73k | return nullptr; | 399 | 853k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IPv6Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 250k | { | 394 | 250k | if (T::isDataValid(data, dataLen)) | 395 | 250k | { | 396 | 250k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 250k | } | 398 | 69 | return nullptr; | 399 | 250k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPP_PPTPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 9.05k | { | 394 | 9.05k | if (T::isDataValid(data, dataLen)) | 395 | 8.44k | { | 396 | 8.44k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 8.44k | } | 398 | 616 | return nullptr; | 399 | 9.05k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthLayer>(unsigned char*, unsigned long, pcpp::Packet*) Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::EthDot3Layer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GtpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 7.38k | { | 394 | 7.38k | if (T::isDataValid(data, dataLen)) | 395 | 5.78k | { | 396 | 5.78k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 5.78k | } | 398 | 1.59k | return nullptr; | 399 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::UdpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 283k | { | 394 | 283k | if (T::isDataValid(data, dataLen)) | 395 | 282k | { | 396 | 282k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 282k | } | 398 | 83 | return nullptr; | 399 | 283k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::TcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 720k | { | 394 | 720k | if (T::isDataValid(data, dataLen)) | 395 | 716k | { | 396 | 716k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 716k | } | 398 | 3.43k | return nullptr; | 399 | 720k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IcmpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 19.8k | { | 394 | 19.8k | if (T::isDataValid(data, dataLen)) | 395 | 19.2k | { | 396 | 19.2k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 19.2k | } | 398 | 606 | return nullptr; | 399 | 19.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv0Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 8.42k | { | 394 | 8.42k | if (T::isDataValid(data, dataLen)) | 395 | 8.42k | { | 396 | 8.42k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 8.42k | } | 398 | 0 | return nullptr; | 399 | 8.42k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::GREv1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 17.8k | { | 394 | 17.8k | if (T::isDataValid(data, dataLen)) | 395 | 17.8k | { | 396 | 17.8k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 17.8k | } | 398 | 0 | return nullptr; | 399 | 17.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV1Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 1.88k | { | 394 | 1.88k | if (T::isDataValid(data, dataLen)) | 395 | 1.88k | { | 396 | 1.88k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 1.88k | } | 398 | 0 | return nullptr; | 399 | 1.88k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 3.14k | { | 394 | 3.14k | if (T::isDataValid(data, dataLen)) | 395 | 3.14k | { | 396 | 3.14k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 3.14k | } | 398 | 0 | return nullptr; | 399 | 3.14k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3QueryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 36 | { | 394 | 36 | if (T::isDataValid(data, dataLen)) | 395 | 36 | { | 396 | 36 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 36 | } | 398 | 0 | return nullptr; | 399 | 36 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::IgmpV3ReportLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.13k | { | 394 | 2.13k | if (T::isDataValid(data, dataLen)) | 395 | 2.13k | { | 396 | 2.13k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.13k | } | 398 | 0 | return nullptr; | 399 | 2.13k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::AuthenticationHeaderLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 28 | { | 394 | 28 | if (T::isDataValid(data, dataLen)) | 395 | 28 | { | 396 | 28 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 28 | } | 398 | 0 | return nullptr; | 399 | 28 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ESPLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 55 | { | 394 | 55 | if (T::isDataValid(data, dataLen)) | 395 | 55 | { | 396 | 55 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 55 | } | 398 | 0 | return nullptr; | 399 | 55 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV2Layer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 12.4k | { | 394 | 12.4k | if (T::isDataValid(data, dataLen)) | 395 | 12.4k | { | 396 | 12.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 12.4k | } | 398 | 0 | return nullptr; | 399 | 12.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VrrpV3Layer, pcpp::IPAddress::AddressType>(unsigned char*, unsigned long, pcpp::Packet*, pcpp::IPAddress::AddressType&&) Line | Count | Source | 393 | 5.03k | { | 394 | 5.03k | if (T::isDataValid(data, dataLen)) | 395 | 5.03k | { | 396 | 5.03k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 5.03k | } | 398 | 0 | return nullptr; | 399 | 5.03k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoESessionLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 26.5k | { | 394 | 26.5k | if (T::isDataValid(data, dataLen)) | 395 | 26.4k | { | 396 | 26.4k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 26.4k | } | 398 | 128 | return nullptr; | 399 | 26.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::PPPoEDiscoveryLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 440 | { | 394 | 440 | if (T::isDataValid(data, dataLen)) | 395 | 440 | { | 396 | 440 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 440 | } | 398 | 0 | return nullptr; | 399 | 440 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::LLCLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 13.0k | { | 394 | 13.0k | if (T::isDataValid(data, dataLen)) | 395 | 12.3k | { | 396 | 12.3k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 12.3k | } | 398 | 746 | return nullptr; | 399 | 13.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::CotpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 12.4k | { | 394 | 12.4k | if (T::isDataValid(data, dataLen)) | 395 | 10.6k | { | 396 | 10.6k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 10.6k | } | 398 | 1.72k | return nullptr; | 399 | 12.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::DhcpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 20.8k | { | 394 | 20.8k | if (T::isDataValid(data, dataLen)) | 395 | 20.6k | { | 396 | 20.6k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 20.6k | } | 398 | 192 | return nullptr; | 399 | 20.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VxlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 6.20k | { | 394 | 6.20k | if (T::isDataValid(data, dataLen)) | 395 | 6.20k | { | 396 | 6.20k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 6.20k | } | 398 | 0 | return nullptr; | 399 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::S7CommLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 8.62k | { | 394 | 8.62k | if (T::isDataValid(data, dataLen)) | 395 | 7.17k | { | 396 | 7.17k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 7.17k | } | 398 | 1.44k | return nullptr; | 399 | 8.62k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::ArpLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 15.6k | { | 394 | 15.6k | 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 | 0 | return nullptr; | 399 | 15.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::VlanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 39.9k | { | 394 | 39.9k | if (T::isDataValid(data, dataLen)) | 395 | 39.7k | { | 396 | 39.7k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 39.7k | } | 398 | 132 | return nullptr; | 399 | 39.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::MplsLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 2.74k | { | 394 | 2.74k | if (T::isDataValid(data, dataLen)) | 395 | 2.74k | { | 396 | 2.74k | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 2.74k | } | 398 | 0 | return nullptr; | 399 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayer<pcpp::WakeOnLanLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 393 | 519 | { | 394 | 519 | if (T::isDataValid(data, dataLen)) | 395 | 87 | { | 396 | 87 | return constructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...); | 397 | 87 | } | 398 | 432 | return nullptr; | 399 | 519 | } |
|
400 | | |
401 | | /// @brief Try to construct the next layer in the protocol stack with a fallback option. |
402 | | /// |
403 | | /// This overload infers the Packet from the current layer. |
404 | | /// |
405 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
406 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
407 | | /// |
408 | | /// @tparam T The type of the layer to construct |
409 | | /// @tparam TFallback The fallback layer type to construct if T fails |
410 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
411 | | /// @param[in] data The data to construct the layer from |
412 | | /// @param[in] dataLen The length of the data |
413 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
414 | | /// @return The constructed layer of type T or TFallback |
415 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
416 | | /// constructor. |
417 | | template <typename T, typename TFallback, typename... Args> |
418 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Args&&... extraArgs) |
419 | 1.48M | { |
420 | 1.48M | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), |
421 | 1.48M | std::forward<Args>(extraArgs)...); |
422 | 1.48M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 853k | { | 420 | 853k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 853k | std::forward<Args>(extraArgs)...); | 422 | 853k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 243k | { | 420 | 243k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 243k | std::forward<Args>(extraArgs)...); | 422 | 243k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 9.05k | { | 420 | 9.05k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 9.05k | std::forward<Args>(extraArgs)...); | 422 | 9.05k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 7.38k | { | 420 | 7.38k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 7.38k | std::forward<Args>(extraArgs)...); | 422 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 9.18k | { | 420 | 9.18k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 9.18k | std::forward<Args>(extraArgs)...); | 422 | 9.18k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 217k | { | 420 | 217k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 217k | std::forward<Args>(extraArgs)...); | 422 | 217k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 3.24k | { | 420 | 3.24k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 3.24k | std::forward<Args>(extraArgs)...); | 422 | 3.24k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long) 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 | 50 | { | 420 | 50 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 50 | std::forward<Args>(extraArgs)...); | 422 | 50 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 26.5k | { | 420 | 26.5k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 26.5k | std::forward<Args>(extraArgs)...); | 422 | 26.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 440 | { | 420 | 440 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 440 | std::forward<Args>(extraArgs)...); | 422 | 440 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 13.0k | { | 420 | 13.0k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 13.0k | std::forward<Args>(extraArgs)...); | 422 | 13.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 12.4k | { | 420 | 12.4k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 12.4k | std::forward<Args>(extraArgs)...); | 422 | 12.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 20.8k | { | 420 | 20.8k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 20.8k | std::forward<Args>(extraArgs)...); | 422 | 20.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 6.20k | { | 420 | 6.20k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 6.20k | std::forward<Args>(extraArgs)...); | 422 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 8.62k | { | 420 | 8.62k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 8.62k | std::forward<Args>(extraArgs)...); | 422 | 8.62k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 15.6k | { | 420 | 15.6k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 15.6k | std::forward<Args>(extraArgs)...); | 422 | 15.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 39.9k | { | 420 | 39.9k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 39.9k | std::forward<Args>(extraArgs)...); | 422 | 39.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 2.74k | { | 420 | 2.74k | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 2.74k | std::forward<Args>(extraArgs)...); | 422 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long) Line | Count | Source | 419 | 519 | { | 420 | 519 | return tryConstructNextLayerWithFallback<T, TFallback>(data, dataLen, getAttachedPacket(), | 421 | 519 | std::forward<Args>(extraArgs)...); | 422 | 519 | } |
|
423 | | |
424 | | /// Try to construct the next layer in the protocol stack with a fallback option. |
425 | | /// |
426 | | /// The method checks if the data is valid for the layer type T before constructing it by calling |
427 | | /// T::isDataValid(data, dataLen). If the data is invalid, it constructs the layer of type TFallback. |
428 | | /// |
429 | | /// @tparam T The type of the layer to construct |
430 | | /// @tparam TFallback The fallback layer type to construct if T fails |
431 | | /// @tparam Args The types of the extra arguments to pass to the layer constructor of T |
432 | | /// @param[in] data The data to construct the layer from |
433 | | /// @param[in] dataLen The length of the data |
434 | | /// @param[in] packet The packet the layer belongs to |
435 | | /// @param[in] extraArgs Extra arguments to be forwarded to the layer constructor of T |
436 | | /// @return The constructed layer of type T or TFallback |
437 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
438 | | /// constructor. |
439 | | template <typename T, typename TFallback, typename... Args> |
440 | | Layer* tryConstructNextLayerWithFallback(uint8_t* data, size_t dataLen, Packet* packet, Args&&... extraArgs) |
441 | 2.34M | { |
442 | 2.34M | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) |
443 | 2.32M | { |
444 | 2.32M | return m_NextLayer; |
445 | 2.32M | } |
446 | | |
447 | 14.9k | return constructNextLayer<TFallback>(data, dataLen, packet); |
448 | 2.34M | } pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv4Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 853k | { | 442 | 853k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 849k | { | 444 | 849k | return m_NextLayer; | 445 | 849k | } | 446 | | | 447 | 3.73k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 853k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IPv6Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 250k | { | 442 | 250k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 250k | { | 444 | 250k | return m_NextLayer; | 445 | 250k | } | 446 | | | 447 | 69 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 250k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPP_PPTPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 9.05k | { | 442 | 9.05k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 8.44k | { | 444 | 8.44k | return m_NextLayer; | 445 | 8.44k | } | 446 | | | 447 | 616 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 9.05k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::EthDot3Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GtpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 7.38k | { | 442 | 7.38k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 5.78k | { | 444 | 5.78k | return m_NextLayer; | 445 | 5.78k | } | 446 | | | 447 | 1.59k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 7.38k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::UdpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 283k | { | 442 | 283k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 282k | { | 444 | 282k | return m_NextLayer; | 445 | 282k | } | 446 | | | 447 | 83 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 283k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::TcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 720k | { | 442 | 720k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 716k | { | 444 | 716k | return m_NextLayer; | 445 | 716k | } | 446 | | | 447 | 3.43k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 720k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IcmpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 19.8k | { | 442 | 19.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 19.2k | { | 444 | 19.2k | return m_NextLayer; | 445 | 19.2k | } | 446 | | | 447 | 606 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 19.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv0Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 8.42k | { | 442 | 8.42k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 8.42k | { | 444 | 8.42k | return m_NextLayer; | 445 | 8.42k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 8.42k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::GREv1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 17.8k | { | 442 | 17.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 17.8k | { | 444 | 17.8k | return m_NextLayer; | 445 | 17.8k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 17.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV1Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 1.88k | { | 442 | 1.88k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 1.88k | { | 444 | 1.88k | return m_NextLayer; | 445 | 1.88k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 1.88k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 3.14k | { | 442 | 3.14k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 3.14k | { | 444 | 3.14k | return m_NextLayer; | 445 | 3.14k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 3.14k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3QueryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 36 | { | 442 | 36 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 36 | { | 444 | 36 | return m_NextLayer; | 445 | 36 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 36 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::IgmpV3ReportLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.13k | { | 442 | 2.13k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.13k | { | 444 | 2.13k | return m_NextLayer; | 445 | 2.13k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.13k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::AuthenticationHeaderLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 28 | { | 442 | 28 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 28 | { | 444 | 28 | return m_NextLayer; | 445 | 28 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 28 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ESPLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 55 | { | 442 | 55 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 55 | { | 444 | 55 | return m_NextLayer; | 445 | 55 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 55 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VrrpV2Layer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 12.4k | { | 442 | 12.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 12.4k | { | 444 | 12.4k | return m_NextLayer; | 445 | 12.4k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 12.4k | } |
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 | 5.03k | { | 442 | 5.03k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 5.03k | { | 444 | 5.03k | return m_NextLayer; | 445 | 5.03k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 5.03k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoESessionLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 26.5k | { | 442 | 26.5k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 26.4k | { | 444 | 26.4k | return m_NextLayer; | 445 | 26.4k | } | 446 | | | 447 | 128 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 26.5k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::PPPoEDiscoveryLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 440 | { | 442 | 440 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 440 | { | 444 | 440 | return m_NextLayer; | 445 | 440 | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 440 | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::LLCLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 13.0k | { | 442 | 13.0k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 12.3k | { | 444 | 12.3k | return m_NextLayer; | 445 | 12.3k | } | 446 | | | 447 | 746 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 13.0k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::CotpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 12.4k | { | 442 | 12.4k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 10.6k | { | 444 | 10.6k | return m_NextLayer; | 445 | 10.6k | } | 446 | | | 447 | 1.72k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 12.4k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::DhcpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 20.8k | { | 442 | 20.8k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 20.6k | { | 444 | 20.6k | return m_NextLayer; | 445 | 20.6k | } | 446 | | | 447 | 192 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 20.8k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VxlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 6.20k | { | 442 | 6.20k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 6.20k | { | 444 | 6.20k | return m_NextLayer; | 445 | 6.20k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 6.20k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::S7CommLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 8.62k | { | 442 | 8.62k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 7.17k | { | 444 | 7.17k | return m_NextLayer; | 445 | 7.17k | } | 446 | | | 447 | 1.44k | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 8.62k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::ArpLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 15.6k | { | 442 | 15.6k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 15.6k | { | 444 | 15.6k | return m_NextLayer; | 445 | 15.6k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 15.6k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::VlanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 39.9k | { | 442 | 39.9k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 39.7k | { | 444 | 39.7k | return m_NextLayer; | 445 | 39.7k | } | 446 | | | 447 | 132 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 39.9k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::MplsLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 2.74k | { | 442 | 2.74k | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 2.74k | { | 444 | 2.74k | return m_NextLayer; | 445 | 2.74k | } | 446 | | | 447 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 2.74k | } |
pcpp::Layer* pcpp::Layer::tryConstructNextLayerWithFallback<pcpp::WakeOnLanLayer, pcpp::PayloadLayer>(unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 441 | 519 | { | 442 | 519 | if (tryConstructNextLayer<T>(data, dataLen, packet, std::forward<Args>(extraArgs)...)) | 443 | 87 | { | 444 | 87 | return m_NextLayer; | 445 | 87 | } | 446 | | | 447 | 432 | return constructNextLayer<TFallback>(data, dataLen, packet); | 448 | 519 | } |
|
449 | | |
450 | | /// @brief Try to construct the next layer in the protocol stack using a factory functor with a fallback option. |
451 | | /// |
452 | | /// The method will attempt to construct the next layer using the provided factory function. |
453 | | /// If the factory function returns nullptr, indicating failure to create the layer, the method will then |
454 | | /// construct a layer of type TFallback. |
455 | | /// |
456 | | /// The factory functor is expected to have the following signature: |
457 | | /// Layer* factoryFn(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet, ...); |
458 | | /// |
459 | | /// This overload infers the Packet from the current layer. |
460 | | /// |
461 | | /// @tparam TFallback The fallback layer type to construct if the factory fails. |
462 | | /// @tparam TFactory The factory functor type. |
463 | | /// @tparam ...Args Parameter pack for extra arguments to pass to the factory functor. |
464 | | /// @param[in] factoryFn The factory functor to create the layer. |
465 | | /// @param[in] data The data to construct the layer from |
466 | | /// @param[in] dataLen The length of the data |
467 | | /// @param[in] extraArgs Extra arguments to be forwarded to the factory. |
468 | | /// @return The return value of the factory functor. |
469 | | /// @remarks The parameters extraArgs are forwarded to the factory function, but not to the TFallback |
470 | | /// constructor. |
471 | | template <typename TFallback, typename TFactory, typename... Args> |
472 | | Layer* tryConstructNextLayerFromFactoryWithFallback(TFactory factoryFn, uint8_t* data, size_t dataLen, |
473 | | Args&&... extraArgs) |
474 | 114k | { |
475 | | // Note that the fallback is first to allow template argument deduction of the factory type. |
476 | 114k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( |
477 | 114k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); |
478 | 114k | } 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 | 29.6k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 29.6k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 29.6k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 29.6k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long) Line | Count | Source | 474 | 965 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 965 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 965 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 965 | } |
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 | 90 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 90 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 90 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 90 | } |
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 | 291 | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 291 | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 291 | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 291 | } |
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 | 12.7k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 12.7k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 12.7k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 12.7k | } |
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 | 1.54k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 1.54k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 1.54k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 1.54k | } |
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 | 69.2k | { | 475 | | // Note that the fallback is first to allow template argument deduction of the factory type. | 476 | 69.2k | return tryConstructNextLayerFromFactoryWithFallback<TFallback, TFactory>( | 477 | 69.2k | factoryFn, data, dataLen, getAttachedPacket(), std::forward<Args>(extraArgs)...); | 478 | 69.2k | } |
|
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 | 114k | { |
504 | 114k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, |
505 | 114k | std::forward<Args>(extraArgs)...); |
506 | 114k | if (nextLayer != nullptr) |
507 | 42.6k | { |
508 | 42.6k | return nextLayer; |
509 | 42.6k | } |
510 | | |
511 | | // factory failed, construct fallback layer |
512 | 71.8k | return constructNextLayer<TFallback>(data, dataLen, packet); |
513 | 114k | } 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 | 29.6k | { | 504 | 29.6k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 29.6k | std::forward<Args>(extraArgs)...); | 506 | 29.6k | if (nextLayer != nullptr) | 507 | 28.7k | { | 508 | 28.7k | return nextLayer; | 509 | 28.7k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 841 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 29.6k | } |
Unexecuted instantiation: pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::DoIpLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) pcpp::Layer* pcpp::Layer::tryConstructNextLayerFromFactoryWithFallback<pcpp::PayloadLayer, pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*)>(pcpp::LdapLayer* (*)(unsigned char*, unsigned long, pcpp::Layer*, pcpp::Packet*), unsigned char*, unsigned long, pcpp::Packet*) Line | Count | Source | 503 | 965 | { | 504 | 965 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 965 | std::forward<Args>(extraArgs)...); | 506 | 965 | if (nextLayer != nullptr) | 507 | 179 | { | 508 | 179 | return nextLayer; | 509 | 179 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 786 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 965 | } |
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 | 90 | { | 504 | 90 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 90 | std::forward<Args>(extraArgs)...); | 506 | 90 | if (nextLayer != nullptr) | 507 | 90 | { | 508 | 90 | return nextLayer; | 509 | 90 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 90 | } |
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 | 291 | { | 504 | 291 | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 291 | std::forward<Args>(extraArgs)...); | 506 | 291 | if (nextLayer != nullptr) | 507 | 291 | { | 508 | 291 | return nextLayer; | 509 | 291 | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 291 | } |
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 | 12.7k | { | 504 | 12.7k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 12.7k | std::forward<Args>(extraArgs)...); | 506 | 12.7k | if (nextLayer != nullptr) | 507 | 10.4k | { | 508 | 10.4k | return nextLayer; | 509 | 10.4k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 2.32k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 12.7k | } |
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 | 1.54k | { | 504 | 1.54k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 1.54k | std::forward<Args>(extraArgs)...); | 506 | 1.54k | if (nextLayer != nullptr) | 507 | 1.54k | { | 508 | 1.54k | return nextLayer; | 509 | 1.54k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 0 | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 1.54k | } |
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 | 69.2k | { | 504 | 69.2k | auto nextLayer = constructNextLayerFromFactory<TFactory>(factoryFn, data, dataLen, packet, | 505 | 69.2k | std::forward<Args>(extraArgs)...); | 506 | 69.2k | if (nextLayer != nullptr) | 507 | 1.32k | { | 508 | 1.32k | return nextLayer; | 509 | 1.32k | } | 510 | | | 511 | | // factory failed, construct fallback layer | 512 | 67.8k | return constructNextLayer<TFallback>(data, dataLen, packet); | 513 | 69.2k | } |
|
514 | | |
515 | | /// @brief Check if the data is large enough to reinterpret as a type |
516 | | /// |
517 | | /// The data must be non-null and at least as large as the type |
518 | | /// |
519 | | /// @tparam T The type to reinterpret as |
520 | | /// @param data The data to check |
521 | | /// @param dataLen The length of the data |
522 | | /// @return True if the data is large enough to reinterpret as T, false otherwise |
523 | | template <typename T> static bool canReinterpretAs(const uint8_t* data, size_t dataLen) |
524 | 1.82M | { |
525 | 1.82M | return data != nullptr && dataLen >= sizeof(T); |
526 | 1.82M | } bool pcpp::Layer::canReinterpretAs<pcpp::arphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 15.6k | { | 525 | 15.6k | return data != nullptr && dataLen >= sizeof(T); | 526 | 15.6k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::iphdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 872k | { | 525 | 872k | return data != nullptr && dataLen >= sizeof(T); | 526 | 872k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::dhcp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 20.8k | { | 525 | 20.8k | return data != nullptr && dataLen >= sizeof(T); | 526 | 20.8k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vrrp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 17.5k | { | 525 | 17.5k | return data != nullptr && dataLen >= sizeof(T); | 526 | 17.5k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ip6_hdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 253k | { | 525 | 253k | return data != nullptr && dataLen >= sizeof(T); | 526 | 253k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 39.9k | { | 525 | 39.9k | return data != nullptr && dataLen >= sizeof(T); | 526 | 39.9k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::MplsLayer::mpls_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 2.74k | { | 525 | 2.74k | return data != nullptr && dataLen >= sizeof(T); | 526 | 2.74k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmp_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 5.02k | { | 525 | 5.02k | return data != nullptr && dataLen >= sizeof(T); | 526 | 5.02k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_query_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 36 | { | 525 | 36 | return data != nullptr && dataLen >= sizeof(T); | 526 | 36 | } |
bool pcpp::Layer::canReinterpretAs<pcpp::igmpv3_report_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 2.13k | { | 525 | 2.13k | return data != nullptr && dataLen >= sizeof(T); | 526 | 2.13k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::ssl_tls_record_layer>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 372k | { | 525 | 372k | return data != nullptr && dataLen >= sizeof(T); | 526 | 372k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::tpkthdr>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 212k | { | 525 | 212k | return data != nullptr && dataLen >= sizeof(T); | 526 | 212k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::vxlan_header>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 6.20k | { | 525 | 6.20k | return data != nullptr && dataLen >= sizeof(T); | 526 | 6.20k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_tcn_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.97k | { | 525 | 1.97k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.97k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::stp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.98k | { | 525 | 1.98k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.98k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::rstp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 1.08k | { | 525 | 1.08k | return data != nullptr && dataLen >= sizeof(T); | 526 | 1.08k | } |
bool pcpp::Layer::canReinterpretAs<pcpp::mstp_conf_bpdu>(unsigned char const*, unsigned long) Line | Count | Source | 524 | 68 | { | 525 | 68 | return data != nullptr && dataLen >= sizeof(T); | 526 | 68 | } |
|
527 | | }; |
528 | | |
529 | | inline std::ostream& operator<<(std::ostream& os, const pcpp::Layer& layer) |
530 | 0 | { |
531 | 0 | os << layer.toString(); |
532 | 0 | return os; |
533 | 0 | } |
534 | | } // namespace pcpp |