PcapPlusPlus  24.09
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()
64  {}
65 
72  {
73  return (sll_header*)m_Data;
74  }
75 
82  bool setLinkLayerAddr(uint8_t* addr, size_t addrLength);
83 
89  bool setMacAddressAsLinkLayer(const MacAddress& macAddr);
90 
96 
100  size_t getHeaderLen() const
101  {
102  return sizeof(sll_header);
103  }
104 
109 
110  std::string toString() const;
111 
113  {
114  return OsiModelDataLinkLayer;
115  }
116  };
117 
118 } // namespace pcpp
Definition: Layer.h:70
Definition: MacAddress.h:25
Definition: Packet.h:27
Definition: SllLayer.h:45
SllLayer(uint16_t packetType, uint16_t ARPHRDType)
size_t getHeaderLen() const
Definition: SllLayer.h:100
void computeCalculateFields()
bool setMacAddressAsLinkLayer(const MacAddress &macAddr)
void parseNextLayer()
bool setLinkLayerAddr(uint8_t *addr, size_t addrLength)
sll_header * getSllHeader() const
Definition: SllLayer.h:71
std::string toString() const
OsiModelLayer getOsiModelLayer() const
Definition: SllLayer.h:112
SllLayer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: SllLayer.h:53
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:358
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