PcapPlusPlus  23.09
Sll2Layer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_SLL2_LAYER
2 #define PACKETPP_SLL2_LAYER
3 
4 #include "MacAddress.h"
5 #include "Layer.h"
6 
8 
13 namespace pcpp
14 {
19 #pragma pack(push, 1)
20  struct sll2_header
21  {
23  uint16_t protocol_type;
25  uint16_t reserved;
29  uint32_t interface_index;
31  uint16_t ARPHRD_type;
36  uint8_t packet_type;
42  uint8_t link_layer_addr[8];
43  };
44 #pragma pack(pop)
45 
50  class Sll2Layer : public Layer
51  {
52  public:
59  Sll2Layer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, nullptr, packet) { m_Protocol = SLL2; }
60 
67  Sll2Layer(uint32_t interfaceIndex, uint16_t ARPHRDType, uint8_t packetType);
68 
69  ~Sll2Layer() {}
70 
75  sll2_header* getSll2Header() const { return (sll2_header*)m_Data; }
76 
83  static bool isDataValid(const uint8_t* data, size_t dataLen);
84 
89  uint16_t getProtocolType() const;
90 
95  void setProtocolType(uint16_t protocolType);
96 
101  uint32_t getInterfaceIndex() const;
102 
107  void setInterfaceIndex(uint32_t interfaceIndex);
108 
113  uint16_t getArphrdType() const;
114 
119  void setArphrdType(uint16_t arphrdType);
120 
125  uint8_t getPacketType() const;
126 
131  void setPacketType(uint8_t packetType);
132 
137  uint8_t getLinkLayerAddrLen() const;
138 
143  const uint8_t* getLinkLayerAddr() const;
144 
151  bool setLinkLayerAddr(const uint8_t* addr, size_t addrLength);
152 
157  MacAddress getLinkLayerAsMacAddress();
158 
164  bool setMacAddressAsLinkLayer(const MacAddress& macAddr);
165 
166  // implement abstract methods
167 
173  void parseNextLayer();
174 
178  void computeCalculateFields();
179 
183  size_t getHeaderLen() const { return sizeof(sll2_header); }
184 
185  std::string toString() const;
186 
188  };
189 
190 } // namespace pcpp
191 
192 #endif /* PACKETPP_SLL2_LAYER */
const ProtocolType SLL2
Definition: ProtocolType.h:328
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
size_t getHeaderLen() const
Definition: Sll2Layer.h:183
Definition: ProtocolType.h:338
Definition: Layer.h:70
Definition: Packet.h:26
uint32_t interface_index
Definition: Sll2Layer.h:29
Sll2Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: Sll2Layer.h:59
sll2_header * getSll2Header() const
Definition: Sll2Layer.h:75
uint8_t link_layer_addr[8]
Definition: Sll2Layer.h:42
uint8_t link_layer_addr_len
Definition: Sll2Layer.h:38
uint16_t ARPHRD_type
Definition: Sll2Layer.h:31
Definition: Sll2Layer.h:50
uint16_t reserved
Definition: Sll2Layer.h:25
uint8_t packet_type
Definition: Sll2Layer.h:36
Definition: Sll2Layer.h:20
Definition: MacAddress.h:28
OsiModelLayer getOsiModelLayer() const
Definition: Sll2Layer.h:187
uint16_t protocol_type
Definition: Sll2Layer.h:23