Coverage Report

Created: 2026-03-07 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PcapPlusPlus/Packet++/header/TLVData.h
Line
Count
Source
1
#pragma once
2
3
#include "Layer.h"
4
#include "IpAddress.h"
5
#include <string.h>
6
7
/// @file
8
9
/// @namespace pcpp
10
/// @brief The main namespace for the PcapPlusPlus lib
11
namespace pcpp
12
{
13
  /// @class TLVRecord
14
  /// A wrapper class for a Type-Length-Value (TLV) record. This class does not create or modify TLV records, but
15
  /// rather serves as a wrapper and provides useful methods for retrieving data from them. This class has several
16
  /// abstract methods that should be implemented in derived classes. These methods are for record length value
17
  /// calculation (the 'L' in TLV) which is implemented differently in different protocols
18
  template <typename TRecType, typename TRecLen> class TLVRecord
19
  {
20
  protected:
21
    /// A struct representing the TLV construct
22
#pragma pack(push, 1)
23
    struct TLVRawData
24
    {
25
      /// Record type
26
      TRecType recordType;
27
      /// Record length in bytes
28
      TRecLen recordLen;
29
      /// Record value (variable size)
30
      uint8_t recordValue[];
31
    };
32
#pragma pack(pop)
33
34
    TLVRawData* m_Data;
35
36
  public:
37
    /// A c'tor for this class that gets a pointer to the TLV record raw data (byte array)
38
    /// @param[in] recordRawData A pointer to the TLV record raw data
39
    TLVRecord(uint8_t* recordRawData)
40
2.36M
    {
41
2.36M
      assign(recordRawData);
42
2.36M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(unsigned char*)
Line
Count
Source
40
2.31M
    {
41
2.31M
      assign(recordRawData);
42
2.31M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(unsigned char*)
Line
Count
Source
40
51.8k
    {
41
51.8k
      assign(recordRawData);
42
51.8k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::TLVRecord(unsigned char*)
43
44
    /// A copy c'tor for this class. This copy c'tor doesn't copy the TLV data, but only the pointer to it,
45
    /// which means that after calling it both the old and the new instance will point to the same TLV raw data
46
    /// @param[in] other The TLVRecord instance to copy from
47
    TLVRecord(const TLVRecord& other)
48
704k
    {
49
704k
      m_Data = other.m_Data;
50
704k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
48
14.1k
    {
49
14.1k
      m_Data = other.m_Data;
50
14.1k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
48
690k
    {
49
690k
      m_Data = other.m_Data;
50
690k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::TLVRecord(pcpp::TLVRecord<unsigned char, unsigned short> const&)
51
52
    /// A d'tor for this class, currently does nothing
53
2.18M
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned char, unsigned char>::~TLVRecord()
Line
Count
Source
53
2.13M
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned short, unsigned short>::~TLVRecord()
Line
Count
Source
53
56.4k
    virtual ~TLVRecord() = default;
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::~TLVRecord()
54
55
    /// Assign a pointer to the TLV record raw data (byte array)
56
    /// @param[in] recordRawData A pointer to the TLV record raw data
57
    void assign(uint8_t* recordRawData)
58
4.31M
    {
59
4.31M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
4.31M
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::assign(unsigned char*)
pcpp::TLVRecord<unsigned char, unsigned char>::assign(unsigned char*)
Line
Count
Source
58
4.21M
    {
59
4.21M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
4.21M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::assign(unsigned char*)
Line
Count
Source
58
106k
    {
59
106k
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
106k
    }
61
62
    /// Check if a pointer can be assigned to the TLV record data
63
    /// @param[in] recordRawData A pointer to the TLV record raw data
64
    /// @param[in] tlvDataLen The size of the TLV record raw data
65
    /// @return True if data is valid and can be assigned
66
    static bool canAssign(const uint8_t* recordRawData, size_t tlvDataLen)
67
432k
    {
68
432k
      return recordRawData != nullptr &&
69
432k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
432k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
380k
    {
68
380k
      return recordRawData != nullptr &&
69
380k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
380k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
51.8k
    {
68
51.8k
      return recordRawData != nullptr &&
69
51.8k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
51.8k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::canAssign(unsigned char const*, unsigned long)
71
72
    /// Overload of the assignment operator. This operator doesn't copy the TLV data, but rather copies the pointer
73
    /// to it, which means that after calling it both the old and the new instance will point to the same TLV raw
74
    /// data
75
    /// @param[in] other The TLVRecord instance to assign
76
    TLVRecord& operator=(const TLVRecord& other)
77
1.60M
    {
78
1.60M
      m_Data = other.m_Data;
79
1.60M
      return *this;
80
1.60M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::operator=(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
77
37.6k
    {
78
37.6k
      m_Data = other.m_Data;
79
37.6k
      return *this;
80
37.6k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::operator=(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
77
1.57M
    {
78
1.57M
      m_Data = other.m_Data;
79
1.57M
      return *this;
80
1.57M
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::operator=(pcpp::TLVRecord<unsigned char, unsigned short> const&)
81
82
    /// Overload of the equality operator. Two record are equal if both of them point to the same data, or if they
83
    /// point to different data but their total size is equal and the raw data they both contain is similar.
84
    /// @param[in] rhs The object to compare to
85
    /// @return True if both objects are equal, false otherwise
86
    bool operator==(const TLVRecord& rhs) const
87
    {
88
      if (m_Data == rhs.m_Data)
89
        return true;
90
91
      if (getTotalSize() != rhs.getTotalSize())
92
        return false;
93
94
      if (isNull() || ((TLVRecord&)rhs).isNull())
95
        return false;
96
97
      return (memcmp(m_Data, rhs.m_Data, getTotalSize()) == 0);
98
    }
99
100
    /// Overload of the not equal operator.
101
    /// @param[in] rhs The object to compare to
102
    /// @return True if objects are not equal, false otherwise
103
    bool operator!=(const TLVRecord& rhs) const
104
    {
105
      return !operator==(rhs);
106
    }
107
108
    /// @return The type field of the record (the 'T' in __Type__-Length-Value)
109
    TRecType getType() const
110
952k
    {
111
952k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
952k
      return m_Data->recordType;
115
952k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getType() const
Line
Count
Source
110
952k
    {
111
952k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
952k
      return m_Data->recordType;
115
952k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::getType() const
116
117
    /// @return A pointer to the value of the record as byte array (the 'V' in Type-Length- __Value__)
118
    uint8_t* getValue() const
119
620
    {
120
620
      if (m_Data == nullptr)
121
0
        return nullptr;
122
123
620
      return m_Data->recordValue;
124
620
    }
125
126
    /// @return True if the TLV record raw data is nullptr, false otherwise
127
    bool isNull() const
128
5.54M
    {
129
5.54M
      return (m_Data == nullptr);
130
5.54M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::isNull() const
Line
Count
Source
128
5.43M
    {
129
5.43M
      return (m_Data == nullptr);
130
5.43M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::isNull() const
Line
Count
Source
128
116k
    {
129
116k
      return (m_Data == nullptr);
130
116k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::isNull() const
131
132
    /// @return True if the TLV record raw data is not nullptr, false otherwise
133
    bool isNotNull() const
134
373k
    {
135
373k
      return (m_Data != nullptr);
136
373k
    }
137
138
    /// @return A pointer to the TLV record raw data byte stream
139
    uint8_t* getRecordBasePtr() const
140
8.16M
    {
141
8.16M
      return reinterpret_cast<uint8_t*>(m_Data);
142
8.16M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getRecordBasePtr() const
Line
Count
Source
140
7.98M
    {
141
7.98M
      return reinterpret_cast<uint8_t*>(m_Data);
142
7.98M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::getRecordBasePtr() const
Line
Count
Source
140
183k
    {
141
183k
      return reinterpret_cast<uint8_t*>(m_Data);
142
183k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::getRecordBasePtr() const
143
144
    /// Free the memory of the TLV record raw data
145
    void purgeRecordData()
146
115k
    {
147
115k
      if (!isNull())
148
115k
      {
149
115k
        delete[] m_Data;
150
115k
        m_Data = nullptr;
151
115k
      }
152
115k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::purgeRecordData()
Line
Count
Source
146
115k
    {
147
115k
      if (!isNull())
148
115k
      {
149
115k
        delete[] m_Data;
150
115k
        m_Data = nullptr;
151
115k
      }
152
115k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned short, unsigned short>::purgeRecordData()
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::purgeRecordData()
153
154
    /// A templated method to retrieve the record data as a certain type T. For example, if record data is 4B long
155
    /// (integer) then this method should be used as getValueAs<int>() and it will return the record data as an
156
    /// integer.<BR> Notice this return value is a copy of the data, not a pointer to the actual data
157
    /// @param[in] offset The offset in the record data to start reading the value from. Useful for cases when you
158
    /// want to read some of the data that doesn't start at offset 0. This is an optional parameter and the default
159
    /// value is 0, meaning start reading the value at the beginning of the record data
160
    /// @return The record data as type T
161
    template <typename T> T getValueAs(size_t offset = 0) const
162
18.3k
    {
163
18.3k
      if (getDataSize() - offset < sizeof(T))
164
6.10k
        return 0;
165
166
12.2k
      T result;
167
12.2k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
12.2k
      return result;
169
18.3k
    }
unsigned int pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned int>(unsigned long) const
Line
Count
Source
162
6.26k
    {
163
6.26k
      if (getDataSize() - offset < sizeof(T))
164
5.77k
        return 0;
165
166
493
      T result;
167
493
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
493
      return result;
169
6.26k
    }
unsigned char pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned char>(unsigned long) const
Line
Count
Source
162
12.0k
    {
163
12.0k
      if (getDataSize() - offset < sizeof(T))
164
327
        return 0;
165
166
11.7k
      T result;
167
11.7k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
11.7k
      return result;
169
12.0k
    }
170
171
    /// A templated method to copy data of type T into the TLV record data. For example: if record data is 4[Bytes]
172
    /// long use this method with \<int\> to set an integer value into the record data: setValue<int>(num)
173
    /// @param[in] newValue The value of type T to copy to the record data
174
    /// @param[in] valueOffset An optional parameter that specifies where to start setting the record data (default
175
    /// set to 0). For example: if record data is 20 bytes long and you only need to set the 4 last bytes as integer
176
    /// then use this method like this: setValue<int>(num, 16)
177
    /// @return True if value was set successfully or false if the size of T is larger than the record data size
178
    template <typename T> bool setValue(T newValue, int valueOffset = 0)
179
0
    {
180
0
      if (getDataSize() < sizeof(T))
181
0
        return false;
182
183
0
      memcpy(m_Data->recordValue + getValueOffset() + valueOffset, &newValue, sizeof(T));
184
0
      return true;
185
0
    }
Unexecuted instantiation: bool pcpp::TLVRecord<unsigned char, unsigned char>::setValue<unsigned int>(unsigned int, int)
Unexecuted instantiation: bool pcpp::TLVRecord<unsigned char, unsigned char>::setValue<unsigned char>(unsigned char, int)
186
187
    /// @return The total size of the TLV record (in bytes)
188
    virtual size_t getTotalSize() const = 0;
189
190
    /// @return The size of the record value (meaning the size of the 'V' part in TLV)
191
    virtual size_t getDataSize() const = 0;
192
193
  protected:
194
    virtual size_t getValueOffset() const
195
12.2k
    {
196
12.2k
      return 0;
197
12.2k
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned short, unsigned short>::getValueOffset() const
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::getValueOffset() const
pcpp::TLVRecord<unsigned char, unsigned char>::getValueOffset() const
Line
Count
Source
195
12.2k
    {
196
12.2k
      return 0;
197
12.2k
    }
198
  };
199
200
  /// @class TLVRecordReader
201
  /// A class for reading TLV records data out of a byte stream. This class contains helper methods for retrieving and
202
  /// counting TLV records. This is a template class that expects template argument class derived from TLVRecord.
203
  template <typename TLVRecordType> class TLVRecordReader
204
  {
205
  private:
206
    mutable size_t m_RecordCount;
207
208
  public:
209
    /// A default c'tor for this class
210
    TLVRecordReader()
211
3.50M
    {
212
3.50M
      m_RecordCount = static_cast<size_t>(-1);
213
3.50M
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::TLVRecordReader()
Line
Count
Source
211
34.3k
    {
212
34.3k
      m_RecordCount = static_cast<size_t>(-1);
213
34.3k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::TLVRecordReader()
Line
Count
Source
211
25.6k
    {
212
25.6k
      m_RecordCount = static_cast<size_t>(-1);
213
25.6k
    }
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::TLVRecordReader()
Line
Count
Source
211
1.68k
    {
212
1.68k
      m_RecordCount = static_cast<size_t>(-1);
213
1.68k
    }
pcpp::TLVRecordReader<pcpp::IPv4Option>::TLVRecordReader()
Line
Count
Source
211
1.88M
    {
212
1.88M
      m_RecordCount = static_cast<size_t>(-1);
213
1.88M
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::TLVRecordReader()
Line
Count
Source
211
3.84k
    {
212
3.84k
      m_RecordCount = static_cast<size_t>(-1);
213
3.84k
    }
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::TLVRecordReader()
Line
Count
Source
211
1.21k
    {
212
1.21k
      m_RecordCount = static_cast<size_t>(-1);
213
1.21k
    }
pcpp::TLVRecordReader<pcpp::TcpOption>::TLVRecordReader()
Line
Count
Source
211
1.48M
    {
212
1.48M
      m_RecordCount = static_cast<size_t>(-1);
213
1.48M
    }
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::TLVRecordReader()
Line
Count
Source
211
32.9k
    {
212
32.9k
      m_RecordCount = static_cast<size_t>(-1);
213
32.9k
    }
pcpp::TLVRecordReader<pcpp::NdpOption>::TLVRecordReader()
Line
Count
Source
211
4.12k
    {
212
4.12k
      m_RecordCount = static_cast<size_t>(-1);
213
4.12k
    }
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::TLVRecordReader()
Line
Count
Source
211
31.0k
    {
212
31.0k
      m_RecordCount = static_cast<size_t>(-1);
213
31.0k
    }
214
215
    /// A default copy c'tor for this class
216
    TLVRecordReader(const TLVRecordReader& other)
217
    {
218
      m_RecordCount = other.m_RecordCount;
219
    }
220
221
    /// A d'tor for this class which currently does nothing
222
3.50M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::TcpOption>::~TLVRecordReader()
Line
Count
Source
222
1.48M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpOption>::~TLVRecordReader()
Line
Count
Source
222
34.3k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::~TLVRecordReader()
Line
Count
Source
222
25.6k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::~TLVRecordReader()
Line
Count
Source
222
1.68k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv4Option>::~TLVRecordReader()
Line
Count
Source
222
1.88M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::~TLVRecordReader()
Line
Count
Source
222
31.0k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NflogTlv>::~TLVRecordReader()
Line
Count
Source
222
3.84k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::~TLVRecordReader()
Line
Count
Source
222
1.21k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::~TLVRecordReader()
Line
Count
Source
222
32.9k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NdpOption>::~TLVRecordReader()
Line
Count
Source
222
4.12k
    virtual ~TLVRecordReader() = default;
223
224
    /// Overload of the assignment operator for this class
225
    /// @param[in] other The TLVRecordReader instance to assign
226
    TLVRecordReader& operator=(const TLVRecordReader& other)
227
236k
    {
228
236k
      m_RecordCount = other.m_RecordCount;
229
236k
      return *this;
230
236k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::operator=(pcpp::TLVRecordReader<pcpp::IPv4Option> const&)
pcpp::TLVRecordReader<pcpp::TcpOption>::operator=(pcpp::TLVRecordReader<pcpp::TcpOption> const&)
Line
Count
Source
227
236k
    {
228
236k
      m_RecordCount = other.m_RecordCount;
229
236k
      return *this;
230
236k
    }
231
232
    /// Get the first TLV record out of a byte stream
233
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
234
    /// @param[in] tlvDataLen The TLV data byte stream length
235
    /// @return An instance of type TLVRecordType that contains the first TLV record. If tlvDataBasePtr is nullptr
236
    /// or tlvDataLen is zero the returned TLVRecordType instance will be logically null, meaning
237
    /// TLVRecordType.isNull() will return true
238
    TLVRecordType getFirstTLVRecord(uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
239
412k
    {
240
412k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
412k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
104k
        return resRec;
243
244
308k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
308k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
8.00k
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
308k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
2.12k
        resRec.assign(nullptr);
252
253
308k
      return resRec;
254
412k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
38.4k
    {
240
38.4k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
38.4k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
20
        return resRec;
243
244
38.4k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
38.4k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
790
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
38.4k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
0
        resRec.assign(nullptr);
252
253
38.4k
      return resRec;
254
38.4k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
14.2k
    {
240
14.2k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
14.2k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
20
        return resRec;
243
244
14.1k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
14.1k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
223
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
14.1k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
0
        resRec.assign(nullptr);
252
253
14.1k
      return resRec;
254
14.2k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::getFirstTLVRecord(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
pcpp::TLVRecordReader<pcpp::TcpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
351k
    {
240
351k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
351k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
103k
        return resRec;
243
244
248k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
248k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
5.16k
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
248k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
575
        resRec.assign(nullptr);
252
253
248k
      return resRec;
254
351k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
pcpp::TLVRecordReader<pcpp::NdpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
2.60k
    {
240
2.60k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
2.60k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
884
        return resRec;
243
244
1.72k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
1.72k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
96
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
1.72k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
252
        resRec.assign(nullptr);
252
253
1.72k
      return resRec;
254
2.60k
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
5.57k
    {
240
5.57k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
5.57k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
137
        return resRec;
243
244
5.43k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
5.43k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
1.73k
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
5.43k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
1.29k
        resRec.assign(nullptr);
252
253
5.43k
      return resRec;
254
5.57k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::getFirstTLVRecord(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::RadiusAttribute>::getFirstTLVRecord(unsigned char*, unsigned long) const
255
256
    /// Get a TLV record that follows a given TLV record in a byte stream
257
    /// @param[in] record A given TLV record
258
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
259
    /// @param[in] tlvDataLen The TLV data byte stream length
260
    /// @return An instance of type TLVRecordType that wraps the record following the record given as input. If the
261
    /// input record.isNull() is true or if the next record is out of bounds of the byte stream, a logical null
262
    /// instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true
263
    TLVRecordType getNextTLVRecord(TLVRecordType& record, const uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
264
1.61M
    {
265
1.61M
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
1.61M
      if (record.isNull())
268
0
        return resRec;
269
270
1.61M
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
1.61M
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
1.61M
                                        record.getTotalSize()))
273
137k
        return resRec;
274
275
1.47M
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
1.47M
      if (resRec.getTotalSize() == 0)
278
2.17k
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
1.47M
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
2.17k
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
1.47M
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
26.4k
        resRec.assign(nullptr);
287
288
1.47M
      return resRec;
289
1.61M
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getNextTLVRecord(pcpp::DhcpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
264
1.14M
    {
265
1.14M
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
1.14M
      if (record.isNull())
268
0
        return resRec;
269
270
1.14M
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
1.14M
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
1.14M
                                        record.getTotalSize()))
273
18.9k
        return resRec;
274
275
1.12M
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
1.12M
      if (resRec.getTotalSize() == 0)
278
0
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
1.12M
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
0
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
1.12M
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
5.37k
        resRec.assign(nullptr);
287
288
1.12M
      return resRec;
289
1.14M
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getNextTLVRecord(pcpp::DhcpV6Option&, unsigned char const*, unsigned long) const
Line
Count
Source
264
37.6k
    {
265
37.6k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
37.6k
      if (record.isNull())
268
0
        return resRec;
269
270
37.6k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
37.6k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
37.6k
                                        record.getTotalSize()))
273
6.27k
        return resRec;
274
275
31.3k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
31.3k
      if (resRec.getTotalSize() == 0)
278
0
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
31.3k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
0
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
31.3k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
5.75k
        resRec.assign(nullptr);
287
288
31.3k
      return resRec;
289
37.6k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::getNextTLVRecord(pcpp::GtpV2InformationElement&, unsigned char const*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::getNextTLVRecord(pcpp::IPv4Option&, unsigned char const*, unsigned long) const
pcpp::TLVRecordReader<pcpp::TcpOption>::getNextTLVRecord(pcpp::TcpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
264
427k
    {
265
427k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
427k
      if (record.isNull())
268
0
        return resRec;
269
270
427k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
427k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
427k
                                        record.getTotalSize()))
273
111k
        return resRec;
274
275
315k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
315k
      if (resRec.getTotalSize() == 0)
278
1.95k
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
315k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
1.95k
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
315k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
13.8k
        resRec.assign(nullptr);
287
288
315k
      return resRec;
289
427k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::getNextTLVRecord(pcpp::IPv6TLVOptionHeader::IPv6Option&, unsigned char const*, unsigned long) const
pcpp::TLVRecordReader<pcpp::NdpOption>::getNextTLVRecord(pcpp::NdpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
264
278
    {
265
278
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
278
      if (record.isNull())
268
0
        return resRec;
269
270
278
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
278
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
278
                                        record.getTotalSize()))
273
12
        return resRec;
274
275
266
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
266
      if (resRec.getTotalSize() == 0)
278
42
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
266
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
42
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
266
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
82
        resRec.assign(nullptr);
287
288
266
      return resRec;
289
278
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getNextTLVRecord(pcpp::NflogTlv&, unsigned char const*, unsigned long) const
Line
Count
Source
264
6.53k
    {
265
6.53k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
6.53k
      if (record.isNull())
268
0
        return resRec;
269
270
6.53k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
6.53k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
6.53k
                                        record.getTotalSize()))
273
42
        return resRec;
274
275
6.49k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
6.49k
      if (resRec.getTotalSize() == 0)
278
183
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
6.49k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
183
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
6.49k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
1.40k
        resRec.assign(nullptr);
287
288
6.49k
      return resRec;
289
6.53k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::getNextTLVRecord(pcpp::PPPoEDiscoveryLayer::PPPoETag&, unsigned char const*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::RadiusAttribute>::getNextTLVRecord(pcpp::RadiusAttribute&, unsigned char const*, unsigned long) const
290
291
    /// Search for the first TLV record that corresponds to a given record type (the 'T' in __Type__-Length-Value)
292
    /// @param[in] recordType The record type to search for
293
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
294
    /// @param[in] tlvDataLen The TLV data byte stream length
295
    /// @return An instance of type TLVRecordType that contains the result record. If record was not found a logical
296
    /// null instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true
297
    TLVRecordType getTLVRecord(uint32_t recordType, uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
298
273k
    {
299
273k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
850k
      while (!curRec.isNull())
301
709k
      {
302
709k
        if (curRec.getType() == recordType)
303
132k
        {
304
132k
          return curRec;
305
132k
        }
306
307
576k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
576k
      }
309
310
140k
      curRec.assign(nullptr);
311
140k
      return curRec;  // for NRVO optimization
312
273k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
25.7k
    {
299
25.7k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
535k
      while (!curRec.isNull())
301
523k
      {
302
523k
        if (curRec.getType() == recordType)
303
13.2k
        {
304
13.2k
          return curRec;
305
13.2k
        }
306
307
509k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
509k
      }
309
310
12.4k
      curRec.assign(nullptr);
311
12.4k
      return curRec;  // for NRVO optimization
312
25.7k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
4.65k
    {
299
4.65k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
13.9k
      while (!curRec.isNull())
301
11.1k
      {
302
11.1k
        if (curRec.getType() == recordType)
303
1.94k
        {
304
1.94k
          return curRec;
305
1.94k
        }
306
307
9.24k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
9.24k
      }
309
310
2.71k
      curRec.assign(nullptr);
311
2.71k
      return curRec;  // for NRVO optimization
312
4.65k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
pcpp::TLVRecordReader<pcpp::TcpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
236k
    {
299
236k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
289k
      while (!curRec.isNull())
301
168k
      {
302
168k
        if (curRec.getType() == recordType)
303
115k
        {
304
115k
          return curRec;
305
115k
        }
306
307
53.2k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
53.2k
      }
309
310
121k
      curRec.assign(nullptr);
311
121k
      return curRec;  // for NRVO optimization
312
236k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
pcpp::TLVRecordReader<pcpp::NdpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
2.60k
    {
299
2.60k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
2.88k
      while (!curRec.isNull())
301
1.51k
      {
302
1.51k
        if (curRec.getType() == recordType)
303
1.24k
        {
304
1.24k
          return curRec;
305
1.24k
        }
306
307
278
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
278
      }
309
310
1.36k
      curRec.assign(nullptr);
311
1.36k
      return curRec;  // for NRVO optimization
312
2.60k
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
3.58k
    {
299
3.58k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
7.75k
      while (!curRec.isNull())
301
4.64k
      {
302
4.64k
        if (curRec.getType() == recordType)
303
471
        {
304
471
          return curRec;
305
471
        }
306
307
4.17k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
4.17k
      }
309
310
3.11k
      curRec.assign(nullptr);
311
3.11k
      return curRec;  // for NRVO optimization
312
3.58k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::RadiusAttribute>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
313
314
    /// Get the TLV record count in a given TLV data byte stream. For efficiency purposes the count is being cached
315
    /// so only the first call to this method will go over all the TLV records, while all consequent calls will
316
    /// return the cached number. This implies that if there is a change in the number of records, it's the user's
317
    /// responsibility to call changeTLVRecordCount() with the record count change
318
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
319
    /// @param[in] tlvDataLen The TLV data byte stream length
320
    /// @return The TLV record count
321
    size_t getTLVRecordCount(uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
322
353k
    {
323
353k
      if (m_RecordCount != static_cast<size_t>(-1))
324
341k
        return m_RecordCount;
325
326
11.3k
      m_RecordCount = 0;
327
11.3k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
342k
      while (!curRec.isNull())
329
331k
      {
330
331k
        m_RecordCount++;
331
331k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
331k
      }
333
334
11.3k
      return m_RecordCount;
335
353k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
322
329k
    {
323
329k
      if (m_RecordCount != static_cast<size_t>(-1))
324
323k
        return m_RecordCount;
325
326
6.43k
      m_RecordCount = 0;
327
6.43k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
323k
      while (!curRec.isNull())
329
316k
      {
330
316k
        m_RecordCount++;
331
316k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
316k
      }
333
334
6.43k
      return m_RecordCount;
335
329k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
322
23.7k
    {
323
23.7k
      if (m_RecordCount != static_cast<size_t>(-1))
324
18.8k
        return m_RecordCount;
325
326
4.90k
      m_RecordCount = 0;
327
4.90k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
19.0k
      while (!curRec.isNull())
329
14.1k
      {
330
14.1k
        m_RecordCount++;
331
14.1k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
14.1k
      }
333
334
4.90k
      return m_RecordCount;
335
23.7k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::TcpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::NdpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::getTLVRecordCount(unsigned char*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::RadiusAttribute>::getTLVRecordCount(unsigned char*, unsigned long) const
336
337
    /// As described in getTLVRecordCount(), the TLV record count is being cached for efficiency purposes. So if the
338
    /// number of TLV records change, it's the user's responsibility to call this method with the number of TLV
339
    /// records being added or removed. If records were added the change should be a positive number, or a negative
340
    /// number if records were removed
341
    /// @param[in] changedBy Number of records that were added or removed
342
    void changeTLVRecordCount(int changedBy)
343
115k
    {
344
115k
      if (m_RecordCount != static_cast<size_t>(-1))
345
0
        m_RecordCount += changedBy;
346
115k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::DhcpOption>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::DhcpV6Option>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv4Option>::changeTLVRecordCount(int)
pcpp::TLVRecordReader<pcpp::TcpOption>::changeTLVRecordCount(int)
Line
Count
Source
343
115k
    {
344
115k
      if (m_RecordCount != static_cast<size_t>(-1))
345
0
        m_RecordCount += changedBy;
346
115k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::NdpOption>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::changeTLVRecordCount(int)
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::RadiusAttribute>::changeTLVRecordCount(int)
347
  };
348
349
  /// @class TLVRecordBuilder
350
  /// A base class for building Type-Length-Value (TLV) records. This builder receives the record parameters in its
351
  /// c'tor, builds the record raw buffer and provides a method to build a TLVRecord object out of it. Please notice
352
  /// this is a base class that lacks the capability of actually building TLVRecord objects and also cannot be
353
  /// instantiated. The reason for that is that different protocols build TLV records in different ways, so these
354
  /// missing capabilities will be implemented by the derived classes which are specific to each protocol. This class
355
  /// only provides the common infrastructure that will be used by them
356
  class TLVRecordBuilder
357
  {
358
  protected:
359
    TLVRecordBuilder();
360
361
    TLVRecordBuilder(uint32_t recType, const uint8_t* recValue, uint8_t recValueLen);
362
363
    TLVRecordBuilder(uint32_t recType, uint8_t recValue);
364
365
    TLVRecordBuilder(uint32_t recType, uint16_t recValue);
366
367
    TLVRecordBuilder(uint32_t recType, uint32_t recValue);
368
369
    TLVRecordBuilder(uint32_t recType, const IPv4Address& recValue);
370
371
    TLVRecordBuilder(uint32_t recType, const std::string& recValue, bool valueIsHexString = false);
372
373
    TLVRecordBuilder(const TLVRecordBuilder& other);
374
375
    TLVRecordBuilder& operator=(const TLVRecordBuilder& other);
376
377
    virtual ~TLVRecordBuilder();
378
379
    void init(uint32_t recType, const uint8_t* recValue, size_t recValueLen);
380
381
    uint8_t* m_RecValue;
382
    size_t m_RecValueLen;
383
    uint32_t m_RecType;
384
385
  private:
386
    void copyData(const TLVRecordBuilder& other);
387
  };
388
}  // namespace pcpp