Coverage Report

Created: 2025-08-26 07:54

/src/PcapPlusPlus/Tests/Fuzzers/ReadParsedPacket.h
Line
Count
Source (jump to first uncovered line)
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
656k
{
29
656k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
39.7k
  {
31
39.7k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
7.94k
    {
33
7.94k
      telnetLayer->getFirstCommand();
34
7.94k
      telnetLayer->getTotalNumberOfCommands();
35
36
7.94k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
7.94k
      do
38
31.4k
      {
39
31.4k
        commandVal = telnetLayer->getNextCommand();
40
31.4k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
31.4k
                  << std::endl;
42
31.4k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
31.4k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
31.4k
        telnetLayer->getDataAsString(true);
46
31.4k
        telnetLayer->getNumberOfCommands(commandVal);
47
31.4k
        telnetLayer->getOption(commandVal);
48
31.4k
        size_t length = 0;
49
31.4k
        telnetLayer->getOptionData(length);
50
31.4k
        telnetLayer->getOptionData(commandVal, length);
51
31.4k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
7.94k
    }
53
39.7k
  }
54
656k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.33k
  {
56
3.33k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.04k
    {
58
1.04k
      arpLayer->isReply();
59
1.04k
      arpLayer->isRequest();
60
1.04k
    }
61
3.33k
  }
62
656k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
27.5k
  {
64
27.5k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.15k
    {
66
3.15k
      auto entries = someipLayer->getEntries();
67
3.15k
      if (!entries.empty())
68
3.10k
      {
69
3.10k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.10k
        for (auto opt : opts)
71
1.99k
          delete opt;
72
3.10k
      }
73
74
3.15k
      for (auto entry : entries)
75
3.11k
      {
76
3.11k
        entry->getNumOptions();
77
3.11k
        entry->getServiceId();
78
3.11k
        entry->getInstanceId();
79
3.11k
        entry->getMajorVersion();
80
3.11k
        entry->getMinorVersion();
81
3.11k
        entry->getCounter();
82
3.11k
        entry->getEventgroupId();
83
3.11k
        delete entry;
84
3.11k
      }
85
86
3.15k
      someipLayer->getFlags();
87
3.15k
      auto opts = someipLayer->getOptions();
88
3.15k
      for (auto opt : opts)
89
2.17k
      {
90
2.17k
        opt->getType();
91
2.17k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
635
        {
93
635
          v4opt->getIpAddress();
94
635
          v4opt->getPort();
95
635
          v4opt->getProtocol();
96
635
        }
97
1.54k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
578
        {
99
578
          v6opt->getIpAddress();
100
578
          v6opt->getPort();
101
578
          v6opt->getProtocol();
102
578
        }
103
2.17k
        delete opt;
104
2.17k
      }
105
3.15k
    }
106
27.5k
  }
107
656k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
22.4k
  {
109
22.4k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.21k
    {
111
4.21k
      uint16_t value16 = 0;
112
4.21k
      gtpLayer->getSequenceNumber(value16);
113
4.21k
      uint8_t value8;
114
4.21k
      gtpLayer->getNpduNumber(value8);
115
4.21k
      gtpLayer->getMessageType();
116
4.21k
      gtpLayer->getMessageTypeAsString();
117
4.21k
      gtpLayer->isGTPUMessage();
118
4.21k
      gtpLayer->isGTPCMessage();
119
4.21k
      auto ext = gtpLayer->getNextExtension();
120
4.21k
      ext.getExtensionType();
121
4.21k
      ext.getContent();
122
4.21k
      ext.getContentLength();
123
4.21k
      ext.getNextExtension();
124
4.21k
    }
125
22.4k
  }
126
656k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
68.3k
  {
128
68.3k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
8.77k
    {
130
8.77k
      uint32_t value32 = 0;
131
8.77k
      greLayer->getSequenceNumber(value32);
132
8.77k
    }
133
68.3k
  }
134
656k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
9.22k
  {
136
9.22k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.29k
    {
138
2.29k
      uint16_t value16 = 0;
139
2.29k
      greLayer->getChecksum(value16);
140
2.29k
      greLayer->getOffset(value16);
141
2.29k
      uint32_t value32 = 0;
142
2.29k
      greLayer->getKey(value32);
143
2.29k
    }
144
9.22k
  }
145
656k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
59.1k
  {
147
59.1k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.48k
    {
149
6.48k
      uint32_t value32 = 0;
150
6.48k
      greLayer->getAcknowledgmentNum(value32);
151
6.48k
    }
152
59.1k
  }
153
656k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
2.82k
  {
155
2.82k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
2.82k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
61
    {
162
61
      ftpLayer->getStatusCode();
163
61
      ftpLayer->getStatusOption(false);
164
61
      ftpLayer->getStatusOption(true);
165
61
    }
166
2.82k
  }
167
656k
  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
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.42k
  {
180
8.42k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.47k
    {
182
2.47k
      vrrpLayer->getIPAddresses();
183
2.47k
      vrrpLayer->isChecksumCorrect();
184
2.47k
      vrrpLayer->getChecksum();
185
2.47k
      vrrpLayer->getPriorityAsEnum();
186
2.47k
      vrrpLayer->getPriority();
187
2.47k
      vrrpLayer->getType();
188
2.47k
    }
189
8.42k
  }
190
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.49k
  {
192
2.49k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
830
    {
194
830
      vrrpLayer->getAuthTypeAsEnum();
195
830
      vrrpLayer->getAdvInt();
196
830
    }
197
2.49k
  }
198
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.92k
  {
200
5.92k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.64k
    {
202
1.64k
      vrrpLayer->getMaxAdvInt();
203
1.64k
    }
204
5.92k
  }
205
656k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
333k
  {
207
333k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
75.4k
    {
209
75.4k
      auto tcpLayer2(*tcpLayer);
210
75.4k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
75.4k
                                     pcpp::TcpOptionEnumType::Nop);
212
75.4k
    }
213
333k
  }
214
656k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
27.0k
  {
216
27.0k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
2.82k
    {
218
2.82k
      sdpLayer->getOwnerIPv4Address();
219
2.82k
      sdpLayer->getMediaPort("audio");
220
2.82k
      sdpLayer->getFieldCount();
221
222
2.82k
      auto sdpLayer2 = *sdpLayer;
223
2.82k
      std::vector<std::string> audioAttributes;
224
2.82k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
2.82k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
2.82k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
2.82k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
2.82k
    }
229
27.0k
  }
230
656k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
76.3k
  {
232
76.3k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
15.6k
    {
234
15.6k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
4.45k
      {
236
4.45k
        clientHelloMessage->getCompressionMethodsValue();
237
4.45k
        clientHelloMessage->getSessionID();
238
4.45k
        clientHelloMessage->getHandshakeType();
239
4.45k
        clientHelloMessage->getHandshakeVersion();
240
241
4.45k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
6.12M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
6.12M
        {
244
6.12M
          clientHelloMessage->getCipherSuite(i);
245
6.12M
          bool valid;
246
6.12M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
6.12M
        }
248
4.45k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.65k
          ext->getHostName();
250
4.45k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
288
          ext->getSupportedVersions();
252
253
4.45k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
4.45k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
4.45k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
4.45k
        fingerprint.toMD5();
258
4.45k
      }
259
15.6k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
3.37k
      {
261
3.37k
        serverHelloMessage->getCompressionMethodsValue();
262
3.37k
        serverHelloMessage->getSessionID();
263
3.37k
        serverHelloMessage->getCipherSuite();
264
265
3.37k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
3.37k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
3.37k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
3.37k
        serverHelloMessage->getHandshakeVersion();
270
3.37k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
3.37k
        fingerprint.toMD5();
272
3.37k
      }
273
15.6k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
14.4k
      {
275
14.4k
        handshakeMessage->isMessageComplete();
276
14.4k
      }
277
15.6k
    }
278
76.3k
  }
279
656k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
9.43k
  {
281
9.43k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
2.35k
    {
283
2.35k
      ntpLayer->getLeapIndicator();
284
2.35k
      ntpLayer->getMode();
285
2.35k
      ntpLayer->getModeString();
286
2.35k
      ntpLayer->getStratum();
287
2.35k
      ntpLayer->getPollInterval();
288
2.35k
      ntpLayer->getPrecision();
289
2.35k
      ntpLayer->getRootDelay();
290
2.35k
      ntpLayer->getRootDispersion();
291
2.35k
      ntpLayer->getReferenceIdentifier();
292
2.35k
      ntpLayer->getReferenceIdentifierString();
293
2.35k
      ntpLayer->getReferenceTimestamp();
294
2.35k
      ntpLayer->getOriginTimestamp();
295
2.35k
      ntpLayer->getReceiveTimestamp();
296
2.35k
      ntpLayer->getTransmitTimestamp();
297
298
2.35k
      ntpLayer->getDigest();
299
2.35k
      ntpLayer->getKeyID();
300
301
2.35k
      ntpLayer->getPollIntervalInSecs();
302
2.35k
      ntpLayer->getPrecisionInSecs();
303
2.35k
      ntpLayer->getRootDelayInSecs();
304
2.35k
      ntpLayer->getRootDispersionInSecs();
305
2.35k
      ntpLayer->getReferenceTimestampInSecs();
306
2.35k
      ntpLayer->getOriginTimestampInSecs();
307
2.35k
      ntpLayer->getReceiveTimestampInSecs();
308
2.35k
      ntpLayer->getTransmitTimestampInSecs();
309
310
2.35k
      ntpLayer->getReferenceTimestampAsString();
311
2.35k
      ntpLayer->getOriginTimestampAsString();
312
2.35k
      ntpLayer->getReceiveTimestampAsString();
313
2.35k
      ntpLayer->getTransmitTimestampAsString();
314
315
2.35k
      auto ntpLayer2(*ntpLayer);
316
2.35k
      ntpLayer2.setRootDelayInSecs(0.1);
317
2.35k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
2.35k
    }
319
9.43k
  }
320
656k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
32.2k
  {
322
32.2k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.70k
    {
324
6.70k
      auto icmpLayer2(*icmpLayer);
325
326
6.70k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.06k
      {
328
1.06k
        icmpLayer->getTimestampReplyData();
329
1.06k
        timeval orig = { 16131, 171000 };
330
1.06k
        timeval recv = { 16133, 474000 };
331
1.06k
        timeval tran = { 16133, 474000 };
332
1.06k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.06k
      }
334
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
1
      {
336
1
        icmpLayer->getAddressMaskRequestData();
337
1
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
1
      }
339
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
1
      {
341
1
        icmpLayer->getAddressMaskReplyData();
342
1
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
1
      }
344
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
701
      {
346
701
        icmpLayer->getDestUnreachableData();
347
701
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
701
      }
349
4.94k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
703
      {
351
703
        auto layerData = icmpLayer->getInfoReplyData();
352
703
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
703
      }
354
4.23k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
515
      {
356
515
        auto layerData = icmpLayer->getInfoRequestData();
357
515
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
515
      }
359
3.72k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
604
      {
361
604
        auto layerData = icmpLayer->getParamProblemData();
362
604
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
604
      }
364
3.11k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
600
      {
366
600
        icmpLayer->getTimeExceededData();
367
600
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
600
      }
369
2.51k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
868
      {
371
868
        icmpLayer->getRouterAdvertisementData();
372
868
        pcpp::icmp_router_address_structure addr1;
373
868
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
868
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
868
        routerAddresses.push_back(addr1);
376
868
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
868
      }
378
6.70k
    }
379
32.2k
  }
380
656k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
14.1k
  {
382
14.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.42k
    {
384
3.42k
      dhcpLayer->getTransactionID();
385
3.42k
      if (dhcpLayer->getOptionCount() > 0)
386
3.32k
      {
387
3.32k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.32k
        opt.getType();
389
3.32k
        opt.getTotalSize();
390
3.32k
        opt.getValueAsHexString();
391
11.0k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
7.75k
        {
393
7.75k
          opt = dhcpLayer->getNextOptionData(opt);
394
7.75k
        }
395
3.32k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.32k
      }
397
3.42k
    }
398
14.1k
  }
399
656k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
13.1k
  {
401
13.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.25k
    {
403
3.25k
      dhcpLayer->getOpCode();
404
3.25k
      dhcpLayer->getDhcpHeader();
405
3.25k
      dhcpLayer->getClientIpAddress();
406
3.25k
      dhcpLayer->getYourIpAddress();
407
3.25k
      dhcpLayer->getServerIpAddress();
408
3.25k
      dhcpLayer->getGatewayIpAddress();
409
3.25k
      dhcpLayer->getClientHardwareAddress();
410
3.25k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.20k
      {
412
3.20k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.20k
        opt.getValueAsIpAddr();
414
3.20k
        opt.getValueAsString();
415
72.0k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
68.8k
        {
417
68.8k
          opt = dhcpLayer->getNextOptionData(opt);
418
68.8k
        }
419
3.20k
      }
420
3.25k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.25k
    }
422
13.1k
  }
423
656k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
38.0k
  {
425
38.0k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
17.7k
    {
427
17.7k
      bgpLayer->getMessageTypeAsString();
428
17.7k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.39k
      {
430
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.39k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.39k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.39k
      }
442
14.3k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.7k
      {
444
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.7k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.7k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.7k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.7k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.7k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.7k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.7k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.7k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.7k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.7k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.7k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.7k
        pathAttributes2.push_back(
468
12.7k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.7k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.7k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.7k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.7k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.7k
      }
474
1.62k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
295
      {
476
295
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
295
      }
478
17.7k
    }
479
38.0k
  }
480
656k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
62.9k
  {
482
62.9k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.0k
    {
484
15.0k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.0k
      dnsLayer->removeQuery("a", true);
486
15.0k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.0k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.0k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.0k
                          &ipv4DnsData);
490
15.0k
      dnsLayer->removeAnswer("a", true);
491
15.0k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.0k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.0k
      dnsLayer->removeAuthority("a", true);
494
15.0k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.0k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.0k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.0k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.0k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.0k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
17.8k
      while (add != nullptr)
502
2.80k
      {
503
2.80k
        add = dnsLayer->getNextAdditionalRecord(add);
504
2.80k
      }
505
506
15.0k
      auto answer = dnsLayer->getFirstAnswer();
507
20.2k
      while (answer != nullptr)
508
5.20k
      {
509
5.20k
        answer = dnsLayer->getNextAnswer(answer);
510
5.20k
      }
511
512
15.0k
      auto auth = dnsLayer->getFirstAuthority();
513
17.5k
      while (auth != nullptr)
514
2.52k
      {
515
2.52k
        auth = dnsLayer->getNextAuthority(auth);
516
2.52k
      }
517
518
15.0k
      pcpp::DnsLayer other(*dnsLayer);
519
15.0k
      other = *dnsLayer;
520
15.0k
    }
521
62.9k
  }
522
656k
}
Unexecuted instantiation: FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
Line
Count
Source
28
656k
{
29
656k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
39.7k
  {
31
39.7k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
7.94k
    {
33
7.94k
      telnetLayer->getFirstCommand();
34
7.94k
      telnetLayer->getTotalNumberOfCommands();
35
36
7.94k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
7.94k
      do
38
31.4k
      {
39
31.4k
        commandVal = telnetLayer->getNextCommand();
40
31.4k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
31.4k
                  << std::endl;
42
31.4k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
31.4k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
31.4k
        telnetLayer->getDataAsString(true);
46
31.4k
        telnetLayer->getNumberOfCommands(commandVal);
47
31.4k
        telnetLayer->getOption(commandVal);
48
31.4k
        size_t length = 0;
49
31.4k
        telnetLayer->getOptionData(length);
50
31.4k
        telnetLayer->getOptionData(commandVal, length);
51
31.4k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
7.94k
    }
53
39.7k
  }
54
656k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.33k
  {
56
3.33k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.04k
    {
58
1.04k
      arpLayer->isReply();
59
1.04k
      arpLayer->isRequest();
60
1.04k
    }
61
3.33k
  }
62
656k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
27.5k
  {
64
27.5k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.15k
    {
66
3.15k
      auto entries = someipLayer->getEntries();
67
3.15k
      if (!entries.empty())
68
3.10k
      {
69
3.10k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.10k
        for (auto opt : opts)
71
1.99k
          delete opt;
72
3.10k
      }
73
74
3.15k
      for (auto entry : entries)
75
3.11k
      {
76
3.11k
        entry->getNumOptions();
77
3.11k
        entry->getServiceId();
78
3.11k
        entry->getInstanceId();
79
3.11k
        entry->getMajorVersion();
80
3.11k
        entry->getMinorVersion();
81
3.11k
        entry->getCounter();
82
3.11k
        entry->getEventgroupId();
83
3.11k
        delete entry;
84
3.11k
      }
85
86
3.15k
      someipLayer->getFlags();
87
3.15k
      auto opts = someipLayer->getOptions();
88
3.15k
      for (auto opt : opts)
89
2.17k
      {
90
2.17k
        opt->getType();
91
2.17k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
635
        {
93
635
          v4opt->getIpAddress();
94
635
          v4opt->getPort();
95
635
          v4opt->getProtocol();
96
635
        }
97
1.54k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
578
        {
99
578
          v6opt->getIpAddress();
100
578
          v6opt->getPort();
101
578
          v6opt->getProtocol();
102
578
        }
103
2.17k
        delete opt;
104
2.17k
      }
105
3.15k
    }
106
27.5k
  }
107
656k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
22.4k
  {
109
22.4k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.21k
    {
111
4.21k
      uint16_t value16 = 0;
112
4.21k
      gtpLayer->getSequenceNumber(value16);
113
4.21k
      uint8_t value8;
114
4.21k
      gtpLayer->getNpduNumber(value8);
115
4.21k
      gtpLayer->getMessageType();
116
4.21k
      gtpLayer->getMessageTypeAsString();
117
4.21k
      gtpLayer->isGTPUMessage();
118
4.21k
      gtpLayer->isGTPCMessage();
119
4.21k
      auto ext = gtpLayer->getNextExtension();
120
4.21k
      ext.getExtensionType();
121
4.21k
      ext.getContent();
122
4.21k
      ext.getContentLength();
123
4.21k
      ext.getNextExtension();
124
4.21k
    }
125
22.4k
  }
126
656k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
68.3k
  {
128
68.3k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
8.77k
    {
130
8.77k
      uint32_t value32 = 0;
131
8.77k
      greLayer->getSequenceNumber(value32);
132
8.77k
    }
133
68.3k
  }
134
656k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
9.22k
  {
136
9.22k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.29k
    {
138
2.29k
      uint16_t value16 = 0;
139
2.29k
      greLayer->getChecksum(value16);
140
2.29k
      greLayer->getOffset(value16);
141
2.29k
      uint32_t value32 = 0;
142
2.29k
      greLayer->getKey(value32);
143
2.29k
    }
144
9.22k
  }
145
656k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
59.1k
  {
147
59.1k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.48k
    {
149
6.48k
      uint32_t value32 = 0;
150
6.48k
      greLayer->getAcknowledgmentNum(value32);
151
6.48k
    }
152
59.1k
  }
153
656k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
2.82k
  {
155
2.82k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
2.82k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
61
    {
162
61
      ftpLayer->getStatusCode();
163
61
      ftpLayer->getStatusOption(false);
164
61
      ftpLayer->getStatusOption(true);
165
61
    }
166
2.82k
  }
167
656k
  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
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.42k
  {
180
8.42k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.47k
    {
182
2.47k
      vrrpLayer->getIPAddresses();
183
2.47k
      vrrpLayer->isChecksumCorrect();
184
2.47k
      vrrpLayer->getChecksum();
185
2.47k
      vrrpLayer->getPriorityAsEnum();
186
2.47k
      vrrpLayer->getPriority();
187
2.47k
      vrrpLayer->getType();
188
2.47k
    }
189
8.42k
  }
190
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.49k
  {
192
2.49k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
830
    {
194
830
      vrrpLayer->getAuthTypeAsEnum();
195
830
      vrrpLayer->getAdvInt();
196
830
    }
197
2.49k
  }
198
656k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.92k
  {
200
5.92k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.64k
    {
202
1.64k
      vrrpLayer->getMaxAdvInt();
203
1.64k
    }
204
5.92k
  }
205
656k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
333k
  {
207
333k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
75.4k
    {
209
75.4k
      auto tcpLayer2(*tcpLayer);
210
75.4k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
75.4k
                                     pcpp::TcpOptionEnumType::Nop);
212
75.4k
    }
213
333k
  }
214
656k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
27.0k
  {
216
27.0k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
2.82k
    {
218
2.82k
      sdpLayer->getOwnerIPv4Address();
219
2.82k
      sdpLayer->getMediaPort("audio");
220
2.82k
      sdpLayer->getFieldCount();
221
222
2.82k
      auto sdpLayer2 = *sdpLayer;
223
2.82k
      std::vector<std::string> audioAttributes;
224
2.82k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
2.82k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
2.82k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
2.82k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
2.82k
    }
229
27.0k
  }
230
656k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
76.3k
  {
232
76.3k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
15.6k
    {
234
15.6k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
4.45k
      {
236
4.45k
        clientHelloMessage->getCompressionMethodsValue();
237
4.45k
        clientHelloMessage->getSessionID();
238
4.45k
        clientHelloMessage->getHandshakeType();
239
4.45k
        clientHelloMessage->getHandshakeVersion();
240
241
4.45k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
6.12M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
6.12M
        {
244
6.12M
          clientHelloMessage->getCipherSuite(i);
245
6.12M
          bool valid;
246
6.12M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
6.12M
        }
248
4.45k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.65k
          ext->getHostName();
250
4.45k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
288
          ext->getSupportedVersions();
252
253
4.45k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
4.45k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
4.45k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
4.45k
        fingerprint.toMD5();
258
4.45k
      }
259
15.6k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
3.37k
      {
261
3.37k
        serverHelloMessage->getCompressionMethodsValue();
262
3.37k
        serverHelloMessage->getSessionID();
263
3.37k
        serverHelloMessage->getCipherSuite();
264
265
3.37k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
3.37k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
3.37k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
3.37k
        serverHelloMessage->getHandshakeVersion();
270
3.37k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
3.37k
        fingerprint.toMD5();
272
3.37k
      }
273
15.6k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
14.4k
      {
275
14.4k
        handshakeMessage->isMessageComplete();
276
14.4k
      }
277
15.6k
    }
278
76.3k
  }
279
656k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
9.43k
  {
281
9.43k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
2.35k
    {
283
2.35k
      ntpLayer->getLeapIndicator();
284
2.35k
      ntpLayer->getMode();
285
2.35k
      ntpLayer->getModeString();
286
2.35k
      ntpLayer->getStratum();
287
2.35k
      ntpLayer->getPollInterval();
288
2.35k
      ntpLayer->getPrecision();
289
2.35k
      ntpLayer->getRootDelay();
290
2.35k
      ntpLayer->getRootDispersion();
291
2.35k
      ntpLayer->getReferenceIdentifier();
292
2.35k
      ntpLayer->getReferenceIdentifierString();
293
2.35k
      ntpLayer->getReferenceTimestamp();
294
2.35k
      ntpLayer->getOriginTimestamp();
295
2.35k
      ntpLayer->getReceiveTimestamp();
296
2.35k
      ntpLayer->getTransmitTimestamp();
297
298
2.35k
      ntpLayer->getDigest();
299
2.35k
      ntpLayer->getKeyID();
300
301
2.35k
      ntpLayer->getPollIntervalInSecs();
302
2.35k
      ntpLayer->getPrecisionInSecs();
303
2.35k
      ntpLayer->getRootDelayInSecs();
304
2.35k
      ntpLayer->getRootDispersionInSecs();
305
2.35k
      ntpLayer->getReferenceTimestampInSecs();
306
2.35k
      ntpLayer->getOriginTimestampInSecs();
307
2.35k
      ntpLayer->getReceiveTimestampInSecs();
308
2.35k
      ntpLayer->getTransmitTimestampInSecs();
309
310
2.35k
      ntpLayer->getReferenceTimestampAsString();
311
2.35k
      ntpLayer->getOriginTimestampAsString();
312
2.35k
      ntpLayer->getReceiveTimestampAsString();
313
2.35k
      ntpLayer->getTransmitTimestampAsString();
314
315
2.35k
      auto ntpLayer2(*ntpLayer);
316
2.35k
      ntpLayer2.setRootDelayInSecs(0.1);
317
2.35k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
2.35k
    }
319
9.43k
  }
320
656k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
32.2k
  {
322
32.2k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.70k
    {
324
6.70k
      auto icmpLayer2(*icmpLayer);
325
326
6.70k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.06k
      {
328
1.06k
        icmpLayer->getTimestampReplyData();
329
1.06k
        timeval orig = { 16131, 171000 };
330
1.06k
        timeval recv = { 16133, 474000 };
331
1.06k
        timeval tran = { 16133, 474000 };
332
1.06k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.06k
      }
334
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
1
      {
336
1
        icmpLayer->getAddressMaskRequestData();
337
1
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
1
      }
339
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
1
      {
341
1
        icmpLayer->getAddressMaskReplyData();
342
1
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
1
      }
344
5.64k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
701
      {
346
701
        icmpLayer->getDestUnreachableData();
347
701
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
701
      }
349
4.94k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
703
      {
351
703
        auto layerData = icmpLayer->getInfoReplyData();
352
703
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
703
      }
354
4.23k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
515
      {
356
515
        auto layerData = icmpLayer->getInfoRequestData();
357
515
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
515
      }
359
3.72k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
604
      {
361
604
        auto layerData = icmpLayer->getParamProblemData();
362
604
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
604
      }
364
3.11k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
600
      {
366
600
        icmpLayer->getTimeExceededData();
367
600
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
600
      }
369
2.51k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
868
      {
371
868
        icmpLayer->getRouterAdvertisementData();
372
868
        pcpp::icmp_router_address_structure addr1;
373
868
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
868
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
868
        routerAddresses.push_back(addr1);
376
868
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
868
      }
378
6.70k
    }
379
32.2k
  }
380
656k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
14.1k
  {
382
14.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.42k
    {
384
3.42k
      dhcpLayer->getTransactionID();
385
3.42k
      if (dhcpLayer->getOptionCount() > 0)
386
3.32k
      {
387
3.32k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.32k
        opt.getType();
389
3.32k
        opt.getTotalSize();
390
3.32k
        opt.getValueAsHexString();
391
11.0k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
7.75k
        {
393
7.75k
          opt = dhcpLayer->getNextOptionData(opt);
394
7.75k
        }
395
3.32k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.32k
      }
397
3.42k
    }
398
14.1k
  }
399
656k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
13.1k
  {
401
13.1k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.25k
    {
403
3.25k
      dhcpLayer->getOpCode();
404
3.25k
      dhcpLayer->getDhcpHeader();
405
3.25k
      dhcpLayer->getClientIpAddress();
406
3.25k
      dhcpLayer->getYourIpAddress();
407
3.25k
      dhcpLayer->getServerIpAddress();
408
3.25k
      dhcpLayer->getGatewayIpAddress();
409
3.25k
      dhcpLayer->getClientHardwareAddress();
410
3.25k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.20k
      {
412
3.20k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.20k
        opt.getValueAsIpAddr();
414
3.20k
        opt.getValueAsString();
415
72.0k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
68.8k
        {
417
68.8k
          opt = dhcpLayer->getNextOptionData(opt);
418
68.8k
        }
419
3.20k
      }
420
3.25k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.25k
    }
422
13.1k
  }
423
656k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
38.0k
  {
425
38.0k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
17.7k
    {
427
17.7k
      bgpLayer->getMessageTypeAsString();
428
17.7k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.39k
      {
430
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.39k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.39k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.39k
      }
442
14.3k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.7k
      {
444
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.7k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.7k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.7k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.7k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.7k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.7k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.7k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.7k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.7k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.7k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.7k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.7k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.7k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.7k
        pathAttributes2.push_back(
468
12.7k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.7k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.7k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.7k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.7k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.7k
      }
474
1.62k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
295
      {
476
295
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
295
      }
478
17.7k
    }
479
38.0k
  }
480
656k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
62.9k
  {
482
62.9k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.0k
    {
484
15.0k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.0k
      dnsLayer->removeQuery("a", true);
486
15.0k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.0k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.0k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.0k
                          &ipv4DnsData);
490
15.0k
      dnsLayer->removeAnswer("a", true);
491
15.0k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.0k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.0k
      dnsLayer->removeAuthority("a", true);
494
15.0k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.0k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.0k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.0k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.0k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.0k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
17.8k
      while (add != nullptr)
502
2.80k
      {
503
2.80k
        add = dnsLayer->getNextAdditionalRecord(add);
504
2.80k
      }
505
506
15.0k
      auto answer = dnsLayer->getFirstAnswer();
507
20.2k
      while (answer != nullptr)
508
5.20k
      {
509
5.20k
        answer = dnsLayer->getNextAnswer(answer);
510
5.20k
      }
511
512
15.0k
      auto auth = dnsLayer->getFirstAuthority();
513
17.5k
      while (auth != nullptr)
514
2.52k
      {
515
2.52k
        auth = dnsLayer->getNextAuthority(auth);
516
2.52k
      }
517
518
15.0k
      pcpp::DnsLayer other(*dnsLayer);
519
15.0k
      other = *dnsLayer;
520
15.0k
    }
521
62.9k
  }
522
656k
}