22 template <
typename TRecType,
typename TRecLen>
class TLVRecord
55 m_Data = other.m_Data;
70 m_Data =
reinterpret_cast<TLVRawData*
>(recordRawData);
79 static bool canAssign(
const uint8_t* recordRawData,
size_t tlvDataLen)
81 return recordRawData !=
nullptr &&
93 m_Data = other.m_Data;
105 if (m_Data == rhs.m_Data)
114 return (memcmp(m_Data, rhs.m_Data,
getTotalSize()) == 0);
132 if (m_Data ==
nullptr)
143 if (m_Data ==
nullptr)
154 return (m_Data ==
nullptr);
162 return (m_Data !=
nullptr);
170 return (uint8_t*)m_Data;
200 memcpy(&result, m_Data->
recordValue + offset,
sizeof(T));
213 template <
typename T>
bool setValue(T newValue,
int valueOffset = 0)
218 memcpy(m_Data->
recordValue + valueOffset, &newValue,
sizeof(T));
241 mutable size_t m_RecordCount;
249 m_RecordCount = (size_t)-1;
257 m_RecordCount = other.m_RecordCount;
272 m_RecordCount = other.m_RecordCount;
286 TLVRecordType resRec(
nullptr);
287 if (!TLVRecordType::canAssign(tlvDataBasePtr, tlvDataLen))
290 resRec.assign(tlvDataBasePtr);
292 if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
293 resRec.assign(
nullptr);
296 if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
297 resRec.assign(
nullptr);
311 TLVRecordType
getNextTLVRecord(TLVRecordType& record,
const uint8_t* tlvDataBasePtr,
size_t tlvDataLen)
const
313 TLVRecordType resRec(
nullptr);
318 if (!TLVRecordType::canAssign(record.getRecordBasePtr() + record.getTotalSize(),
319 tlvDataBasePtr - record.getRecordBasePtr() + tlvDataLen -
320 record.getTotalSize()))
323 resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
325 if (resRec.getTotalSize() == 0)
326 resRec.assign(
nullptr);
329 if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
330 resRec.assign(
nullptr);
333 if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
334 resRec.assign(
nullptr);
347 TLVRecordType
getTLVRecord(uint32_t recordType, uint8_t* tlvDataBasePtr,
size_t tlvDataLen)
const
350 while (!curRec.isNull())
352 if (curRec.getType() == recordType)
360 curRec.assign(
nullptr);
375 if (m_RecordCount != (
size_t)-1)
376 return m_RecordCount;
380 while (!curRec.isNull())
386 return m_RecordCount;
398 if (m_RecordCount != (
size_t)-1)
399 m_RecordCount += changedBy;
417 TLVRecordBuilder(uint32_t recType,
const uint8_t* recValue, uint8_t recValueLen);
427 TLVRecordBuilder(uint32_t recType,
const std::string& recValue,
bool valueIsHexString =
false);
435 void init(uint32_t recType,
const uint8_t* recValue,
size_t recValueLen);
438 size_t m_RecValueLen;
Definition: IpAddress.h:32
Definition: TLVData.h:413
TLVRecord(uint8_t *recordRawData)
Definition: TLVData.h:43
TLVRecord(const TLVRecord &other)
Definition: TLVData.h:53
virtual size_t getTotalSize() const =0
TRecType getType() const
Definition: TLVData.h:130
bool setValue(T newValue, int valueOffset=0)
Definition: TLVData.h:213
bool operator!=(const TLVRecord &rhs) const
Definition: TLVData.h:122
uint8_t * getRecordBasePtr() const
Definition: TLVData.h:168
uint8_t * getValue() const
Definition: TLVData.h:141
bool operator==(const TLVRecord &rhs) const
Definition: TLVData.h:103
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TLVData.h:79
virtual size_t getDataSize() const =0
bool isNotNull() const
Definition: TLVData.h:160
bool isNull() const
Definition: TLVData.h:152
T getValueAs(size_t offset=0) const
Definition: TLVData.h:194
TLVRecord & operator=(const TLVRecord &other)
Definition: TLVData.h:91
void purgeRecordData()
Definition: TLVData.h:176
virtual ~TLVRecord()
Definition: TLVData.h:61
void assign(uint8_t *recordRawData)
Definition: TLVData.h:68
Definition: TLVData.h:239
void changeTLVRecordCount(int changedBy)
Definition: TLVData.h:396
TLVRecordReader & operator=(const TLVRecordReader &other)
Definition: TLVData.h:270
TLVRecordType getTLVRecord(uint32_t recordType, uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:347
TLVRecordReader(const TLVRecordReader &other)
Definition: TLVData.h:255
TLVRecordType getNextTLVRecord(TLVRecordType &record, const uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:311
TLVRecordReader()
Definition: TLVData.h:247
TLVRecordType getFirstTLVRecord(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:284
size_t getTLVRecordCount(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:373
virtual ~TLVRecordReader()
Definition: TLVData.h:263
The main namespace for the PcapPlusPlus lib.
uint8_t recordValue[]
Definition: TLVData.h:33
TRecType recordType
Definition: TLVData.h:29
TRecLen recordLen
Definition: TLVData.h:31