Coverage Report

Created: 2026-09-03 08:09

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
749k
    {
41
749k
      assign(recordRawData);
42
749k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(unsigned char*)
Line
Count
Source
40
715k
    {
41
715k
      assign(recordRawData);
42
715k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(unsigned char*)
Line
Count
Source
40
34.0k
    {
41
34.0k
      assign(recordRawData);
42
34.0k
    }
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
234k
    {
49
234k
      m_Data = other.m_Data;
50
234k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
48
8.47k
    {
49
8.47k
      m_Data = other.m_Data;
50
8.47k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
48
225k
    {
49
225k
      m_Data = other.m_Data;
50
225k
    }
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
595k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned char, unsigned char>::~TLVRecord()
Line
Count
Source
53
560k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned short, unsigned short>::~TLVRecord()
Line
Count
Source
53
34.8k
    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
1.33M
    {
59
1.33M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.33M
    }
Unexecuted instantiation: pcpp::TLVRecord<unsigned char, unsigned short>::assign(unsigned char*)
pcpp::TLVRecord<unsigned char, unsigned char>::assign(unsigned char*)
Line
Count
Source
58
1.27M
    {
59
1.27M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.27M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::assign(unsigned char*)
Line
Count
Source
58
68.1k
    {
59
68.1k
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
68.1k
    }
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
195k
    {
68
195k
      return recordRawData != nullptr &&
69
195k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
195k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
161k
    {
68
161k
      return recordRawData != nullptr &&
69
161k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
161k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
34.0k
    {
68
34.0k
      return recordRawData != nullptr &&
69
34.0k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
34.0k
    }
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
440k
    {
78
440k
      m_Data = other.m_Data;
79
440k
      return *this;
80
440k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::operator=(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
77
22.6k
    {
78
22.6k
      m_Data = other.m_Data;
79
22.6k
      return *this;
80
22.6k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::operator=(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
77
417k
    {
78
417k
      m_Data = other.m_Data;
79
417k
      return *this;
80
417k
    }
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
317k
    {
111
317k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
317k
      return m_Data->recordType;
115
317k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getType() const
Line
Count
Source
110
317k
    {
111
317k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
317k
      return m_Data->recordType;
115
317k
    }
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
0
    {
120
0
      if (m_Data == nullptr)
121
0
        return nullptr;
122
123
0
      return m_Data->recordValue;
124
0
    }
125
126
    /// @return True if the TLV record raw data is nullptr, false otherwise
127
    bool isNull() const
128
1.70M
    {
129
1.70M
      return (m_Data == nullptr);
130
1.70M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::isNull() const
Line
Count
Source
128
1.63M
    {
129
1.63M
      return (m_Data == nullptr);
130
1.63M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::isNull() const
Line
Count
Source
128
72.5k
    {
129
72.5k
      return (m_Data == nullptr);
130
72.5k
    }
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
172k
    {
135
172k
      return (m_Data != nullptr);
136
172k
    }
137
138
    /// @return A pointer to the TLV record raw data byte stream
139
    uint8_t* getRecordBasePtr() const
140
2.27M
    {
141
2.27M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.27M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getRecordBasePtr() const
Line
Count
Source
140
2.16M
    {
141
2.16M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.16M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::getRecordBasePtr() const
Line
Count
Source
140
106k
    {
141
106k
      return reinterpret_cast<uint8_t*>(m_Data);
142
106k
    }
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
53.7k
    {
147
53.7k
      if (!isNull())
148
53.7k
      {
149
53.7k
        delete[] m_Data;
150
53.7k
        m_Data = nullptr;
151
53.7k
      }
152
53.7k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::purgeRecordData()
Line
Count
Source
146
53.7k
    {
147
53.7k
      if (!isNull())
148
53.7k
      {
149
53.7k
        delete[] m_Data;
150
53.7k
        m_Data = nullptr;
151
53.7k
      }
152
53.7k
    }
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
7.67k
    {
163
7.67k
      if (getDataSize() < sizeof(T) + offset)
164
2.55k
        return 0;
165
166
5.12k
      T result;
167
5.12k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
5.12k
      return result;
169
7.67k
    }
unsigned int pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned int>(unsigned long) const
Line
Count
Source
162
2.75k
    {
163
2.75k
      if (getDataSize() < sizeof(T) + offset)
164
2.51k
        return 0;
165
166
242
      T result;
167
242
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
242
      return result;
169
2.75k
    }
unsigned char pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned char>(unsigned long) const
Line
Count
Source
162
4.92k
    {
163
4.92k
      if (getDataSize() < sizeof(T) + offset)
164
42
        return 0;
165
166
4.88k
      T result;
167
4.88k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
4.88k
      return result;
169
4.92k
    }
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
5.12k
    {
196
5.12k
      return 0;
197
5.12k
    }
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
5.12k
    {
196
5.12k
      return 0;
197
5.12k
    }
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
1.51M
    {
212
1.51M
      m_RecordCount = static_cast<size_t>(-1);
213
1.51M
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::TLVRecordReader()
Line
Count
Source
211
14.0k
    {
212
14.0k
      m_RecordCount = static_cast<size_t>(-1);
213
14.0k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::TLVRecordReader()
Line
Count
Source
211
20.2k
    {
212
20.2k
      m_RecordCount = static_cast<size_t>(-1);
213
20.2k
    }
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::TLVRecordReader()
Line
Count
Source
211
8
    {
212
8
      m_RecordCount = static_cast<size_t>(-1);
213
8
    }
pcpp::TLVRecordReader<pcpp::IPv4Option>::TLVRecordReader()
Line
Count
Source
211
888k
    {
212
888k
      m_RecordCount = static_cast<size_t>(-1);
213
888k
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::TLVRecordReader()
Line
Count
Source
211
1.71k
    {
212
1.71k
      m_RecordCount = static_cast<size_t>(-1);
213
1.71k
    }
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::TLVRecordReader()
Line
Count
Source
211
1.23k
    {
212
1.23k
      m_RecordCount = static_cast<size_t>(-1);
213
1.23k
    }
pcpp::TLVRecordReader<pcpp::TcpOption>::TLVRecordReader()
Line
Count
Source
211
559k
    {
212
559k
      m_RecordCount = static_cast<size_t>(-1);
213
559k
    }
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::TLVRecordReader()
Line
Count
Source
211
11.1k
    {
212
11.1k
      m_RecordCount = static_cast<size_t>(-1);
213
11.1k
    }
pcpp::TLVRecordReader<pcpp::NdpOption>::TLVRecordReader()
Line
Count
Source
211
1.34k
    {
212
1.34k
      m_RecordCount = static_cast<size_t>(-1);
213
1.34k
    }
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::TLVRecordReader()
Line
Count
Source
211
15.8k
    {
212
15.8k
      m_RecordCount = static_cast<size_t>(-1);
213
15.8k
    }
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
1.51M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::TcpOption>::~TLVRecordReader()
Line
Count
Source
222
559k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpOption>::~TLVRecordReader()
Line
Count
Source
222
14.0k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::~TLVRecordReader()
Line
Count
Source
222
20.2k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::~TLVRecordReader()
Line
Count
Source
222
8
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv4Option>::~TLVRecordReader()
Line
Count
Source
222
888k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::~TLVRecordReader()
Line
Count
Source
222
15.8k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NflogTlv>::~TLVRecordReader()
Line
Count
Source
222
1.71k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::~TLVRecordReader()
Line
Count
Source
222
1.23k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::~TLVRecordReader()
Line
Count
Source
222
11.1k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NdpOption>::~TLVRecordReader()
Line
Count
Source
222
1.34k
    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
86.1k
    {
228
86.1k
      m_RecordCount = other.m_RecordCount;
229
86.1k
      return *this;
230
86.1k
    }
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
86.1k
    {
228
86.1k
      m_RecordCount = other.m_RecordCount;
229
86.1k
      return *this;
230
86.1k
    }
231
232
    // cppcheck-suppress functionStatic
233
    /// Get the first TLV record out of a byte stream
234
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
235
    /// @param[in] tlvDataLen The TLV data byte stream length
236
    /// @return An instance of type TLVRecordType that contains the first TLV record. If tlvDataBasePtr is nullptr
237
    /// or tlvDataLen is zero the returned TLVRecordType instance will be logically null, meaning
238
    /// TLVRecordType.isNull() will return true
239
    TLVRecordType getFirstTLVRecord(uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
240
171k
    {
241
171k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
171k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
27.5k
        return resRec;
244
245
143k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
143k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
4.18k
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
143k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
987
        resRec.assign(nullptr);
253
254
143k
      return resRec;
255
171k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
16.7k
    {
241
16.7k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
16.7k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
5
        return resRec;
244
245
16.7k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
16.7k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
190
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
16.7k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
0
        resRec.assign(nullptr);
253
254
16.7k
      return resRec;
255
16.7k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
11.4k
    {
241
11.4k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
11.4k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
1
        return resRec;
244
245
11.4k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
11.4k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
136
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
11.4k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
0
        resRec.assign(nullptr);
253
254
11.4k
      return resRec;
255
11.4k
    }
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
240
139k
    {
241
139k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
139k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
26.8k
        return resRec;
244
245
112k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
112k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
3.18k
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
112k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
312
        resRec.assign(nullptr);
253
254
112k
      return resRec;
255
139k
    }
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
240
670
    {
241
670
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
670
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
670
        return resRec;
244
245
0
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
0
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
0
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
0
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
0
        resRec.assign(nullptr);
253
254
0
      return resRec;
255
670
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
2.54k
    {
241
2.54k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
2.54k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
16
        return resRec;
244
245
2.52k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
2.52k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
678
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
2.52k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
675
        resRec.assign(nullptr);
253
254
2.52k
      return resRec;
255
2.54k
    }
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
256
257
    // cppcheck-suppress [constParameterReference, functionStatic]
258
    /// Get a TLV record that follows a given TLV record in a byte stream
259
    /// @param[in] record A given TLV record
260
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
261
    /// @param[in] tlvDataLen The TLV data byte stream length
262
    /// @return An instance of type TLVRecordType that wraps the record following the record given as input. If the
263
    /// input record.isNull() is true or if the next record is out of bounds of the byte stream, a logical null
264
    /// instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true
265
    TLVRecordType getNextTLVRecord(TLVRecordType& record, const uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
266
442k
    {
267
442k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
442k
      if (record.isNull())
270
0
        return resRec;
271
272
442k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
442k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
442k
                                        record.getTotalSize()))
275
58.0k
        return resRec;
276
277
384k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
384k
      if (resRec.getTotalSize() == 0)
280
2.53k
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
384k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
2.53k
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
384k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
16.9k
        resRec.assign(nullptr);
289
290
384k
      return resRec;
291
442k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getNextTLVRecord(pcpp::DhcpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
266
222k
    {
267
222k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
222k
      if (record.isNull())
270
0
        return resRec;
271
272
222k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
222k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
222k
                                        record.getTotalSize()))
275
9.66k
        return resRec;
276
277
212k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
212k
      if (resRec.getTotalSize() == 0)
280
0
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
212k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
0
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
212k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
1.27k
        resRec.assign(nullptr);
289
290
212k
      return resRec;
291
222k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getNextTLVRecord(pcpp::DhcpV6Option&, unsigned char const*, unsigned long) const
Line
Count
Source
266
22.6k
    {
267
22.6k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
22.6k
      if (record.isNull())
270
0
        return resRec;
271
272
22.6k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
22.6k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
22.6k
                                        record.getTotalSize()))
275
6.00k
        return resRec;
276
277
16.6k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
16.6k
      if (resRec.getTotalSize() == 0)
280
0
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
16.6k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
0
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
16.6k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
3.67k
        resRec.assign(nullptr);
289
290
16.6k
      return resRec;
291
22.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
266
195k
    {
267
195k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
195k
      if (record.isNull())
270
0
        return resRec;
271
272
195k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
195k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
195k
                                        record.getTotalSize()))
275
42.3k
        return resRec;
276
277
153k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
153k
      if (resRec.getTotalSize() == 0)
280
2.48k
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
153k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
2.48k
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
153k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
10.8k
        resRec.assign(nullptr);
289
290
153k
      return resRec;
291
195k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::getNextTLVRecord(pcpp::IPv6TLVOptionHeader::IPv6Option&, unsigned char const*, unsigned long) const
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::NdpOption>::getNextTLVRecord(pcpp::NdpOption&, unsigned char const*, unsigned long) const
pcpp::TLVRecordReader<pcpp::NflogTlv>::getNextTLVRecord(pcpp::NflogTlv&, unsigned char const*, unsigned long) const
Line
Count
Source
266
1.89k
    {
267
1.89k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
1.89k
      if (record.isNull())
270
0
        return resRec;
271
272
1.89k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
1.89k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
1.89k
                                        record.getTotalSize()))
275
0
        return resRec;
276
277
1.89k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
1.89k
      if (resRec.getTotalSize() == 0)
280
48
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
1.89k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
48
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
1.89k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
1.12k
        resRec.assign(nullptr);
289
290
1.89k
      return resRec;
291
1.89k
    }
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
292
293
    /// Search for the first TLV record that corresponds to a given record type (the 'T' in __Type__-Length-Value)
294
    /// @param[in] recordType The record type to search for
295
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
296
    /// @param[in] tlvDataLen The TLV data byte stream length
297
    /// @return An instance of type TLVRecordType that contains the result record. If record was not found a logical
298
    /// null instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true
299
    TLVRecordType getTLVRecord(uint32_t recordType, uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
300
103k
    {
301
103k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
249k
      while (!curRec.isNull())
303
206k
      {
304
206k
        if (curRec.getType() == recordType)
305
60.9k
        {
306
60.9k
          return curRec;
307
60.9k
        }
308
309
145k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
145k
      }
311
312
42.5k
      curRec.assign(nullptr);
313
42.5k
      return curRec;  // for NRVO optimization
314
103k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
11.1k
    {
301
11.1k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
126k
      while (!curRec.isNull())
303
121k
      {
304
121k
        if (curRec.getType() == recordType)
305
5.58k
        {
306
5.58k
          return curRec;
307
5.58k
        }
308
309
115k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
115k
      }
311
312
5.59k
      curRec.assign(nullptr);
313
5.59k
      return curRec;  // for NRVO optimization
314
11.1k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
3.77k
    {
301
3.77k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
9.46k
      while (!curRec.isNull())
303
7.31k
      {
304
7.31k
        if (curRec.getType() == recordType)
305
1.63k
        {
306
1.63k
          return curRec;
307
1.63k
        }
308
309
5.68k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
5.68k
      }
311
312
2.14k
      curRec.assign(nullptr);
313
2.14k
      return curRec;  // for NRVO optimization
314
3.77k
    }
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
300
86.1k
    {
301
86.1k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
109k
      while (!curRec.isNull())
303
76.7k
      {
304
76.7k
        if (curRec.getType() == recordType)
305
53.7k
        {
306
53.7k
          return curRec;
307
53.7k
        }
308
309
22.9k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
22.9k
      }
311
312
32.4k
      curRec.assign(nullptr);
313
32.4k
      return curRec;  // for NRVO optimization
314
86.1k
    }
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
300
670
    {
301
670
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
670
      while (!curRec.isNull())
303
0
      {
304
0
        if (curRec.getType() == recordType)
305
0
        {
306
0
          return curRec;
307
0
        }
308
309
0
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
0
      }
311
312
670
      curRec.assign(nullptr);
313
670
      return curRec;  // for NRVO optimization
314
670
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
1.68k
    {
301
1.68k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
2.95k
      while (!curRec.isNull())
303
1.26k
      {
304
1.26k
        if (curRec.getType() == recordType)
305
0
        {
306
0
          return curRec;
307
0
        }
308
309
1.26k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
1.26k
      }
311
312
1.68k
      curRec.assign(nullptr);
313
1.68k
      return curRec;  // for NRVO optimization
314
1.68k
    }
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
315
316
    /// Get the TLV record count in a given TLV data byte stream. For efficiency purposes the count is being cached
317
    /// so only the first call to this method will go over all the TLV records, while all consequent calls will
318
    /// return the cached number. This implies that if there is a change in the number of records, it's the user's
319
    /// responsibility to call changeTLVRecordCount() with the record count change
320
    /// @param[in] tlvDataBasePtr A pointer to the TLV data byte stream
321
    /// @param[in] tlvDataLen The TLV data byte stream length
322
    /// @return The TLV record count
323
    size_t getTLVRecordCount(uint8_t* tlvDataBasePtr, size_t tlvDataLen) const
324
74.9k
    {
325
74.9k
      if (m_RecordCount != static_cast<size_t>(-1))
326
68.2k
        return m_RecordCount;
327
328
6.70k
      m_RecordCount = 0;
329
6.70k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
68.4k
      while (!curRec.isNull())
331
61.7k
      {
332
61.7k
        m_RecordCount++;
333
61.7k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
61.7k
      }
335
336
6.70k
      return m_RecordCount;
337
74.9k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
324
58.8k
    {
325
58.8k
      if (m_RecordCount != static_cast<size_t>(-1))
326
56.0k
        return m_RecordCount;
327
328
2.79k
      m_RecordCount = 0;
329
2.79k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
56.0k
      while (!curRec.isNull())
331
53.2k
      {
332
53.2k
        m_RecordCount++;
333
53.2k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
53.2k
      }
335
336
2.79k
      return m_RecordCount;
337
58.8k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
324
16.1k
    {
325
16.1k
      if (m_RecordCount != static_cast<size_t>(-1))
326
12.2k
        return m_RecordCount;
327
328
3.90k
      m_RecordCount = 0;
329
3.90k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
12.3k
      while (!curRec.isNull())
331
8.47k
      {
332
8.47k
        m_RecordCount++;
333
8.47k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
8.47k
      }
335
336
3.90k
      return m_RecordCount;
337
16.1k
    }
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
338
339
    /// As described in getTLVRecordCount(), the TLV record count is being cached for efficiency purposes. So if the
340
    /// number of TLV records change, it's the user's responsibility to call this method with the number of TLV
341
    /// records being added or removed. If records were added the change should be a positive number, or a negative
342
    /// number if records were removed
343
    /// @param[in] changedBy Number of records that were added or removed
344
    void changeTLVRecordCount(int changedBy)
345
53.7k
    {
346
53.7k
      if (m_RecordCount != static_cast<size_t>(-1))
347
0
        m_RecordCount += changedBy;
348
53.7k
    }
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
345
53.7k
    {
346
53.7k
      if (m_RecordCount != static_cast<size_t>(-1))
347
0
        m_RecordCount += changedBy;
348
53.7k
    }
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)
349
  };
350
351
  /// @class TLVRecordBuilder
352
  /// A base class for building Type-Length-Value (TLV) records. This builder receives the record parameters in its
353
  /// c'tor, builds the record raw buffer and provides a method to build a TLVRecord object out of it. Please notice
354
  /// this is a base class that lacks the capability of actually building TLVRecord objects and also cannot be
355
  /// instantiated. The reason for that is that different protocols build TLV records in different ways, so these
356
  /// missing capabilities will be implemented by the derived classes which are specific to each protocol. This class
357
  /// only provides the common infrastructure that will be used by them
358
  class TLVRecordBuilder
359
  {
360
  protected:
361
    TLVRecordBuilder();
362
363
    TLVRecordBuilder(uint32_t recType, const uint8_t* recValue, uint8_t recValueLen);
364
365
    TLVRecordBuilder(uint32_t recType, uint8_t recValue);
366
367
    TLVRecordBuilder(uint32_t recType, uint16_t recValue);
368
369
    TLVRecordBuilder(uint32_t recType, uint32_t recValue);
370
371
    TLVRecordBuilder(uint32_t recType, const IPv4Address& recValue);
372
373
    TLVRecordBuilder(uint32_t recType, const std::string& recValue, bool valueIsHexString = false);
374
375
    TLVRecordBuilder(const TLVRecordBuilder& other);
376
377
    TLVRecordBuilder& operator=(const TLVRecordBuilder& other);
378
379
    virtual ~TLVRecordBuilder();
380
381
    void init(uint32_t recType, const uint8_t* recValue, size_t recValueLen);
382
383
    uint8_t* m_RecValue;
384
    size_t m_RecValueLen;
385
    uint32_t m_RecType;
386
387
  private:
388
    void copyData(const TLVRecordBuilder& other);
389
  };
390
}  // namespace pcpp