|
PcapPlusPlus
20.08
|
Go to the documentation of this file. 1 #ifndef PACKETPP_IPV4_LAYER
2 #define PACKETPP_IPV4_LAYER
25 #if (BYTE_ORDER == LITTLE_ENDIAN)
157 #define PCPP_IP_DONT_FRAGMENT 0x40
158 #define PCPP_IP_MORE_FRAGMENTS 0x20
233 std::vector<IPv4Address> res;
242 uint8_t valueOffset = (uint8_t)(1);
244 while ((
size_t)valueOffset < dataSize)
247 memcpy(&curValue, m_Data->
recordValue + valueOffset,
sizeof(uint32_t));
253 valueOffset += (uint8_t)(4);
283 uint8_t valueOffset = (uint8_t)(2);
286 while ((
size_t)valueOffset < dataSize)
289 memcpy(&curValue, m_Data->
recordValue + valueOffset,
sizeof(uint32_t));
299 readIPAddr = !readIPAddr;
301 valueOffset += (uint8_t)(4);
327 return sizeof(uint8_t);
340 return (
size_t)m_Data->
recordLen - (2*
sizeof(uint8_t));
353 bool m_BuilderParamsValid;
367 TLVRecordBuilder((uint8_t)optionType, optionValue, optionValueLen) { m_BuilderParamsValid =
true; }
376 TLVRecordBuilder((uint8_t)optionType, optionValue) { m_BuilderParamsValid =
true; }
428 IPv4Layer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet,
bool setTotalLenAsDataLen);
604 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
607 int m_NumOfTrailingBytes;
608 int m_TempHeaderExtension;
611 void copyLayerData(
const IPv4Layer& other);
612 uint8_t* getOptionsBasePtr()
const {
return m_Data +
sizeof(
iphdr); }
613 IPv4Option addOptionAt(
const IPv4OptionBuilder& optionBuilder,
int offset);
614 void adjustOptionsTrailer(
size_t totalOptSize);
616 void initLayerInPacket(uint8_t* data,
size_t dataLen, Layer* prevLayer, Packet* packet,
bool setTotalLenAsDataLen);
624 const iphdr* hdr =
reinterpret_cast<const iphdr*
>(data);
@ PACKETPP_IPPROTO_EGP
Definition: IPv4Layer.h:76
OsiModelLayer
Definition: ProtocolType.h:233
@ IPV4OPT_Unknown
Definition: IPv4Layer.h:154
@ PACKETPP_IPPROTO_IGMP
Definition: IPv4Layer.h:70
Definition: IpAddress.h:26
std::vector< IPv4Address > ipAddresses
Definition: IPv4Layer.h:188
@ IPV4OPT_NOP
Definition: IPv4Layer.h:116
@ TimestampsForPrespecifiedIPs
Definition: IPv4Layer.h:176
IPv4Option getFirstOption() const
@ PACKETPP_IPPROTO_ICMPV6
Definition: IPv4Layer.h:96
@ PACKETPP_IPPROTO_NONE
Definition: IPv4Layer.h:98
uint16_t fragmentOffset
Definition: IPv4Layer.h:43
IPv4OptionTypes
Definition: IPv4Layer.h:111
size_t getTotalSize() const
Definition: IPv4Layer.h:321
bool removeOption(IPv4OptionTypes option)
@ IPV4OPT_Security
Definition: IPv4Layer.h:130
@ IPV4OPT_StreamID
Definition: IPv4Layer.h:138
TimestampType
Definition: IPv4Layer.h:169
@ IPV4OPT_Timestamp
Definition: IPv4Layer.h:126
std::string toString() const
@ IPV4OPT_SelectiveDirectedBroadcast
Definition: IPv4Layer.h:148
@ IPV4OPT_UpstreamMulticastPkt
Definition: IPv4Layer.h:152
void clear()
Definition: IPv4Layer.h:196
uint8_t recordType
Definition: TLVData.h:31
void setDstIpAddress(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:481
size_t getOptionCount() const
OsiModelLayer getOsiModelLayer() const
Definition: IPv4Layer.h:596
Definition: IPv4Layer.h:164
uint8_t protocol
Definition: IPv4Layer.h:47
@ IPV4OPT_StrictSourceRoute
Definition: IPv4Layer.h:140
bool isLastFragment() const
std::vector< IPv4Address > getValueAsIpList() const
Definition: IPv4Layer.h:231
Definition: IPv4Layer.h:405
@ IPV4OPT_QuickStart
Definition: IPv4Layer.h:124
uint16_t headerChecksum
Definition: IPv4Layer.h:49
uint16_t getFragmentOffset() const
void computeCalculateFields()
IPv4OptionBuilder(IPv4OptionTypes optionType, const uint8_t *optionValue, uint8_t optionValueLen)
Definition: IPv4Layer.h:366
@ OsiModelNetworkLayer
Definition: ProtocolType.h:240
@ PACKETPP_IPPROTO_UDP
Definition: IPv4Layer.h:80
@ IPV4OPT_RouterAlert
Definition: IPv4Layer.h:146
std::vector< uint32_t > timestamps
Definition: IPv4Layer.h:185
@ IPV4OPT_EndOfOptionsList
Definition: IPv4Layer.h:114
TimestampType type
Definition: IPv4Layer.h:182
@ PACKETPP_IPPROTO_ICMP
Definition: IPv4Layer.h:68
IPv4OptionTypes getIPv4OptionType() const
Definition: IPv4Layer.h:310
@ PACKETPP_IPPROTO_ROUTING
Definition: IPv4Layer.h:86
@ Unknown
Definition: IPv4Layer.h:178
@ PACKETPP_IPPROTO_GRE
Definition: IPv4Layer.h:90
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv4Layer.h:622
@ TimestampAndIP
Definition: IPv4Layer.h:174
IPv4Address getDstIpAddress() const
Definition: IPv4Layer.h:475
@ IPV4OPT_RecordRoute
Definition: IPv4Layer.h:118
@ PACKETPP_IPPROTO_FRAGMENT
Definition: IPv4Layer.h:88
size_t getDataSize() const
Definition: IPv4Layer.h:332
uint32_t ipSrc
Definition: IPv4Layer.h:51
IPProtocolTypes
Definition: IPv4Layer.h:61
size_t getHeaderLen() const
Definition: IPv4Layer.h:583
IPv4Option getOption(IPv4OptionTypes option) const
@ PACKETPP_IPPROTO_IDP
Definition: IPv4Layer.h:82
uint32_t toInt() const
Definition: IpAddress.h:125
Definition: IPv4Layer.h:350
@ PACKETPP_IPPROTO_AH
Definition: IPv4Layer.h:94
@ IPV4OPT_DynamicPacketState
Definition: IPv4Layer.h:150
@ TimestampOnly
Definition: IPv4Layer.h:172
@ IPV4OPT_MTUProbe
Definition: IPv4Layer.h:120
@ PACKETPP_IPPROTO_IPIP
Definition: IPv4Layer.h:72
IPv4Option(uint8_t *optionRawData)
Definition: IPv4Layer.h:218
Definition: IPv4Layer.h:24
@ IPV4OPT_Traceroute
Definition: IPv4Layer.h:128
IPv4Option addOption(const IPv4OptionBuilder &optionBuilder)
uint16_t totalLength
Definition: IPv4Layer.h:39
~IPv4Option()
Definition: IPv4Layer.h:223
IPv4TimestampOptionValue()
Definition: IPv4Layer.h:191
bool isFirstFragment() const
uint8_t getFragmentFlags() const
Definition: IPv4Layer.h:210
@ IPV4OPT_CommercialSecurity
Definition: IPv4Layer.h:136
iphdr * getIPv4Header() const
Definition: IPv4Layer.h:457
uint8_t internetHeaderLength
Definition: IPv4Layer.h:27
The main namespace for the PcapPlusPlus lib.
Definition: TLVData.h:351
IPv4Layer & operator=(const IPv4Layer &other)
uint32_t ipDst
Definition: IPv4Layer.h:53
@ PACKETPP_IPPROTO_PUP
Definition: IPv4Layer.h:78
@ PACKETPP_IPPROTO_DSTOPTS
Definition: IPv4Layer.h:100
Definition: TLVData.h:197
uint8_t timeToLive
Definition: IPv4Layer.h:45
uint8_t typeOfService
Definition: IPv4Layer.h:37
uint8_t recordValue[]
Definition: TLVData.h:35
@ PACKETPP_IPPROTO_ESP
Definition: IPv4Layer.h:92
@ PACKETPP_IPPROTO_IPV6
Definition: IPv4Layer.h:84
IPv4TimestampOptionValue getTimestampOptionValue() const
Definition: IPv4Layer.h:266
@ PACKETPP_IPPROTO_IP
Definition: IPv4Layer.h:64
uint16_t ipId
Definition: IPv4Layer.h:41
void setSrcIpAddress(const IPv4Address &ipAddr)
Definition: IPv4Layer.h:469
@ IPV4OPT_AddressExtension
Definition: IPv4Layer.h:144
@ PACKETPP_IPPROTO_HOPOPTS
Definition: IPv4Layer.h:66
@ PACKETPP_IPPROTO_TCP
Definition: IPv4Layer.h:74
IPv4OptionBuilder(IPv4OptionTypes optionType, uint16_t optionValue)
Definition: IPv4Layer.h:375
@ PACKETPP_IPPROTO_MAX
Definition: IPv4Layer.h:104
@ IPV4OPT_ExtendedSecurity
Definition: IPv4Layer.h:134
uint8_t recordLen
Definition: TLVData.h:33
@ IPV4OPT_ExtendedInternetProtocol
Definition: IPv4Layer.h:142
@ IPV4OPT_MTUReply
Definition: IPv4Layer.h:122
IPv4Option getNextOption(IPv4Option &option) const
@ PACKETPP_IPPROTO_RAW
Definition: IPv4Layer.h:102
IPv4Address getSrcIpAddress() const
Definition: IPv4Layer.h:463
IPv4Option addOptionAfter(const IPv4OptionBuilder &optionBuilder, IPv4OptionTypes prevOptionType=IPV4OPT_Unknown)
uint8_t ipVersion
Definition: IPv4Layer.h:29
@ IPV4OPT_LooseSourceRoute
Definition: IPv4Layer.h:132