Coverage Report

Created: 2026-06-10 07:57

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