PcapPlusPlus  Next
CotpLayer.h
1 #pragma once
2 
3 #include "EthLayer.h"
4 #include "Layer.h"
5 
6 namespace pcpp
7 {
8 
13 #pragma pack(push, 1)
14  typedef struct
15  {
17  uint8_t length;
19  uint8_t pduType;
21  uint8_t tpduNumber;
22  } cotphdr;
23 #pragma pack(pop)
24 
29  class CotpLayer : public Layer
30  {
31  public:
39  CotpLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
40  : Layer(data, dataLen, prevLayer, packet, COTP)
41  {}
42 
47  explicit CotpLayer(uint8_t tpduNumber);
48 
49  ~CotpLayer() override = default;
50 
54  uint8_t getLength() const;
55 
59  uint8_t getPduType() const;
60 
64  uint8_t getTpduNumber() const;
65 
69  size_t getHeaderLen() const override
70  {
71  return sizeof(cotphdr);
72  }
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  {}
97 
101  void parseNextLayer() override;
102 
109  static bool isDataValid(const uint8_t* data, size_t dataSize);
110 
111  std::string toString() const override;
112 
114  {
115  return OsiModelTransportLayer;
116  }
117 
118  private:
119  cotphdr* getCotpHeader() const
120  {
121  return reinterpret_cast<cotphdr*>(m_Data);
122  }
123  };
124 
125 } // namespace pcpp
Definition: CotpLayer.h:30
uint8_t getTpduNumber() const
CotpLayer(uint8_t tpduNumber)
size_t getHeaderLen() const override
Definition: CotpLayer.h:69
uint8_t getPduType() const
OsiModelLayer getOsiModelLayer() const override
Definition: CotpLayer.h:113
uint8_t getLength() const
void setPduType(uint8_t pduType) const
CotpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: CotpLayer.h:39
std::string toString() const override
void setLength(uint8_t length) const
void setTpduNumber(uint8_t tpduNumber) const
void parseNextLayer() override
static bool isDataValid(const uint8_t *data, size_t dataSize)
void computeCalculateFields() override
Definition: CotpLayer.h:95
Definition: Layer.h:69
Definition: Packet.h:27
The main namespace for the PcapPlusPlus lib.
const ProtocolType COTP
Definition: ProtocolType.h:328
OsiModelLayer
Definition: ProtocolType.h:364
@ OsiModelTransportLayer
Definition: ProtocolType.h:372
Definition: CotpLayer.h:15
uint8_t tpduNumber
Definition: CotpLayer.h:21
uint8_t length
Definition: CotpLayer.h:17
uint8_t pduType
Definition: CotpLayer.h:19