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 
53  EthDot3Layer(const MacAddress& sourceMac, const MacAddress& destMac, uint16_t length);
54 
55  ~EthDot3Layer() {}
56 
61  ether_dot3_header* getEthHeader() const { return (ether_dot3_header*)m_Data; }
62 
67  MacAddress getSourceMac() const { return MacAddress(getEthHeader()->srcMac); }
68 
73  void setSourceMac(const MacAddress& sourceMac) { sourceMac.copyTo(getEthHeader()->srcMac); }
74 
79  MacAddress getDestMac() const { return MacAddress(getEthHeader()->dstMac); }
80 
85  void setDestMac(const MacAddress& destMac) { destMac.copyTo(getEthHeader()->dstMac); }
86 
87  // implement abstract methods
88 
92  void parseNextLayer();
93 
97  size_t getHeaderLen() const { return sizeof(ether_dot3_header); }
98 
103 
104  std::string toString() const;
105 
107  };
108 }
109 
110 #endif // PACKETPP_ETH_DOT3_LAYER
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:233
ether_dot3_header * getEthHeader() const
Definition: EthDot3Layer.h:61
Definition: ProtocolType.h:238
Definition: Layer.h:70
MacAddress getSourceMac() const
Definition: EthDot3Layer.h:67
Definition: Packet.h:26
size_t getHeaderLen() const
Definition: EthDot3Layer.h:97
void setSourceMac(const MacAddress &sourceMac)
Definition: EthDot3Layer.h:73
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:102
MacAddress getDestMac() const
Definition: EthDot3Layer.h:79
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:106
void setDestMac(const MacAddress &destMac)
Definition: EthDot3Layer.h:85
Definition: EthDot3Layer.h:21
Definition: MacAddress.h:27
const ProtocolType EthernetDot3
Definition: ProtocolType.h:223