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
pcpp::EthDot3Layer::parseNextLayer
void parseNextLayer()
pcpp::OsiModelLayer
OsiModelLayer
Definition: ProtocolType.h:233
pcpp::EthDot3Layer::getSourceMac
MacAddress getSourceMac() const
Definition: EthDot3Layer.h:67
pcpp::Packet
Definition: Packet.h:26
pcpp::OsiModelDataLinkLayer
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:238
pcpp::EthDot3Layer::setSourceMac
void setSourceMac(const MacAddress &sourceMac)
Definition: EthDot3Layer.h:73
Layer.h
pcpp::EthDot3Layer::getEthHeader
ether_dot3_header * getEthHeader() const
Definition: EthDot3Layer.h:61
MacAddress.h
pcpp::ether_dot3_header::srcMac
uint8_t srcMac[6]
Definition: EthDot3Layer.h:25
pcpp::EthDot3Layer
Definition: EthDot3Layer.h:35
pcpp::MacAddress::copyTo
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:143
pcpp::MacAddress
Definition: MacAddress.h:27
pcpp::EthDot3Layer::getHeaderLen
size_t getHeaderLen() const
Definition: EthDot3Layer.h:97
pcpp::EthDot3Layer::EthDot3Layer
EthDot3Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: EthDot3Layer.h:45
pcpp::EthDot3Layer::getDestMac
MacAddress getDestMac() const
Definition: EthDot3Layer.h:79
pcpp::ether_dot3_header::dstMac
uint8_t dstMac[6]
Definition: EthDot3Layer.h:23
pcpp::EthDot3Layer::computeCalculateFields
void computeCalculateFields()
Definition: EthDot3Layer.h:102
pcpp::EthDot3Layer::toString
std::string toString() const
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::ether_dot3_header
Definition: EthDot3Layer.h:21
pcpp::Layer
Definition: Layer.h:70
pcpp::EthDot3Layer::setDestMac
void setDestMac(const MacAddress &destMac)
Definition: EthDot3Layer.h:85
pcpp::EthDot3Layer::getOsiModelLayer
OsiModelLayer getOsiModelLayer() const
Definition: EthDot3Layer.h:106
pcpp::ether_dot3_header::length
uint16_t length
Definition: EthDot3Layer.h:27
pcpp::EthernetDot3
const ProtocolType EthernetDot3
Definition: ProtocolType.h:223