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);
124 if (m_Data ==
nullptr)
134 if (m_Data ==
nullptr)
143 bool isNull()
const {
return (m_Data ==
nullptr); }
176 memcpy(&result, m_Data->
recordValue + offset,
sizeof(T));
195 memcpy(m_Data->
recordValue + valueOffset, &newValue,
sizeof(T));
216 template<
typename TLVRecordType>
220 mutable size_t m_RecordCount;
234 m_RecordCount = other.m_RecordCount;
248 m_RecordCount = other.m_RecordCount;
262 TLVRecordType resRec(tlvDataBasePtr);
265 if (resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
269 if (!resRec.isNull() && (tlvDataLen == 0 || resRec.getTotalSize() == 0))
284 TLVRecordType
getNextTLVRecord(TLVRecordType& record,
const uint8_t* tlvDataBasePtr,
size_t tlvDataLen)
const 286 TLVRecordType resRec(NULL);
291 resRec.assign(record.getRecordBasePtr() + record.getTotalSize());
292 if (resRec.getTotalSize() == 0)
296 if ((resRec.getRecordBasePtr() - tlvDataBasePtr) < 0)
300 if (!resRec.isNull() && resRec.getRecordBasePtr() + resRec.getTotalSize() > tlvDataBasePtr + tlvDataLen)
316 TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
317 while (!curRec.isNull())
324 curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
342 if (m_RecordCount != (
size_t)-1)
343 return m_RecordCount;
346 TLVRecordType curRec = getFirstTLVRecord(tlvDataBasePtr, tlvDataLen);
347 while (!curRec.isNull())
350 curRec = getNextTLVRecord(curRec, tlvDataBasePtr, tlvDataLen);
353 return m_RecordCount;
382 TLVRecordBuilder(uint32_t recType,
const uint8_t* recValue, uint8_t recValueLen);
392 TLVRecordBuilder(uint32_t recType,
const std::string& recValue,
bool valueIsHexString =
false);
400 void init(uint32_t recType,
const uint8_t* recValue,
size_t recValueLen);
403 size_t m_RecValueLen;
411 #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:314
uint8_t * getRecordBasePtr() const
Definition: TLVData.h:153
TLVRecord(uint8_t *recordRawData)
Definition: TLVData.h:47
TRecType recordType
Definition: TLVData.h:32
TRecType getType() const
Definition: TLVData.h:123
Definition: TLVData.h:376
size_t getTLVRecordCount(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:340
TLVRecordType getFirstTLVRecord(uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:260
void changeTLVRecordCount(int changedBy)
Definition: TLVData.h:363
TLVRecordType getNextTLVRecord(TLVRecordType &record, const uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
Definition: TLVData.h:284
TLVRecordReader & operator=(const TLVRecordReader &other)
Definition: TLVData.h:246
virtual ~TLVRecord()
Definition: TLVData.h:65
Definition: TLVData.h:217
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:143
Definition: IpAddress.h:42
TLVRecord & operator=(const TLVRecord &other)
Definition: TLVData.h:84
TLVRecordReader(const TLVRecordReader &other)
Definition: TLVData.h:232
virtual ~TLVRecordReader()
Definition: TLVData.h:240
bool setValue(T newValue, int valueOffset=0)
Definition: TLVData.h:190
TRecLen recordLen
Definition: TLVData.h:34
uint8_t recordValue[]
Definition: TLVData.h:36
TLVRecordReader()
Definition: TLVData.h:227
T getValueAs(size_t offset=0) const
Definition: TLVData.h:170
bool operator==(const TLVRecord &rhs) const
Definition: TLVData.h:96
bool isNotNull() const
Definition: TLVData.h:148
uint8_t * getValue() const
Definition: TLVData.h:133
TLVRecord(const TLVRecord &other)
Definition: TLVData.h:57
void purgeRecordData()
Definition: TLVData.h:158
virtual size_t getTotalSize() const =0