Coverage Report

Created: 2025-12-14 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Tests/Fuzzers/ReadParsedPacket.h
Line
Count
Source
1
#pragma once
2
3
#include <Packet.h>
4
#include <IPv4Layer.h>
5
#include <TelnetLayer.h>
6
#include <BgpLayer.h>
7
#include <DhcpLayer.h>
8
#include <DhcpV6Layer.h>
9
#include <DnsLayer.h>
10
#include <IcmpLayer.h>
11
#include <NtpLayer.h>
12
#include <SSLLayer.h>
13
#include <SSLHandshake.h>
14
#include <TcpLayer.h>
15
#include <SdpLayer.h>
16
#include <VrrpLayer.h>
17
#include <Sll2Layer.h>
18
#include <FtpLayer.h>
19
#include <GreLayer.h>
20
#include <GtpLayer.h>
21
#include <SomeIpSdLayer.h>
22
23
// Call some pcpp::Packet methods that are not invoked from general virtual methods
24
// as `pcpp::Packet::toString` or `pcpp::Packet::computeCalculateFields` to trigger possible crashes.
25
// The general rule is the functions do not modify the `parsedPacket`.
26
// If you made changes to PcapPlusPlus and the code doesn't compile - fix the method call as any other unit test
27
static void readParsedPacket(pcpp::Packet parsedPacket, pcpp::Layer* layer)
28
724k
{
29
724k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
31.0k
  {
31
31.0k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
6.21k
    {
33
6.21k
      telnetLayer->getFirstCommand();
34
6.21k
      telnetLayer->getTotalNumberOfCommands();
35
36
6.21k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
6.21k
      do
38
24.7k
      {
39
24.7k
        commandVal = telnetLayer->getNextCommand();
40
24.7k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
24.7k
                  << std::endl;
42
24.7k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
24.7k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
24.7k
        telnetLayer->getDataAsString(true);
46
24.7k
        telnetLayer->getNumberOfCommands(commandVal);
47
24.7k
        telnetLayer->getOption(commandVal);
48
24.7k
        size_t length = 0;
49
24.7k
        telnetLayer->getOptionData(length);
50
24.7k
        telnetLayer->getOptionData(commandVal, length);
51
24.7k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
6.21k
    }
53
31.0k
  }
54
724k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.22k
  {
56
3.22k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.21k
    {
58
1.21k
      arpLayer->isReply();
59
1.21k
      arpLayer->isRequest();
60
1.21k
    }
61
3.22k
  }
62
724k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
26.2k
  {
64
26.2k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.00k
    {
66
3.00k
      auto entries = someipLayer->getEntries();
67
3.00k
      if (!entries.empty())
68
2.94k
      {
69
2.94k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
2.94k
        for (auto opt : opts)
71
1.80k
          delete opt;
72
2.94k
      }
73
74
3.00k
      for (auto entry : entries)
75
2.94k
      {
76
2.94k
        entry->getNumOptions();
77
2.94k
        entry->getServiceId();
78
2.94k
        entry->getInstanceId();
79
2.94k
        entry->getMajorVersion();
80
2.94k
        entry->getMinorVersion();
81
2.94k
        entry->getCounter();
82
2.94k
        entry->getEventgroupId();
83
2.94k
        delete entry;
84
2.94k
      }
85
86
3.00k
      someipLayer->getFlags();
87
3.00k
      auto opts = someipLayer->getOptions();
88
3.00k
      for (auto opt : opts)
89
2.08k
      {
90
2.08k
        opt->getType();
91
2.08k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
620
        {
93
620
          v4opt->getIpAddress();
94
620
          v4opt->getPort();
95
620
          v4opt->getProtocol();
96
620
        }
97
1.46k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
545
        {
99
545
          v6opt->getIpAddress();
100
545
          v6opt->getPort();
101
545
          v6opt->getProtocol();
102
545
        }
103
2.08k
        delete opt;
104
2.08k
      }
105
3.00k
    }
106
26.2k
  }
107
724k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
25.3k
  {
109
25.3k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.50k
    {
111
4.50k
      uint16_t value16 = 0;
112
4.50k
      gtpLayer->getSequenceNumber(value16);
113
4.50k
      uint8_t value8;
114
4.50k
      gtpLayer->getNpduNumber(value8);
115
4.50k
      gtpLayer->getMessageType();
116
4.50k
      gtpLayer->getMessageTypeAsString();
117
4.50k
      gtpLayer->isGTPUMessage();
118
4.50k
      gtpLayer->isGTPCMessage();
119
4.50k
      auto ext = gtpLayer->getNextExtension();
120
4.50k
      ext.getExtensionType();
121
4.50k
      ext.getContent();
122
4.50k
      ext.getContentLength();
123
4.50k
      ext.getNextExtension();
124
4.50k
    }
125
25.3k
  }
126
724k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
69.0k
  {
128
69.0k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
8.96k
    {
130
8.96k
      uint32_t value32 = 0;
131
8.96k
      greLayer->getSequenceNumber(value32);
132
8.96k
    }
133
69.0k
  }
134
724k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.45k
  {
136
8.45k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.07k
    {
138
2.07k
      uint16_t value16 = 0;
139
2.07k
      greLayer->getChecksum(value16);
140
2.07k
      greLayer->getOffset(value16);
141
2.07k
      uint32_t value32 = 0;
142
2.07k
      greLayer->getKey(value32);
143
2.07k
    }
144
8.45k
  }
145
724k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
60.5k
  {
147
60.5k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.89k
    {
149
6.89k
      uint32_t value32 = 0;
150
6.89k
      greLayer->getAcknowledgmentNum(value32);
151
6.89k
    }
152
60.5k
  }
153
724k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
6.38k
  {
155
6.38k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
6.38k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
971
    {
162
971
      ftpLayer->getStatusCode();
163
971
      ftpLayer->getStatusOption(false);
164
971
      ftpLayer->getStatusOption(true);
165
971
    }
166
6.38k
  }
167
724k
  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
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.07k
  {
180
8.07k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.31k
    {
182
2.31k
      vrrpLayer->getIPAddresses();
183
2.31k
      vrrpLayer->isChecksumCorrect();
184
2.31k
      vrrpLayer->getChecksum();
185
2.31k
      vrrpLayer->getPriorityAsEnum();
186
2.31k
      vrrpLayer->getPriority();
187
2.31k
      vrrpLayer->getType();
188
2.31k
    }
189
8.07k
  }
190
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.62k
  {
192
2.62k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
872
    {
194
872
      vrrpLayer->getAuthTypeAsEnum();
195
872
      vrrpLayer->getAdvInt();
196
872
    }
197
2.62k
  }
198
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.45k
  {
200
5.45k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.44k
    {
202
1.44k
      vrrpLayer->getMaxAdvInt();
203
1.44k
    }
204
5.45k
  }
205
724k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
368k
  {
207
368k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
83.3k
    {
209
83.3k
      auto tcpLayer2(*tcpLayer);
210
83.3k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
83.3k
                                     pcpp::TcpOptionEnumType::Nop);
212
83.3k
    }
213
368k
  }
214
724k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
29.9k
  {
216
29.9k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.07k
    {
218
3.07k
      sdpLayer->getOwnerIPv4Address();
219
3.07k
      sdpLayer->getMediaPort("audio");
220
3.07k
      sdpLayer->getFieldCount();
221
222
3.07k
      auto sdpLayer2 = *sdpLayer;
223
3.07k
      std::vector<std::string> audioAttributes;
224
3.07k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.07k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.07k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.07k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.07k
    }
229
29.9k
  }
230
724k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
88.2k
  {
232
88.2k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
18.0k
    {
234
18.0k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
5.16k
      {
236
5.16k
        clientHelloMessage->getCompressionMethodsValue();
237
5.16k
        clientHelloMessage->getSessionID();
238
5.16k
        clientHelloMessage->getHandshakeType();
239
5.16k
        clientHelloMessage->getHandshakeVersion();
240
241
5.16k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
5.68M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.68M
        {
244
5.68M
          clientHelloMessage->getCipherSuite(i);
245
5.68M
          bool valid;
246
5.68M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.68M
        }
248
5.16k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.69k
          ext->getHostName();
250
5.16k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
554
          ext->getSupportedVersions();
252
253
5.16k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
5.16k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
5.16k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
5.16k
        fingerprint.toMD5();
258
5.16k
      }
259
18.0k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.41k
      {
261
4.41k
        serverHelloMessage->getCompressionMethodsValue();
262
4.41k
        serverHelloMessage->getSessionID();
263
4.41k
        serverHelloMessage->getCipherSuite();
264
265
4.41k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.41k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.41k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.41k
        serverHelloMessage->getHandshakeVersion();
270
4.41k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.41k
        fingerprint.toMD5();
272
4.41k
      }
273
18.0k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
16.9k
      {
275
16.9k
        handshakeMessage->isMessageComplete();
276
16.9k
      }
277
18.0k
    }
278
88.2k
  }
279
724k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
11.5k
  {
281
11.5k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
2.87k
    {
283
2.87k
      ntpLayer->getLeapIndicator();
284
2.87k
      ntpLayer->getMode();
285
2.87k
      ntpLayer->getModeString();
286
2.87k
      ntpLayer->getStratum();
287
2.87k
      ntpLayer->getPollInterval();
288
2.87k
      ntpLayer->getPrecision();
289
2.87k
      ntpLayer->getRootDelay();
290
2.87k
      ntpLayer->getRootDispersion();
291
2.87k
      ntpLayer->getReferenceIdentifier();
292
2.87k
      ntpLayer->getReferenceIdentifierString();
293
2.87k
      ntpLayer->getReferenceTimestamp();
294
2.87k
      ntpLayer->getOriginTimestamp();
295
2.87k
      ntpLayer->getReceiveTimestamp();
296
2.87k
      ntpLayer->getTransmitTimestamp();
297
298
2.87k
      ntpLayer->getDigest();
299
2.87k
      ntpLayer->getKeyID();
300
301
2.87k
      ntpLayer->getPollIntervalInSecs();
302
2.87k
      ntpLayer->getPrecisionInSecs();
303
2.87k
      ntpLayer->getRootDelayInSecs();
304
2.87k
      ntpLayer->getRootDispersionInSecs();
305
2.87k
      ntpLayer->getReferenceTimestampInSecs();
306
2.87k
      ntpLayer->getOriginTimestampInSecs();
307
2.87k
      ntpLayer->getReceiveTimestampInSecs();
308
2.87k
      ntpLayer->getTransmitTimestampInSecs();
309
310
2.87k
      ntpLayer->getReferenceTimestampAsString();
311
2.87k
      ntpLayer->getOriginTimestampAsString();
312
2.87k
      ntpLayer->getReceiveTimestampAsString();
313
2.87k
      ntpLayer->getTransmitTimestampAsString();
314
315
2.87k
      auto ntpLayer2(*ntpLayer);
316
2.87k
      ntpLayer2.setRootDelayInSecs(0.1);
317
2.87k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
2.87k
    }
319
11.5k
  }
320
724k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
30.0k
  {
322
30.0k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.40k
    {
324
6.40k
      auto icmpLayer2(*icmpLayer);
325
326
6.40k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.18k
      {
328
1.18k
        icmpLayer->getTimestampReplyData();
329
1.18k
        timeval orig = { 16131, 171000 };
330
1.18k
        timeval recv = { 16133, 474000 };
331
1.18k
        timeval tran = { 16133, 474000 };
332
1.18k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.18k
      }
334
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
0
      {
336
0
        icmpLayer->getAddressMaskRequestData();
337
0
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
0
      }
339
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
42
      {
341
42
        icmpLayer->getAddressMaskReplyData();
342
42
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
42
      }
344
5.17k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
715
      {
346
715
        icmpLayer->getDestUnreachableData();
347
715
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
715
      }
349
4.45k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
390
      {
351
390
        auto layerData = icmpLayer->getInfoReplyData();
352
390
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
390
      }
354
4.06k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
521
      {
356
521
        auto layerData = icmpLayer->getInfoRequestData();
357
521
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
521
      }
359
3.54k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
654
      {
361
654
        auto layerData = icmpLayer->getParamProblemData();
362
654
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
654
      }
364
2.89k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.30k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
887
      {
371
887
        icmpLayer->getRouterAdvertisementData();
372
887
        pcpp::icmp_router_address_structure addr1;
373
887
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
887
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
887
        routerAddresses.push_back(addr1);
376
887
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
887
      }
378
6.40k
    }
379
30.0k
  }
380
724k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
14.5k
  {
382
14.5k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.50k
    {
384
3.50k
      dhcpLayer->getTransactionID();
385
3.50k
      if (dhcpLayer->getOptionCount() > 0)
386
3.42k
      {
387
3.42k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.42k
        opt.getType();
389
3.42k
        opt.getTotalSize();
390
3.42k
        opt.getValueAsHexString();
391
11.6k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.19k
        {
393
8.19k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.19k
        }
395
3.42k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.42k
      }
397
3.50k
    }
398
14.5k
  }
399
724k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
10.8k
  {
401
10.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
2.68k
    {
403
2.68k
      dhcpLayer->getOpCode();
404
2.68k
      dhcpLayer->getDhcpHeader();
405
2.68k
      dhcpLayer->getClientIpAddress();
406
2.68k
      dhcpLayer->getYourIpAddress();
407
2.68k
      dhcpLayer->getServerIpAddress();
408
2.68k
      dhcpLayer->getGatewayIpAddress();
409
2.68k
      dhcpLayer->getClientHardwareAddress();
410
2.68k
      if (dhcpLayer->getOptionsCount() > 0)
411
2.63k
      {
412
2.63k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
2.63k
        opt.getValueAsIpAddr();
414
2.63k
        opt.getValueAsString();
415
55.9k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
53.3k
        {
417
53.3k
          opt = dhcpLayer->getNextOptionData(opt);
418
53.3k
        }
419
2.63k
      }
420
2.68k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
2.68k
    }
422
10.8k
  }
423
724k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
38.6k
  {
425
38.6k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
17.4k
    {
427
17.4k
      bgpLayer->getMessageTypeAsString();
428
17.4k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.29k
      {
430
3.29k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.29k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.29k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.29k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.29k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.29k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.29k
      }
442
14.1k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.1k
      {
444
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.1k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.1k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.1k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.1k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.1k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.1k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.1k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.1k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.1k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.1k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.1k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.1k
        pathAttributes2.push_back(
468
12.1k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.1k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.1k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.1k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.1k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.1k
      }
474
2.07k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
549
      {
476
549
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
549
      }
478
17.4k
    }
479
38.6k
  }
480
724k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
63.7k
  {
482
63.7k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.1k
    {
484
15.1k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.1k
      dnsLayer->removeQuery("a", true);
486
15.1k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.1k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.1k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.1k
                          &ipv4DnsData);
490
15.1k
      dnsLayer->removeAnswer("a", true);
491
15.1k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.1k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.1k
      dnsLayer->removeAuthority("a", true);
494
15.1k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.1k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.1k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.1k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.1k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.1k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.5k
      while (add != nullptr)
502
3.40k
      {
503
3.40k
        add = dnsLayer->getNextAdditionalRecord(add);
504
3.40k
      }
505
506
15.1k
      auto answer = dnsLayer->getFirstAnswer();
507
19.0k
      while (answer != nullptr)
508
3.92k
      {
509
3.92k
        answer = dnsLayer->getNextAnswer(answer);
510
3.92k
      }
511
512
15.1k
      auto auth = dnsLayer->getFirstAuthority();
513
18.0k
      while (auth != nullptr)
514
2.87k
      {
515
2.87k
        auth = dnsLayer->getNextAuthority(auth);
516
2.87k
      }
517
518
15.1k
      pcpp::DnsLayer other(*dnsLayer);
519
15.1k
      other = *dnsLayer;
520
15.1k
    }
521
63.7k
  }
522
724k
}
Unexecuted instantiation: FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
FuzzTarget.cpp:readParsedPacket(pcpp::Packet, pcpp::Layer*)
Line
Count
Source
28
724k
{
29
724k
  if (parsedPacket.isPacketOfType(pcpp::Telnet))
30
31.0k
  {
31
31.0k
    if (auto telnetLayer = dynamic_cast<pcpp::TelnetLayer*>(layer))
32
6.21k
    {
33
6.21k
      telnetLayer->getFirstCommand();
34
6.21k
      telnetLayer->getTotalNumberOfCommands();
35
36
6.21k
      pcpp::TelnetLayer::TelnetCommand commandVal;
37
6.21k
      do
38
24.7k
      {
39
24.7k
        commandVal = telnetLayer->getNextCommand();
40
24.7k
        std::cout << "Telnet command is '" << telnetLayer->getTelnetCommandAsString(commandVal) << "'"
41
24.7k
                  << std::endl;
42
24.7k
        pcpp::TelnetLayer::TelnetOption option = telnetLayer->getOption();
43
24.7k
        std::cout << "Telnet option is '" << telnetLayer->getTelnetOptionAsString(option) << "'" << std::endl;
44
45
24.7k
        telnetLayer->getDataAsString(true);
46
24.7k
        telnetLayer->getNumberOfCommands(commandVal);
47
24.7k
        telnetLayer->getOption(commandVal);
48
24.7k
        size_t length = 0;
49
24.7k
        telnetLayer->getOptionData(length);
50
24.7k
        telnetLayer->getOptionData(commandVal, length);
51
24.7k
      } while (commandVal != pcpp::TelnetLayer::TelnetCommand::TelnetCommandEndOfPacket);
52
6.21k
    }
53
31.0k
  }
54
724k
  if (parsedPacket.isPacketOfType(pcpp::ARP))
55
3.22k
  {
56
3.22k
    if (auto arpLayer = dynamic_cast<pcpp::ArpLayer*>(layer))
57
1.21k
    {
58
1.21k
      arpLayer->isReply();
59
1.21k
      arpLayer->isRequest();
60
1.21k
    }
61
3.22k
  }
62
724k
  if (parsedPacket.isPacketOfType(pcpp::SomeIP))
63
26.2k
  {
64
26.2k
    if (auto someipLayer = dynamic_cast<pcpp::SomeIpSdLayer*>(layer))
65
3.00k
    {
66
3.00k
      auto entries = someipLayer->getEntries();
67
3.00k
      if (!entries.empty())
68
2.94k
      {
69
2.94k
        auto opts = someipLayer->getOptionsFromEntry(0);
70
2.94k
        for (auto opt : opts)
71
1.80k
          delete opt;
72
2.94k
      }
73
74
3.00k
      for (auto entry : entries)
75
2.94k
      {
76
2.94k
        entry->getNumOptions();
77
2.94k
        entry->getServiceId();
78
2.94k
        entry->getInstanceId();
79
2.94k
        entry->getMajorVersion();
80
2.94k
        entry->getMinorVersion();
81
2.94k
        entry->getCounter();
82
2.94k
        entry->getEventgroupId();
83
2.94k
        delete entry;
84
2.94k
      }
85
86
3.00k
      someipLayer->getFlags();
87
3.00k
      auto opts = someipLayer->getOptions();
88
3.00k
      for (auto opt : opts)
89
2.08k
      {
90
2.08k
        opt->getType();
91
2.08k
        if (auto v4opt = dynamic_cast<pcpp::SomeIpSdIPv4Option*>(opt))
92
620
        {
93
620
          v4opt->getIpAddress();
94
620
          v4opt->getPort();
95
620
          v4opt->getProtocol();
96
620
        }
97
1.46k
        else if (auto v6opt = dynamic_cast<pcpp::SomeIpSdIPv6Option*>(opt))
98
545
        {
99
545
          v6opt->getIpAddress();
100
545
          v6opt->getPort();
101
545
          v6opt->getProtocol();
102
545
        }
103
2.08k
        delete opt;
104
2.08k
      }
105
3.00k
    }
106
26.2k
  }
107
724k
  if (parsedPacket.isPacketOfType(pcpp::GTP))
108
25.3k
  {
109
25.3k
    if (auto gtpLayer = dynamic_cast<pcpp::GtpV1Layer*>(layer))
110
4.50k
    {
111
4.50k
      uint16_t value16 = 0;
112
4.50k
      gtpLayer->getSequenceNumber(value16);
113
4.50k
      uint8_t value8;
114
4.50k
      gtpLayer->getNpduNumber(value8);
115
4.50k
      gtpLayer->getMessageType();
116
4.50k
      gtpLayer->getMessageTypeAsString();
117
4.50k
      gtpLayer->isGTPUMessage();
118
4.50k
      gtpLayer->isGTPCMessage();
119
4.50k
      auto ext = gtpLayer->getNextExtension();
120
4.50k
      ext.getExtensionType();
121
4.50k
      ext.getContent();
122
4.50k
      ext.getContentLength();
123
4.50k
      ext.getNextExtension();
124
4.50k
    }
125
25.3k
  }
126
724k
  if (parsedPacket.isPacketOfType(pcpp::GRE))
127
69.0k
  {
128
69.0k
    if (auto greLayer = dynamic_cast<pcpp::GreLayer*>(layer))
129
8.96k
    {
130
8.96k
      uint32_t value32 = 0;
131
8.96k
      greLayer->getSequenceNumber(value32);
132
8.96k
    }
133
69.0k
  }
134
724k
  if (parsedPacket.isPacketOfType(pcpp::GREv0))
135
8.45k
  {
136
8.45k
    if (auto greLayer = dynamic_cast<pcpp::GREv0Layer*>(layer))
137
2.07k
    {
138
2.07k
      uint16_t value16 = 0;
139
2.07k
      greLayer->getChecksum(value16);
140
2.07k
      greLayer->getOffset(value16);
141
2.07k
      uint32_t value32 = 0;
142
2.07k
      greLayer->getKey(value32);
143
2.07k
    }
144
8.45k
  }
145
724k
  if (parsedPacket.isPacketOfType(pcpp::GREv1))
146
60.5k
  {
147
60.5k
    if (auto greLayer = dynamic_cast<pcpp::GREv1Layer*>(layer))
148
6.89k
    {
149
6.89k
      uint32_t value32 = 0;
150
6.89k
      greLayer->getAcknowledgmentNum(value32);
151
6.89k
    }
152
60.5k
  }
153
724k
  if (parsedPacket.isPacketOfType(pcpp::FTP))
154
6.38k
  {
155
6.38k
    if (auto ftpLayer = dynamic_cast<pcpp::FtpRequestLayer*>(layer))
156
0
    {
157
0
      ftpLayer->getCommandOption(false);
158
0
      ftpLayer->getCommandOption(true);
159
0
    }
160
6.38k
    else if (auto ftpLayer = dynamic_cast<pcpp::FtpResponseLayer*>(layer))
161
971
    {
162
971
      ftpLayer->getStatusCode();
163
971
      ftpLayer->getStatusOption(false);
164
971
      ftpLayer->getStatusOption(true);
165
971
    }
166
6.38k
  }
167
724k
  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
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRP))
179
8.07k
  {
180
8.07k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpLayer*>(layer))
181
2.31k
    {
182
2.31k
      vrrpLayer->getIPAddresses();
183
2.31k
      vrrpLayer->isChecksumCorrect();
184
2.31k
      vrrpLayer->getChecksum();
185
2.31k
      vrrpLayer->getPriorityAsEnum();
186
2.31k
      vrrpLayer->getPriority();
187
2.31k
      vrrpLayer->getType();
188
2.31k
    }
