1 #ifndef PACKETPP_IPV6_LAYER 2 #define PACKETPP_IPV6_LAYER 9 #ifndef PCPP_DEPRECATED 10 #if defined(__GNUC__) || defined(__clang__) 11 #define PCPP_DEPRECATED __attribute__((deprecated)) 12 #elif defined(_MSC_VER) 13 #define PCPP_DEPRECATED __declspec(deprecated) 15 #pragma message("WARNING: DEPRECATED feature is not implemented for this compiler") 16 #define PCPP_DEPRECATED 36 #if (BYTE_ORDER == LITTLE_ENDIAN) 122 PCPP_DEPRECATED
IPv6Address getSrcIpAddress()
const {
return getSrcIPv6Address(); }
153 PCPP_DEPRECATED
IPv6Address getDstIpAddress()
const {
return getDstIPv6Address(); }
164 size_t getExtensionCount()
const;
171 template<
class TIPv6Extension>
172 TIPv6Extension* getExtensionOfType()
const;
183 template<
class TIPv6Extension>
184 TIPv6Extension* addExtension(
const TIPv6Extension& extensionHeader);
189 void removeAllExtensions();
194 bool isFragment()
const;
202 static inline bool isDataValid(
const uint8_t* data,
size_t dataLen);
219 void parseNextLayer();
232 void computeCalculateFields();
234 std::string toString()
const;
240 void parseExtensions();
241 void deleteExtensions();
245 size_t m_ExtensionsLen;
249 template<
class TIPv6Extension>
253 while (curExt != NULL && dynamic_cast<TIPv6Extension*>(curExt) == NULL)
256 return (TIPv6Extension*)curExt;
259 template<
class TIPv6Extension>
262 int offsetToAddHeader = (int)getHeaderLen();
263 if (!extendLayer(offsetToAddHeader, extensionHeader.getExtensionLen()))
268 TIPv6Extension* newHeader =
new TIPv6Extension(
this, (
size_t)offsetToAddHeader);
269 (*newHeader) = extensionHeader;
271 if (m_FirstExtension != NULL)
273 newHeader->getBaseHeader()->nextHeader = m_LastExtension->getBaseHeader()->nextHeader;
274 m_LastExtension->getBaseHeader()->nextHeader = newHeader->getExtensionType();
275 m_LastExtension->setNextHeader(newHeader);
276 m_LastExtension = newHeader;
280 m_FirstExtension = newHeader;
281 m_LastExtension = newHeader;
282 newHeader->getBaseHeader()->nextHeader = getIPv6Header()->nextHeader;
283 getIPv6Header()->nextHeader = newHeader->getExtensionType();
286 m_ExtensionsLen += newHeader->getExtensionLen();
295 return dataLen >=
sizeof(
ip6_hdr);
IPAddress getSrcIPAddress() const
Definition: IPv6Layer.h:117
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:258
Definition: IPv6Extensions.h:23
uint8_t ipSrc[16]
Definition: IPv6Layer.h:56
uint16_t payloadLength
Definition: IPv6Layer.h:50
TIPv6Extension * addExtension(const TIPv6Extension &extensionHeader)
Definition: IPv6Layer.h:260
Definition: IPv6Layer.h:34
Definition: IPv6Layer.h:67
uint8_t trafficClass
Definition: IPv6Layer.h:38
Definition: ProtocolType.h:265
uint8_t flowLabel[3]
Definition: IPv6Layer.h:48
uint8_t ipDst[16]
Definition: IPv6Layer.h:58
size_t getHeaderLen() const
Definition: IPv6Layer.h:224
Definition: IpAddress.h:167
uint8_t hopLimit
Definition: IPv6Layer.h:54
IPv6Extension * getNextHeader() const
Definition: IPv6Extensions.h:66
TIPv6Extension * getExtensionOfType() const
Definition: IPv6Layer.h:250
IPv6Address getDstIPv6Address() const
Definition: IPv6Layer.h:159
ip6_hdr * getIPv6Header() const
Definition: IPv6Layer.h:110
void setSrcIPv6Address(const IPv6Address &ipAddr)
Definition: IPv6Layer.h:134
void setDstIPv6Address(const IPv6Address &ipAddr)
Definition: IPv6Layer.h:141
uint8_t ipVersion
Definition: IPv6Layer.h:38
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: IPv6Layer.h:293
IPAddress getDstIPAddress() const
Definition: IPv6Layer.h:148
void copyTo(uint8_t **arr, size_t &length) const
Definition: IpAddress.h:278
IPv6Address getSrcIPv6Address() const
Definition: IPv6Layer.h:128
OsiModelLayer getOsiModelLayer() const
Definition: IPv6Layer.h:236
uint8_t nextHeader
Definition: IPv6Layer.h:52