1 #ifndef PACKETPP_IPV4_LAYER 2 #define PACKETPP_IPV4_LAYER 27 #if (BYTE_ORDER == LITTLE_ENDIAN) 161 #define PCPP_IP_DONT_FRAGMENT 0x40 162 #define PCPP_IP_MORE_FRAGMENTS 0x20 180 TimestampsForPrespecifiedIPs = 2,
237 std::vector<IPv4Address> res;
239 if (m_Data ==
nullptr)
242 size_t dataSize = getDataSize();
246 uint8_t valueOffset = (uint8_t)(1);
248 while ((
size_t)valueOffset < dataSize)
251 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
257 valueOffset += (uint8_t)(4);
275 if (m_Data ==
nullptr)
281 size_t dataSize = getDataSize();
287 uint8_t valueOffset = (uint8_t)(2);
290 while ((
size_t)valueOffset < dataSize)
293 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
303 readIPAddr = !readIPAddr;
305 valueOffset += (uint8_t)(4);
316 if (m_Data ==
nullptr)
327 if (m_Data ==
nullptr)
331 return sizeof(uint8_t);
333 return (
size_t)m_Data->recordLen;
338 if (m_Data ==
nullptr)
344 return (
size_t)m_Data->recordLen - (2*
sizeof(uint8_t));
357 bool m_BuilderParamsValid;
371 TLVRecordBuilder((uint8_t)optionType, optionValue, optionValueLen) { m_BuilderParamsValid =
true; }
380 TLVRecordBuilder((uint8_t)optionType, optionValue) { m_BuilderParamsValid =
true; }
432 IPv4Layer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
bool setTotalLenAsDataLen);
504 bool isFragment()
const;
510 bool isFirstFragment()
const;
516 bool isLastFragment()
const;
521 uint8_t getFragmentFlags()
const;
526 uint16_t getFragmentOffset()
const;
554 size_t getOptionCount()
const;
588 bool removeAllOptions();
607 void parseNextLayer();
612 size_t getHeaderLen()
const {
return (
size_t)((uint16_t)(getIPv4Header()->internetHeaderLength) * 4) + m_TempHeaderExtension; }
621 void computeCalculateFields();
623 std::string toString()
const;
633 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
636 int m_NumOfTrailingBytes;
637 int m_TempHeaderExtension;
640 void copyLayerData(
const IPv4Layer& other);
641 uint8_t* getOptionsBasePtr()
const {
return m_Data +
sizeof(
iphdr); }
643 void adjustOptionsTrailer(
size_t totalOptSize);
645 void initLayerInPacket(
bool setTotalLenAsDataLen);
653 const iphdr* hdr =
reinterpret_cast<const iphdr*
>(data);
Definition: IPv4Layer.h:106
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
size_t getTotalSize() const
Definition: IPv4Layer.h:325
Definition: IPv4Layer.h:100
std::vector< uint32_t > timestamps
Definition: IPv4Layer.h:189
Definition: IPv4Layer.h:134
uint16_t ipId
Definition: IPv4Layer.h:43
Definition: IPv4Layer.h:130
Definition: IPv4Layer.h:136
IPv4Option(uint8_t *optionRawData)
Definition: IPv4Layer.h:222
uint8_t timeToLive
Definition: IPv4Layer.h:47
uint8_t internetHeaderLength
Definition: IPv4Layer.h:29
Definition: IPv4Layer.h:72
uint8_t typeOfService
Definition: IPv4Layer.h:39
Definition: IPv4Layer.h:120
Definition: IPv4Layer.h:104
Definition: IPv4Layer.h:98
Definition: IPv4Layer.h:142
Definition: TLVData.h:376
Definition: IPv4Layer.h:152
Definition: IPv4Layer.h:144
Definition: IPv4Layer.h:156
IPAddress getDstIPAddress() const
Definition: IPv4Layer.h:487
Definition: IPv4Layer.h:128
IPv4OptionTypes getIPv4OptionType() const
Definition: IPv4Layer.h:314
Definition: IPv4Layer.h:178
TimestampType
Definition: IPv4Layer.h:173
void setSrcIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:480
Definition: IPv4Layer.h:118
Definition: IPv4Layer.h:70
std::vector< IPv4Address > getValueAsIpList() const
Definition: IPv4Layer.h:235
Definition: TLVData.h:217
Definition: IPv4Layer.h:92
IPProtocolTypes
Definition: IPv4Layer.h:63
Definition: IPv4Layer.h:82
Definition: ProtocolType.h:340
Definition: IPv4Layer.h:90
Definition: IPv4Layer.h:150
Definition: IPv4Layer.h:354
uint16_t totalLength
Definition: IPv4Layer.h:41
IPv4Address getSrcIPv4Address() const
Definition: IPv4Layer.h:474
Definition: IPv4Layer.h:84
Definition: IPv4Layer.h:25
Definition: IPv4Layer.h:88
Definition: IPv4Layer.h:182
IPv4OptionBuilder(IPv4OptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: IPv4Layer.h:370
Definition: IPv4Layer.h:154
Definition: IPv4Layer.h:122
Definition: IPv4Layer.h:74
Definition: IpAddress.h:42
IPv4TimestampOptionValue getTimestampOptionValue() const
Definition: IPv4Layer.h:270
uint16_t fragmentOffset
Definition: IPv4Layer.h:45
IPAddress getSrcIPAddress() const
Definition: IPv4Layer.h:468
std::vector< IPv4Address > ipAddresses
Definition: IPv4Layer.h:192
Definition: IPv4Layer.h:214
Definition: IPv4Layer.h:140
Definition: IPv4Layer.h:96
Definition: IPv4Layer.h:124
void setDstIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:499
uint8_t ipVersion
Definition: IPv4Layer.h:29
OsiModelLayer getOsiModelLayer() const
Definition: IPv4Layer.h:625
uint8_t protocol
Definition: IPv4Layer.h:49
Definition: IPv4Layer.h:132
Definition: IPv4Layer.h:168
TimestampType type
Definition: IPv4Layer.h:186
Definition: IPv4Layer.h:80
IPv4TimestampOptionValue()
Definition: IPv4Layer.h:195
uint16_t headerChecksum
Definition: IPv4Layer.h:51
~IPv4Option()
Definition: IPv4Layer.h:227
void clear()
Definition: IPv4Layer.h:200
size_t getDataSize() const
Definition: IPv4Layer.h:336
Definition: IPv4Layer.h:94
IPv4OptionBuilder(IPv4OptionTypes optionType, uint16_t optionValue)
Definition: IPv4Layer.h:379
Definition: IPv4Layer.h:102
uint32_t ipDst
Definition: IPv4Layer.h:55
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv4Layer.h:651
Definition: IPv4Layer.h:86
Definition: IPv4Layer.h:409
IPv4Address getDstIPv4Address() const
Definition: IPv4Layer.h:493
Definition: IpAddress.h:321
Definition: IPv4Layer.h:148
Definition: IPv4Layer.h:108
Definition: IPv4Layer.h:138
Definition: IPv4Layer.h:126
Definition: IPv4Layer.h:66
uint32_t ipSrc
Definition: IPv4Layer.h:53
Definition: IPv4Layer.h:68
Definition: IPv4Layer.h:76
IPv4OptionTypes
Definition: IPv4Layer.h:115
uint32_t toInt() const
Definition: IpAddress.h:181
size_t getHeaderLen() const
Definition: IPv4Layer.h:612
Definition: IPv4Layer.h:78
Definition: IPv4Layer.h:158
Definition: IPv4Layer.h:146
iphdr * getIPv4Header() const
Definition: IPv4Layer.h:461