189
8.07k
  }
190
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv2))
191
2.62k
  {
192
2.62k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV2Layer*>(layer))
193
872
    {
194
872
      vrrpLayer->getAuthTypeAsEnum();
195
872
      vrrpLayer->getAdvInt();
196
872
    }
197
2.62k
  }
198
724k
  if (parsedPacket.isPacketOfType(pcpp::VRRPv3))
199
5.45k
  {
200
5.45k
    if (auto vrrpLayer = dynamic_cast<pcpp::VrrpV3Layer*>(layer))
201
1.44k
    {
202
1.44k
      vrrpLayer->getMaxAdvInt();
203
1.44k
    }
204
5.45k
  }
205
724k
  if (parsedPacket.isPacketOfType(pcpp::TCP))
206
368k
  {
207
368k
    if (auto tcpLayer = dynamic_cast<pcpp::TcpLayer*>(layer))
208
83.3k
    {
209
83.3k
      auto tcpLayer2(*tcpLayer);
210
83.3k
      tcpLayer2.insertTcpOptionAfter(pcpp::TcpOptionBuilder(pcpp::TcpOptionBuilder::NopEolOptionEnumType::Nop),
211
83.3k
                                     pcpp::TcpOptionEnumType::Nop);
212
83.3k
    }
213
368k
  }
