PcapPlusPlus  23.09
CotpLayer.h
1 #ifndef PCAPPLUSPLUS_COTPLAYER_H
2 #define PCAPPLUSPLUS_COTPLAYER_H
3 
4 #include "EthLayer.h"
5 #include "Layer.h"
6 
7 namespace pcpp
8 {
9 
14 #pragma pack(push, 1)
15  typedef struct
16  {
18  uint8_t length;
20  uint8_t pduType ;
22  uint8_t tpduNumber;
23  } cotphdr;
24 #pragma pack(pop)
25 
30  class CotpLayer : public Layer
31  {
32  public:
40  CotpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
41  : Layer(data, dataLen, prevLayer, packet)
42  {
43  m_Protocol = COTP;
44  }
45 
50  explicit CotpLayer(uint8_t tpduNumber);
51 
52  virtual ~CotpLayer() {}
53 
57  uint8_t getLength() const;
58 
62  uint8_t getPduType() const;
63 
67  uint8_t getTpduNumber() const;
68 
72  size_t getHeaderLen() const override { return sizeof(cotphdr); }
73 
78  void setLength(uint8_t length) const;
79 
84  void setPduType(uint8_t pduType) const;
85 
90  void setTpduNumber(uint8_t tpduNumber) const;
91 
95  void computeCalculateFields() override {}
96 
100  void parseNextLayer() override;
101 
108  static bool isDataValid(const uint8_t *data, size_t dataSize);
109 
110  std::string toString() const override;
111 
113 
114  private:
115  cotphdr *getCotpHeader() const { return (cotphdr *)m_Data; }
116  };
117 
118 } // namespace pcpp
119 
120 #endif // PCAPPLUSPLUS_COTPLAYER_H
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
Definition: Layer.h:70
size_t getHeaderLen() const override
Definition: CotpLayer.h:72
Definition: Packet.h:26
const ProtocolType COTP
Definition: ProtocolType.h:323
uint8_t getTpduNumber() const
std::string toString() const override
Definition: CotpLayer.h:15
void setLength(uint8_t length) const
OsiModelLayer getOsiModelLayer() const override
Definition: CotpLayer.h:112
uint8_t getLength() const
uint8_t pduType
Definition: CotpLayer.h:20
Definition: ProtocolType.h:342
static bool isDataValid(const uint8_t *data, size_t dataSize)
CotpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: CotpLayer.h:40
void setPduType(uint8_t pduType) const
void parseNextLayer() override
uint8_t getPduType() const
void computeCalculateFields() override
Definition: CotpLayer.h:95
uint8_t tpduNumber
Definition: CotpLayer.h:22
Definition: CotpLayer.h:30
uint8_t length
Definition: CotpLayer.h:18
void setTpduNumber(uint8_t tpduNumber) const