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