214
724k
  if (parsedPacket.isPacketOfType(pcpp::SDP))
215
29.9k
  {
216
29.9k
    if (auto sdpLayer = dynamic_cast<pcpp::SdpLayer*>(layer))
217
3.07k
    {
218
3.07k
      sdpLayer->getOwnerIPv4Address();
219
3.07k
      sdpLayer->getMediaPort("audio");
220
3.07k
      sdpLayer->getFieldCount();
221
222
3.07k
      auto sdpLayer2 = *sdpLayer;
223
3.07k
      std::vector<std::string> audioAttributes;
224
3.07k
      audioAttributes.push_back("rtpmap:8 PCMA/8000");
225
3.07k
      sdpLayer2.addMediaDescription("audio", 6010, "RTP/AVP", "8 96", audioAttributes);
226
3.07k
      sdpLayer2.addField(PCPP_SDP_PROTOCOL_VERSION_FIELD, "0");
227
3.07k
      sdpLayer2.removeField(PCPP_SDP_PROTOCOL_VERSION_FIELD);
228
3.07k
    }
229
29.9k
  }
230
724k
  if (parsedPacket.isPacketOfType(pcpp::SSL))
231
88.2k
  {
232
88.2k
    if (auto handshakeLayer = dynamic_cast<pcpp::SSLHandshakeLayer*>(layer))
233
18.0k
    {
234
18.0k
      if (auto clientHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLClientHelloMessage>())
235
5.16k
      {
236
5.16k
        clientHelloMessage->getCompressionMethodsValue();
237
5.16k
        clientHelloMessage->getSessionID();
238
5.16k
        clientHelloMessage->getHandshakeType();
239
5.16k
        clientHelloMessage->getHandshakeVersion();
240
241
5.16k
        pcpp::SSLCipherSuite::getCipherSuiteByName("TLS_RSA_WITH_NULL_MD5");
242
5.68M
        for (int i = 0; i < clientHelloMessage->getCipherSuiteCount(); i++)
243
5.68M
        {
244
5.68M
          clientHelloMessage->getCipherSuite(i);
245
5.68M
          bool valid;
246
5.68M
          clientHelloMessage->getCipherSuiteID(i, valid);
247
5.68M
        }
248
5.16k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>())
249
2.69k
          ext->getHostName();
250
5.16k
        if (auto ext = clientHelloMessage->getExtensionOfType<pcpp::SSLSupportedVersionsExtension>())
251
554
          ext->getSupportedVersions();
252
253
5.16k
        clientHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
254
5.16k
        clientHelloMessage->getExtensionOfType((uint16_t)0);
255
256
5.16k
        auto fingerprint = clientHelloMessage->generateTLSFingerprint();
257
5.16k
        fingerprint.toMD5();
258
5.16k
      }
259
18.0k
      if (auto serverHelloMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLServerHelloMessage>())
260
4.41k
      {
261
4.41k
        serverHelloMessage->getCompressionMethodsValue();
262
4.41k
        serverHelloMessage->getSessionID();
263
4.41k
        serverHelloMessage->getCipherSuite();
264
265
4.41k
        serverHelloMessage->getExtensionOfType<pcpp::SSLServerNameIndicationExtension>();
266
4.41k
        serverHelloMessage->getExtensionOfType(pcpp::SSL_EXT_SERVER_NAME);
267
4.41k
        serverHelloMessage->getExtensionOfType((uint16_t)0);
268
269
4.41k
        serverHelloMessage->getHandshakeVersion();
270
4.41k
        auto fingerprint = serverHelloMessage->generateTLSFingerprint();
271
4.41k
        fingerprint.toMD5();
272
4.41k
      }
273
18.0k
      if (auto handshakeMessage = handshakeLayer->getHandshakeMessageOfType<pcpp::SSLHandshakeMessage>())
274
16.9k
      {
275
16.9k
        handshakeMessage->isMessageComplete();
276
16.9k
      }
277
18.0k
    }
