PcapPlusPlus
IPv6Layer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_IPV6_LAYER
2 #define PACKETPP_IPV6_LAYER
3 
4 #include "Layer.h"
5 #include "IpAddress.h"
6 
8 
13 namespace pcpp
14 {
15 
20 #pragma pack(push, 1)
21  struct ip6_hdr {
22  #if (BYTE_ORDER == LITTLE_ENDIAN)
23 
24  uint8_t trafficClass:4,
26  ipVersion:4;
27  #else
28 
29  uint8_t ipVersion:4,
31  trafficClass:4;
32  #endif
33 
34  uint8_t flowLabel[3];
36  uint16_t payloadLength;
38  uint8_t nextHeader;
40  uint8_t hopLimit;
42  uint8_t ipSrc[16];
44  uint8_t ipDst[16];
45  };
46 #pragma pack(pop)
47 
48 
53  class IPv6Layer : public Layer
54  {
55  public:
63  IPv6Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = IPv6; }
64 
68  IPv6Layer();
69 
75  IPv6Layer(const IPv6Address& srcIP, const IPv6Address& dstIP);
76 
81  inline ip6_hdr* getIPv6Header() { return (ip6_hdr*)m_Data; };
82 
87  inline IPv6Address getSrcIpAddress() { return IPv6Address(getIPv6Header()->ipSrc); }
88 
93  inline IPv6Address getDstIpAddress() { return IPv6Address(getIPv6Header()->ipDst); }
94 
95  // implement abstract methods
96 
100  void parseNextLayer();
101 
105  inline size_t getHeaderLen() { return sizeof(ip6_hdr); }
106 
113  void computeCalculateFields();
114 
115  std::string toString();
116 
118 
119  private:
120  void initLayer();
121  };
122 
123 } // namespace pcpp
124 
125 #endif /* PACKETPP_IPV6_LAYER */
uint8_t ipVersion
Definition: IPv6Layer.h:24
Definition: IpAddress.h:196
uint8_t ipDst[16]
Definition: IPv6Layer.h:44
void computeCalculateFields()
Definition: ProtocolType.h:210
void parseNextLayer()
OsiModelLayer
Definition: ProtocolType.h:203
ip6_hdr * getIPv6Header()
Definition: IPv6Layer.h:81
uint8_t nextHeader
Definition: IPv6Layer.h:38
uint8_t hopLimit
Definition: IPv6Layer.h:40
Definition: Packet.h:26
uint8_t ipSrc[16]
Definition: IPv6Layer.h:42
OsiModelLayer getOsiModelLayer()
Definition: IPv6Layer.h:117
IPv6Address getDstIpAddress()
Definition: IPv6Layer.h:93
Definition: Layer.h:52
Definition: ProtocolType.h:36
size_t getHeaderLen()
Definition: IPv6Layer.h:105
IPv6Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: IPv6Layer.h:63
Definition: IPv6Layer.h:53
Definition: IPv6Layer.h:21
IPv6Address getSrcIpAddress()
Definition: IPv6Layer.h:87
uint16_t payloadLength
Definition: IPv6Layer.h:36
The main namespace for the PcapPlusPlus lib.
uint8_t trafficClass
Definition: IPv6Layer.h:24
uint8_t flowLabel[3]
Definition: IPv6Layer.h:34
std::string toString()