Coverage Report

Created: 2025-12-31 07:37

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
762k
{
29
762k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
34.6k
  {
31
34.6k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
6.92k
    {
33
6.92k
      telnetLayer->getFirstCommand();
34
6.92k
      telnetLayer->getTotalNumberOfCommands();
35
36
6.92k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
6.92k
      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.92k
    }
53
34.6k
  }
54
762k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.47k
  {
56
3.47k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.29k
    {
58
1.29k
      arpLayer->isReply();
59
1.29k
      arpLayer->isRequest();
60
1.29k
    }
61
3.47k
  }
62
762k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
27.9k
  {
64
27.9k
    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.82k
          delete opt;
72
3.11k
      }
73
74
3.18k
      for (auto entry : entries)
75
3.14k
      {
76
3.14k
        entry->getNumOptions();
77
3.14k
        entry->getServiceId();
78
3.14k
        entry->getInstanceId();
79
3.14k
        entry->getMajorVersion();
80
3.14k
        entry->getMinorVersion();
81
3.14k
        entry->getCounter();
82
3.14k
        entry->getEventgroupId();
83
3.14k
        delete entry;
84
3.14k
      }
85
86
3.18k
      someipLayer->getFlags();
87
3.18k
      auto opts = someipLayer->getOptions();
88
3.18k
      for (auto opt : opts)
89
2.17k
      {
90
2.17k
        opt->getType();
91
2.17k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
672
        {
93
672
          v4opt->getIpAddress();
94
672
          v4opt->getPort();
95
672
          v4opt->getProtocol();
96
672
        }
97
1.50k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
553
        {
99
553
          v6opt->getIpAddress();
100
553
          v6opt->getPort();
101
553
          v6opt->getProtocol();
102
553
        }
103
2.17k
        delete opt;
104
2.17k
      }
105
3.18k
    }
106
27.9k
  }
107
762k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
26.0k
  {
109
26.0k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.63k
    {
111
4.63k
      uint16_t value16 = 0;
112
4.63k
      gtpLayer->getSequenceNumber(value16);
113
4.63k
      uint8_t value8;
114
4.63k
      gtpLayer->getNpduNumber(value8);
115
4.63k
      gtpLayer->getMessageType();
116
4.63k
      gtpLayer->getMessageTypeAsString();
117
4.63k
      gtpLayer->isGTPUMessage();
118
4.63k
      gtpLayer->isGTPCMessage();
119
4.63k
      auto ext = gtpLayer->getNextExtension();
120
4.63k
      ext.getExtensionType();
121
4.63k
      ext.getContent();
122
4.63k
      ext.getContentLength();
123
4.63k
      ext.getNextExtension();
124
4.63k
    }
125
26.0k
  }
126
762k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
69.3k
  {
128
69.3k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
9.02k
    {
130
9.02k
      uint32_t value32 = 0;
131
9.02k
      greLayer->getSequenceNumber(value32);
132
9.02k
    }
133
69.3k
  }
134
762k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.58k
  {
136
8.58k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.11k
    {
138
2.11k
      uint16_t value16 = 0;
139
2.11k
      greLayer->getChecksum(value16);
140
2.11k
      greLayer->getOffset(value16);
141
2.11k
      uint32_t value32 = 0;
142
2.11k
      greLayer->getKey(value32);
143
2.11k
    }
144
8.58k
  }
145
762k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
60.7k
  {
147
60.7k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.91k
    {
149
6.91k
      uint32_t value32 = 0;
150
6.91k
      greLayer->getAcknowledgmentNum(value32);
151
6.91k
    }
152
60.7k
  }
153
762k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
6.83k
  {
155
6.83k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
6.83k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
1.06k
    {
162
1.06k
      ftpLayer->getStatusCode();
163
1.06k
      ftpLayer->getStatusOption(false);
164
1.06k
      ftpLayer->getStatusOption(true);
165
1.06k
    }
166
6.83k
  }
167
762k
  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
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.99k
  {
180
8.99k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.57k
    {
182
2.57k
      vrrpLayer->getIPAddresses();
183
2.57k
      vrrpLayer->isChecksumCorrect();
184
2.57k
      vrrpLayer->getChecksum();
185
2.57k
      vrrpLayer->getPriorityAsEnum();
186
2.57k
      vrrpLayer->getPriority();
187
2.57k
      vrrpLayer->getType();
188
2.57k
    }
189
8.99k
  }