278
88.2k
  }
279
724k
  if (parsedPacket.isPacketOfType(pcpp::NTP))
280
11.5k
  {
281
11.5k
    if (auto ntpLayer = dynamic_cast<pcpp::NtpLayer*>(layer))
282
2.87k
    {
283
2.87k
      ntpLayer->getLeapIndicator();
284
2.87k
      ntpLayer->getMode();
285
2.87k
      ntpLayer->getModeString();
286
2.87k
      ntpLayer->getStratum();
287
2.87k
      ntpLayer->getPollInterval();
288
2.87k
      ntpLayer->getPrecision();
289
2.87k
      ntpLayer->getRootDelay();
290
2.87k
      ntpLayer->getRootDispersion();
291
2.87k
      ntpLayer->getReferenceIdentifier();
292
2.87k
      ntpLayer->getReferenceIdentifierString();
293
2.87k
      ntpLayer->getReferenceTimestamp();
294
2.87k
      ntpLayer->getOriginTimestamp();
295
2.87k
      ntpLayer->getReceiveTimestamp();
296
2.87k
      ntpLayer->getTransmitTimestamp();
297
298
2.87k
      ntpLayer->getDigest();
299
2.87k
      ntpLayer->getKeyID();
300
301
2.87k
      ntpLayer->getPollIntervalInSecs();
302
2.87k
      ntpLayer->getPrecisionInSecs();
303
2.87k
      ntpLayer->getRootDelayInSecs();
304
2.87k
      ntpLayer->getRootDispersionInSecs();
305
2.87k
      ntpLayer->getReferenceTimestampInSecs();
306
2.87k
      ntpLayer->getOriginTimestampInSecs();
307
2.87k
      ntpLayer->getReceiveTimestampInSecs();
308
2.87k
      ntpLayer->getTransmitTimestampInSecs();
309
310
2.87k
      ntpLayer->getReferenceTimestampAsString();
311
2.87k
      ntpLayer->getOriginTimestampAsString();
312
2.87k
      ntpLayer->getReceiveTimestampAsString();
313
2.87k
      ntpLayer->getTransmitTimestampAsString();
314
315
2.87k
      auto ntpLayer2(*ntpLayer);
316
2.87k
      ntpLayer2.setRootDelayInSecs(0.1);
317
2.87k
      ntpLayer2.setReferenceTimestampInSecs(0.1);
318
2.87k
    }
319
11.5k
  }
