PcapPlusPlus  Next
SllLayer.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 {
14 
19 #pragma pack(push, 1)
20  struct sll_header
21  {
26  uint16_t packet_type;
28  uint16_t ARPHRD_type;
34  uint8_t link_layer_addr[8];
36  uint16_t protocol_type;
37  };
38 #pragma pack(pop)
39 
44  class SllLayer : public Layer
45  {
46  public:
53  SllLayer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, nullptr, packet, SLL)
54  {}
55 
61  SllLayer(uint16_t packetType, uint16_t ARPHRDType);
62 
63  ~SllLayer() override = default;
64 
71  {
72  return reinterpret_cast<sll_header*>(m_Data);
73  }
74 
81  bool setLinkLayerAddr(uint8_t* addr, size_t addrLength);
82 
88  bool setMacAddressAsLinkLayer(const MacAddress& macAddr);
89 
94  void parseNextLayer() override;
95 
99  size_t getHeaderLen() const override
100  {
101  return sizeof(sll_header);
102  }
103 
107  void computeCalculateFields() override;
108 
109  std::string toString() const override;
110 
112  {
113  return OsiModelDataLinkLayer;
114  }
115  };
116 
117 } // namespace pcpp
Definition: Layer.h:69
Definition: MacAddress.h:25
Definition: Packet.h:27
Definition: SllLayer.h:45
SllLayer(uint16_t packetType, uint16_t ARPHRDType)
bool setMacAddressAsLinkLayer(const MacAddress &macAddr)
size_t getHeaderLen() const override
Definition: SllLayer.h:99
bool setLinkLayerAddr(uint8_t *addr, size_t addrLength)
sll_header * getSllHeader() const
Definition: SllLayer.h:70
std::string toString() const override
OsiModelLayer getOsiModelLayer() const override
Definition: SllLayer.h:111
void parseNextLayer() override
void computeCalculateFields() override
SllLayer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: SllLayer.h:53
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:364
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:368
const ProtocolType SLL
Definition: ProtocolType.h:143
Definition: SllLayer.h:21
uint16_t protocol_type
Definition: SllLayer.h:36
uint16_t ARPHRD_type
Definition: SllLayer.h:28
uint16_t packet_type
Definition: SllLayer.h:26
uint16_t link_layer_addr_len
Definition: SllLayer.h:30
uint8_t link_layer_addr[8]
Definition: SllLayer.h:34