190
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.96k
  {
192
2.96k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
986
    {
194
986
      vrrpLayer->getAuthTypeAsEnum();
195
986
      vrrpLayer->getAdvInt();
196
986
    }
197
2.96k
  }
198
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
6.02k
  {
200
6.02k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.58k
    {
202
1.58k
      vrrpLayer->getMaxAdvInt();
203
1.58k
    }
204
6.02k
  }
205
762k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
386k
  {
207
386k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
87.5k
    {
209
87.5k
      auto tcpLayer2(*tcpLayer);
210
87.5k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
87.5k
                                     pcpp::TcpOptionEnumType::Nop);
212
87.5k
    }
213
386k
  }
214
762k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
30.6k
  {
216
30.6k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.13k
    {
218
3.13k
      sdpLayer->getOwnerIPv4Address();
219
3.13k
      sdpLayer->getMediaPort("audio");
220
3.13k
      sdpLayer->getFieldCount();
221
222
3.13k
      auto sdpLayer2 = *sdpLayer;
223
3.13k
      std::vector<std::string> audioAttributes;
224
3.13k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.13k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.13k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.13k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.13k
    }
229
30.6k
  }
230
762k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
91.6k
  {
232
91.6k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
18.5k
    {
234
18.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.79M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.79M
        {
244
5.79M
          clientHelloMessage->getCipherSuite(i);
245
5.79M
          bool valid;
246
5.79M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.79M
        }
248
5.21k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.76k
          ext->getHostName();
250
5.21k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
589
          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
18.5k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.61k
      {
261
4.61k
        serverHelloMessage->getCompressionMethodsValue();
262
4.61k
        serverHelloMessage->getSessionID();
263
4.61k
        serverHelloMessage->getCipherSuite();
264
265
4.61k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.61k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.61k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.61k
        serverHelloMessage->getHandshakeVersion();
270
4.61k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.61k
        fingerprint.toMD5();
272
4.61k
      }
273
18.5k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
17.4k
      {
275
17.4k
        handshakeMessage->isMessageComplete();
276
17.4k
      }
277
18.5k
    }
278
91.6k
  }
279
762k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
12.3k
  {
281
12.3k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.07k
    {
283
3.07k
      ntpLayer->getLeapIndicator();
284
3.07k
      ntpLayer->getMode();
285
3.07k
      ntpLayer->getModeString();
286
3.07k
      ntpLayer->getStratum();
287
3.07k
      ntpLayer->getPollInterval();
288
3.07k
      ntpLayer->getPrecision();
289
3.07k
      ntpLayer->getRootDelay();
290
3.07k
      ntpLayer->getRootDispersion();
291
3.07k
      ntpLayer->getReferenceIdentifier();
292
3.07k
      ntpLayer->getReferenceIdentifierString();
293
3.07k
      ntpLayer->getReferenceTimestamp();
294
3.07k
      ntpLayer->getOriginTimestamp();
295
3.07k
      ntpLayer->getReceiveTimestamp();
296
3.07k
      ntpLayer->getTransmitTimestamp();
297
298
3.07k
      ntpLayer->getDigest();
299
3.07k
      ntpLayer->getKeyID();
300
301
3.07k
      ntpLayer->getPollIntervalInSecs();
302
3.07k
      ntpLayer->getPrecisionInSecs();
303
3.07k
      ntpLayer->getRootDelayInSecs();
304
3.07k
      ntpLayer->getRootDispersionInSecs();
305
3.07k
      ntpLayer->getReferenceTimestampInSecs();
306
3.07k
      ntpLayer->getOriginTimestampInSecs();
307
3.07k
      ntpLayer->getReceiveTimestampInSecs();
308
3.07k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.07k
      ntpLayer->getReferenceTimestampAsString();
311
3.07k
      ntpLayer->getOriginTimestampAsString();
312
3.07k
      ntpLayer->getReceiveTimestampAsString();
313
3.07k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.07k
      auto ntpLayer2(*ntpLayer);
316
3.07k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.07k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.07k
    }
319
12.3k
  }
