PcapPlusPlus  19.12
GtpLayer.h
Go to the documentation of this file.
1 #ifndef PACKETPP_GTP_LAYER
2 #define PACKETPP_GTP_LAYER
3 
4 #include "Layer.h"
5 
7 
8 
13 namespace pcpp
14 {
15 
16 #pragma pack(push, 1)
17 
21  struct gtpv1_header
22  {
23 #if (BYTE_ORDER == LITTLE_ENDIAN)
24 
25  uint8_t npduNumberFlag:1,
31  reserved:1,
33  protocolType:1,
35  version:3;
36 #else
37 
38  uint8_t version:3,
40  protocolType:1,
42  reserved:1,
49 #endif
50 
51  uint8_t messageType;
52 
54  uint16_t messageLength;
55 
57  uint32_t teid;
58  };
59 
60 #pragma pack(pop)
61 
67  {
206  };
207 
208 
213  class GtpV1Layer : public Layer
214  {
215  private:
216  struct gtpv1_header_extra
217  {
218  uint16_t sequenceNumber;
219  uint8_t npduNumber;
220  uint8_t nextExtensionHeader;
221  };
222 
223  gtpv1_header_extra* getHeaderExtra() const;
224 
225  void init(GtpV1MessageType messageType, uint32_t teid, bool setSeqNum, uint16_t seqNum, bool setNpduNum, uint8_t npduNum);
226 
227  public:
228 
234  {
235  friend class GtpV1Layer;
236 
237  private:
238  uint8_t* m_Data;
239  size_t m_DataLen;
240  uint8_t m_ExtType;
241 
242  GtpExtension(uint8_t* data, size_t dataLen, uint8_t type);
243 
244  void setNextHeaderType(uint8_t nextHeaderType);
245 
246  static GtpExtension createGtpExtension(uint8_t* data, size_t dataLen, uint8_t extType, uint16_t content);
247 
248  public:
249 
253  GtpExtension();
254 
258  GtpExtension(const GtpExtension& other);
259 
263  GtpExtension& operator=(const GtpExtension& other);
264 
269  bool isNull() const;
270 
274  uint8_t getExtensionType() const;
275 
280  size_t getTotalLength() const;
281 
286  size_t getContentLength() const;
287 
292  uint8_t* getContent() const;
293 
298  uint8_t getNextExtensionHeaderType() const;
299 
306  }; // GtpExtension
307 
308  virtual ~GtpV1Layer() {}
309 
316  GtpV1Layer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol = GTPv1; }
317 
323  GtpV1Layer(GtpV1MessageType messageType, uint32_t teid);
324 
334  GtpV1Layer(GtpV1MessageType messageType, uint32_t teid, bool setSeqNum, uint16_t seqNum, bool setNpduNum, uint8_t npduNum);
335 
342  static bool isGTPv1(const uint8_t* data, size_t dataSize);
343 
347  gtpv1_header* getHeader() const { return (gtpv1_header*)m_Data; }
348 
355  bool getSequenceNumber(uint16_t& seqNumber) const;
356 
362  bool setSequenceNumber(const uint16_t seqNumber);
363 
370  bool getNpduNumber(uint8_t& npduNum) const;
371 
377  bool setNpduNumber(const uint8_t npduNum);
378 
385  bool getNextExtensionHeaderType(uint8_t& nextExtType) const;
386 
391  GtpExtension getNextExtension() const;
392 
402  GtpExtension addExtension(uint8_t extensionType, uint16_t extensionContent);
403 
408 
412  std::string getMessageTypeAsString() const;
413 
417  bool isGTPUMessage() const;
418 
422  bool isGTPCMessage() const;
423 
424 
425  // implement abstract methods
426 
430  void parseNextLayer();
431 
438  size_t getHeaderLen() const;
439 
444  void computeCalculateFields();
445 
446  std::string toString() const;
447 
449  };
450 }
451 
452 #endif //PACKETPP_GTP_LAYER
pcpp::GtpV1Layer::isGTPv1
static bool isGTPv1(const uint8_t *data, size_t dataSize)
pcpp::GtpV1_MBMSSessionUpdateRequest
Definition: GtpLayer.h:191
pcpp::GtpV1_ForwardRelocationCompleteAcknowledge
Definition: GtpLayer.h:145
pcpp::GtpV1_DeletePDPContextRequest
Definition: GtpLayer.h:91
pcpp::OsiModelLayer
OsiModelLayer
Definition: ProtocolType.h:224
pcpp::GtpV1Layer::getNpduNumber
bool getNpduNumber(uint8_t &npduNum) const
pcpp::GtpV1_InitiatePDPContextActivationResponse
Definition: GtpLayer.h:97
pcpp::GtpV1Layer::GtpExtension::GtpExtension
GtpExtension()
pcpp::GtpV1_ForwardRelocationResponse
Definition: GtpLayer.h:135
pcpp::Packet
Definition: Packet.h:26
pcpp::GtpV1_UpdatePDPContextResponse
Definition: GtpLayer.h:89
pcpp::GtpV1_RANInformationRelay
Definition: GtpLayer.h:153
pcpp::GtpV1_NodeAliveResponse
Definition: GtpLayer.h:79
pcpp::GtpV1_EchoResponse
Definition: GtpLayer.h:73
pcpp::GtpV1_MessageTypeUnknown
Definition: GtpLayer.h:69
pcpp::GtpV1_MSInfoChangeResponse
Definition: GtpLayer.h:197
pcpp::GtpV1_UERegistrationRequest
Definition: GtpLayer.h:149
pcpp::GtpV1Layer::getMessageType
GtpV1MessageType getMessageType() const
pcpp::GtpV1Layer::getMessageTypeAsString
std::string getMessageTypeAsString() const
pcpp::GtpV1_SendRoutingforGPRSRequest
Definition: GtpLayer.h:111
pcpp::GtpV1_DeletePDPContextResponse
Definition: GtpLayer.h:93
pcpp::GtpV1_ForwardRelocationComplete
Definition: GtpLayer.h:137
Layer.h
pcpp::gtpv1_header::messageLength
uint16_t messageLength
Definition: GtpLayer.h:54
pcpp::GtpV1_FailureReportResponse
Definition: GtpLayer.h:117
pcpp::GtpV1_RelocationCancelResponse
Definition: GtpLayer.h:141
pcpp::GtpV1_DataRecordTransferResponse
Definition: GtpLayer.h:201
pcpp::GtpV1_MBMSSessionUpdateResponse
Definition: GtpLayer.h:193
pcpp::GtpV1_MBMSNotificationRejectRequest
Definition: GtpLayer.h:159
pcpp::gtpv1_header
Definition: GtpLayer.h:21
pcpp::GtpV1_MBMSSessionStartRequest
Definition: GtpLayer.h:183
pcpp::GtpV1_MBMSNotificationRequest
Definition: GtpLayer.h:155
pcpp::gtpv1_header::messageType
uint8_t messageType
Definition: GtpLayer.h:51
pcpp::GtpV1Layer::GtpExtension::operator=
GtpExtension & operator=(const GtpExtension &other)
pcpp::GtpV1_SGSNContextRequest
Definition: GtpLayer.h:127
pcpp::GtpV1_CreateMBMSNotificationResponse
Definition: GtpLayer.h:165
pcpp::GtpV1_DataRecordTransferRequest
Definition: GtpLayer.h:199
pcpp::GtpV1Layer::addExtension
GtpExtension addExtension(uint8_t extensionType, uint16_t extensionContent)
pcpp::GtpV1_PDUNotificationRejectRequest
Definition: GtpLayer.h:105
pcpp::GtpV1_UpdateMBMSNotificationRequest
Definition: GtpLayer.h:167
pcpp::GtpV1_MBMSRegistrationRequest
Definition: GtpLayer.h:175
pcpp::GtpV1_CreatePDPContextResponse
Definition: GtpLayer.h:85
pcpp::GtpV1Layer::GtpExtension::isNull
bool isNull() const
pcpp::GtpV1Layer::GtpExtension::getContentLength
size_t getContentLength() const
pcpp::GtpV1_EndMarker
Definition: GtpLayer.h:203
pcpp::GtpV1Layer::GtpExtension::getExtensionType
uint8_t getExtensionType() const
pcpp::GtpV1_VersionNotSupported
Definition: GtpLayer.h:75
pcpp::GtpV1_RedirectionRequest
Definition: GtpLayer.h:81
pcpp::GtpV1_DeleteMBMSNotificationResponse
Definition: GtpLayer.h:173
pcpp::GtpV1_ErrorIndication
Definition: GtpLayer.h:99
pcpp::gtpv1_header::version
uint8_t version
Definition: GtpLayer.h:25
pcpp::GtpV1_MBMSSessionStopRequest
Definition: GtpLayer.h:187
pcpp::gtpv1_header::reserved
uint8_t reserved
Definition: GtpLayer.h:25
pcpp::GtpV1_CreateMBMSNotificationRequest
Definition: GtpLayer.h:163
pcpp::GtpV1Layer::GtpV1Layer
GtpV1Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: GtpLayer.h:316
pcpp::GtpV1Layer::setSequenceNumber
bool setSequenceNumber(const uint16_t seqNumber)
pcpp::GtpV1_IdentificationRequest
Definition: GtpLayer.h:123
pcpp::GtpV1_MBMSSessionStopResponse
Definition: GtpLayer.h:189
pcpp::GtpV1_GPDU
Definition: GtpLayer.h:205
pcpp::GtpV1Layer::parseNextLayer
void parseNextLayer()
pcpp::GtpV1Layer::getNextExtensionHeaderType
bool getNextExtensionHeaderType(uint8_t &nextExtType) const
pcpp::GtpV1MessageType
GtpV1MessageType
Definition: GtpLayer.h:66
pcpp::gtpv1_header::extensionHeaderFlag
uint8_t extensionHeaderFlag
Definition: GtpLayer.h:25
pcpp::GtpV1_FailureReportRequest
Definition: GtpLayer.h:115
pcpp::GtpV1_PDUNotificationResponse
Definition: GtpLayer.h:103
pcpp::GtpV1Layer::getHeaderLen
size_t getHeaderLen() const
pcpp::GtpV1Layer::getOsiModelLayer
OsiModelLayer getOsiModelLayer() const
Definition: GtpLayer.h:448
pcpp::GtpV1_ForwardSRNSContextAcknowledge
Definition: GtpLayer.h:147
pcpp::GtpV1_UERegistrationResponse
Definition: GtpLayer.h:151
pcpp::GtpV1_SupportedExtensionsHeaderNotification
Definition: GtpLayer.h:109
pcpp::GtpV1_MBMSDeRegistrationResponse
Definition: GtpLayer.h:181
pcpp::GtpV1Layer::GtpExtension::getNextExtensionHeaderType
uint8_t getNextExtensionHeaderType() const
pcpp::GtpV1Layer::setNpduNumber
bool setNpduNumber(const uint8_t npduNum)
pcpp::gtpv1_header::npduNumberFlag
uint8_t npduNumberFlag
Definition: GtpLayer.h:25
pcpp::GtpV1_UpdateMBMSNotificationResponse
Definition: GtpLayer.h:169
pcpp::GtpV1_NoteMSPresentRequest
Definition: GtpLayer.h:119
pcpp::GtpV1_RelocationCancelRequest
Definition: GtpLayer.h:139
pcpp::GtpV1Layer::GtpExtension::getTotalLength
size_t getTotalLength() const
pcpp::GtpV1_MBMSNotificationResponse
Definition: GtpLayer.h:157
pcpp::OsiModelTransportLayer
Definition: ProtocolType.h:233
pcpp::GtpV1_DeleteMBMSNotificationRequest
Definition: GtpLayer.h:171
pcpp::GtpV1Layer
Definition: GtpLayer.h:213
pcpp::gtpv1_header::teid
uint32_t teid
Definition: GtpLayer.h:57
pcpp::GtpV1_NodeAliveRequest
Definition: GtpLayer.h:77
pcpp::GtpV1_MSInfoChangeRequest
Definition: GtpLayer.h:195
pcpp::GtpV1_MBMSSessionStartResponse
Definition: GtpLayer.h:185
pcpp::GtpV1_UpdatePDPContextRequest
Definition: GtpLayer.h:87
pcpp::GtpV1Layer::GtpExtension::getNextExtension
GtpExtension getNextExtension() const
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::GtpV1_PDUNotificationRejectResponse
Definition: GtpLayer.h:107
pcpp::GtpV1Layer::isGTPUMessage
bool isGTPUMessage() const
pcpp::GtpV1_MBMSDeRegistrationRequest
Definition: GtpLayer.h:179
pcpp::GtpV1_PDUNotificationRequest
Definition: GtpLayer.h:101
pcpp::GtpV1_InitiatePDPContextActivationRequest
Definition: GtpLayer.h:95
pcpp::Layer
Definition: Layer.h:70
pcpp::GtpV1Layer::toString
std::string toString() const
pcpp::GtpV1_SGSNContextResponse
Definition: GtpLayer.h:129
pcpp::GtpV1Layer::getNextExtension
GtpExtension getNextExtension() const
pcpp::GtpV1_CreatePDPContextRequest
Definition: GtpLayer.h:83
pcpp::GtpV1_MBMSNotificationRejectResponse
Definition: GtpLayer.h:161
pcpp::GtpV1_MBMSRegistrationResponse
Definition: GtpLayer.h:177
pcpp::GtpV1Layer::isGTPCMessage
bool isGTPCMessage() const
pcpp::GtpV1Layer::getSequenceNumber
bool getSequenceNumber(uint16_t &seqNumber) const
pcpp::GtpV1Layer::computeCalculateFields
void computeCalculateFields()
pcpp::GtpV1Layer::GtpExtension::getContent
uint8_t * getContent() const
pcpp::gtpv1_header::sequenceNumberFlag
uint8_t sequenceNumberFlag
Definition: GtpLayer.h:25
pcpp::GtpV1_SendRoutingforGPRSResponse
Definition: GtpLayer.h:113
pcpp::GtpV1_IdentificationResponse
Definition: GtpLayer.h:125
pcpp::GtpV1Layer::getHeader
gtpv1_header * getHeader() const
Definition: GtpLayer.h:347
pcpp::GtpV1_SGSNContextAcknowledge
Definition: GtpLayer.h:131
pcpp::GtpV1_ForwardSRNSContext
Definition: GtpLayer.h:143
pcpp::GtpV1_NoteMSPresentResponse
Definition: GtpLayer.h:121
pcpp::GtpV1Layer::GtpExtension
Definition: GtpLayer.h:233
pcpp::GtpV1_ForwardRelocationRequest
Definition: GtpLayer.h:133
pcpp::GtpV1_EchoRequest
Definition: GtpLayer.h:71
pcpp::GTPv1
Definition: ProtocolType.h:211
pcpp::gtpv1_header::protocolType
uint8_t protocolType
Definition: GtpLayer.h:25