PcapPlusPlus  22.05
EthDot3Layer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_ETH_DOT3_LAYER
2 #define PACKETPP_ETH_DOT3_LAYER
3 
4 #include "Layer.h"
5 #include "MacAddress.h"
6 
8 
13 namespace pcpp
14 {
15 
20 #pragma pack(push, 1)
22  {
24  uint8_t dstMac[6];
26  uint8_t srcMac[6];
28  uint16_t length;
29  };
30 #pragma pack(pop)
31 
36  class EthDot3Layer : public Layer
37  {
38  public:
39 
46  EthDot3Layer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, NULL, packet) { m_Protocol = EthernetDot3; }
47 
55  EthDot3Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = EthernetDot3; }
56 
63  EthDot3Layer(const MacAddress& sourceMac, const MacAddress& destMac, uint16_t length);
64 
65  ~EthDot3Layer() {}
66 
71  ether_dot3_header* getEthHeader() const { return (ether_dot3_header*)m_Data; }
72 
77  MacAddress getSourceMac() const { return MacAddress(getEthHeader()->srcMac); }
78 
83  void setSourceMac(const MacAddress& sourceMac) { sourceMac.copyTo(getEthHeader()->srcMac); }
84 
89  MacAddress getDestMac() const { return MacAddress(getEthHeader()->dstMac); }
90 
95  void setDestMac(const MacAddress& destMac) { destMac.copyTo(getEthHeader()->dstMac); }
96 
97  // implement abstract methods
98 
102  void parseNextLayer();
103 
107  size_t getHeaderLen() const { return sizeof(ether_dot3_header); }
108 
113 
114  std::string toString() const;
115 
117 
124  static bool isDataValid(const uint8_t* data, size_t dataLen);
125  };
126 
127 } // namespace pcpp
128 
129 #endif // PACKETPP_ETH_DOT3_LAYER
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:263
ether_dot3_header * getEthHeader() const
Definition: EthDot3Layer.h:71
Definition: ProtocolType.h:268
Definition: Layer.h:70
MacAddress getSourceMac() const
Definition: EthDot3Layer.h:77
Definition: Packet.h:26
size_t getHeaderLen() const
Definition: EthDot3Layer.h:107
void setSourceMac(const MacAddress &sourceMac)
Definition: EthDot3Layer.h:83
EthDot3Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: EthDot3Layer.h:55
uint8_t srcMac[6]
Definition: EthDot3Layer.h:26
EthDot3Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: EthDot3Layer.h:46
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:146
void computeCalculateFields()
Definition: EthDot3Layer.h:112
MacAddress getDestMac() const
Definition: EthDot3Layer.h:89
Definition: EthDot3Layer.h:36
uint8_t dstMac[6]
Definition: EthDot3Layer.h:24
uint16_t length
Definition: EthDot3Layer.h:28
OsiModelLayer getOsiModelLayer() const
Definition: EthDot3Layer.h:116
void setDestMac(const MacAddress &destMac)
Definition: EthDot3Layer.h:95
Definition: EthDot3Layer.h:21
Definition: MacAddress.h:28
const ProtocolType EthernetDot3
Definition: ProtocolType.h:223