320
762k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
31.0k
  {
322
31.0k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.69k
    {
324
6.69k
      auto icmpLayer2(*icmpLayer);
325
326
6.69k
      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.50k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
3
      {
336
3
        icmpLayer->getAddressMaskRequestData();
337
3
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
3
      }
339
5.49k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
124
      {
341
124
        icmpLayer->getAddressMaskReplyData();
342
124
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
124
      }
344
5.37k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
682
      {
346
682
        icmpLayer->getDestUnreachableData();
347
682
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
682
      }
349
4.69k
      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.28k
      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.75k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
669
      {
361
669
        auto layerData = icmpLayer->getParamProblemData();
362
669
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
669
      }
364
3.08k
      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.49k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
905
      {
371
905
        icmpLayer->getRouterAdvertisementData();
372
905
        pcpp::icmp_router_address_structure addr1;
373
905
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
905
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
905
        routerAddresses.push_back(addr1);
376
905
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
905
      }
378
6.69k
    }
379
31.0k
  }
380
762k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
13.9k
  {
382
13.9k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.35k
    {
384
3.35k
      dhcpLayer->getTransactionID();
385
3.35k
      if (dhcpLayer->getOptionCount() > 0)
386
3.25k
      {
387
3.25k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.25k
        opt.getType();
389
3.25k
        opt.getTotalSize();
390
3.25k
        opt.getValueAsHexString();
391
10.9k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
7.67k
        {
393
7.67k
          opt = dhcpLayer->getNextOptionData(opt);
394
7.67k
        }
395
3.25k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.25k
      }
397
3.35k
    }
398
13.9k
  }
399
762k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.8k
  {
401
12.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.17k
    {
403
3.17k
      dhcpLayer->getOpCode();
404
3.17k
      dhcpLayer->getDhcpHeader();
405
3.17k
      dhcpLayer->getClientIpAddress();
406
3.17k
      dhcpLayer->getYourIpAddress();
407
3.17k
      dhcpLayer->getServerIpAddress();
408
3.17k
      dhcpLayer->getGatewayIpAddress();
409
3.17k
      dhcpLayer->getClientHardwareAddress();
410
3.17k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.12k
      {
412
3.12k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.12k
        opt.getValueAsIpAddr();
414
3.12k
        opt.getValueAsString();
415
63.8k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
60.7k
        {
417
60.7k
          opt = dhcpLayer->getNextOptionData(opt);
418
60.7k
        }
419
3.12k
      }
420
3.17k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.17k
    }
422
12.8k
  }
423
762k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
40.4k
  {
425
40.4k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
18.3k
    {
427
18.3k
      bgpLayer->getMessageTypeAsString();
428
18.3k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.39k
      {
430
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.39k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.39k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.39k
      }
442
14.9k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.8k
      {
444
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.8k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.8k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.8k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.8k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.8k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.8k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.8k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.8k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.8k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.8k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.8k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.8k
        pathAttributes2.push_back(
468
12.8k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.8k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.8k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.8k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.8k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.8k
      }
474
2.08k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
569
      {
476
569
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
569
      }
478
18.3k
    }
479
40.4k
  }
480
762k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
64.2k
  {
482
64.2k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.2k
    {
484
15.2k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.2k
      dnsLayer->removeQuery("a", true);
486
15.2k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.2k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.2k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.2k
                          &ipv4DnsData);
490
15.2k
      dnsLayer->removeAnswer("a", true);
491
15.2k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.2k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.2k
      dnsLayer->removeAuthority("a", true);
494
15.2k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.2k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.2k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.2k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.2k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.2k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.5k
      while (add != nullptr)
502
3.30k
      {
503
3.30k
        add = dnsLayer->getNextAdditionalRecord(add);
504
3.30k
      }
505
506
15.2k
      auto answer = dnsLayer->getFirstAnswer();
507
19.3k
      while (answer != nullptr)
508
4.03k
      {
509
4.03k
        answer = dnsLayer->getNextAnswer(answer);
510
4.03k
      }
511
512
15.2k
      auto auth = dnsLayer->getFirstAuthority();
513
18.2k
      while (auth != nullptr)
514
2.93k
      {
515
2.93k
        auth = dnsLayer->getNextAuthority(auth);
516
2.93k
      }
517
518
15.2k
      pcpp::DnsLayer other(*dnsLayer);
519
15.2k
      other = *dnsLayer;
520
15.2k
    }
521
64.2k
  }