320
724k
  if (parsedPacket.isPacketOfType(pcpp::ICMP))
321
30.0k
  {
322
30.0k
    if (auto icmpLayer = dynamic_cast<pcpp::IcmpLayer*>(layer))
323
6.40k
    {
324
6.40k
      auto icmpLayer2(*icmpLayer);
325
326
6.40k
      if (icmpLayer->isMessageOfType(pcpp::ICMP_TIMESTAMP_REPLY))
327
1.18k
      {
328
1.18k
        icmpLayer->getTimestampReplyData();
329
1.18k
        timeval orig = { 16131, 171000 };
330
1.18k
        timeval recv = { 16133, 474000 };
331
1.18k
        timeval tran = { 16133, 474000 };
332
1.18k
        icmpLayer2.setTimestampReplyData(14640, 0, orig, recv, tran);
333
1.18k
      }
334
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REQUEST))
335
0
      {
336
0
        icmpLayer->getAddressMaskRequestData();
337
0
        icmpLayer2.setAddressMaskRequestData(45068, 1536, pcpp::IPv4Address::Zero);
338
0
      }
339
5.21k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ADDRESS_MASK_REPLY))
340
42
      {
341
42
        icmpLayer->getAddressMaskReplyData();
342
42
        icmpLayer2.setAddressMaskReplyData(45068, 1536, pcpp::IPv4Address::Zero);
343
42
      }
