Coverage Report

Created: 2026-05-30 07:22

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
869k
{
29
869k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
47.0k
  {
31
47.0k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
9.42k
    {
33
9.42k
      telnetLayer->getFirstCommand();
34
9.42k
      telnetLayer->getTotalNumberOfCommands();
35
36
9.42k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
9.42k
      do
38
40.9k
      {
39
40.9k
        commandVal = telnetLayer->getNextCommand();
40
40.9k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
40.9k
                  << std::endl;
42
40.9k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
40.9k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
40.9k
        telnetLayer->getDataAsString(true);
46
40.9k
        telnetLayer->getNumberOfCommands(commandVal);
47
40.9k
        telnetLayer->getOption(commandVal);
48
40.9k
        size_t length = 0;
49
40.9k
        telnetLayer->getOptionData(length);
50
40.9k
        telnetLayer->getOptionData(commandVal, length);
51
40.9k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
9.42k
    }
53
47.0k
  }
54
869k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.95k
  {
56
3.95k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.56k
    {
58
1.56k
      arpLayer->isReply();
59
1.56k
      arpLayer->isRequest();
60
1.56k
    }
61
3.95k
  }
62
869k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
30.3k
  {
64
30.3k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.53k
    {
66
3.53k
      auto entries = someipLayer->getEntries();
67
3.53k
      if (!entries.empty())
68
3.46k
      {
69
3.46k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.46k
        for (auto opt : opts)
71
2.27k
          delete opt;
72
3.46k
      }
73
74
3.53k
      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.53k
      someipLayer->getFlags();
87
3.53k
      auto opts = someipLayer->getOptions();
88
3.53k
      for (auto opt : opts)
89
2.88k
      {
90
2.88k
        opt->getType();
91
2.88k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
928
        {
93
928
          v4opt->getIpAddress();
94
928
          v4opt->getPort();
95
928
          v4opt->getProtocol();
96
928
        }
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.53k
    }
106
30.3k
  }
107
869k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
29.5k
  {
109
29.5k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
5.04k
    {
111
5.04k
      uint16_t value16 = 0;
112
5.04k
      gtpLayer->getSequenceNumber(value16);
113
5.04k
      uint8_t value8;
114
5.04k
      gtpLayer->getNpduNumber(value8);
115
5.04k
      gtpLayer->getMessageType();
116
5.04k
      gtpLayer->getMessageTypeAsString();
117
5.04k
      gtpLayer->isGTPUMessage();
118
5.04k
      gtpLayer->isGTPCMessage();
119
5.04k
      auto ext = gtpLayer->getNextExtension();
120
5.04k
      ext.getExtensionType();
121
5.04k
      ext.getContent();
122
5.04k
      ext.getContentLength();
123
5.04k
      ext.getNextExtension();
124
5.04k
    }
125
29.5k
  }
126
869k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
80.4k
  {
128
80.4k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
10.0k
    {
130
10.0k
      uint32_t value32 = 0;
131
10.0k
      greLayer->getSequenceNumber(value32);
132
10.0k
    }
133
80.4k
  }
134
869k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.52k
  {
136
8.52k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.07k
    {
138
2.07k
      uint16_t value16 = 0;
139
2.07k
      greLayer->getChecksum(value16);
140
2.07k
      greLayer->getOffset(value16);
141
2.07k
      uint32_t value32 = 0;
142
2.07k
      greLayer->getKey(value32);
143
2.07k
    }
144
8.52k
  }
145
869k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
71.9k
  {
147
71.9k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
7.99k
    {
149
7.99k
      uint32_t value32 = 0;
150
7.99k
      greLayer->getAcknowledgmentNum(value32);
151
7.99k
    }
152
71.9k
  }
153
869k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
11.1k
  {
155
11.1k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
11.1k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
2.04k
    {
162
2.04k
      ftpLayer->getStatusCode();
163
2.04k
      ftpLayer->getStatusOption(false);
164
2.04k
      ftpLayer->getStatusOption(true);
165
2.04k
    }
166
11.1k
  }
167
869k
  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
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
9.48k
  {
180
9.48k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.68k
    {
182
2.68k
      vrrpLayer->getIPAddresses();
183
2.68k
      vrrpLayer->isChecksumCorrect();
184
2.68k
      vrrpLayer->getChecksum();
185
2.68k
      vrrpLayer->getPriorityAsEnum();
186
2.68k
      vrrpLayer->getPriority();
187
2.68k
      vrrpLayer->getType();
188
2.68k
    }
189
9.48k
  }
190
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.93k
  {
192
2.93k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
963
    {
194
963
      vrrpLayer->getAuthTypeAsEnum();
195
963
      vrrpLayer->getAdvInt();
196
963
    }
197
2.93k
  }
198
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
6.54k
  {
200
6.54k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.71k
    {
202
1.71k
      vrrpLayer->getMaxAdvInt();
203
1.71k
    }
204
6.54k
  }
205
869k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
447k
  {
207
447k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
100k
    {
209
100k
      auto tcpLayer2(*tcpLayer);
210
100k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
100k
                                     pcpp::TcpOptionEnumType::Nop);
212
100k
    }
213
447k
  }
214
869k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
41.2k
  {
216
41.2k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
4.02k
    {
218
4.02k
      sdpLayer->getOwnerIPv4Address();
219
4.02k
      sdpLayer->getMediaPort("audio");
220
4.02k
      sdpLayer->getFieldCount();
221
222
4.02k
      auto sdpLayer2 = *sdpLayer;
223
4.02k
      std::vector<std::string> audioAttributes;
224
4.02k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
4.02k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
4.02k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
4.02k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
4.02k
    }
229
41.2k
  }
230
869k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
100k
  {
232
100k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
19.8k
    {
234
19.8k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
6.53k
      {
236
6.53k
        clientHelloMessage->getCompressionMethodsValue();
237
6.53k
        clientHelloMessage->getSessionID();
238
6.53k
        clientHelloMessage->getHandshakeType();
239
6.53k
        clientHelloMessage->getHandshakeVersion();
240
241
6.53k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
2.90M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
2.89M
        {
244
2.89M
          clientHelloMessage->getCipherSuite(i);
245
2.89M
          bool valid;
246
2.89M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
2.89M
        }
248
6.53k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
3.05k
          ext->getHostName();
250
6.53k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
866
          ext->getSupportedVersions();
252
253
6.53k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
6.53k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
6.53k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
6.53k
        fingerprint.toMD5();
258
6.53k
      }
259
19.8k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.54k
      {
261
4.54k
        serverHelloMessage->getCompressionMethodsValue();
262
4.54k
        serverHelloMessage->getSessionID();
263
4.54k
        serverHelloMessage->getCipherSuite();
264
265
4.54k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.54k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.54k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.54k
        serverHelloMessage->getHandshakeVersion();
270
4.54k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.54k
        fingerprint.toMD5();
272
4.54k
      }
273
19.8k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
18.6k
      {
275
18.6k
        handshakeMessage->isMessageComplete();
276
18.6k
      }
277
19.8k
    }
278
100k
  }
279
869k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
13.6k
  {
281
13.6k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.42k
    {
283
3.42k
      ntpLayer->getLeapIndicator();
284
3.42k
      ntpLayer->getMode();
285
3.42k
      ntpLayer->getModeString();
286
3.42k
      ntpLayer->getStratum();
287
3.42k
      ntpLayer->getPollInterval();
288
3.42k
      ntpLayer->getPrecision();
289
3.42k
      ntpLayer->getRootDelay();
290
3.42k
      ntpLayer->getRootDispersion();
291
3.42k
      ntpLayer->getReferenceIdentifier();
292
3.42k
      ntpLayer->getReferenceIdentifierString();
293
3.42k
      ntpLayer->getReferenceTimestamp();
294
3.42k
      ntpLayer->getOriginTimestamp();
295
3.42k
      ntpLayer->getReceiveTimestamp();
296
3.42k
      ntpLayer->getTransmitTimestamp();
297
298
3.42k
      ntpLayer->getDigest();
299
3.42k
      ntpLayer->getKeyID();
300
301
3.42k
      ntpLayer->getPollIntervalInSecs();
302
3.42k
      ntpLayer->getPrecisionInSecs();
303
3.42k
      ntpLayer->getRootDelayInSecs();
304
3.42k
      ntpLayer->getRootDispersionInSecs();
305
3.42k
      ntpLayer->getReferenceTimestampInSecs();
306
3.42k
      ntpLayer->getOriginTimestampInSecs();
307
3.42k
      ntpLayer->getReceiveTimestampInSecs();
308
3.42k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.42k
      ntpLayer->getReferenceTimestampAsString();
311
3.42k
      ntpLayer->getOriginTimestampAsString();
312
3.42k
      ntpLayer->getReceiveTimestampAsString();
313
3.42k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.42k
      auto ntpLayer2(*ntpLayer);
316
3.42k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.42k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.42k
    }
319
13.6k
  }
320
869k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
36.2k
  {
322
36.2k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
7.94k
    {
324
7.94k
      auto icmpLayer2(*icmpLayer);
325
326
7.94k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.09k
      {
328
1.09k
        icmpLayer->getTimestampReplyData();
329
1.09k
        timeval orig = { 16131, 171000 };
330
1.09k
        timeval recv = { 16133, 474000 };
331
1.09k
        timeval tran = { 16133, 474000 };
332
1.09k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.09k
      }
334
6.85k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
489
      {
336
489
        icmpLayer->getAddressMaskRequestData();
337
489
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
489
      }
339
6.36k
      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.22k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
578
      {
346
578
        icmpLayer->getDestUnreachableData();
347
578
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
578
      }
349
4.64k
      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.24k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
481
      {
356
481
        auto layerData = icmpLayer->getInfoRequestData();
357
481
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
481
      }
359
3.76k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
755
      {
361
755
        auto layerData = icmpLayer->getParamProblemData();
362
755
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
755
      }
364
3.01k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.42k
      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
7.94k
    }
379
36.2k
  }
380
869k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
16.8k
  {
382
16.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
4.02k
    {
384
4.02k
      dhcpLayer->getTransactionID();
385
4.02k
      if (dhcpLayer->getOptionCount() > 0)
386
3.84k
      {
387
3.84k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.84k
        opt.getType();
389
3.84k
        opt.getTotalSize();
390
3.84k
        opt.getValueAsHexString();
391
12.5k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.74k
        {
393
8.74k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.74k
        }
395
3.84k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.84k
      }
397
4.02k
    }
398
16.8k
  }
399
869k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.6k
  {
401
12.6k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.13k
    {
403
3.13k
      dhcpLayer->getOpCode();
404
3.13k
      dhcpLayer->getDhcpHeader();
405
3.13k
      dhcpLayer->getClientIpAddress();
406
3.13k
      dhcpLayer->getYourIpAddress();
407
3.13k
      dhcpLayer->getServerIpAddress();
408
3.13k
      dhcpLayer->getGatewayIpAddress();
409
3.13k
      dhcpLayer->getClientHardwareAddress();
410
3.13k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.08k
      {
412
3.08k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.08k
        opt.getValueAsIpAddr();
414
3.08k
        opt.getValueAsString();
415
63.1k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
60.0k
        {
417
60.0k
          opt = dhcpLayer->getNextOptionData(opt);
418
60.0k
        }
419
3.08k
      }
420
3.13k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.13k
    }
422
12.6k
  }
423
869k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
43.1k
  {
425
43.1k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
19.5k
    {
427
19.5k
      bgpLayer->getMessageTypeAsString();
428
19.5k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.80k
      {
430
3.80k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.80k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.80k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.80k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.80k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.80k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.80k
      }
442
15.7k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
13.5k
      {
444
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
13.5k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
13.5k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
13.5k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
13.5k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
13.5k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
13.5k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
13.5k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
13.5k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
13.5k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
13.5k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
13.5k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
13.5k
        pathAttributes2.push_back(
468
13.5k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
13.5k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
13.5k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
13.5k
        bgpUpdateMsgLayer->clearPathAttributes();
472
13.5k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
13.5k
      }
474
2.19k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
681
      {
476
681
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
681
      }
478
19.5k
    }
479
43.1k
  }
480
869k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
63.8k
  {
482
63.8k
    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.82k
      {
509
3.82k
        answer = dnsLayer->getNextAnswer(answer);
510
3.82k
      }
511
512
14.9k
      auto auth = dnsLayer->getFirstAuthority();
513
17.7k
      while (auth != nullptr)
514
2.77k
      {
515
2.77k
        auth = dnsLayer->getNextAuthority(auth);
516
2.77k
      }
517
518
14.9k
      pcpp::DnsLayer other(*dnsLayer);
519
14.9k
      other = *dnsLayer;
520
14.9k
    }
521
63.8k
  }
522
869k
}
Unexecuted instantiation: FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
Line
Count
Source
28
869k
{
29
869k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
47.0k
  {
31
47.0k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
9.42k
    {
33
9.42k
      telnetLayer->getFirstCommand();
34
9.42k
      telnetLayer->getTotalNumberOfCommands();
35
36
9.42k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
9.42k
      do
38
40.9k
      {
39
40.9k
        commandVal = telnetLayer->getNextCommand();
40
40.9k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
40.9k
                  << std::endl;
42
40.9k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
40.9k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
40.9k
        telnetLayer->getDataAsString(true);
46
40.9k
        telnetLayer->getNumberOfCommands(commandVal);
47
40.9k
        telnetLayer->getOption(commandVal);
48
40.9k
        size_t length = 0;
49
40.9k
        telnetLayer->getOptionData(length);
50
40.9k
        telnetLayer->getOptionData(commandVal, length);
51
40.9k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
9.42k
    }
53
47.0k
  }
54
869k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.95k
  {
56
3.95k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.56k
    {
58
1.56k
      arpLayer->isReply();
59
1.56k
      arpLayer->isRequest();
60
1.56k
    }
61
3.95k
  }
62
869k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
30.3k
  {
64
30.3k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.53k
    {
66
3.53k
      auto entries = someipLayer->getEntries();
67
3.53k
      if (!entries.empty())
68
3.46k
      {
69
3.46k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
3.46k
        for (auto opt : opts)
71
2.27k
          delete opt;
72
3.46k
      }
73
74
3.53k
      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.53k
      someipLayer->getFlags();
87
3.53k
      auto opts = someipLayer->getOptions();
88
3.53k
      for (auto opt : opts)
89
2.88k
      {
90
2.88k
        opt->getType();
91
2.88k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
928
        {
93
928
          v4opt->getIpAddress();
94
928
          v4opt->getPort();
95
928
          v4opt->getProtocol();
96
928
        }
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.53k
    }
106
30.3k
  }
107
869k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
29.5k
  {
109
29.5k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
5.04k
    {
111
5.04k
      uint16_t value16 = 0;
112
5.04k
      gtpLayer->getSequenceNumber(value16);
113
5.04k
      uint8_t value8;
114
5.04k
      gtpLayer->getNpduNumber(value8);
115
5.04k
      gtpLayer->getMessageType();
116
5.04k
      gtpLayer->getMessageTypeAsString();
117
5.04k
      gtpLayer->isGTPUMessage();
118
5.04k
      gtpLayer->isGTPCMessage();
119
5.04k
      auto ext = gtpLayer->getNextExtension();
120
5.04k
      ext.getExtensionType();
121
5.04k
      ext.getContent();
122
5.04k
      ext.getContentLength();
123
5.04k
      ext.getNextExtension();
124
5.04k
    }
125
29.5k
  }
126
869k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
80.4k
  {
128
80.4k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
10.0k
    {
130
10.0k
      uint32_t value32 = 0;
131
10.0k
      greLayer->getSequenceNumber(value32);
132
10.0k
    }
133
80.4k
  }
134
869k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.52k
  {
136
8.52k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.07k
    {
138
2.07k
      uint16_t value16 = 0;
139
2.07k
      greLayer->getChecksum(value16);
140
2.07k
      greLayer->getOffset(value16);
141
2.07k
      uint32_t value32 = 0;
142
2.07k
      greLayer->getKey(value32);
143
2.07k
    }
144
8.52k
  }
145
869k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
71.9k
  {
147
71.9k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
7.99k
    {
149
7.99k
      uint32_t value32 = 0;
150
7.99k
      greLayer->getAcknowledgmentNum(value32);
151
7.99k
    }
152
71.9k
  }
153
869k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
11.1k
  {
155
11.1k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
11.1k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
2.04k
    {
162
2.04k
      ftpLayer->getStatusCode();
163
2.04k
      ftpLayer->getStatusOption(false);
164
2.04k
      ftpLayer->getStatusOption(true);
165
2.04k
    }
166
11.1k
  }
167
869k
  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
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
9.48k
  {
180
9.48k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.68k
    {
182
2.68k
      vrrpLayer->getIPAddresses();
183
2.68k
      vrrpLayer->isChecksumCorrect();
184
2.68k
      vrrpLayer->getChecksum();
185
2.68k
      vrrpLayer->getPriorityAsEnum();
186
2.68k
      vrrpLayer->getPriority();
187
2.68k
      vrrpLayer->getType();
188
2.68k
    }
189
9.48k
  }
190
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.93k
  {
192
2.93k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
963
    {
194
963
      vrrpLayer->getAuthTypeAsEnum();
195
963
      vrrpLayer->getAdvInt();
196
963
    }
197
2.93k
  }
198
869k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
6.54k
  {
200
6.54k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.71k
    {
202
1.71k
      vrrpLayer->getMaxAdvInt();
203
1.71k
    }
204
6.54k
  }
205
869k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
447k
  {
207
447k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
100k
    {
209
100k
      auto tcpLayer2(*tcpLayer);
210
100k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
100k
                                     pcpp::TcpOptionEnumType::Nop);
212
100k
    }
213
447k
  }
214
869k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
41.2k
  {
216
41.2k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
4.02k
    {
218
4.02k
      sdpLayer->getOwnerIPv4Address();
219
4.02k
      sdpLayer->getMediaPort("audio");
220
4.02k
      sdpLayer->getFieldCount();
221
222
4.02k
      auto sdpLayer2 = *sdpLayer;
223
4.02k
      std::vector<std::string> audioAttributes;
224
4.02k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
4.02k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
4.02k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
4.02k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
4.02k
    }
229
41.2k
  }
230
869k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
100k
  {
232
100k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
19.8k
    {
234
19.8k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
6.53k
      {
236
6.53k
        clientHelloMessage->getCompressionMethodsValue();
237
6.53k
        clientHelloMessage->getSessionID();
238
6.53k
        clientHelloMessage->getHandshakeType();
239
6.53k
        clientHelloMessage->getHandshakeVersion();
240
241
6.53k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
2.90M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
2.89M
        {
244
2.89M
          clientHelloMessage->getCipherSuite(i);
245
2.89M
          bool valid;
246
2.89M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
2.89M
        }
248
6.53k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
3.05k
          ext->getHostName();
250
6.53k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
866
          ext->getSupportedVersions();
252
253
6.53k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
6.53k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
6.53k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
6.53k
        fingerprint.toMD5();
258
6.53k
      }
259
19.8k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.54k
      {
261
4.54k
        serverHelloMessage->getCompressionMethodsValue();
262
4.54k
        serverHelloMessage->getSessionID();
263
4.54k
        serverHelloMessage->getCipherSuite();
264
265
4.54k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.54k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.54k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.54k
        serverHelloMessage->getHandshakeVersion();
270
4.54k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.54k
        fingerprint.toMD5();
272
4.54k
      }
273
19.8k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
18.6k
      {
275
18.6k
        handshakeMessage->isMessageComplete();
276
18.6k
      }
277
19.8k
    }
278
100k
  }
279
869k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
13.6k
  {
281
13.6k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.42k
    {
283
3.42k
      ntpLayer->getLeapIndicator();
284
3.42k
      ntpLayer->getMode();
285
3.42k
      ntpLayer->getModeString();
286
3.42k
      ntpLayer->getStratum();
287
3.42k
      ntpLayer->getPollInterval();
288
3.42k
      ntpLayer->getPrecision();
289
3.42k
      ntpLayer->getRootDelay();
290
3.42k
      ntpLayer->getRootDispersion();
291
3.42k
      ntpLayer->getReferenceIdentifier();
292
3.42k
      ntpLayer->getReferenceIdentifierString();
293
3.42k
      ntpLayer->getReferenceTimestamp();
294
3.42k
      ntpLayer->getOriginTimestamp();
295
3.42k
      ntpLayer->getReceiveTimestamp();
296
3.42k
      ntpLayer->getTransmitTimestamp();
297
298
3.42k
      ntpLayer->getDigest();
299
3.42k
      ntpLayer->getKeyID();
300
301
3.42k
      ntpLayer->getPollIntervalInSecs();
302
3.42k
      ntpLayer->getPrecisionInSecs();
303
3.42k
      ntpLayer->getRootDelayInSecs();
304
3.42k
      ntpLayer->getRootDispersionInSecs();
305
3.42k
      ntpLayer->getReferenceTimestampInSecs();
306
3.42k
      ntpLayer->getOriginTimestampInSecs();
307
3.42k
      ntpLayer->getReceiveTimestampInSecs();
308
3.42k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.42k
      ntpLayer->getReferenceTimestampAsString();
311
3.42k
      ntpLayer->getOriginTimestampAsString();
312
3.42k
      ntpLayer->getReceiveTimestampAsString();
313
3.42k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.42k
      auto ntpLayer2(*ntpLayer);
316
3.42k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.42k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.42k
    }
319
13.6k
  }
320
869k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
36.2k
  {
322
36.2k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
7.94k
    {
324
7.94k
      auto icmpLayer2(*icmpLayer);
325
326
7.94k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.09k
      {
328
1.09k
        icmpLayer->getTimestampReplyData();
329
1.09k
        timeval orig = { 16131, 171000 };
330
1.09k
        timeval recv = { 16133, 474000 };
331
1.09k
        timeval tran = { 16133, 474000 };
332
1.09k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.09k
      }
334
6.85k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
489
      {
336
489
        icmpLayer->getAddressMaskRequestData();
337
489
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
489
      }
339
6.36k
      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.22k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
578
      {
346
578
        icmpLayer->getDestUnreachableData();
347
578
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
578
      }
349
4.64k
      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.24k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
481
      {
356
481
        auto layerData = icmpLayer->getInfoRequestData();
357
481
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
481
      }
359
3.76k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
755
      {
361
755
        auto layerData = icmpLayer->getParamProblemData();
362
755
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
755
      }
364
3.01k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.42k
      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
7.94k
    }
379
36.2k
  }
380
869k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
16.8k
  {
382
16.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
4.02k
    {
384
4.02k
      dhcpLayer->getTransactionID();
385
4.02k
      if (dhcpLayer->getOptionCount() > 0)
386
3.84k
      {
387
3.84k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.84k
        opt.getType();
389
3.84k
        opt.getTotalSize();
390
3.84k
        opt.getValueAsHexString();
391
12.5k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.74k
        {
393
8.74k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.74k
        }
395
3.84k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.84k
      }
397
4.02k
    }
398
16.8k
  }
399
869k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.6k
  {
401
12.6k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.13k
    {
403
3.13k
      dhcpLayer->getOpCode();
404
3.13k
      dhcpLayer->getDhcpHeader();
405
3.13k
      dhcpLayer->getClientIpAddress();
406
3.13k
      dhcpLayer->getYourIpAddress();
407
3.13k
      dhcpLayer->getServerIpAddress();
408
3.13k
      dhcpLayer->getGatewayIpAddress();
409
3.13k
      dhcpLayer->getClientHardwareAddress();
410
3.13k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.08k
      {
412
3.08k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.08k
        opt.getValueAsIpAddr();
414
3.08k
        opt.getValueAsString();
415
63.1k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
60.0k
        {
417
60.0k
          opt = dhcpLayer->getNextOptionData(opt);
418
60.0k
        }
419
3.08k
      }
420
3.13k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.13k
    }
422
12.6k
  }
423
869k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
43.1k
  {
425
43.1k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
19.5k
    {
427
19.5k
      bgpLayer->getMessageTypeAsString();
428
19.5k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.80k
      {
430
3.80k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.80k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.80k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.80k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.80k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.80k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.80k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.80k
      }
442
15.7k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
13.5k
      {
444
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
13.5k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
13.5k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
13.5k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
13.5k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
13.5k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
13.5k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
13.5k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
13.5k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
13.5k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
13.5k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
13.5k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
13.5k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
13.5k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
13.5k
        pathAttributes2.push_back(
468
13.5k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
13.5k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
13.5k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
13.5k
        bgpUpdateMsgLayer->clearPathAttributes();
472
13.5k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
13.5k
      }
474
2.19k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
681
      {
476
681
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
681
      }
478
19.5k
    }
479
43.1k
  }
480
869k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
63.8k
  {
482
63.8k
    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.82k
      {
509
3.82k
        answer = dnsLayer->getNextAnswer(answer);
510
3.82k
      }
511
512
14.9k
      auto auth = dnsLayer->getFirstAuthority();
513
17.7k
      while (auth != nullptr)
514
2.77k
      {
515
2.77k
        auth = dnsLayer->getNextAuthority(auth);
516
2.77k
      }
517
518
14.9k
      pcpp::DnsLayer other(*dnsLayer);
519
14.9k
      other = *dnsLayer;
520
14.9k
    }
521
63.8k
  }
522
869k
}