Coverage Report

Created: 2026-08-31 07:52

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
845k
    {
41
845k
      assign(recordRawData);
42
845k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(unsigned char*)
Line
Count
Source
40
806k
    {
41
806k
      assign(recordRawData);
42
806k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(unsigned char*)
Line
Count
Source
40
39.6k
    {
41
39.6k
      assign(recordRawData);
42
39.6k
    }
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
263k
    {
49
263k
      m_Data = other.m_Data;
50
263k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::TLVRecord(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
48
9.88k
    {
49
9.88k
      m_Data = other.m_Data;
50
9.88k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::TLVRecord(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
48
253k
    {
49
253k
      m_Data = other.m_Data;
50
253k
    }
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
667k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned char, unsigned char>::~TLVRecord()
Line
Count
Source
53
626k
    virtual ~TLVRecord() = default;
pcpp::TLVRecord<unsigned short, unsigned short>::~TLVRecord()
Line
Count
Source
53
40.9k
    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.51M
    {
59
1.51M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.51M
    }
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.43M
    {
59
1.43M
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
1.43M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::assign(unsigned char*)
Line
Count
Source
58
78.7k
    {
59
78.7k
      m_Data = reinterpret_cast<TLVRawData*>(recordRawData);
60
78.7k
    }
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
220k
    {
68
220k
      return recordRawData != nullptr &&
69
220k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
220k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
180k
    {
68
180k
      return recordRawData != nullptr &&
69
180k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
180k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::canAssign(unsigned char const*, unsigned long)
Line
Count
Source
67
39.6k
    {
68
39.6k
      return recordRawData != nullptr &&
69
39.6k
             tlvDataLen >= (sizeof(TLVRawData::recordType) + sizeof(TLVRawData::recordLen));
70
39.6k
    }
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
495k
    {
78
495k
      m_Data = other.m_Data;
79
495k
      return *this;
80
495k
    }
pcpp::TLVRecord<unsigned short, unsigned short>::operator=(pcpp::TLVRecord<unsigned short, unsigned short> const&)
Line
Count
Source
77
26.8k
    {
78
26.8k
      m_Data = other.m_Data;
79
26.8k
      return *this;
80
26.8k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::operator=(pcpp::TLVRecord<unsigned char, unsigned char> const&)
Line
Count
Source
77
468k
    {
78
468k
      m_Data = other.m_Data;
79
468k
      return *this;
80
468k
    }
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
359k
    {
111
359k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
359k
      return m_Data->recordType;
115
359k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getType() const
Line
Count
Source
110
359k
    {
111
359k
      if (m_Data == nullptr)
112
0
        return 0;
113
114
359k
      return m_Data->recordType;
115
359k
    }
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
2
    {
120
2
      if (m_Data == nullptr)
121
0
        return nullptr;
122
123
2
      return m_Data->recordValue;
124
2
    }
125
126
    /// @return True if the TLV record raw data is nullptr, false otherwise
127
    bool isNull() const
128
1.92M
    {
129
1.92M
      return (m_Data == nullptr);
130
1.92M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::isNull() const
Line
Count
Source
128
1.84M
    {
129
1.84M
      return (m_Data == nullptr);
130
1.84M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::isNull() const
Line
Count
Source
128
84.8k
    {
129
84.8k
      return (m_Data == nullptr);
130
84.8k
    }
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
196k
    {
135
196k
      return (m_Data != nullptr);
136
196k
    }
137
138
    /// @return A pointer to the TLV record raw data byte stream
139
    uint8_t* getRecordBasePtr() const
140
2.55M
    {
141
2.55M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.55M
    }
pcpp::TLVRecord<unsigned char, unsigned char>::getRecordBasePtr() const
Line
Count
Source
140
2.43M
    {
141
2.43M
      return reinterpret_cast<uint8_t*>(m_Data);
142
2.43M
    }
pcpp::TLVRecord<unsigned short, unsigned short>::getRecordBasePtr() const
Line
Count
Source
140
125k
    {
141
125k
      return reinterpret_cast<uint8_t*>(m_Data);
142
125k
    }
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
61.2k
    {
147
61.2k
      if (!isNull())
148
61.2k
      {
149
61.2k
        delete[] m_Data;
150
61.2k
        m_Data = nullptr;
151
61.2k
      }
152
61.2k
    }
pcpp::TLVRecord<unsigned char, unsigned char>::purgeRecordData()
Line
Count
Source
146
61.2k
    {
147
61.2k
      if (!isNull())
148
61.2k
      {
149
61.2k
        delete[] m_Data;
150
61.2k
        m_Data = nullptr;
151
61.2k
      }
152
61.2k
    }
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.81k
    {
163
7.81k
      if (getDataSize() < sizeof(T) + offset)
164
2.68k
        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.81k
    }
unsigned int pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned int>(unsigned long) const
Line
Count
Source
162
2.88k
    {
163
2.88k
      if (getDataSize() < sizeof(T) + offset)
164
2.60k
        return 0;
165
166
274
      T result;
167
274
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
274
      return result;
169
2.88k
    }
unsigned char pcpp::TLVRecord<unsigned char, unsigned char>::getValueAs<unsigned char>(unsigned long) const
Line
Count
Source
162
4.93k
    {
163
4.93k
      if (getDataSize() < sizeof(T) + offset)
164
81
        return 0;
165
166
4.85k
      T result;
167
4.85k
      memcpy(&result, m_Data->recordValue + getValueOffset() + offset, sizeof(T));
168
4.85k
      return result;
169
4.93k
    }
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.72M
    {
212
1.72M
      m_RecordCount = static_cast<size_t>(-1);
213
1.72M
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::TLVRecordReader()
Line
Count
Source
211
14.8k
    {
212
14.8k
      m_RecordCount = static_cast<size_t>(-1);
213
14.8k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::TLVRecordReader()
Line
Count
Source
211
22.7k
    {
212
22.7k
      m_RecordCount = static_cast<size_t>(-1);
213
22.7k
    }
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::TLVRecordReader()
Line
Count
Source
211
184
    {
212
184
      m_RecordCount = static_cast<size_t>(-1);
213
184
    }
pcpp::TLVRecordReader<pcpp::IPv4Option>::TLVRecordReader()
Line
Count
Source
211
1.00M
    {
212
1.00M
      m_RecordCount = static_cast<size_t>(-1);
213
1.00M
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::TLVRecordReader()
Line
Count
Source
211
2.14k
    {
212
2.14k
      m_RecordCount = static_cast<size_t>(-1);
213
2.14k
    }
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::TLVRecordReader()
Line
Count
Source
211
1.43k
    {
212
1.43k
      m_RecordCount = static_cast<size_t>(-1);
213
1.43k
    }
pcpp::TLVRecordReader<pcpp::TcpOption>::TLVRecordReader()
Line
Count
Source
211
639k
    {
212
639k
      m_RecordCount = static_cast<size_t>(-1);
213
639k
    }
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::TLVRecordReader()
Line
Count
Source
211
11.4k
    {
212
11.4k
      m_RecordCount = static_cast<size_t>(-1);
213
11.4k
    }
pcpp::TLVRecordReader<pcpp::NdpOption>::TLVRecordReader()
Line
Count
Source
211
1.85k
    {
212
1.85k
      m_RecordCount = static_cast<size_t>(-1);
213
1.85k
    }
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::TLVRecordReader()
Line
Count
Source
211
18.5k
    {
212
18.5k
      m_RecordCount = static_cast<size_t>(-1);
213
18.5k
    }
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.72M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::TcpOption>::~TLVRecordReader()
Line
Count
Source
222
639k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpOption>::~TLVRecordReader()
Line
Count
Source
222
14.8k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::~TLVRecordReader()
Line
Count
Source
222
22.7k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::GtpV2InformationElement>::~TLVRecordReader()
Line
Count
Source
222
184
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv4Option>::~TLVRecordReader()
Line
Count
Source
222
1.00M
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::IPv6TLVOptionHeader::IPv6Option>::~TLVRecordReader()
Line
Count
Source
222
18.5k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NflogTlv>::~TLVRecordReader()
Line
Count
Source
222
2.14k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::PPPoEDiscoveryLayer::PPPoETag>::~TLVRecordReader()
Line
Count
Source
222
1.43k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::RadiusAttribute>::~TLVRecordReader()
Line
Count
Source
222
11.4k
    virtual ~TLVRecordReader() = default;
pcpp::TLVRecordReader<pcpp::NdpOption>::~TLVRecordReader()
Line
Count
Source
222
1.85k
    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
98.3k
    {
228
98.3k
      m_RecordCount = other.m_RecordCount;
229
98.3k
      return *this;
230
98.3k
    }
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
98.3k
    {
228
98.3k
      m_RecordCount = other.m_RecordCount;
229
98.3k
      return *this;
230
98.3k
    }
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
194k
    {
241
194k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
194k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
30.6k
        return resRec;
244
245
163k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
163k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
5.58k
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
163k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
1.22k
        resRec.assign(nullptr);
253
254
163k
      return resRec;
255
194k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
17.5k
    {
241
17.5k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
17.5k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
10
        return resRec;
244
245
17.5k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
17.5k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
270
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
17.5k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
0
        resRec.assign(nullptr);
253
254
17.5k
      return resRec;
255
17.5k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
12.7k
    {
241
12.7k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
12.7k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
20
        return resRec;
244
245
12.7k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
12.7k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
186
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
12.7k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
0
        resRec.assign(nullptr);
253
254
12.7k
      return resRec;
255
12.7k
    }
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
159k
    {
241
159k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
159k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
29.6k
        return resRec;
244
245
129k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
129k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
4.25k
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
129k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
438
        resRec.assign(nullptr);
253
254
129k
      return resRec;
255
159k
    }
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
926
    {
241
926
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
926
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
900
        return resRec;
244
245
26
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
26
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
8
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
26
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
6
        resRec.assign(nullptr);
253
254
26
      return resRec;
255
926
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getFirstTLVRecord(unsigned char*, unsigned long) const
Line
Count
Source
240
3.15k
    {
241
3.15k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
242
3.15k
      if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
243
85
        return resRec;
244
245
3.07k
      resRec.assign(tlvDataBasePtr);
246
      // resRec pointer is out-bounds of the TLV records memory
247
3.07k
      if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
248
864
        resRec.assign(nullptr);
249
250
      // check if there are records at all and the total size is not zero
251
3.07k
      if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
252
780
        resRec.assign(nullptr);
253
254
3.07k
      return resRec;
255
3.15k
    }
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
497k
    {
267
497k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
497k
      if (record.isNull())
270
0
        return resRec;
271
272
497k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
497k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
497k
                                        record.getTotalSize()))
275
64.9k
        return resRec;
276
277
432k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
432k
      if (resRec.getTotalSize() == 0)
280
3.13k
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
432k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
3.13k
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
432k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
19.9k
        resRec.assign(nullptr);
289
290
432k
      return resRec;
291
497k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getNextTLVRecord(pcpp::DhcpOption&, unsigned char const*, unsigned long) const
Line
Count
Source
266
243k
    {
267
243k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
243k
      if (record.isNull())
270
0
        return resRec;
271
272
243k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
243k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
243k
                                        record.getTotalSize()))
275
10.2k
        return resRec;
276
277
233k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
233k
      if (resRec.getTotalSize() == 0)
280
0
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
233k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
0
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
233k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
1.53k
        resRec.assign(nullptr);
289
290
233k
      return resRec;
291
243k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getNextTLVRecord(pcpp::DhcpV6Option&, unsigned char const*, unsigned long) const
Line
Count
Source
266
26.8k
    {
267
26.8k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
26.8k
      if (record.isNull())
270
0
        return resRec;
271
272
26.8k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
26.8k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
26.8k
                                        record.getTotalSize()))
275
7.22k
        return resRec;
276
277
19.6k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
19.6k
      if (resRec.getTotalSize() == 0)
280
0
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
19.6k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
0
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
19.6k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
3.83k
        resRec.assign(nullptr);
289
290
19.6k
      return resRec;
291
26.8k
    }
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
224k
    {
267
224k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
224k
      if (record.isNull())
270
0
        return resRec;
271
272
224k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
224k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
224k
                                        record.getTotalSize()))
275
47.5k
        return resRec;
276
277
177k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
177k
      if (resRec.getTotalSize() == 0)
280
3.02k
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
177k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
3.02k
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
177k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
13.2k
        resRec.assign(nullptr);
289
290
177k
      return resRec;
291
224k
    }
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
266
8
    {
267
8
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
8
      if (record.isNull())
270
0
        return resRec;
271
272
8
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
8
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
8
                                        record.getTotalSize()))
275
4
        return resRec;
276
277
4
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
4
      if (resRec.getTotalSize() == 0)
280
2
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
4
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
2
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
4
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
2
        resRec.assign(nullptr);
289
290
4
      return resRec;
291
8
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getNextTLVRecord(pcpp::NflogTlv&, unsigned char const*, unsigned long) const
Line
Count
Source
266
2.31k
    {
267
2.31k
      TLVRecordType resRec(nullptr);  // for NRVO optimization
268
269
2.31k
      if (record.isNull())
270
0
        return resRec;
271
272
2.31k
      if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
273
2.31k
                                    tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
274
2.31k
                                        record.getTotalSize()))
275
3
        return resRec;
276
277
2.30k
      resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
278
279
2.30k
      if (resRec.getTotalSize() == 0)
280
108
        resRec.assign(nullptr);
281
282
      // resRec pointer is out-bounds of the TLV records memory
283
2.30k
      if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
284
108
        resRec.assign(nullptr);
285
286
      // resRec pointer is out-bounds of the TLV records memory
287
2.30k
      if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
288
1.31k
        resRec.assign(nullptr);
289
290
2.30k
      return resRec;
291
2.31k
    }
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
117k
    {
301
117k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
282k
      while (!curRec.isNull())
303
233k
      {
304
233k
        if (curRec.getType() == recordType)
305
68.3k
        {
306
68.3k
          return curRec;
307
68.3k
        }
308
309
165k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
165k
      }
311
312
48.9k
      curRec.assign(nullptr);
313
48.9k
      return curRec;  // for NRVO optimization
314
117k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
11.7k
    {
301
11.7k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
140k
      while (!curRec.isNull())
303
134k
      {
304
134k
        if (curRec.getType() == recordType)
305
5.54k
        {
306
5.54k
          return curRec;
307
5.54k
        }
308
309
129k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
129k
      }
311
312
6.20k
      curRec.assign(nullptr);
313
6.20k
      return curRec;  // for NRVO optimization
314
11.7k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
4.19k
    {
301
4.19k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
11.2k
      while (!curRec.isNull())
303
8.62k
      {
304
8.62k
        if (curRec.getType() == recordType)
305
1.52k
        {
306
1.52k
          return curRec;
307
1.52k
        }
308
309
7.09k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
7.09k
      }
311
312
2.66k
      curRec.assign(nullptr);
313
2.66k
      return curRec;  // for NRVO optimization
314
4.19k
    }
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
98.3k
    {
301
98.3k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
126k
      while (!curRec.isNull())
303
89.0k
      {
304
89.0k
        if (curRec.getType() == recordType)
305
61.2k
        {
306
61.2k
          return curRec;
307
61.2k
        }
308
309
27.8k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
27.8k
      }
311
312
37.0k
      curRec.assign(nullptr);
313
37.0k
      return curRec;  // for NRVO optimization
314
98.3k
    }
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
926
    {
301
926
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
934
      while (!curRec.isNull())
303
12
      {
304
12
        if (curRec.getType() == recordType)
305
4
        {
306
4
          return curRec;
307
4
        }
308
309
8
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
8
      }
311
312
922
      curRec.assign(nullptr);
313
922
      return curRec;  // for NRVO optimization
314
926
    }
pcpp::TLVRecordReader<pcpp::NflogTlv>::getTLVRecord(unsigned int, unsigned char*, unsigned long) const
Line
Count
Source
300
2.08k
    {
301
2.08k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
302
3.62k
      while (!curRec.isNull())
303
1.54k
      {
304
1.54k
        if (curRec.getType() == recordType)
305
0
        {
306
0
          return curRec;
307
0
        }
308
309
1.54k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
310
1.54k
      }
311
312
2.08k
      curRec.assign(nullptr);
313
2.08k
      return curRec;  // for NRVO optimization
314
2.08k
    }
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
81.4k
    {
325
81.4k
      if (m_RecordCount != static_cast<size_t>(-1))
326
74.0k
        return m_RecordCount;
327
328
7.33k
      m_RecordCount = 0;
329
7.33k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
74.3k
      while (!curRec.isNull())
331
67.0k
      {
332
67.0k
        m_RecordCount++;
333
67.0k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
67.0k
      }
335
336
7.33k
      return m_RecordCount;
337
81.4k
    }
pcpp::TLVRecordReader<pcpp::DhcpOption>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
324
62.9k
    {
325
62.9k
      if (m_RecordCount != static_cast<size_t>(-1))
326
59.9k
        return m_RecordCount;
327
328
2.93k
      m_RecordCount = 0;
329
2.93k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
60.0k
      while (!curRec.isNull())
331
57.1k
      {
332
57.1k
        m_RecordCount++;
333
57.1k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
57.1k
      }
335
336
2.93k
      return m_RecordCount;
337
62.9k
    }
pcpp::TLVRecordReader<pcpp::DhcpV6Option>::getTLVRecordCount(unsigned char*, unsigned long) const
Line
Count
Source
324
18.4k
    {
325
18.4k
      if (m_RecordCount != static_cast<size_t>(-1))
326
14.0k
        return m_RecordCount;
327
328
4.40k
      m_RecordCount = 0;
329
4.40k
      TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
330
14.2k
      while (!curRec.isNull())
331
9.88k
      {
332
9.88k
        m_RecordCount++;
333
9.88k
        curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
334
9.88k
      }
335
336
4.40k
      return m_RecordCount;
337
18.4k
    }
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
61.2k
    {
346
61.2k
      if (m_RecordCount != static_cast<size_t>(-1))
347
0
        m_RecordCount += changedBy;
348
61.2k
    }
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
61.2k
    {
346
61.2k
      if (m_RecordCount != static_cast<size_t>(-1))
347
0
        m_RecordCount += changedBy;
348
61.2k
    }
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