PcapPlusPlus  20.08+
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)
23  uint8_t dstMac[6];
25  uint8_t srcMac[6];
27  uint16_t length;
28  };
29 #pragma pack(pop)
30 
35  class EthDot3Layer : public Layer
36  {
37  public:
38 
45  EthDot3Layer(uint8_t* data, size_t dataLen, Packet* packet) : Layer(data, dataLen, NULL, packet) { m_Protocol = EthernetDot3; }
46 
54  EthDot3Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = EthernetDot3; }
55 
62  EthDot3Layer(const MacAddress& sourceMac, const MacAddress& destMac, uint16_t length);
63 
64  ~EthDot3Layer() {}
65 
70  ether_dot3_header* getEthHeader() const { return (ether_dot3_header*)m_Data; }
71 
76  MacAddress getSourceMac() const { return MacAddress(getEthHeader()->srcMac); }
77 
82  void setSourceMac(const MacAddress& sourceMac) { sourceMac.copyTo(getEthHeader()->srcMac); }
83 
88  MacAddress getDestMac() const { return MacAddress(getEthHeader()->dstMac); }
89 
94  void setDestMac(const MacAddress& destMac) { destMac.copyTo(getEthHeader()->dstMac); }
95 
96  // implement abstract methods
97 
101  void parseNextLayer();
102 
106  size_t getHeaderLen() const { return sizeof(ether_dot3_header); }
107 
112 
113  std::string toString() const;
114 
116 
123  static bool isDataValid(const uint8_t* data, size_t dataLen);
124  };
125 
126 } // namespace pcpp
127 
128 #endif // PACKETPP_ETH_DOT3_LAYER
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:238
ether_dot3_header * getEthHeader() const
Definition: EthDot3Layer.h:70
Definition: ProtocolType.h:243
Definition: Layer.h:70
MacAddress getSourceMac() const
Definition: EthDot3Layer.h:76
Definition: Packet.h:26
size_t getHeaderLen() const
Definition: EthDot3Layer.h:106
void setSourceMac(const MacAddress &sourceMac)
Definition: EthDot3Layer.h:82
EthDot3Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: EthDot3Layer.h:54
uint8_t srcMac[6]
Definition: EthDot3Layer.h:25
EthDot3Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: EthDot3Layer.h:45
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:143
void computeCalculateFields()
Definition: EthDot3Layer.h:111
MacAddress getDestMac() const
Definition: EthDot3Layer.h:88
Definition: EthDot3Layer.h:35
uint8_t dstMac[6]
Definition: EthDot3Layer.h:23
uint16_t length
Definition: EthDot3Layer.h:27
OsiModelLayer getOsiModelLayer() const
Definition: EthDot3Layer.h:115
void setDestMac(const MacAddress &destMac)
Definition: EthDot3Layer.h:94
Definition: EthDot3Layer.h:21
Definition: MacAddress.h:27
const ProtocolType EthernetDot3
Definition: ProtocolType.h:223