344
5.17k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_DEST_UNREACHABLE))
345
715
      {
346
715
        icmpLayer->getDestUnreachableData();
347
715
        icmpLayer2.setDestUnreachableData(pcpp::IcmpHostUnreachable, 0, nullptr, nullptr);
348
715
      }
349
4.45k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REPLY))
350
390
      {
351
390
        auto layerData = icmpLayer->getInfoReplyData();
352
390
        icmpLayer2.setInfoReplyData(layerData->id, layerData->sequence);
353
390
      }
354
4.06k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_INFO_REQUEST))
355
521
      {
356
521
        auto layerData = icmpLayer->getInfoRequestData();
357
521
        icmpLayer2.setInfoRequestData(layerData->id, layerData->sequence);
358
521
      }
359
3.54k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_PARAM_PROBLEM))
360
654
      {
361
654
        auto layerData = icmpLayer->getParamProblemData();
362
654
        icmpLayer2.setParamProblemData(layerData->code, layerData->pointer, nullptr, nullptr);
363
654
      }
364
2.89k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_TIME_EXCEEDED))
365
586
      {
366
586
        icmpLayer->getTimeExceededData();
367
586
        icmpLayer2.setTimeExceededData(1, nullptr, nullptr);
368
586
      }
369
2.30k
      else if (icmpLayer->isMessageOfType(pcpp::ICMP_ROUTER_ADV))
