1 #ifndef PACKETPP_TLV_DATA 2 #define PACKETPP_TLV_DATA 23 template<
typename TRecType,
typename TRecLen>
59 m_Data = other.m_Data;
73 if(recordRawData == NULL)
76 m_Data = (TLVRawData*)recordRawData;
86 m_Data = other.m_Data;
98 if (m_Data == rhs.m_Data)
107 return (memcmp(m_Data, rhs.m_Data,
getTotalSize()) == 0);
133 bool isNull()
const {
return (m_Data == NULL); }
166 memcpy(&result, m_Data->
recordValue + offset,
sizeof(T));
185 memcpy(m_Data->
recordValue + valueOffset, &newValue,
sizeof(T));
206 template<
typename TLVRecordType>
210 mutable size_t m_RecordCount;
224 m_RecordCount = other.m_RecordCount;
238 m_RecordCount = other.m_RecordCount;
253 TLVRecordType resRec(tlvDataBasePtr);
256 if (tlvDataLen == 0 || resRec.getTotalSize() == 0)
271 TLVRecordType
getNextTLVRecord(TLVRecordType& record, uint8_t* tlvDataBasePtr,
size_t tlvDataLen)
const 273 TLVRecordType resRec(NULL);
279 if ((record.getRecordBasePtr() - tlvDataBasePtr) < 0)
283 if (record.getRecordBasePtr() - tlvDataBasePtr + (int)record.getTotalSize() >= (int)tlvDataLen)
286 resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
287 if (resRec.getTotalSize() == 0)
303 TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
304 while (!curRec.isNull())
311 curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
329 if (m_RecordCount != (
size_t)-1)
330 return m_RecordCount;
333 TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
334 while (!curRec.isNull())
337 curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
340 return m_RecordCount;
369 TLVRecordBuilder(uint32_t recType,
const uint8_t* recValue, uint8_t recValueLen);
379 TLVRecordBuilder(uint32_t recType,
const std::string& recValue,
bool valueIsHexString =
false);
387 void init(uint32_t recType,
const uint8_t* recValue,
size_t recValueLen);
390 size_t m_RecValueLen;
398 #endif // PACKETPP_TLV_DATA The main namespace for the PcapPlusPlus lib.
TLVRecordType getTLVRecord(uint32_t recordType, uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:301
uint8_t * getRecordBasePtr() const
Definition: TLVData.h:143
TLVRecord(uint8_t *recordRawData)
Definition: TLVData.h:47
TRecType recordType
Definition: TLVData.h:32
TRecType getType() const
Definition: TLVData.h:123
Definition: TLVData.h:363
size_t getTLVRecordCount(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:327
TLVRecordType getFirstTLVRecord(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:250
void changeTLVRecordCount(int changedBy)
Definition: TLVData.h:350
TLVRecordReader & operator=(const TLVRecordReader &other)
Definition: TLVData.h:236
virtual ~TLVRecord()
Definition: TLVData.h:65
Definition: TLVData.h:207
void assign(uint8_t *recordRawData)
Definition: TLVData.h:71
virtual size_t getDataSize() const =0
bool operator!=(const TLVRecord &rhs) const
Definition: TLVData.h:115
bool isNull() const
Definition: TLVData.h:133
Definition: IpAddress.h:27
TLVRecord & operator=(const TLVRecord &other)
Definition: TLVData.h:84
TLVRecordReader(const TLVRecordReader &other)
Definition: TLVData.h:222
virtual ~TLVRecordReader()
Definition: TLVData.h:230
TLVRecordType getNextTLVRecord(TLVRecordType &record, uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:271
bool setValue(T newValue, int valueOffset=0)
Definition: TLVData.h:180
TRecLen recordLen
Definition: TLVData.h:34
uint8_t recordValue[]
Definition: TLVData.h:36
TLVRecordReader()
Definition: TLVData.h:217
T getValueAs(size_t offset=0) const
Definition: TLVData.h:160
bool operator==(const TLVRecord &rhs) const
Definition: TLVData.h:96
bool isNotNull() const
Definition: TLVData.h:138
uint8_t * getValue() const
Definition: TLVData.h:128
TLVRecord(const TLVRecord &other)
Definition: TLVData.h:57
void purgeRecordData()
Definition: TLVData.h:148
virtual size_t getTotalSize() const =0