Coverage Report

Created: 2026-03-31 07:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Tests/Fuzzers/ReadParsedPacket.h
Line
Count
Source
1
#pragma once
2
3
#include <Packet.h>
4
#include <IPv4Layer.h>
5
#include <TelnetLayer.h>
6
#include <BgpLayer.h>
7
#include <DhcpLayer.h>
8
#include <DhcpV6Layer.h>
9
#include <DnsLayer.h>
10
#include <IcmpLayer.h>
11
#include <NtpLayer.h>
12
#include <SSLLayer.h>
13
#include <SSLHandshake.h>
14
#include <TcpLayer.h>
15
#include <SdpLayer.h>
16
#include <VrrpLayer.h>
17
#include <Sll2Layer.h>
18
#include <FtpLayer.h>
19
#include <GreLayer.h>
20
#include <GtpLayer.h>
21
#include <SomeIpSdLayer.h>
22
23
// Call some pcpp::Packet methods that are not invoked from general virtual methods
24
// as `pcpp::Packet::toString` or `pcpp::Packet::computeCalculateFields` to trigger possible crashes.
25
// The general rule is the functions do not modify the `parsedPacket`.
26
// If you made changes to PcapPlusPlus and the code doesn't compile - fix the method call as any other unit test
27
static void readParsedPacket(pcpp::Packet parsedPacket, pcpp::Layer* layer)
28
850k
{
29
850k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
41.1k
  {
31
41.1k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
8.24k
    {
33
8.24k
      telnetLayer->getFirstCommand();
34
8.24k
      telnetLayer->getTotalNumberOfCommands();
35
36
8.24k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
8.24k
      do
38
36.3k
      {
39
36.3k
        commandVal = telnetLayer->getNextCommand();
40
36.3k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
36.3k
                  << std::endl;
42
36.3k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
36.3k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
36.3k
        telnetLayer->getDataAsString(true);
46
36.3k
        telnetLayer->getNumberOfCommands(commandVal);
47
36.3k
        telnetLayer->getOption(commandVal);
48
36.3k
        size_t length = 0;
49
36.3k
        telnetLayer->getOptionData(length);
50
36.3k
        telnetLayer->getOptionData(commandVal, length);
51
36.3k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
8.24k
    }
53
41.1k
  }
54
850k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.77k
  {
56
3.77k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.48k
    {
58
1.48k
      arpLayer->isReply();
59
1.48k
      arpLayer->isRequest();
60
1.48k
    }
61
3.77k
  }
62
850k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
30.9k
  {
64
30.9k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.67k
    {
66
3.67k
      auto entries = someipLayer->getEntries();
67
3.67k
      if (!entries.empty())
68
3.59k
      {
69
3.59k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.59k
        for (auto opt : opts)
71
2.35k
          delete opt;
72
3.59k
      }
73
74
3.67k
      for (auto entry : entries)
75
3.60k
      {
76
3.60k
        entry->getNumOptions();
77
3.60k
        entry->getServiceId();
78
3.60k
        entry->getInstanceId();
79
3.60k
        entry->getMajorVersion();
80
3.60k
        entry->getMinorVersion();
81
3.60k
        entry->getCounter();
82
3.60k
        entry->getEventgroupId();
83
3.60k
        delete entry;
84
3.60k
      }
85
86
3.67k
      someipLayer->getFlags();
87
3.67k
      auto opts = someipLayer->getOptions();
88
3.67k
      for (auto opt : opts)
89
2.90k
      {
90
2.90k
        opt->getType();
91
2.90k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
1.02k
        {
93
1.02k
          v4opt->getIpAddress();
94
1.02k
          v4opt->getPort();
95
1.02k
          v4opt->getProtocol();
96
1.02k
        }
97
1.88k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
779
        {
99
779
          v6opt->getIpAddress();
100
779
          v6opt->getPort();
101
779
          v6opt->getProtocol();
102
779
        }
103
2.90k
        delete opt;
104
2.90k
      }
105
3.67k
    }
106
30.9k
  }
107
850k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
27.2k
  {
109
27.2k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.73k
    {
111
4.73k
      uint16_t value16 = 0;
112
4.73k
      gtpLayer->getSequenceNumber(value16);
113
4.73k
      uint8_t value8;
114
4.73k
      gtpLayer->getNpduNumber(value8);
115
4.73k
      gtpLayer->getMessageType();
116
4.73k
      gtpLayer->getMessageTypeAsString();
117
4.73k
      gtpLayer->isGTPUMessage();
118
4.73k
      gtpLayer->isGTPCMessage();
119
4.73k
      auto ext = gtpLayer->getNextExtension();
120
4.73k
      ext.getExtensionType();
121
4.73k
      ext.getContent();
122
4.73k
      ext.getContentLength();
123
4.73k
      ext.getNextExtension();
124
4.73k
    }
125
27.2k
  }
126
850k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
75.6k
  {
128
75.6k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
9.58k
    {
130
9.58k
      uint32_t value32 = 0;
131
9.58k
      greLayer->getSequenceNumber(value32);
132
9.58k
    }
133
75.6k
  }
134
850k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.11k
  {
136
8.11k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
1.96k
    {
138
1.96k
      uint16_t value16 = 0;
139
1.96k
      greLayer->getChecksum(value16);
140
1.96k
      greLayer->getOffset(value16);
141
1.96k
      uint32_t value32 = 0;
142
1.96k
      greLayer->getKey(value32);
143
1.96k
    }
144
8.11k
  }
145
850k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
67.5k
  {
147
67.5k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
7.62k
    {
149
7.62k
      uint32_t value32 = 0;
150
7.62k
      greLayer->getAcknowledgmentNum(value32);
151
7.62k
    }
152
67.5k
  }
153
850k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
9.48k
  {
155
9.48k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
9.48k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
1.73k
    {
162
1.73k
      ftpLayer->getStatusCode();
163
1.73k
      ftpLayer->getStatusOption(false);
164
1.73k
      ftpLayer->getStatusOption(true);
165
1.73k
    }
166
9.48k
  }
167
850k
  if (parsedPacket.isPacketOfType(pcpp::SLL2))
168
0
  {
169
0
    if (auto sllLayer = dynamic_cast<pcpp::Sll2Layer*>(layer))
170
0
    {
171
0
      sllLayer->getLinkLayerAsMacAddress();
172
0
      sllLayer->getProtocolType();
173
0
      sllLayer->getInterfaceIndex();
174
0
      sllLayer->getArphrdType();
175
0
      sllLayer->getPacketType();
176
0
    }
177
0
  }
178
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.95k
  {
180
8.95k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.54k
    {
182
2.54k
      vrrpLayer->getIPAddresses();
183
2.54k
      vrrpLayer->isChecksumCorrect();
184
2.54k
      vrrpLayer->getChecksum();
185
2.54k
      vrrpLayer->getPriorityAsEnum();
186
2.54k
      vrrpLayer->getPriority();
187
2.54k
      vrrpLayer->getType();
188
2.54k
    }
189
8.95k
  }
190
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.99k
  {
192
2.99k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
988
    {
194
988
      vrrpLayer->getAuthTypeAsEnum();
195
988
      vrrpLayer->getAdvInt();
196
988
    }
197
2.99k
  }
198
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.96k
  {
200
5.96k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.55k
    {
202
1.55k
      vrrpLayer->getMaxAdvInt();
203
1.55k
    }
204
5.96k
  }
205
850k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
429k
  {
207
429k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
96.9k
    {
209
96.9k
      auto tcpLayer2(*tcpLayer);
210
96.9k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
96.9k
                                     pcpp::TcpOptionEnumType::Nop);
212
96.9k
    }
213
429k
  }
214
850k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
34.9k
  {
216
34.9k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.48k
    {
218
3.48k
      sdpLayer->getOwnerIPv4Address();
219
3.48k
      sdpLayer->getMediaPort("audio");
220
3.48k
      sdpLayer->getFieldCount();
221
222
3.48k
      auto sdpLayer2 = *sdpLayer;
223
3.48k
      std::vector<std::string> audioAttributes;
224
3.48k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.48k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.48k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.48k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.48k
    }
229
34.9k
  }
230
850k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
97.7k
  {
232
97.7k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
19.2k
    {
234
19.2k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
6.00k
      {
236
6.00k
        clientHelloMessage->getCompressionMethodsValue();
237
6.00k
        clientHelloMessage->getSessionID();
238
6.00k
        clientHelloMessage->getHandshakeType();
239
6.00k
        clientHelloMessage->getHandshakeVersion();
240
241
6.00k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
5.62M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.61M
        {
244
5.61M
          clientHelloMessage->getCipherSuite(i);
245
5.61M
          bool valid;
246
5.61M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.61M
        }
248
6.00k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
3.05k
          ext->getHostName();
250
6.00k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
711
          ext->getSupportedVersions();
252
253
6.00k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
6.00k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
6.00k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
6.00k
        fingerprint.toMD5();
258
6.00k
      }
259
19.2k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.71k
      {
261
4.71k
        serverHelloMessage->getCompressionMethodsValue();
262
4.71k
        serverHelloMessage->getSessionID();
263
4.71k
        serverHelloMessage->getCipherSuite();
264
265
4.71k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.71k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.71k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.71k
        serverHelloMessage->getHandshakeVersion();
270
4.71k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.71k
        fingerprint.toMD5();
272
4.71k
      }
273
19.2k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
18.0k
      {
275
18.0k
        handshakeMessage->isMessageComplete();
276
18.0k
      }
277
19.2k
    }
278
97.7k
  }
279
850k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
13.4k
  {
281
13.4k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.35k
    {
283
3.35k
      ntpLayer->getLeapIndicator();
284
3.35k
      ntpLayer->getMode();
285
3.35k
      ntpLayer->getModeString();
286
3.35k
      ntpLayer->getStratum();
287
3.35k
      ntpLayer->getPollInterval();
288
3.35k
      ntpLayer->getPrecision();
289
3.35k
      ntpLayer->getRootDelay();
290
3.35k
      ntpLayer->getRootDispersion();
291
3.35k
      ntpLayer->getReferenceIdentifier();
292
3.35k
      ntpLayer->getReferenceIdentifierString();
293
3.35k
      ntpLayer->getReferenceTimestamp();
294
3.35k
      ntpLayer->getOriginTimestamp();
295
3.35k
      ntpLayer->getReceiveTimestamp();
296
3.35k
      ntpLayer->getTransmitTimestamp();
297
298
3.35k
      ntpLayer->getDigest();
299
3.35k
      ntpLayer->getKeyID();
300
301
3.35k
      ntpLayer->getPollIntervalInSecs();
302
3.35k
      ntpLayer->getPrecisionInSecs();
303
3.35k
      ntpLayer->getRootDelayInSecs();
304
3.35k
      ntpLayer->getRootDispersionInSecs();
305
3.35k
      ntpLayer->getReferenceTimestampInSecs();
306
3.35k
      ntpLayer->getOriginTimestampInSecs();
307
3.35k
      ntpLayer->getReceiveTimestampInSecs();
308
3.35k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.35k
      ntpLayer->getReferenceTimestampAsString();
311
3.35k
      ntpLayer->getOriginTimestampAsString();
312
3.35k
      ntpLayer->getReceiveTimestampAsString();
313
3.35k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.35k
      auto ntpLayer2(*ntpLayer);
316
3.35k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.35k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.35k
    }
319
13.4k
  }
320
850k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
34.1k
  {
322
34.1k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
7.46k
    {
324
7.46k
      auto icmpLayer2(*icmpLayer);
325
326
7.46k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.09k
      {
328
1.09k
        icmpLayer->getTimestampReplyData();
329
1.09k
        timeval orig = { 16131, 171000 };
330
1.09k
        timeval recv = { 16133, 474000 };
331
1.09k
        timeval tran = { 16133, 474000 };
332
1.09k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.09k
      }
334
6.37k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
30
      {
336
30
        icmpLayer->getAddressMaskRequestData();
337
30
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
30
      }
339
6.34k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
1.12k
      {
341
1.12k
        icmpLayer->getAddressMaskReplyData();
342
1.12k
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
1.12k
      }
344
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
586
      {
346
586
        icmpLayer->getDestUnreachableData();
347
586
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
586
      }
349
4.62k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
406
      {
351
406
        auto layerData = icmpLayer->getInfoReplyData();
352
406
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
406
      }
354
4.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
568
      {
356
568
        auto layerData = icmpLayer->getInfoRequestData();
357
568
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
568
      }
359
3.65k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
685
      {
361
685
        auto layerData = icmpLayer->getParamProblemData();
362
685
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
685
      }
364
2.96k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.38k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
735
      {
371
735
        icmpLayer->getRouterAdvertisementData();
372
735
        pcpp::icmp_router_address_structure addr1;
373
735
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
735
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
735
        routerAddresses.push_back(addr1);
376
735
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
735
      }
378
7.46k
    }
379
34.1k
  }
380
850k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
16.0k
  {
382
16.0k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.79k
    {
384
3.79k
      dhcpLayer->getTransactionID();
385
3.79k
      if (dhcpLayer->getOptionCount() > 0)
386
3.62k
      {
387
3.62k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.62k
        opt.getType();
389
3.62k
        opt.getTotalSize();
390
3.62k
        opt.getValueAsHexString();
391
11.8k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.21k
        {
393
8.21k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.21k
        }
395
3.62k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.62k
      }
397
3.79k
    }
398
16.0k
  }
399
850k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.1k
  {
401
12.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.00k
    {
403
3.00k
      dhcpLayer->getOpCode();
404
3.00k
      dhcpLayer->getDhcpHeader();
405
3.00k
      dhcpLayer->getClientIpAddress();
406
3.00k
      dhcpLayer->getYourIpAddress();
407
3.00k
      dhcpLayer->getServerIpAddress();
408
3.00k
      dhcpLayer->getGatewayIpAddress();
409
3.00k
      dhcpLayer->getClientHardwareAddress();
410
3.00k
      if (dhcpLayer->getOptionsCount() > 0)
411
2.95k
      {
412
2.95k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
2.95k
        opt.getValueAsIpAddr();
414
2.95k
        opt.getValueAsString();
415
59.8k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
56.9k
        {
417
56.9k
          opt = dhcpLayer->getNextOptionData(opt);
418
56.9k
        }
419
2.95k
      }
420
3.00k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.00k
    }
422
12.1k
  }
423
850k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
42.1k
  {
425
42.1k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
19.4k
    {
427
19.4k
      bgpLayer->getMessageTypeAsString();
428
19.4k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.55k
      {
430
3.55k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.55k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.55k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.55k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.55k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.55k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.55k
      }
442
15.8k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
13.6k
      {
444
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
13.6k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
13.6k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
13.6k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
13.6k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
13.6k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
13.6k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
13.6k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
13.6k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
13.6k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
13.6k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
13.6k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
13.6k
        pathAttributes2.push_back(
468
13.6k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
13.6k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
13.6k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
13.6k
        bgpUpdateMsgLayer->clearPathAttributes();
472
13.6k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
13.6k
      }
474
2.17k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
626
      {
476
626
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
626
      }
478
19.4k
    }
479
42.1k
  }
480
850k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
64.9k
  {
482
64.9k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.3k
    {
484
15.3k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.3k
      dnsLayer->removeQuery("a", true);
486
15.3k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.3k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.3k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.3k
                          &ipv4DnsData);
490
15.3k
      dnsLayer->removeAnswer("a", true);
491
15.3k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.3k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.3k
      dnsLayer->removeAuthority("a", true);
494
15.3k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.3k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.3k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.3k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.3k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.3k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.0k
      while (add != nullptr)
502
2.70k
      {
503
2.70k
        add = dnsLayer->getNextAdditionalRecord(add);
504
2.70k
      }
505
506
15.3k
      auto answer = dnsLayer->getFirstAnswer();
507
19.2k
      while (answer != nullptr)
508
3.94k
      {
509
3.94k
        answer = dnsLayer->getNextAnswer(answer);
510
3.94k
      }
511
512
15.3k
      auto auth = dnsLayer->getFirstAuthority();
513
18.1k
      while (auth != nullptr)
514
2.86k
      {
515
2.86k
        auth = dnsLayer->getNextAuthority(auth);
516
2.86k
      }
517
518
15.3k
      pcpp::DnsLayer other(*dnsLayer);
519
15.3k
      other = *dnsLayer;
520
15.3k
    }
521
64.9k
  }
522
850k
}
Unexecuted instantiation: FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
Line
Count
Source
28
850k
{
29
850k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
41.1k
  {
31
41.1k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
8.24k
    {
33
8.24k
      telnetLayer->getFirstCommand();
34
8.24k
      telnetLayer->getTotalNumberOfCommands();
35
36
8.24k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
8.24k
      do
38
36.3k
      {
39
36.3k
        commandVal = telnetLayer->getNextCommand();
40
36.3k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
36.3k
                  << std::endl;
42
36.3k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
36.3k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
36.3k
        telnetLayer->getDataAsString(true);
46
36.3k
        telnetLayer->getNumberOfCommands(commandVal);
47
36.3k
        telnetLayer->getOption(commandVal);
48
36.3k
        size_t length = 0;
49
36.3k
        telnetLayer->getOptionData(length);
50
36.3k
        telnetLayer->getOptionData(commandVal, length);
51
36.3k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
8.24k
    }
53
41.1k
  }
54
850k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.77k
  {
56
3.77k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.48k
    {
58
1.48k
      arpLayer->isReply();
59
1.48k
      arpLayer->isRequest();
60
1.48k
    }
61
3.77k
  }
62
850k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
30.9k
  {
64
30.9k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.67k
    {
66
3.67k
      auto entries = someipLayer->getEntries();
67
3.67k
      if (!entries.empty())
68
3.59k
      {
69
3.59k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.59k
        for (auto opt : opts)
71
2.35k
          delete opt;
72
3.59k
      }
73
74
3.67k
      for (auto entry : entries)
75
3.60k
      {
76
3.60k
        entry->getNumOptions();
77
3.60k
        entry->getServiceId();
78
3.60k
        entry->getInstanceId();
79
3.60k
        entry->getMajorVersion();
80
3.60k
        entry->getMinorVersion();
81
3.60k
        entry->getCounter();
82
3.60k
        entry->getEventgroupId();
83
3.60k
        delete entry;
84
3.60k
      }
85
86
3.67k
      someipLayer->getFlags();
87
3.67k
      auto opts = someipLayer->getOptions();
88
3.67k
      for (auto opt : opts)
89
2.90k
      {
90
2.90k
        opt->getType();
91
2.90k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
1.02k
        {
93
1.02k
          v4opt->getIpAddress();
94
1.02k
          v4opt->getPort();
95
1.02k
          v4opt->getProtocol();
96
1.02k
        }
97
1.88k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
779
        {
99
779
          v6opt->getIpAddress();
100
779
          v6opt->getPort();
101
779
          v6opt->getProtocol();
102
779
        }
103
2.90k
        delete opt;
104
2.90k
      }
105
3.67k
    }
106
30.9k
  }
107
850k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
27.2k
  {
109
27.2k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.73k
    {
111
4.73k
      uint16_t value16 = 0;
112
4.73k
      gtpLayer->getSequenceNumber(value16);
113
4.73k
      uint8_t value8;
114
4.73k
      gtpLayer->getNpduNumber(value8);
115
4.73k
      gtpLayer->getMessageType();
116
4.73k
      gtpLayer->getMessageTypeAsString();
117
4.73k
      gtpLayer->isGTPUMessage();
118
4.73k
      gtpLayer->isGTPCMessage();
119
4.73k
      auto ext = gtpLayer->getNextExtension();
120
4.73k
      ext.getExtensionType();
121
4.73k
      ext.getContent();
122
4.73k
      ext.getContentLength();
123
4.73k
      ext.getNextExtension();
124
4.73k
    }
125
27.2k
  }
126
850k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
75.6k
  {
128
75.6k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
9.58k
    {
130
9.58k
      uint32_t value32 = 0;
131
9.58k
      greLayer->getSequenceNumber(value32);
132
9.58k
    }
133
75.6k
  }
134
850k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.11k
  {
136
8.11k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
1.96k
    {
138
1.96k
      uint16_t value16 = 0;
139
1.96k
      greLayer->getChecksum(value16);
140
1.96k
      greLayer->getOffset(value16);
141
1.96k
      uint32_t value32 = 0;
142
1.96k
      greLayer->getKey(value32);
143
1.96k
    }
144
8.11k
  }
145
850k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
67.5k
  {
147
67.5k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
7.62k
    {
149
7.62k
      uint32_t value32 = 0;
150
7.62k
      greLayer->getAcknowledgmentNum(value32);
151
7.62k
    }
152
67.5k
  }
153
850k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
9.48k
  {
155
9.48k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
9.48k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
1.73k
    {
162
1.73k
      ftpLayer->getStatusCode();
163
1.73k
      ftpLayer->getStatusOption(false);
164
1.73k
      ftpLayer->getStatusOption(true);
165
1.73k
    }
166
9.48k
  }
167
850k
  if (parsedPacket.isPacketOfType(pcpp::SLL2))
168
0
  {
169
0
    if (auto sllLayer = dynamic_cast<pcpp::Sll2Layer*>(layer))
170
0
    {
171
0
      sllLayer->getLinkLayerAsMacAddress();
172
0
      sllLayer->getProtocolType();
173
0
      sllLayer->getInterfaceIndex();
174
0
      sllLayer->getArphrdType();
175
0
      sllLayer->getPacketType();
176
0
    }
177
0
  }
178
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.95k
  {
180
8.95k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.54k
    {
182
2.54k
      vrrpLayer->getIPAddresses();
183
2.54k
      vrrpLayer->isChecksumCorrect();
184
2.54k
      vrrpLayer->getChecksum();
185
2.54k
      vrrpLayer->getPriorityAsEnum();
186
2.54k
      vrrpLayer->getPriority();
187
2.54k
      vrrpLayer->getType();
188
2.54k
    }
189
8.95k
  }
190
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.99k
  {
192
2.99k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
988
    {
194
988
      vrrpLayer->getAuthTypeAsEnum();
195
988
      vrrpLayer->getAdvInt();
196
988
    }
197
2.99k
  }
198
850k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.96k
  {
200
5.96k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.55k
    {
202
1.55k
      vrrpLayer->getMaxAdvInt();
203
1.55k
    }
204
5.96k
  }
205
850k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
429k
  {
207
429k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
96.9k
    {
209
96.9k
      auto tcpLayer2(*tcpLayer);
210
96.9k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
96.9k
                                     pcpp::TcpOptionEnumType::Nop);
212
96.9k
    }
213
429k
  }
214
850k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
34.9k
  {
216
34.9k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.48k
    {
218
3.48k
      sdpLayer->getOwnerIPv4Address();
219
3.48k
      sdpLayer->getMediaPort("audio");
220
3.48k
      sdpLayer->getFieldCount();
221
222
3.48k
      auto sdpLayer2 = *sdpLayer;
223
3.48k
      std::vector<std::string> audioAttributes;
224
3.48k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.48k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.48k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.48k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.48k
    }
229
34.9k
  }
230
850k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
97.7k
  {
232
97.7k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
19.2k
    {
234
19.2k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
6.00k
      {
236
6.00k
        clientHelloMessage->getCompressionMethodsValue();
237
6.00k
        clientHelloMessage->getSessionID();
238
6.00k
        clientHelloMessage->getHandshakeType();
239
6.00k
        clientHelloMessage->getHandshakeVersion();
240
241
6.00k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
5.62M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.61M
        {
244
5.61M
          clientHelloMessage->getCipherSuite(i);
245
5.61M
          bool valid;
246
5.61M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.61M
        }
248
6.00k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
3.05k
          ext->getHostName();
250
6.00k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
711
          ext->getSupportedVersions();
252
253
6.00k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
6.00k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
6.00k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
6.00k
        fingerprint.toMD5();
258
6.00k
      }
259
19.2k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.71k
      {
261
4.71k
        serverHelloMessage->getCompressionMethodsValue();
262
4.71k
        serverHelloMessage->getSessionID();
263
4.71k
        serverHelloMessage->getCipherSuite();
264
265
4.71k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.71k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.71k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.71k
        serverHelloMessage->getHandshakeVersion();
270
4.71k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.71k
        fingerprint.toMD5();
272
4.71k
      }
273
19.2k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
18.0k
      {
275
18.0k
        handshakeMessage->isMessageComplete();
276
18.0k
      }
277
19.2k
    }
278
97.7k
  }
279
850k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
13.4k
  {
281
13.4k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.35k
    {
283
3.35k
      ntpLayer->getLeapIndicator();
284
3.35k
      ntpLayer->getMode();
285
3.35k
      ntpLayer->getModeString();
286
3.35k
      ntpLayer->getStratum();
287
3.35k
      ntpLayer->getPollInterval();
288
3.35k
      ntpLayer->getPrecision();
289
3.35k
      ntpLayer->getRootDelay();
290
3.35k
      ntpLayer->getRootDispersion();
291
3.35k
      ntpLayer->getReferenceIdentifier();
292
3.35k
      ntpLayer->getReferenceIdentifierString();
293
3.35k
      ntpLayer->getReferenceTimestamp();
294
3.35k
      ntpLayer->getOriginTimestamp();
295
3.35k
      ntpLayer->getReceiveTimestamp();
296
3.35k
      ntpLayer->getTransmitTimestamp();
297
298
3.35k
      ntpLayer->getDigest();
299
3.35k
      ntpLayer->getKeyID();
300
301
3.35k
      ntpLayer->getPollIntervalInSecs();
302
3.35k
      ntpLayer->getPrecisionInSecs();
303
3.35k
      ntpLayer->getRootDelayInSecs();
304
3.35k
      ntpLayer->getRootDispersionInSecs();
305
3.35k
      ntpLayer->getReferenceTimestampInSecs();
306
3.35k
      ntpLayer->getOriginTimestampInSecs();
307
3.35k
      ntpLayer->getReceiveTimestampInSecs();
308
3.35k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.35k
      ntpLayer->getReferenceTimestampAsString();
311
3.35k
      ntpLayer->getOriginTimestampAsString();
312
3.35k
      ntpLayer->getReceiveTimestampAsString();
313
3.35k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.35k
      auto ntpLayer2(*ntpLayer);
316
3.35k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.35k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.35k
    }
319
13.4k
  }
320
850k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
34.1k
  {
322
34.1k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
7.46k
    {
324
7.46k
      auto icmpLayer2(*icmpLayer);
325
326
7.46k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.09k
      {
328
1.09k
        icmpLayer->getTimestampReplyData();
329
1.09k
        timeval orig = { 16131, 171000 };
330
1.09k
        timeval recv = { 16133, 474000 };
331
1.09k
        timeval tran = { 16133, 474000 };
332
1.09k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.09k
      }
334
6.37k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
30
      {
336
30
        icmpLayer->getAddressMaskRequestData();
337
30
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
30
      }
339
6.34k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
1.12k
      {
341
1.12k
        icmpLayer->getAddressMaskReplyData();
342
1.12k
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
1.12k
      }
344
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
586
      {
346
586
        icmpLayer->getDestUnreachableData();
347
586
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
586
      }
349
4.62k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
406
      {
351
406
        auto layerData = icmpLayer->getInfoReplyData();
352
406
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
406
      }
354
4.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
568
      {
356
568
        auto layerData = icmpLayer->getInfoRequestData();
357
568
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
568
      }
359
3.65k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
685
      {
361
685
        auto layerData = icmpLayer->getParamProblemData();
362
685
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
685
      }
364
2.96k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.38k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
735
      {
371
735
        icmpLayer->getRouterAdvertisementData();
372
735
        pcpp::icmp_router_address_structure addr1;
373
735
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
735
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
735
        routerAddresses.push_back(addr1);
376
735
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
735
      }
378
7.46k
    }
379
34.1k
  }
380
850k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
16.0k
  {
382
16.0k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.79k
    {
384
3.79k
      dhcpLayer->getTransactionID();
385
3.79k
      if (dhcpLayer->getOptionCount() > 0)
386
3.62k
      {
387
3.62k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.62k
        opt.getType();
389
3.62k
        opt.getTotalSize();
390
3.62k
        opt.getValueAsHexString();
391
11.8k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.21k
        {
393
8.21k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.21k
        }
395
3.62k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.62k
      }
397
3.79k
    }
398
16.0k
  }
399
850k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.1k
  {
401
12.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.00k
    {
403
3.00k
      dhcpLayer->getOpCode();
404
3.00k
      dhcpLayer->getDhcpHeader();
405
3.00k
      dhcpLayer->getClientIpAddress();
406
3.00k
      dhcpLayer->getYourIpAddress();
407
3.00k
      dhcpLayer->getServerIpAddress();
408
3.00k
      dhcpLayer->getGatewayIpAddress();
409
3.00k
      dhcpLayer->getClientHardwareAddress();
410
3.00k
      if (dhcpLayer->getOptionsCount() > 0)
411
2.95k
      {
412
2.95k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
2.95k
        opt.getValueAsIpAddr();
414
2.95k
        opt.getValueAsString();
415
59.8k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
56.9k
        {
417
56.9k
          opt = dhcpLayer->getNextOptionData(opt);
418
56.9k
        }
419
2.95k
      }
420
3.00k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.00k
    }
422
12.1k
  }
423
850k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
42.1k
  {
425
42.1k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
19.4k
    {
427
19.4k
      bgpLayer->getMessageTypeAsString();
428
19.4k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.55k
      {
430
3.55k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.55k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.55k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.55k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.55k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.55k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.55k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.55k
      }
442
15.8k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
13.6k
      {
444
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
13.6k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
13.6k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
13.6k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
13.6k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
13.6k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
13.6k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
13.6k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
13.6k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
13.6k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
13.6k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
13.6k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
13.6k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
13.6k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
13.6k
        pathAttributes2.push_back(
468
13.6k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
13.6k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
13.6k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
13.6k
        bgpUpdateMsgLayer->clearPathAttributes();
472
13.6k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
13.6k
      }
474
2.17k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
626
      {
476
626
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
626
      }
478
19.4k
    }
479
42.1k
  }
480
850k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
64.9k
  {
482
64.9k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.3k
    {
484
15.3k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.3k
      dnsLayer->removeQuery("a", true);
486
15.3k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.3k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.3k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.3k
                          &ipv4DnsData);
490
15.3k
      dnsLayer->removeAnswer("a", true);
491
15.3k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.3k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.3k
      dnsLayer->removeAuthority("a", true);
494
15.3k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.3k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.3k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.3k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.3k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.3k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.0k
      while (add != nullptr)
502
2.70k
      {
503
2.70k
        add = dnsLayer->getNextAdditionalRecord(add);
504
2.70k
      }
505
506
15.3k
      auto answer = dnsLayer->getFirstAnswer();
507
19.2k
      while (answer != nullptr)
508
3.94k
      {
509
3.94k
        answer = dnsLayer->getNextAnswer(answer);
510
3.94k
      }
511
512
15.3k
      auto auth = dnsLayer->getFirstAuthority();
513
18.1k
      while (auth != nullptr)
514
2.86k
      {
515
2.86k
        auth = dnsLayer->getNextAuthority(auth);
516
2.86k
      }
517
518
15.3k
      pcpp::DnsLayer other(*dnsLayer);
519
15.3k
      other = *dnsLayer;
520
15.3k
    }
521
64.9k
  }
522
850k
}