370
887
      {
371
887
        icmpLayer->getRouterAdvertisementData();
372
887
        pcpp::icmp_router_address_structure addr1;
373
887
        addr1.setRouterAddress(pcpp::IPv4Address("192.168.144.2"), (uint32_t)0x08000000);
374
887
        std::vector<pcpp::icmp_router_address_structure> routerAddresses;
375
887
        routerAddresses.push_back(addr1);
376
887
        icmpLayer2.setRouterAdvertisementData(16, 200, routerAddresses);
377
887
      }
378
6.40k
    }
379
30.0k
  }
380
724k
  if (parsedPacket.isPacketOfType(pcpp::DHCPv6))
381
14.5k
  {
382
14.5k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpV6Layer*>(layer))
383
3.50k
    {
384
3.50k
      dhcpLayer->getTransactionID();
385
3.50k
      if (dhcpLayer->getOptionCount() > 0)
386
3.42k
      {
387
3.42k
        pcpp::DhcpV6Option opt = dhcpLayer->getFirstOptionData();
388
3.42k
        opt.getType();
389
3.42k
        opt.getTotalSize();
390
3.42k
        opt.getValueAsHexString();
391
11.6k
        for (size_t i = 0; i < dhcpLayer->getOptionCount(); i++)
392
8.19k
        {
393
8.19k
          opt = dhcpLayer->getNextOptionData(opt);
394
8.19k
        }
395
3.42k
        dhcpLayer->getOptionData(pcpp::DHCPV6_OPT_CLIENTID);
396
3.42k
      }
397
3.50k
    }
398
14.5k
  }
399
724k
  if (parsedPacket.isPacketOfType(pcpp::DHCP))
400
10.8k
  {
401
10.8k
    if (auto dhcpLayer = dynamic_cast<pcpp::DhcpLayer*>(layer))
402
2.68k
    {
403
2.68k
      dhcpLayer->getOpCode();
404
2.68k
      dhcpLayer->getDhcpHeader();
405
2.68k
      dhcpLayer->getClientIpAddress();
406
2.68k
      dhcpLayer->getYourIpAddress();
407
2.68k
      dhcpLayer->getServerIpAddress();
408
2.68k
      dhcpLayer->getGatewayIpAddress();
409
2.68k
      dhcpLayer->getClientHardwareAddress();
410
2.68k
      if (dhcpLayer->getOptionsCount() > 0)
411
2.63k
      {
412
2.63k
        pcpp::DhcpOption opt = dhcpLayer->getFirstOptionData();
413
2.63k
        opt.getValueAsIpAddr();
414
2.63k
        opt.getValueAsString();
415
55.9k
        for (size_t i = 0; i < dhcpLayer->getOptionsCount(); i++)
416
53.3k
        {
417
53.3k
          opt = dhcpLayer->getNextOptionData(opt);
418
53.3k
        }
419
2.63k
      }
420
2.68k
      dhcpLayer->getOptionData(pcpp::DHCPOPT_SUBNET_MASK);
421
2.68k
    }
422
10.8k
  }
423
724k
  if (parsedPacket.isPacketOfType(pcpp::BGP))
424
38.6k
  {
425
38.6k
    if (auto bgpLayer = dynamic_cast<pcpp::BgpLayer*>(layer))
426
17.4k
    {
427
17.4k
      bgpLayer->getMessageTypeAsString();
428
17.4k
      if (auto bgpOpenMsgLayer = dynamic_cast<pcpp::BgpOpenMessageLayer*>(bgpLayer))
429
3.29k
      {
430
3.29k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams;
431
3.29k
        bgpOpenMsgLayer->getOptionalParameters(optionalParams);
432
3.29k
        std::vector<pcpp::BgpOpenMessageLayer::optional_parameter> optionalParams2(optionalParams);
433
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "010400010001"));
434
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "8000"));
435
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "0200"));
436
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "4600"));
437
3.29k
        optionalParams2.push_back(pcpp::BgpOpenMessageLayer::optional_parameter(2, "410400000001"));
