26 #if (BYTE_ORDER == LITTLE_ENDIAN)
161 #define PCPP_IP_DONT_FRAGMENT 0x40
162 #define PCPP_IP_MORE_FRAGMENTS 0x20
242 std::vector<IPv4Address> res;
244 if (m_Data ==
nullptr)
251 uint8_t valueOffset =
static_cast<uint8_t
>(1);
253 while (
static_cast<size_t>(valueOffset) < dataSize)
256 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
262 valueOffset +=
static_cast<uint8_t
>(4);
282 if (m_Data ==
nullptr)
294 uint8_t valueOffset =
static_cast<uint8_t
>(2);
297 while (
static_cast<size_t>(valueOffset) < dataSize)
300 memcpy(&curValue, m_Data->recordValue + valueOffset,
sizeof(uint32_t));
310 readIPAddr = !readIPAddr;
312 valueOffset +=
static_cast<uint8_t
>(4);
332 static bool canAssign(
const uint8_t* recordRawData,
size_t tlvDataLen)
334 auto data =
reinterpret_cast<TLVRawData const*
>(recordRawData);
338 if (tlvDataLen <
sizeof(TLVRawData::recordType))
342 data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
352 if (m_Data ==
nullptr)
356 m_Data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
357 return sizeof(uint8_t);
359 return static_cast<size_t>(m_Data->recordLen);
364 if (m_Data ==
nullptr)
368 m_Data->recordType ==
static_cast<uint8_t
>(
IPV4OPT_NOP))
371 return static_cast<size_t>(m_Data->recordLen) - (2 *
sizeof(uint8_t));
395 bool m_BuilderParamsValid;
410 m_BuilderParamsValid =
true;
422 m_BuilderParamsValid =
true;
508 return (
iphdr*)m_Data;
684 m_TempHeaderExtension;
710 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
713 int m_NumOfTrailingBytes;
714 int m_TempHeaderExtension;
717 void copyLayerData(
const IPv4Layer& other);
718 uint8_t* getOptionsBasePtr()
const
720 return m_Data +
sizeof(
iphdr);
722 IPv4Option addOptionAt(
const IPv4OptionBuilder& optionBuilder,
int offset);
723 void adjustOptionsTrailer(
size_t totalOptSize);
725 void initLayerInPacket(
bool setTotalLenAsDataLen);
732 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:453
IPv4Option getNextOption(IPv4Option &option) const
iphdr * getIPv4Header() const
Definition: IPv4Layer.h:506
uint8_t getFragmentFlags() const
IPv4Address getSrcIPv4Address() const
Definition: IPv4Layer.h:525
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv4Layer.h:730
IPv4Option addOption(const IPv4OptionBuilder &optionBuilder)
IPAddress getDstIPAddress() const
Definition: IPv4Layer.h:544
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:562
IPAddress getSrcIPAddress() const
Definition: IPv4Layer.h:516
void setSrcIPv4Address(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:534
IPv4Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet, bool setTotalLenAsDataLen)
size_t getHeaderLen() const
Definition: IPv4Layer.h:681
bool isLastFragment() const
OsiModelLayer getOsiModelLayer() const
Definition: IPv4Layer.h:699
IPv4Layer & operator=(const IPv4Layer &other)
IPv4Address getDstIPv4Address() const
Definition: IPv4Layer.h:553
std::string toString() const
void computeCalculateFields()
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
Definition: IPv4Layer.h:393
IPv4OptionBuilder(IPv4OptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: IPv4Layer.h:407
IPv4OptionBuilder(IPv4OptionTypes optionType, uint16_t optionValue)
Definition: IPv4Layer.h:419
IPv4OptionBuilder(const IPv4TimestampOptionValue ×tampValue)
IPv4OptionBuilder(IPv4OptionTypes optionType, const std::vector< IPv4Address > &ipList)
Definition: IPv4Layer.h:217
IPv4Option(uint8_t *optionRawData)
Definition: IPv4Layer.h:223
~IPv4Option()
Definition: IPv4Layer.h:229
std::vector< IPv4Address > getValueAsIpList() const
Definition: IPv4Layer.h:240
IPv4OptionTypes getIPv4OptionType() const
Definition: IPv4Layer.h:321
size_t getTotalSize() const
Definition: IPv4Layer.h:350
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: IPv4Layer.h:332
size_t getDataSize() const
Definition: IPv4Layer.h:362
IPv4TimestampOptionValue getTimestampOptionValue() const
Definition: IPv4Layer.h:277
Definition: TLVData.h:413
static bool canAssign(const uint8_t *recordRawData, size_t tlvDataLen)
Definition: TLVData.h:79
Definition: TLVData.h:239
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:354
@ OsiModelNetworkLayer
Definition: ProtocolType.h:360
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