522
762k
}
Unexecuted instantiation: FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
Line
Count
Source
28
762k
{
29
762k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
34.6k
  {
31
34.6k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
6.92k
    {
33
6.92k
      telnetLayer->getFirstCommand();
34
6.92k
      telnetLayer->getTotalNumberOfCommands();
35
36
6.92k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
6.92k
      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.92k
    }
53
34.6k
  }
54
762k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.47k
  {
56
3.47k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.29k
    {
58
1.29k
      arpLayer->isReply();
59
1.29k
      arpLayer->isRequest();
60
1.29k
    }
61
3.47k
  }
62
762k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
27.9k
  {
64
27.9k
    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.82k
          delete opt;
72
3.11k
      }
73
74
3.18k
      for (auto entry : entries)
75
3.14k
      {
76
3.14k
        entry->getNumOptions();
77
3.14k
        entry->getServiceId();
78
3.14k
        entry->getInstanceId();
79
3.14k
        entry->getMajorVersion();
80
3.14k
        entry->getMinorVersion();
81
3.14k
        entry->getCounter();
82
3.14k
        entry->getEventgroupId();
83
3.14k
        delete entry;
84
3.14k
      }
85
86
3.18k
      someipLayer->getFlags();
87
3.18k
      auto opts = someipLayer->getOptions();
88
3.18k
      for (auto opt : opts)
89
2.17k
      {
90
2.17k
        opt->getType();
91
2.17k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
672
        {
93
672
          v4opt->getIpAddress();
94
672
          v4opt->getPort();
95
672
          v4opt->getProtocol();
96
672
        }
97
1.50k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
553
        {
99
553
          v6opt->getIpAddress();
100
553
          v6opt->getPort();
101
553
          v6opt->getProtocol();
102
553
        }
103
2.17k
        delete opt;
104
2.17k
      }
105
3.18k
    }
106
27.9k
  }
107
762k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
26.0k
  {
109
26.0k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.63k
    {
111
4.63k
      uint16_t value16 = 0;
112
4.63k
      gtpLayer->getSequenceNumber(value16);
113
4.63k
      uint8_t value8;
114
4.63k
      gtpLayer->getNpduNumber(value8);
115
4.63k
      gtpLayer->getMessageType();
116
4.63k
      gtpLayer->getMessageTypeAsString();
117
4.63k
      gtpLayer->isGTPUMessage();
118
4.63k
      gtpLayer->isGTPCMessage();
119
4.63k
      auto ext = gtpLayer->getNextExtension();
120
4.63k
      ext.getExtensionType();
121
4.63k
      ext.getContent();
122
4.63k
      ext.getContentLength();
123
4.63k
      ext.getNextExtension();
124
4.63k
    }
125
26.0k
  }
126
762k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
69.3k
  {
128
69.3k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
9.02k
    {
130
9.02k
      uint32_t value32 = 0;
131
9.02k
      greLayer->getSequenceNumber(value32);
132
9.02k
    }
133
69.3k
  }
134
762k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.58k
  {
136
8.58k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.11k
    {
138
2.11k
      uint16_t value16 = 0;
139
2.11k
      greLayer->getChecksum(value16);
140
2.11k
      greLayer->getOffset(value16);
141
2.11k
      uint32_t value32 = 0;
142
2.11k
      greLayer->getKey(value32);
143
2.11k
    }
144
8.58k
  }
145
762k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
60.7k
  {
147
60.7k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.91k
    {
149
6.91k
      uint32_t value32 = 0;
150
6.91k
      greLayer->getAcknowledgmentNum(value32);
151
6.91k
    }
152
60.7k
  }
153
762k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
6.83k
  {
155
6.83k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
6.83k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
1.06k
    {
162
1.06k
      ftpLayer->getStatusCode();
163
1.06k
      ftpLayer->getStatusOption(false);
164
1.06k
      ftpLayer->getStatusOption(true);
165
1.06k
    }
166
6.83k
  }
167
762k
  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
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.99k
  {
180
8.99k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.57k
    {
182
2.57k
      vrrpLayer->getIPAddresses();
183
2.57k
      vrrpLayer->isChecksumCorrect();
184
2.57k
      vrrpLayer->getChecksum();
185
2.57k
      vrrpLayer->getPriorityAsEnum();
186
2.57k
      vrrpLayer->getPriority();
187
2.57k
      vrrpLayer->getType();
188
2.57k
    }
189
8.99k
  }
190
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.96k
  {
192
2.96k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
986
    {
194
986
      vrrpLayer->getAuthTypeAsEnum();
195
986
      vrrpLayer->getAdvInt();
196
986
    }
197
2.96k
  }
