Coverage Report

Created: 2026-09-28 07:37

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