PcapPlusPlus  24.09
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  virtual ~CotpLayer()
50  {}
51 
55  uint8_t getLength() const;
56 
60  uint8_t getPduType() const;
61 
65  uint8_t getTpduNumber() const;
66 
70  size_t getHeaderLen() const override
71  {
72  return sizeof(cotphdr);
73  }
74 
79  void setLength(uint8_t length) const;
80 
85  void setPduType(uint8_t pduType) const;
86 
91  void setTpduNumber(uint8_t tpduNumber) const;
92 
96  void computeCalculateFields() override
97  {}
98 
102  void parseNextLayer() override;
103 
110  static bool isDataValid(const uint8_t* data, size_t dataSize);
111 
112  std::string toString() const override;
113 
115  {
116  return OsiModelTransportLayer;
117  }
118 
119  private:
120  cotphdr* getCotpHeader() const
121  {
122  return (cotphdr*)m_Data;
123  }
124  };
125 
126 } // namespace pcpp
Definition: CotpLayer.h:30
uint8_t getTpduNumber() const
CotpLayer(uint8_t tpduNumber)
size_t getHeaderLen() const override
Definition: CotpLayer.h:70
uint8_t getPduType() const
OsiModelLayer getOsiModelLayer() const override
Definition: CotpLayer.h:114
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:96
Definition: Layer.h:70
Definition: Packet.h:27
The main namespace for the PcapPlusPlus lib.
const ProtocolType COTP
Definition: ProtocolType.h:328
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelTransportLayer
Definition: ProtocolType.h:362
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