198
762k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
6.02k
  {
200
6.02k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.58k
    {
202
1.58k
      vrrpLayer->getMaxAdvInt();
203
1.58k
    }
204
6.02k
  }
205
762k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
386k
  {
207
386k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
87.5k
    {
209
87.5k
      auto tcpLayer2(*tcpLayer);
210
87.5k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
87.5k
                                     pcpp::TcpOptionEnumType::Nop);
212
87.5k
    }
213
386k
  }
214
762k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
30.6k
  {
216
30.6k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.13k
    {
218
3.13k
      sdpLayer->getOwnerIPv4Address();
219
3.13k
      sdpLayer->getMediaPort("audio");
220
3.13k
      sdpLayer->getFieldCount();
221
222
3.13k
      auto sdpLayer2 = *sdpLayer;
223
3.13k
      std::vector<std::string> audioAttributes;
224
3.13k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.13k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.13k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.13k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.13k
    }
229
30.6k
  }
230
762k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
91.6k
  {
232
91.6k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
18.5k
    {
234
18.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.79M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.79M
        {
244
5.79M
          clientHelloMessage->getCipherSuite(i);
245
5.79M
          bool valid;
246
5.79M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.79M
        }
248
5.21k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.76k
          ext->getHostName();
250
5.21k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
589
          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
18.5k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.61k
      {
261
4.61k
        serverHelloMessage->getCompressionMethodsValue();
262
4.61k
        serverHelloMessage->getSessionID();
263
4.61k
        serverHelloMessage->getCipherSuite();
264
265
4.61k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.61k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.61k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.61k
        serverHelloMessage->getHandshakeVersion();
270
4.61k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.61k
        fingerprint.toMD5();
272
4.61k
      }
273
18.5k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
17.4k
      {
275
17.4k
        handshakeMessage->isMessageComplete();
276
17.4k
      }
277
18.5k
    }
278
91.6k
  }
279
762k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
12.3k
  {
281
12.3k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
3.07k
    {
283
3.07k
      ntpLayer->getLeapIndicator();
284
3.07k
      ntpLayer->getMode();
285
3.07k
      ntpLayer->getModeString();
286
3.07k
      ntpLayer->getStratum();
287
3.07k
      ntpLayer->getPollInterval();
288
3.07k
      ntpLayer->getPrecision();
289
3.07k
      ntpLayer->getRootDelay();
290
3.07k
      ntpLayer->getRootDispersion();
291
3.07k
      ntpLayer->getReferenceIdentifier();
292
3.07k
      ntpLayer->getReferenceIdentifierString();
293
3.07k
      ntpLayer->getReferenceTimestamp();
294
3.07k
      ntpLayer->getOriginTimestamp();
295
3.07k
      ntpLayer->getReceiveTimestamp();
296
3.07k
      ntpLayer->getTransmitTimestamp();
297
298
3.07k
      ntpLayer->getDigest();
299
3.07k
      ntpLayer->getKeyID();
300
301
3.07k
      ntpLayer->getPollIntervalInSecs();
302
3.07k
      ntpLayer->getPrecisionInSecs();
303
3.07k
      ntpLayer->getRootDelayInSecs();
304
3.07k
      ntpLayer->getRootDispersionInSecs();
305
3.07k
      ntpLayer->getReferenceTimestampInSecs();
306
3.07k
      ntpLayer->getOriginTimestampInSecs();
307
3.07k
      ntpLayer->getReceiveTimestampInSecs();
308
3.07k
      ntpLayer->getTransmitTimestampInSecs();
309
310
3.07k
      ntpLayer->getReferenceTimestampAsString();
311
3.07k
      ntpLayer->getOriginTimestampAsString();
312
3.07k
      ntpLayer->getReceiveTimestampAsString();
313
3.07k
      ntpLayer->getTransmitTimestampAsString();
314
315
3.07k
      auto ntpLayer2(*ntpLayer);
316
3.07k
      ntpLayer2.setRootDelayInSecs(0.1);
317
3.07k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
3.07k
    }
319
12.3k
  }
