Coverage Report

Created: 2025-08-26 07:54

/src/PcapPlusPlus/Packet++/header/TLVData.h
Line
Count
Source (jump to first uncovered line)
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
803k
    {
41
803k
      assign(recordRawData);
42
803k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(unsigned char*)
Line
Count
Source
40
773k
    {
41
773k
      assign(recordRawData);
42
773k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(unsigned char*)
Line
Count
Source
40
30.3k
    {
41
30.3k
      assign(recordRawData);
42
30.3k
    }
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
243k
    {
49
243k
      m_Data = other.m_Data;
50
243k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
48
7.75k
    {
49
7.75k
      m_Data = other.m_Data;
50
7.75k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
48
235k
    {
49
235k
      m_Data = other.m_Data;
50
235k
    }
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
679k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned char, unsigned char>::~TLVRecord()
Line
Count
Source
53
648k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned short, unsigned short>::~TLVRecord()
Line
Count
Source
53
31.3k
    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.45M
    {
59
1.45M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.45M
    }
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.39M
    {
59
1.39M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.39M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::assign(unsigned char*)
Line
Count
Source
58
60.9k
    {
59
60.9k
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
60.9k
    }
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
201k
    {
68
201k
      return recordRawData != nullptr &&
69
201k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
201k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
171k
    {
68
171k
      return recordRawData != nullptr &&
69
171k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
171k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
30.3k
    {
68
30.3k
      return recordRawData != nullptr &&
69
30.3k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
30.3k
    }
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
520k
    {
78
520k
      m_Data = other.m_Data;
79
520k
      return *this;
80
520k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::operator=(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
77
20.2k
    {
78
20.2k
      m_Data = other.m_Data;
79
20.2k
      return *this;
80
20.2k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::operator=(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
77
500k
    {
78
500k
      m_Data = other.m_Data;
79
500k
      return *this;
80
500k
    }
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
368k
    {
111
368k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
368k
      return m_Data->recordType;
115
368k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getType() const
Line
Count
Source
110
368k
    {
111
368k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
368k
      return m_Data->recordType;
115
368k
    }
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.90M
    {
129
1.90M
      return (m_Data == nullptr);
130
1.90M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::isNull() const
Line
Count
Source
128
1.83M
    {
129
1.83M
      return (m_Data == nullptr);
130
1.83M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::isNull() const
Line
Count
Source
128
64.9k
    {
129
64.9k
      return (m_Data == nullptr);
130
64.9k
    }
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
167k
    {
135
167k
      return (m_Data != nullptr);
136
167k
    }
137
138
    /// @return A pointer to the TLV record raw data byte stream
139
    uint8_t* getRecordBasePtr() const
140
2.66M
    {
141
2.66M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.66M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getRecordBasePtr() const
Line
Count
Source
140
2.57M
    {
141
2.57M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.57M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::getRecordBasePtr() const
Line
Count
Source
140
96.5k
    {
141
96.5k
      return reinterpret_cast<uint8_t*>(m_Data);
142
96.5k
    }
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
51.1k
    {
147
51.1k
      if (!isNull())
148
51.1k
      {
149
51.1k
        delete[] m_Data;
150
51.1k
        m_Data = nullptr;
151
51.1k
      }
152
51.1k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::purgeRecordData()
Line
Count
Source
146
51.1k
    {
147
51.1k
      if (!isNull())
148
51.1k
      {
149
51.1k
        delete[] m_Data;
150
51.1k
        m_Data = nullptr;
151
51.1k
      }
152
51.1k
    }
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
8.26k
    {
163
8.26k
      if (getDataSize() - offset < sizeof(T))
164
2.87k
        return 0;
165
166
5.38k
      T result;
167
5.38k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
5.38k
      return result;
169
8.26k
    }
unsigned int pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned int>(unsigned long) const
Line
Count
Source
162
3.20k
    {
163
3.20k
      if (getDataSize() - offset < sizeof(T))
164
2.84k
        return 0;
165
166
359
      T result;
167
359
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
359
      return result;
169
3.20k
    }
unsigned char pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned char>(unsigned long) const
Line
Count
Source
162
5.05k
    {
163
5.05k
      if (getDataSize() - offset < sizeof(T))
164
33
        return 0;
165
166
5.02k
      T result;
167
5.02k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
5.02k
      return result;
169
5.05k
    }
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.38k
    {
196
5.38k
      return 0;
197
5.38k
    }
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.38k
    {
196
5.38k
      return 0;
197
5.38k
    }
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.26M
    {
212
1.26M
      m_RecordCount = static_cast<size_t>(-1);
213
1.26M
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::TLVRecordReader()
Line
Count
Source
211
16.3k
    {
212
16.3k
      m_RecordCount = static_cast<size_t>(-1);
213
16.3k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::TLVRecordReader()
Line
Count
Source
211
17.6k
    {
212
17.6k
      m_RecordCount = static_cast<size_t>(-1);
213
17.6k
    }
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::TLVRecordReader()
pcpp::TLVRecordReader<pcpp::IPv4Option>::TLVRecordReader()
Line
Count
Source
211
708k
    {
212
708k
      m_RecordCount = static_cast<size_t>(-1);
213
708k
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::TLVRecordReader()
Line
Count
Source
211
1.83k
    {
212
1.83k
      m_RecordCount = static_cast<size_t>(-1);
213
1.83k
    }
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::TLVRecordReader()
Line
Count
Source
211
43
    {
212
43
      m_RecordCount = static_cast<size_t>(-1);
213
43
    }
pcpp::TLVRecordReader<pcpp::TcpOption>::TLVRecordReader()
Line
Count
Source
211
484k
    {
212
484k
      m_RecordCount = static_cast<size_t>(-1);
213
484k
    }
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::TLVRecordReader()
Line
Count
Source
211
9.75k
    {
212
9.75k
      m_RecordCount = static_cast<size_t>(-1);
213
9.75k
    }
pcpp::TLVRecordReader<pcpp::NdpOption>::TLVRecordReader()
Line
Count
Source
211
376
    {
212
376
      m_RecordCount = static_cast<size_t>(-1);
213
376
    }
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::TLVRecordReader()
Line
Count
Source
211
22.6k
    {
212
22.6k
      m_RecordCount = static_cast<size_t>(-1);
213
22.6k
    }
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.26M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::TcpOption>::~TLVRecordReader()
Line
Count
Source
222
484k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpOption>::~TLVRecordReader()
Line
Count
Source
222
16.3k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::~TLVRecordReader()
Line
Count
Source
222
17.6k
    virtual ~TLVRecordReader() = default;
Unexecuted instantiation: pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::~TLVRecordReader()
pcpp::TLVRecordReader<pcpp::IPv4Option>::~TLVRecordReader()
Line
Count
Source
222
708k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::~TLVRecordReader()
Line
Count
Source
222
22.6k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NflogTlv>::~TLVRecordReader()
Line
Count
Source
222
1.83k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::~TLVRecordReader()
Line
Count
Source
222
43
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::~TLVRecordReader()
Line
Count
Source
222
9.75k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NdpOption>::~TLVRecordReader()
Line
Count
Source
222
376
    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
75.4k
    {
228
75.4k
      m_RecordCount = other.m_RecordCount;
229
75.4k
      return *this;
230
75.4k
    }
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
75.4k
    {
228
75.4k
      m_RecordCount = other.m_RecordCount;
229
75.4k
      return *this;
230
75.4k
    }
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
158k
    {
240
158k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
158k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
20.6k
        return resRec;
243
244
138k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
138k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
3.58k
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
138k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
1.21k
        resRec.assign(nullptr);
252
253
138k
      return resRec;
254
158k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
19.4k
    {
240
19.4k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
19.4k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
0
        return resRec;
243
244
19.4k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
19.4k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
285
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
19.4k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
0
        resRec.assign(nullptr);
252
253
19.4k
      return resRec;
254
19.4k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
10.0k
    {
240
10.0k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
10.0k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
18
        return resRec;
243
244
10.0k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
10.0k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
73
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
10.0k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
0
        resRec.assign(nullptr);
252
253
10.0k
      return resRec;
254
10.0k
    }
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
126k
    {
240
126k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
126k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
20.3k
        return resRec;
243
244
106k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
106k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
2.38k
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
106k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
166
        resRec.assign(nullptr);
252
253
106k
      return resRec;
254
126k
    }
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
188
    {
240
188
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
188
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
188
        return resRec;
243
244
0
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
0
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
0
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
0
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
0
        resRec.assign(nullptr);
252
253
0
      return resRec;
254
188
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
239
2.68k
    {
240
2.68k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
241
2.68k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
242
34
        return resRec;
243
244
2.65k
      resRec.assign(tlvDataBasePtr);
245
      // resRec pointer is out-bounds of the TLV records memory
246
2.65k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
247
837
        resRec.assign(nullptr);
248
249
      // check if there are records at all and the total size is not zero
250
2.65k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
251
1.04k
        resRec.assign(nullptr);
252
253
2.65k
      return resRec;
254
2.68k
    }
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
522k
    {
265
522k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
522k
      if (record.isNull())
268
0
        return resRec;
269
270
522k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
522k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
522k
                                        record.getTotalSize()))
273
57.6k
        return resRec;
274
275
465k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
465k
      if (resRec.getTotalSize() == 0)
278
1.24k
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
465k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
1.24k
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
465k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
16.4k
        resRec.assign(nullptr);
287
288
465k
      return resRec;
289
522k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getNextTLVRecord(pcpp::DhcpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
264
311k
    {
265
311k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
311k
      if (record.isNull())
268
0
        return resRec;
269
270
311k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
311k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
311k
                                        record.getTotalSize()))
273
12.9k
        return resRec;
274
275
298k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
298k
      if (resRec.getTotalSize() == 0)
278
0
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
298k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
0
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
298k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
797
        resRec.assign(nullptr);
287
288
298k
      return resRec;
289
311k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getNextTLVRecord(pcpp::DhcpV6Option&, unsigned char const*, unsigned long) const
Line
Count
Source
264
20.2k
    {
265
20.2k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
20.2k
      if (record.isNull())
268
0
        return resRec;
269
270
20.2k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
20.2k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
20.2k
                                        record.getTotalSize()))
273
4.97k
        return resRec;
274
275
15.3k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
15.3k
      if (resRec.getTotalSize() == 0)
278
0
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
15.3k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
0
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
15.3k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
3.39k
        resRec.assign(nullptr);
287
288
15.3k
      return resRec;
289
20.2k
    }
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
189k
    {
265
189k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
189k
      if (record.isNull())
268
0
        return resRec;
269
270
189k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
189k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
189k
                                        record.getTotalSize()))
273
39.7k
        return resRec;
274
275
149k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
149k
      if (resRec.getTotalSize() == 0)
278
1.13k
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
149k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
1.13k
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
149k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
11.5k
        resRec.assign(nullptr);
287
288
149k
      return resRec;
289
189k
    }
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
264
2.04k
    {
265
2.04k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
266
267
2.04k
      if (record.isNull())
268
0
        return resRec;
269
270
2.04k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
271
2.04k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
272
2.04k
                                        record.getTotalSize()))
273
0
        return resRec;
274
275
2.04k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
276
277
2.04k
      if (resRec.getTotalSize() == 0)
278
102
        resRec.assign(nullptr);
279
280
      // resRec pointer is out-bounds of the TLV records memory
281
2.04k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
282
102
        resRec.assign(nullptr);
283
284
      // resRec pointer is out-bounds of the TLV records memory
285
2.04k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
286
666
        resRec.assign(nullptr);
287
288
2.04k
      return resRec;
289
2.04k
    }
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
93.7k
    {
299
93.7k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
295k
      while (!curRec.isNull())
301
260k
      {
302
260k
        if (curRec.getType() == recordType)
303
58.1k
        {
304
58.1k
          return curRec;
305
58.1k
        }
306
307
201k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
201k
      }
309
310
35.5k
      curRec.assign(nullptr);
311
35.5k
      return curRec;  // for NRVO optimization
312
93.7k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
13.0k
    {
299
13.0k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
186k
      while (!curRec.isNull())
301
179k
      {
302
179k
        if (curRec.getType() == recordType)
303
5.42k
        {
304
5.42k
          return curRec;
305
5.42k
        }
306
307
173k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
173k
      }
309
310
7.60k
      curRec.assign(nullptr);
311
7.60k
      return curRec;  // for NRVO optimization
312
13.0k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
3.32k
    {
299
3.32k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
8.11k
      while (!curRec.isNull())
301
6.39k
      {
302
6.39k
        if (curRec.getType() == recordType)
303
1.61k
        {
304
1.61k
          return curRec;
305
1.61k
        }
306
307
4.78k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
4.78k
      }
309
310
1.71k
      curRec.assign(nullptr);
311
1.71k
      return curRec;  // for NRVO optimization
312
3.32k
    }
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
75.4k
    {
299
75.4k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
97.3k
      while (!curRec.isNull())
301
73.0k
      {
302
73.0k
        if (curRec.getType() == recordType)
303
51.1k
        {
304
51.1k
          return curRec;
305
51.1k
        }
306
307
21.9k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
21.9k
      }
309
310
24.2k
      curRec.assign(nullptr);
311
24.2k
      return curRec;  // for NRVO optimization
312
75.4k
    }
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
188
    {
299
188
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
188
      while (!curRec.isNull())
301
0
      {
302
0
        if (curRec.getType() == recordType)
303
0
        {
304
0
          return curRec;
305
0
        }
306
307
0
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
0
      }
309
310
188
      curRec.assign(nullptr);
311
188
      return curRec;  // for NRVO optimization
312
188
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
298
1.76k
    {
299
1.76k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
300
3.13k
      while (!curRec.isNull())
301
1.36k
      {
302
1.36k
        if (curRec.getType() == recordType)
303
0
        {
304
0
          return curRec;
305
0
        }
306
307
1.36k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
308
1.36k
      }
309
310
1.76k
      curRec.assign(nullptr);
311
1.76k
      return curRec;  // for NRVO optimization
312
1.76k
    }
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
89.7k
    {
323
89.7k
      if (m_RecordCount != static_cast<size_t>(-1))
324
83.1k
        return m_RecordCount;
325
326
6.67k
      m_RecordCount = 0;
327
6.67k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
83.2k
      while (!curRec.isNull())
329
76.5k
      {
330
76.5k
        m_RecordCount++;
331
76.5k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
76.5k
      }
333
334
6.67k
      return m_RecordCount;
335
89.7k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
322
75.2k
    {
323
75.2k
      if (m_RecordCount != static_cast<size_t>(-1))
324
72.0k
        return m_RecordCount;
325
326
3.25k
      m_RecordCount = 0;
327
3.25k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
72.0k
      while (!curRec.isNull())
329
68.8k
      {
330
68.8k
        m_RecordCount++;
331
68.8k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
68.8k
      }
333
334
3.25k
      return m_RecordCount;
335
75.2k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
322
14.5k
    {
323
14.5k
      if (m_RecordCount != static_cast<size_t>(-1))
324
11.0k
        return m_RecordCount;
325
326
3.42k
      m_RecordCount = 0;
327
3.42k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
328
11.1k
      while (!curRec.isNull())
329
7.75k
      {
330
7.75k
        m_RecordCount++;
331
7.75k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
332
7.75k
      }
333
334
3.42k
      return m_RecordCount;
335
14.5k
    }
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
51.1k
    {
344
51.1k
      if (m_RecordCount != static_cast<size_t>(-1))
345
0
        m_RecordCount += changedBy;
346
51.1k
    }
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
51.1k
    {
344
51.1k
      if (m_RecordCount != static_cast<size_t>(-1))
345
0
        m_RecordCount += changedBy;
346
51.1k
    }
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