Coverage Report

Created: 2025-11-11 07:46

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