320
762k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
31.0k
  {
322
31.0k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.69k
    {
324
6.69k
      auto icmpLayer2(*icmpLayer);
325
326
6.69k
      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.50k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
3
      {
336
3
        icmpLayer->getAddressMaskRequestData();
337
3
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
3
      }
339
5.49k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
124
      {
341
124
        icmpLayer->getAddressMaskReplyData();
342
124
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
124
      }
344
5.37k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
682
      {
346
682
        icmpLayer->getDestUnreachableData();
347
682
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
682
      }
349
4.69k
      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.28k
      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.75k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
669
      {
361
669
        auto layerData = icmpLayer->getParamProblemData();
362
669
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
669
      }
364
3.08k
      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.49k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
905
      {
371
905
        icmpLayer->getRouterAdvertisementData();
372
905
        pcpp::icmp_router_address_structure addr1;
373
905
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
905
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
905
        routerAddresses.push_back(addr1);
376
905
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
905
      }
378
6.69k
    }
379
31.0k
  }
380
762k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
13.9k
  {
382
13.9k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.35k
    {
384
3.35k
      dhcpLayer->getTransactionID();
385
3.35k
      if (dhcpLayer->getOptionCount() > 0)
386
3.25k
      {
387
3.25k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.25k
        opt.getType();
389
3.25k
        opt.getTotalSize();
390
3.25k
        opt.getValueAsHexString();
391
10.9k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
7.67k
        {
393
7.67k
          opt = dhcpLayer->getNextOptionData(opt);
394
7.67k
        }
395
3.25k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.25k
      }
397
3.35k
    }
398
13.9k
  }
399
762k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
12.8k
  {
401
12.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
3.17k
    {
403
3.17k
      dhcpLayer->getOpCode();
404
3.17k
      dhcpLayer->getDhcpHeader();
405
3.17k
      dhcpLayer->getClientIpAddress();
406
3.17k
      dhcpLayer->getYourIpAddress();
407
3.17k
      dhcpLayer->getServerIpAddress();
408
3.17k
      dhcpLayer->getGatewayIpAddress();
409
3.17k
      dhcpLayer->getClientHardwareAddress();
410
3.17k
      if (dhcpLayer->getOptionsCount() > 0)
411
3.12k
      {
412
3.12k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
3.12k
        opt.getValueAsIpAddr();
414
3.12k
        opt.getValueAsString();
415
63.8k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
60.7k
        {
417
60.7k
          opt = dhcpLayer->getNextOptionData(opt);
418
60.7k
        }
419
3.12k
      }
420
3.17k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
3.17k
    }
422
12.8k
  }
423
762k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
40.4k
  {
425
40.4k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
18.3k
    {
427
18.3k
      bgpLayer->getMessageTypeAsString();
428
18.3k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.39k
      {
430
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.39k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.39k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.39k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.39k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.39k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.39k
      }
442
14.9k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.8k
      {
444
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.8k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.8k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.8k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.8k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.8k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.8k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.8k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.8k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.8k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.8k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.8k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.8k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.8k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.8k
        pathAttributes2.push_back(
468
12.8k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.8k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.8k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.8k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.8k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.8k
      }
474
2.08k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
569
      {
476
569
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
569
      }
478
18.3k
    }
479
40.4k
  }
480
762k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
64.2k
  {
482
64.2k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.2k
    {
484
15.2k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.2k
      dnsLayer->removeQuery("a", true);
486
15.2k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.2k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.2k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.2k
                          &ipv4DnsData);
490
15.2k
      dnsLayer->removeAnswer("a", true);
491
15.2k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.2k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.2k
      dnsLayer->removeAuthority("a", true);
494
15.2k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.2k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.2k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.2k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.2k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.2k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.5k
      while (add != nullptr)
502
3.30k
      {
503
3.30k
        add = dnsLayer->getNextAdditionalRecord(add);
504
3.30k
      }
505
506
15.2k
      auto answer = dnsLayer->getFirstAnswer();
507
19.3k
      while (answer != nullptr)
508
4.03k
      {
509
4.03k
        answer = dnsLayer->getNextAnswer(answer);
510
4.03k
      }
511
512
15.2k
      auto auth = dnsLayer->getFirstAuthority();
513
18.2k
      while (auth != nullptr)
514
2.93k
      {
515
2.93k
        auth = dnsLayer->getNextAuthority(auth);
516
2.93k
      }
517
518
15.2k
      pcpp::DnsLayer other(*dnsLayer);
519
15.2k
      other = *dnsLayer;
520
15.2k
    }
521
64.2k
  }
522
762k
}