438
3.29k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams2);
439
3.29k
        bgpOpenMsgLayer->clearOptionalParameters();
440
3.29k
        bgpOpenMsgLayer->setOptionalParameters(optionalParams);
441
3.29k
      }
442
14.1k
      else if (auto bgpUpdateMsgLayer = dynamic_cast<pcpp::BgpUpdateMessageLayer*>(bgpLayer))
443
12.1k
      {
444
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes;
445
12.1k
        bgpUpdateMsgLayer->getWithdrawnRoutes(withdrawnRoutes);
446
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> withdrawnRoutes2(withdrawnRoutes);
447
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
448
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.40.40.0"));
449
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(16, "103.103.0.0"));
450
12.1k
        withdrawnRoutes2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "103.103.40.0"));
451
12.1k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes2);
452
12.1k
        bgpUpdateMsgLayer->clearWithdrawnRoutes();
453
12.1k
        bgpUpdateMsgLayer->setWithdrawnRoutes(withdrawnRoutes);
454
455
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec;
456
12.1k
        bgpUpdateMsgLayer->getNetworkLayerReachabilityInfo(nlriVec);
457
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::prefix_and_ip> nlriVec2(nlriVec);
458
12.1k
        nlriVec2.push_back(pcpp::BgpUpdateMessageLayer::prefix_and_ip(24, "40.1.1.0"));
459
12.1k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec2);
460
12.1k
        bgpUpdateMsgLayer->clearNetworkLayerReachabilityInfo();
461
12.1k
        bgpUpdateMsgLayer->setNetworkLayerReachabilityInfo(nlriVec);
462
463
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes;
464
12.1k
        bgpUpdateMsgLayer->getPathAttributes(pathAttributes);
465
12.1k
        std::vector<pcpp::BgpUpdateMessageLayer::path_attribute> pathAttributes2(pathAttributes);
466
12.1k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 1, "02"));
467
12.1k
        pathAttributes2.push_back(
468
12.1k
            pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 2, "02030000000a0000001400000028"));
469
12.1k
        pathAttributes2.push_back(pcpp::BgpUpdateMessageLayer::path_attribute(0x40, 3, "1e031e03"));
470
12.1k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes2);
471
12.1k
        bgpUpdateMsgLayer->clearPathAttributes();
472
12.1k
        bgpUpdateMsgLayer->setPathAttributes(pathAttributes);
473
12.1k
      }
474
2.07k
      else if (auto bgpNotificationMsgLayer = dynamic_cast<pcpp::BgpNotificationMessageLayer*>(bgpLayer))
475
549
      {
476
549
        bgpNotificationMsgLayer->getNotificationDataAsHexString();
477
549
      }
478
17.4k
    }
479
38.6k
  }
480
724k
  if (parsedPacket.isPacketOfType(pcpp::DNS))
481
63.7k
  {
482
63.7k
    if (auto dnsLayer = dynamic_cast<pcpp::DnsLayer*>(layer))
483
15.1k
    {
484
15.1k
      dnsLayer->addQuery("mail-attachment.googleusercontent.com", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN);
485
15.1k
      dnsLayer->removeQuery("a", true);
486
15.1k
      dnsLayer->removeQuery("mail-attachment.googleusercontent.com", false);
487
15.1k
      pcpp::IPv4DnsResourceData ipv4DnsData(std::string("151.249.90.217"));
488
15.1k
      dnsLayer->addAnswer("assets.pinterest.com.cdngc.net", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 3,
489
15.1k
                          &ipv4DnsData);
490
15.1k
      dnsLayer->removeAnswer("a", true);
491
15.1k
      dnsLayer->removeAnswer("assets.pinterest.com.cdngc.net", false);
492
15.1k
      dnsLayer->addAuthority("Yaels-iPhone.local", pcpp::DNS_TYPE_A, pcpp::DNS_CLASS_IN, 120, &ipv4DnsData);
493
15.1k
      dnsLayer->removeAuthority("a", true);
494
15.1k
      dnsLayer->removeAuthority("Yaels-iPhone.local", false);
495
15.1k
      pcpp::GenericDnsResourceData genericData("0004000800df581faa4f3f9d");
496
15.1k
      dnsLayer->addAdditionalRecord("abc", pcpp::DNS_TYPE_OPT, 0xa005, 0x1194, &genericData);
497
15.1k
      dnsLayer->removeAdditionalRecord("a", true);
498
15.1k
      dnsLayer->removeAdditionalRecord("abc", false);
499
500
15.1k
      auto add = dnsLayer->getFirstAdditionalRecord();
501
18.5k
      while (add != nullptr)
502
3.40k
      {
503
3.40k
        add = dnsLayer->getNextAdditionalRecord(add);
504
3.40k
      }
505
506
15.1k
      auto answer = dnsLayer->getFirstAnswer();
507
19.0k
      while (answer != nullptr)
508
3.92k
      {
509
3.92k
        answer = dnsLayer->getNextAnswer(answer);
510
3.92k
      }
511
512
15.1k
      auto auth = dnsLayer->getFirstAuthority();
513
18.0k
      while (auth != nullptr)
514
2.87k
      {
515
2.87k
        auth = dnsLayer->getNextAuthority(auth);
516
2.87k
      }
517
518
15.1k
      pcpp::DnsLayer other(*dnsLayer);
519
15.1k
      other = *dnsLayer;
520
15.1k
    }
521
63.7k
  }
522
724k
}