PcapPlusPlus  24.09
Sll2Layer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "MacAddress.h"
4 #include "Layer.h"
5 
7 
12 namespace pcpp
13 {
18 #pragma pack(push, 1)
19  struct sll2_header
20  {
22  uint16_t protocol_type;
24  uint16_t reserved;
28  uint32_t interface_index;
30  uint16_t ARPHRD_type;
35  uint8_t packet_type;
41  uint8_t link_layer_addr[8];
42  };
43 #pragma pack(pop)
44 
49  class Sll2Layer : public Layer
50  {
51  public:
58  Sll2Layer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, nullptr, packet, SLL2)
59  {}
60 
67  Sll2Layer(uint32_t interfaceIndex, uint16_t ARPHRDType, uint8_t packetType);
68 
69  ~Sll2Layer()
70  {}
71 
78  {
79  return (sll2_header*)m_Data;
80  }
81 
88  static bool isDataValid(const uint8_t* data, size_t dataLen);
89 
94  uint16_t getProtocolType() const;
95 
100  void setProtocolType(uint16_t protocolType);
101 
106  uint32_t getInterfaceIndex() const;
107 
112  void setInterfaceIndex(uint32_t interfaceIndex);
113 
118  uint16_t getArphrdType() const;
119 
124  void setArphrdType(uint16_t arphrdType);
125 
130  uint8_t getPacketType() const;
131 
136  void setPacketType(uint8_t packetType);
137 
142  uint8_t getLinkLayerAddrLen() const;
143 
148  const uint8_t* getLinkLayerAddr() const;
149 
156  bool setLinkLayerAddr(const uint8_t* addr, size_t addrLength);
157 
164 
170  bool setMacAddressAsLinkLayer(const MacAddress& macAddr);
171 
172  // implement abstract methods
173 
179 
184 
188  size_t getHeaderLen() const
189  {
190  return sizeof(sll2_header);
191  }
192 
193  std::string toString() const;
194 
196  {
197  return OsiModelDataLinkLayer;
198  }
199  };
200 
201 } // namespace pcpp
Definition: Layer.h:70
Definition: MacAddress.h:25
Definition: Packet.h:27
Definition: Sll2Layer.h:50
size_t getHeaderLen() const
Definition: Sll2Layer.h:188
uint8_t getLinkLayerAddrLen() const
const uint8_t * getLinkLayerAddr() const
void setArphrdType(uint16_t arphrdType)
bool setLinkLayerAddr(const uint8_t *addr, size_t addrLength)
uint8_t getPacketType() const
void computeCalculateFields()
Sll2Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: Sll2Layer.h:58
uint16_t getProtocolType() const
bool setMacAddressAsLinkLayer(const MacAddress &macAddr)
void setProtocolType(uint16_t protocolType)
void parseNextLayer()
void setPacketType(uint8_t packetType)
std::string toString() const
uint16_t getArphrdType() const
MacAddress getLinkLayerAsMacAddress()
sll2_header * getSll2Header() const
Definition: Sll2Layer.h:77
Sll2Layer(uint32_t interfaceIndex, uint16_t ARPHRDType, uint8_t packetType)
void setInterfaceIndex(uint32_t interfaceIndex)
uint32_t getInterfaceIndex() const
OsiModelLayer getOsiModelLayer() const
Definition: Sll2Layer.h:195
static bool isDataValid(const uint8_t *data, size_t dataLen)
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:358
const ProtocolType SLL2
Definition: ProtocolType.h:333
Definition: Sll2Layer.h:20
uint16_t ARPHRD_type
Definition: Sll2Layer.h:30
uint16_t protocol_type
Definition: Sll2Layer.h:22
uint8_t link_layer_addr_len
Definition: Sll2Layer.h:37
uint16_t reserved
Definition: Sll2Layer.h:24
uint8_t link_layer_addr[8]
Definition: Sll2Layer.h:41
uint32_t interface_index
Definition: Sll2Layer.h:28
uint8_t packet_type
Definition: Sll2Layer.h:35