Coverage Report

Created: 2026-09-01 08:15

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