1 #ifndef PACKETPP_IPV4_LAYER 2 #define PACKETPP_IPV4_LAYER 27 #if (BYTE_ORDER == LITTLE_ENDIAN) 159 #define PCPP_IP_DONT_FRAGMENT 0x40 160 #define PCPP_IP_MORE_FRAGMENTS 0x20 178 TimestampsForPrespecifiedIPs = 2,
235 std::vector<IPv4Address> res;
240 size_t dataSize = getDataSize();
244 uint8_t valueOffset = (uint8_t)(1);
246 while ((
size_t)valueOffset < dataSize)
249 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
255 valueOffset += (uint8_t)(4);
279 size_t dataSize = getDataSize();
285 uint8_t valueOffset = (uint8_t)(2);
288 while ((
size_t)valueOffset < dataSize)
291 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
301 readIPAddr = !readIPAddr;
303 valueOffset += (uint8_t)(4);
329 return sizeof(uint8_t);
331 return (
size_t)m_Data->recordLen;
342 return (
size_t)m_Data->recordLen - (2*
sizeof(uint8_t));
355 bool m_BuilderParamsValid;
369 TLVRecordBuilder((uint8_t)optionType, optionValue, optionValueLen) { m_BuilderParamsValid =
true; }
378 TLVRecordBuilder((uint8_t)optionType, optionValue) { m_BuilderParamsValid =
true; }
430 IPv4Layer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
bool setTotalLenAsDataLen);
502 bool isFragment()
const;
508 bool isFirstFragment()
const;
514 bool isLastFragment()
const;
519 uint8_t getFragmentFlags()
const;
524 uint16_t getFragmentOffset()
const;
552 size_t getOptionCount()
const;
586 bool removeAllOptions();
605 void parseNextLayer();
610 size_t getHeaderLen()
const {
return (
size_t)((uint16_t)(getIPv4Header()->internetHeaderLength) * 4) + m_TempHeaderExtension; }
619 void computeCalculateFields();
621 std::string toString()
const;
631 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
634 int m_NumOfTrailingBytes;
635 int m_TempHeaderExtension;
638 void copyLayerData(
const IPv4Layer& other);
639 uint8_t* getOptionsBasePtr()
const {
return m_Data +
sizeof(
iphdr); }
641 void adjustOptionsTrailer(
size_t totalOptSize);
643 void initLayerInPacket(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
bool setTotalLenAsDataLen);
651 const iphdr* hdr =
reinterpret_cast<const iphdr*
>(data);
Definition: IPv4Layer.h:104
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:298
size_t getTotalSize() const
Definition: IPv4Layer.h:323
Definition: IPv4Layer.h:100
std::vector< uint32_t > timestamps
Definition: IPv4Layer.h:187
Definition: IPv4Layer.h:132
uint16_t ipId
Definition: IPv4Layer.h:43
Definition: IPv4Layer.h:128
Definition: IPv4Layer.h:134
IPv4Option(uint8_t *optionRawData)
Definition: IPv4Layer.h:220
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:118
Definition: IPv4Layer.h:98
Definition: IPv4Layer.h:140
Definition: TLVData.h:363
Definition: IPv4Layer.h:150
Definition: IPv4Layer.h:142
Definition: IPv4Layer.h:154
IPAddress getDstIPAddress() const
Definition: IPv4Layer.h:485
Definition: IPv4Layer.h:126
IPv4OptionTypes getIPv4OptionType() const
Definition: IPv4Layer.h:312
Definition: IPv4Layer.h:176
TimestampType
Definition: IPv4Layer.h:171
void setSrcIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:478
Definition: IPv4Layer.h:116
Definition: IPv4Layer.h:70
std::vector< IPv4Address > getValueAsIpList() const
Definition: IPv4Layer.h:233
Definition: TLVData.h:207
Definition: IPv4Layer.h:92
IPProtocolTypes
Definition: IPv4Layer.h:63
Definition: IPv4Layer.h:82
Definition: ProtocolType.h:305
Definition: IPv4Layer.h:90
Definition: IPv4Layer.h:148
Definition: IPv4Layer.h:352
uint16_t totalLength
Definition: IPv4Layer.h:41
IPv4Address getSrcIPv4Address() const
Definition: IPv4Layer.h:472
Definition: IPv4Layer.h:84
Definition: IPv4Layer.h:25
Definition: IPv4Layer.h:88
Definition: IPv4Layer.h:180
IPv4OptionBuilder(IPv4OptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: IPv4Layer.h:368
Definition: IPv4Layer.h:152
Definition: IPv4Layer.h:120
Definition: IPv4Layer.h:74
Definition: IpAddress.h:27
IPv4TimestampOptionValue getTimestampOptionValue() const
Definition: IPv4Layer.h:268
uint16_t fragmentOffset
Definition: IPv4Layer.h:45
IPAddress getSrcIPAddress() const
Definition: IPv4Layer.h:466
std::vector< IPv4Address > ipAddresses
Definition: IPv4Layer.h:190
Definition: IPv4Layer.h:212
Definition: IPv4Layer.h:138
Definition: IPv4Layer.h:96
Definition: IPv4Layer.h:122
void setDstIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:497
uint8_t ipVersion
Definition: IPv4Layer.h:29
OsiModelLayer getOsiModelLayer() const
Definition: IPv4Layer.h:623
uint8_t protocol
Definition: IPv4Layer.h:49
Definition: IPv4Layer.h:130
Definition: IPv4Layer.h:166
TimestampType type
Definition: IPv4Layer.h:184
Definition: IPv4Layer.h:80
IPv4TimestampOptionValue()
Definition: IPv4Layer.h:193
uint16_t headerChecksum
Definition: IPv4Layer.h:51
~IPv4Option()
Definition: IPv4Layer.h:225
void clear()
Definition: IPv4Layer.h:198
size_t getDataSize() const
Definition: IPv4Layer.h:334
Definition: IPv4Layer.h:94
IPv4OptionBuilder(IPv4OptionTypes optionType, uint16_t optionValue)
Definition: IPv4Layer.h:377
Definition: IPv4Layer.h:102
uint32_t ipDst
Definition: IPv4Layer.h:55
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv4Layer.h:649
Definition: IPv4Layer.h:86
Definition: IPv4Layer.h:407
IPv4Address getDstIPv4Address() const
Definition: IPv4Layer.h:491
Definition: IpAddress.h:278
Definition: IPv4Layer.h:146
Definition: IPv4Layer.h:106
Definition: IPv4Layer.h:136
Definition: IPv4Layer.h:124
Definition: IPv4Layer.h:66
uint32_t ipSrc
Definition: IPv4Layer.h:53
Definition: IPv4Layer.h:68
Definition: IPv4Layer.h:76
IPv4OptionTypes
Definition: IPv4Layer.h:113
uint32_t toInt() const
Definition: IpAddress.h:156
size_t getHeaderLen() const
Definition: IPv4Layer.h:610
Definition: IPv4Layer.h:78
Definition: IPv4Layer.h:156
Definition: IPv4Layer.h:144
iphdr * getIPv4Header() const
Definition: IPv4Layer.h:459