1 #ifndef PACKETPP_IPV6_LAYER 2 #define PACKETPP_IPV6_LAYER 25 #if (BYTE_ORDER == LITTLE_ENDIAN) 143 size_t getExtensionCount()
const;
150 template<
class TIPv6Extension>
151 TIPv6Extension* getExtensionOfType()
const;
162 template<
class TIPv6Extension>
163 TIPv6Extension* addExtension(
const TIPv6Extension& extensionHeader);
168 void removeAllExtensions();
173 bool isFragment()
const;
181 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
198 void parseNextLayer();
211 void computeCalculateFields();
213 std::string toString()
const;
219 void parseExtensions();
220 void deleteExtensions();
224 size_t m_ExtensionsLen;
228 template<
class TIPv6Extension>
232 while (curExt != NULL && dynamic_cast<TIPv6Extension*>(curExt) == NULL)
235 return (TIPv6Extension*)curExt;
238 template<
class TIPv6Extension>
241 int offsetToAddHeader = (int)getHeaderLen();
242 if (!extendLayer(offsetToAddHeader, extensionHeader.getExtensionLen()))
247 TIPv6Extension* newHeader =
new TIPv6Extension(
this, (
size_t)offsetToAddHeader);
248 (*newHeader) = extensionHeader;
250 if (m_FirstExtension != NULL)
252 newHeader->getBaseHeader()->nextHeader = m_LastExtension->getBaseHeader()->nextHeader;
253 m_LastExtension->getBaseHeader()->nextHeader = newHeader->getExtensionType();
254 m_LastExtension->setNextHeader(newHeader);
255 m_LastExtension = newHeader;
259 m_FirstExtension = newHeader;
260 m_LastExtension = newHeader;
261 newHeader->getBaseHeader()->nextHeader = getIPv6Header()->nextHeader;
262 getIPv6Header()->nextHeader = newHeader->getExtensionType();
265 m_ExtensionsLen += newHeader->getExtensionLen();
274 return dataLen >=
sizeof(
ip6_hdr);
IPAddress getSrcIPAddress() const
Definition: IPv6Layer.h:106
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:263
Definition: IPv6Extensions.h:23
uint8_t ipSrc[16]
Definition: IPv6Layer.h:45
uint16_t payloadLength
Definition: IPv6Layer.h:39
TIPv6Extension * addExtension(const TIPv6Extension &extensionHeader)
Definition: IPv6Layer.h:239
Definition: IPv6Layer.h:23
Definition: IPv6Layer.h:56
uint8_t trafficClass
Definition: IPv6Layer.h:27
Definition: ProtocolType.h:270
uint8_t flowLabel[3]
Definition: IPv6Layer.h:37
uint8_t ipDst[16]
Definition: IPv6Layer.h:47
size_t getHeaderLen() const
Definition: IPv6Layer.h:203
Definition: IpAddress.h:167
uint8_t hopLimit
Definition: IPv6Layer.h:43
IPv6Extension * getNextHeader() const
Definition: IPv6Extensions.h:66
TIPv6Extension * getExtensionOfType() const
Definition: IPv6Layer.h:229
IPv6Address getDstIPv6Address() const
Definition: IPv6Layer.h:138
ip6_hdr * getIPv6Header() const
Definition: IPv6Layer.h:99
void setSrcIPv6Address(const IPv6Address &ipAddr)
Definition: IPv6Layer.h:118
void setDstIPv6Address(const IPv6Address &ipAddr)
Definition: IPv6Layer.h:125
uint8_t ipVersion
Definition: IPv6Layer.h:27
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv6Layer.h:272
IPAddress getDstIPAddress() const
Definition: IPv6Layer.h:132
void copyTo(uint8_t **arr, size_t &length) const
Definition: IpAddress.h:278
IPv6Address getSrcIPv6Address() const
Definition: IPv6Layer.h:112
OsiModelLayer getOsiModelLayer() const
Definition: IPv6Layer.h:215
uint8_t nextHeader
Definition: IPv6Layer.h:41