PcapPlusPlus  24.09
EthDot3Layer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Layer.h"
4 #include "MacAddress.h"
5 
7 
12 namespace pcpp
13 {
14 
19 #pragma pack(push, 1)
21  {
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:
44  EthDot3Layer(uint8_t* data, size_t dataLen, Packet* packet)
45  : Layer(data, dataLen, nullptr, packet, EthernetDot3)
46  {}
47 
55  EthDot3Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
56  : Layer(data, dataLen, prevLayer, packet, EthernetDot3)
57  {}
58 
65  EthDot3Layer(const MacAddress& sourceMac, const MacAddress& destMac, uint16_t length);
66 
67  ~EthDot3Layer()
68  {}
69 
76  {
77  return (ether_dot3_header*)m_Data;
78  }
79 
85  {
86  return MacAddress(getEthHeader()->srcMac);
87  }
88 
93  void setSourceMac(const MacAddress& sourceMac)
94  {
95  sourceMac.copyTo(getEthHeader()->srcMac);
96  }
97 
103  {
104  return MacAddress(getEthHeader()->dstMac);
105  }
106 
111  void setDestMac(const MacAddress& destMac)
112  {
113  destMac.copyTo(getEthHeader()->dstMac);
114  }
115 
116  // implement abstract methods
117 
122 
126  size_t getHeaderLen() const
127  {
128  return sizeof(ether_dot3_header);
129  }
130 
135  {}
136 
137  std::string toString() const;
138 
140  {
141  return OsiModelDataLinkLayer;
142  }
143 
150  static bool isDataValid(const uint8_t* data, size_t dataLen);
151  };
152 
153 } // namespace pcpp
Definition: EthDot3Layer.h:36
void computeCalculateFields()
Definition: EthDot3Layer.h:134
EthDot3Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: EthDot3Layer.h:55
size_t getHeaderLen() const
Definition: EthDot3Layer.h:126
std::string toString() const
void setDestMac(const MacAddress &destMac)
Definition: EthDot3Layer.h:111
MacAddress getSourceMac() const
Definition: EthDot3Layer.h:84
EthDot3Layer(uint8_t *data, size_t dataLen, Packet *packet)
Definition: EthDot3Layer.h:44
MacAddress getDestMac() const
Definition: EthDot3Layer.h:102
static bool isDataValid(const uint8_t *data, size_t dataLen)
EthDot3Layer(const MacAddress &sourceMac, const MacAddress &destMac, uint16_t length)
void setSourceMac(const MacAddress &sourceMac)
Definition: EthDot3Layer.h:93
OsiModelLayer getOsiModelLayer() const
Definition: EthDot3Layer.h:139
ether_dot3_header * getEthHeader() const
Definition: EthDot3Layer.h:75
Definition: Layer.h:70
Definition: MacAddress.h:25
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:152
Definition: Packet.h:27
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelDataLinkLayer
Definition: ProtocolType.h:358
const ProtocolType EthernetDot3
Definition: ProtocolType.h:228
Definition: EthDot3Layer.h:21
uint16_t length
Definition: EthDot3Layer.h:27
uint8_t srcMac[6]
Definition: EthDot3Layer.h:25
uint8_t dstMac[6]
Definition: EthDot3Layer.h:23