26 #if (BYTE_ORDER == LITTLE_ENDIAN)
161 #define PCPP_IP_DONT_FRAGMENT 0x40
162 #define PCPP_IP_MORE_FRAGMENTS 0x20
241 std::vector<IPv4Address> res;
243 if (m_Data ==
nullptr)
250 uint8_t valueOffset =
static_cast<uint8_t
>(1);
252 while (
static_cast<size_t>(valueOffset) < dataSize)
255 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
261 valueOffset +=
static_cast<uint8_t
>(4);
281 if (m_Data ==
nullptr)
293 uint8_t valueOffset =
static_cast<uint8_t
>(2);
296 while (
static_cast<size_t>(valueOffset) < dataSize)
299 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
309 readIPAddr = !readIPAddr;
311 valueOffset +=
static_cast<uint8_t
>(4);
331 static bool canAssign(
const uint8_t* recordRawData,
size_t tlvDataLen)
333 auto data =
reinterpret_cast<TLVRawData const*
>(recordRawData);
337 if (tlvDataLen <
sizeof(TLVRawData::recordType))
341 data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
351 if (m_Data ==
nullptr)
355 m_Data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
356 return sizeof(uint8_t);
358 return static_cast<size_t>(m_Data->recordLen);
363 if (m_Data ==
nullptr)
367 m_Data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
370 return static_cast<size_t>(m_Data->recordLen) - (2 *
sizeof(uint8_t));
394 bool m_BuilderParamsValid;
409 m_BuilderParamsValid =
true;
421 m_BuilderParamsValid =
true;
507 return reinterpret_cast<iphdr*
>(m_Data);
683 m_TempHeaderExtension;
709 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
712 int m_NumOfTrailingBytes;
713 int m_TempHeaderExtension;
716 void copyLayerData(
const IPv4Layer& other);
717 uint8_t* getOptionsBasePtr()
const
719 return m_Data +
sizeof(
iphdr);
721 IPv4Option addOptionAt(
const IPv4OptionBuilder& optionBuilder,
int offset);
722 void adjustOptionsTrailer(
size_t totalOptSize);
724 void initLayerInPacket(
bool setTotalLenAsDataLen);
731 const iphdr* hdr =
reinterpret_cast<const iphdr*
>(data);
Definition: IpAddress.h:358
Definition: IpAddress.h:32
uint32_t toInt() const
Definition: IpAddress.h:187
Definition: IPv4Layer.h:452
IPv4Option getNextOption(IPv4Option &option) const
iphdr * getIPv4Header() const
Definition: IPv4Layer.h:505
size_t getHeaderLen() const override
Definition: IPv4Layer.h:680
uint8_t getFragmentFlags() const
IPv4Address getSrcIPv4Address() const
Definition: IPv4Layer.h:524
IPAddress getDstIPAddress() const override
Definition: IPv4Layer.h:543
IPAddress getSrcIPAddress() const override
Definition: IPv4Layer.h:515
void parseNextLayer() override
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv4Layer.h:729
IPv4Option addOption(const IPv4OptionBuilder &optionBuilder)
IPv4Layer(const IPv4Address &srcIP, const IPv4Address &dstIP)
IPv4Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
IPv4Option getOption(IPv4OptionTypes option) const
void setDstIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:561
void setSrcIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:533
IPv4Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet, bool setTotalLenAsDataLen)
void computeCalculateFields() override
OsiModelLayer getOsiModelLayer() const override
Definition: IPv4Layer.h:698
bool isLastFragment() const
IPv4Layer & operator=(const IPv4Layer &other)
IPv4Address getDstIPv4Address() const
Definition: IPv4Layer.h:552
IPv4Layer(const IPv4Layer &other)
size_t getOptionCount() const
IPv4Option addOptionAfter(const IPv4OptionBuilder &optionBuilder, IPv4OptionTypes prevOptionType=IPV4OPT_Unknown)
IPv4Option getFirstOption() const
bool removeOption(IPv4OptionTypes option)
uint16_t getFragmentOffset() const
bool isFirstFragment() const
std::string toString() const override
Definition: IPv4Layer.h:392
IPv4OptionBuilder(IPv4OptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: IPv4Layer.h:406
IPv4OptionBuilder(IPv4OptionTypes optionType, uint16_t optionValue)
Definition: IPv4Layer.h:418
IPv4OptionBuilder(const IPv4TimestampOptionValue ×tampValue)
IPv4OptionBuilder(IPv4OptionTypes optionType, const std::vector< IPv4Address > &ipList)
Definition: IPv4Layer.h:217
IPv4Option(uint8_t *optionRawData)
Definition: IPv4Layer.h:223
std::vector< IPv4Address > getValueAsIpList() const
Definition: IPv4Layer.h:239
~IPv4Option() override=default
IPv4OptionTypes getIPv4OptionType() const
Definition: IPv4Layer.h:320
size_t getDataSize() const override
Definition: IPv4Layer.h:361
size_t getTotalSize() const override
Definition: IPv4Layer.h:349
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: IPv4Layer.h:331
IPv4TimestampOptionValue getTimestampOptionValue() const
Definition: IPv4Layer.h:276
Definition: TLVData.h:419
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TLVData.h:80
Definition: TLVData.h:246
The main namespace for the PcapPlusPlus lib.
IPv4OptionTypes
Definition: IPv4Layer.h:116
@ IPV4OPT_MTUReply
Definition: IPv4Layer.h:126
@ IPV4OPT_QuickStart
Definition: IPv4Layer.h:128
@ IPV4OPT_LooseSourceRoute
Definition: IPv4Layer.h:136
@ IPV4OPT_Traceroute
Definition: IPv4Layer.h:132
@ IPV4OPT_NOP
Definition: IPv4Layer.h:120
@ IPV4OPT_UpstreamMulticastPkt
Definition: IPv4Layer.h:156
@ IPV4OPT_DynamicPacketState
Definition: IPv4Layer.h:154
@ IPV4OPT_EndOfOptionsList
Definition: IPv4Layer.h:118
@ IPV4OPT_ExtendedSecurity
Definition: IPv4Layer.h:138
@ IPV4OPT_RouterAlert
Definition: IPv4Layer.h:150
@ IPV4OPT_SelectiveDirectedBroadcast
Definition: IPv4Layer.h:152
@ IPV4OPT_Security
Definition: IPv4Layer.h:134
@ IPV4OPT_Timestamp
Definition: IPv4Layer.h:130
@ IPV4OPT_Unknown
Definition: IPv4Layer.h:158
@ IPV4OPT_AddressExtension
Definition: IPv4Layer.h:148
@ IPV4OPT_CommercialSecurity
Definition: IPv4Layer.h:140
@ IPV4OPT_MTUProbe
Definition: IPv4Layer.h:124
@ IPV4OPT_StrictSourceRoute
Definition: IPv4Layer.h:144
@ IPV4OPT_ExtendedInternetProtocol
Definition: IPv4Layer.h:146
@ IPV4OPT_StreamID
Definition: IPv4Layer.h:142
@ IPV4OPT_RecordRoute
Definition: IPv4Layer.h:122
OsiModelLayer
Definition: ProtocolType.h:364
@ OsiModelNetworkLayer
Definition: ProtocolType.h:370
IPProtocolTypes
Definition: IPv4Layer.h:65
@ PACKETPP_IPPROTO_ROUTING
Definition: IPv4Layer.h:89
@ PACKETPP_IPPROTO_AH
Definition: IPv4Layer.h:97
@ PACKETPP_IPPROTO_ICMP
Definition: IPv4Layer.h:71
@ PACKETPP_IPPROTO_IPIP
Definition: IPv4Layer.h:75
@ PACKETPP_IPPROTO_FRAGMENT
Definition: IPv4Layer.h:91
@ PACKETPP_IPPROTO_UDP
Definition: IPv4Layer.h:83
@ PACKETPP_IPPROTO_IP
Definition: IPv4Layer.h:67
@ PACKETPP_IPPROTO_ESP
Definition: IPv4Layer.h:95
@ PACKETPP_IPPROTO_IGMP
Definition: IPv4Layer.h:73
@ PACKETPP_IPPROTO_GRE
Definition: IPv4Layer.h:93
@ PACKETPP_IPPROTO_TCP
Definition: IPv4Layer.h:77
@ PACKETPP_IPPROTO_ICMPV6
Definition: IPv4Layer.h:99
@ PACKETPP_IPPROTO_PUP
Definition: IPv4Layer.h:81
@ PACKETPP_IPPROTO_VRRP
Definition: IPv4Layer.h:105
@ PACKETPP_IPPROTO_IDP
Definition: IPv4Layer.h:85
@ PACKETPP_IPPROTO_EGP
Definition: IPv4Layer.h:79
@ PACKETPP_IPPROTO_HOPOPTS
Definition: IPv4Layer.h:69
@ PACKETPP_IPPROTO_DSTOPTS
Definition: IPv4Layer.h:103
@ PACKETPP_IPPROTO_RAW
Definition: IPv4Layer.h:107
@ PACKETPP_IPPROTO_NONE
Definition: IPv4Layer.h:101
@ PACKETPP_IPPROTO_MAX
Definition: IPv4Layer.h:109
@ PACKETPP_IPPROTO_IPV6
Definition: IPv4Layer.h:87
Definition: IPv4Layer.h:170
TimestampType type
Definition: IPv4Layer.h:187
std::vector< IPv4Address > ipAddresses
Definition: IPv4Layer.h:193
TimestampType
Definition: IPv4Layer.h:175
@ Unknown
Definition: IPv4Layer.h:183
@ TimestampsForPrespecifiedIPs
Definition: IPv4Layer.h:181
@ TimestampAndIP
Definition: IPv4Layer.h:179
@ TimestampOnly
Definition: IPv4Layer.h:177
std::vector< uint32_t > timestamps
Definition: IPv4Layer.h:190
void clear()
Definition: IPv4Layer.h:203
IPv4TimestampOptionValue()
Definition: IPv4Layer.h:196
Definition: IPv4Layer.h:25
uint8_t typeOfService
Definition: IPv4Layer.h:38
uint32_t ipDst
Definition: IPv4Layer.h:56
uint16_t headerChecksum
Definition: IPv4Layer.h:52
uint8_t ipVersion
Definition: IPv4Layer.h:30
uint32_t ipSrc
Definition: IPv4Layer.h:54
uint8_t protocol
Definition: IPv4Layer.h:50
uint16_t fragmentOffset
Definition: IPv4Layer.h:45
uint16_t ipId
Definition: IPv4Layer.h:43
uint8_t timeToLive
Definition: IPv4Layer.h:48
uint16_t totalLength
Definition: IPv4Layer.h:40
uint8_t internetHeaderLength
Definition: IPv4Layer.h:28