20 #if (BYTE_ORDER == LITTLE_ENDIAN)
59 static_assert(
sizeof(
gtpv1_header) == 8,
"gtpv1_header size is not 8 bytes");
211 struct gtpv1_header_extra
213 uint16_t sequenceNumber;
215 uint8_t nextExtensionHeader;
218 gtpv1_header_extra* getHeaderExtra()
const;
220 void init(
GtpV1MessageType messageType, uint32_t teid,
bool setSeqNum, uint16_t seqNum,
bool setNpduNum,
235 GtpExtension(uint8_t* data,
size_t dataLen, uint8_t type);
237 void setNextHeaderType(uint8_t nextHeaderType);
239 static GtpExtension createGtpExtension(uint8_t* data,
size_t dataLen, uint8_t extType, uint16_t content);
291 :
Layer(data, dataLen, prevLayer, packet,
GTPv1)
317 static bool isGTPv1(
const uint8_t* data,
size_t dataSize);
388 return port == 2152 || port == 2123 ;
608 constexpr
operator Value()
const
614 explicit operator bool()
const =
delete;
933 size_t getValueOffset()
const override
935 return sizeof(uint8_t);
956 const std::bitset<4>& instance,
const std::vector<uint8_t>& infoElementValue);
963 std::bitset<4> m_CRFlag;
964 std::bitset<4> m_Instance;
980 :
Layer(data, dataLen, prevLayer, packet,
GTPv2)
1118 #pragma pack(push, 1)
1119 struct gtpv2_basic_header
1121 #if (BYTE_ORDER == LITTLE_ENDIAN)
1122 uint8_t unused : 2, messagePriorityPresent : 1, teidPresent : 1, piggybacking : 1, version : 3;
1124 uint8_t version : 3, piggybacking : 1, teidPresent : 1, messagePriorityPresent : 1, unused : 2;
1126 uint8_t messageType;
1127 uint16_t messageLength;
1131 TLVRecordReader<GtpV2InformationElement> m_IEReader;
1133 gtpv2_basic_header* getHeader()
const
1135 return reinterpret_cast<gtpv2_basic_header*
>(m_Data);
1138 uint8_t* getIEBasePtr()
const;
1140 GtpV2InformationElement addInformationElementAt(
const GtpV2InformationElementBuilder& infoElementBuilder,
Definition: GtpLayer.h:227
uint8_t getNextExtensionHeaderType() const
GtpExtension & operator=(const GtpExtension &other)
uint8_t getExtensionType() const
GtpExtension(const GtpExtension &other)
size_t getContentLength() const
GtpExtension()
An empty c'tor that creates an empty object, meaning one that isNull() returns "true")
size_t getTotalLength() const
uint8_t * getContent() const
GtpExtension getNextExtension() const
Definition: GtpLayer.h:209
bool setSequenceNumber(uint16_t seqNumber)
bool isGTPCMessage() const
std::string toString() const override
bool getSequenceNumber(uint16_t &seqNumber) const
bool isGTPUMessage() const
GtpV1Layer(GtpV1MessageType messageType, uint32_t teid)
void computeCalculateFields() override
bool setNpduNumber(uint8_t npduNum)
OsiModelLayer getOsiModelLayer() const override
Definition: GtpLayer.h:408
GtpV1MessageType getMessageType() const
GtpExtension addExtension(uint8_t extensionType, uint16_t extensionContent)
GtpV1Layer(GtpV1MessageType messageType, uint32_t teid, bool setSeqNum, uint16_t seqNum, bool setNpduNum, uint8_t npduNum)
GtpExtension getNextExtension() const
void parseNextLayer() override
Identifies the following next layers for GTP-U packets: IPv4Layer, IPv6Layer. Otherwise sets PayloadL...
gtpv1_header * getHeader() const
Definition: GtpLayer.h:321
bool getNextExtensionHeaderType(uint8_t &nextExtType) const
static bool isGTPv1Port(uint16_t port)
Definition: GtpLayer.h:386
static bool isGTPv1(const uint8_t *data, size_t dataSize)
GtpV1Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: GtpLayer.h:290
std::string getMessageTypeAsString() const
size_t getHeaderLen() const override
bool getNpduNumber(uint8_t &npduNum) const
Definition: GtpLayer.h:970
OsiModelLayer getOsiModelLayer() const override
Definition: GtpLayer.h:1112
void setSequenceNumber(uint32_t sequenceNumber)
uint16_t getMessageLength() const
void unsetMessagePriority()
Unset Message Priority if exists in the layer (otherwise does nothing)
GtpV2Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: GtpLayer.h:979
static bool isDataValid(const uint8_t *data, size_t dataSize)
void setMessageType(const GtpV2MessageType &type)
void setTeid(uint32_t teid)
GtpV2InformationElement getFirstInformationElement() const
std::string toString() const override
GtpV2InformationElement addInformationElementAfter(const GtpV2InformationElementBuilder &infoElementBuilder, GtpV2InformationElement::Type infoElementType)
void parseNextLayer() override
Identifies if the next layer is GTPv2 piggyback. Otherwise sets PayloadLayer.
size_t getHeaderLen() const override
size_t getInformationElementCount() const
void unsetTeid()
Unset Tunnel Endpoint Identifier (TEID) if exists in the layer (otherwise does nothing)
std::pair< bool, uint8_t > getMessagePriority() const
void computeCalculateFields() override
Computes the piggybacking flag by checking if the next layer is also a GTPv2 message.
GtpV2MessageType getMessageType() const
bool isPiggybacking() const
GtpV2InformationElement getInformationElement(GtpV2InformationElement::Type infoElementType) const
uint32_t getSequenceNumber() const
static bool isGTPv2Port(uint16_t port)
Definition: GtpLayer.h:996
bool removeAllInformationElements()
GtpV2Layer(GtpV2MessageType messageType, uint32_t sequenceNumber, bool setTeid=false, uint32_t teid=0, bool setMessagePriority=false, std::bitset< 4 > messagePriority=0)
GtpV2InformationElement getNextInformationElement(GtpV2InformationElement infoElement) const
bool removeInformationElement(GtpV2InformationElement::Type infoElementType)
std::pair< bool, uint32_t > getTeid() const
void setMessagePriority(const std::bitset< 4 > &messagePriority)
GtpV2InformationElement addInformationElement(const GtpV2InformationElementBuilder &infoElementBuilder)
Definition: GtpLayer.h:417
Value
Define enum types and the corresponding int values.
Definition: GtpLayer.h:421
@ EchoResponse
Echo Response message.
Definition: GtpLayer.h:427
@ CreateForwardingRequest
Create Forwarding Request message.
Definition: GtpLayer.h:537
@ DeleteBearerFailure
Delete Bearer Failure message.
Definition: GtpLayer.h:457
@ MMBSSessionUpdateRequest
MMBS Session Update Request message.
Definition: GtpLayer.h:581
@ ContextAcknowledge
Context Acknowledge message.
Definition: GtpLayer.h:499
@ PGWDownlinkNotification
PGW Downlink Notification message.
Definition: GtpLayer.h:487
@ SuspendAcknowledge
Suspend Acknowledge message.
Definition: GtpLayer.h:543
@ RemoteUEReportAcknowledge
Remote UE Report Acknowledge message.
Definition: GtpLayer.h:449
@ CreateBearerRequest
Create Bearer Request message.
Definition: GtpLayer.h:471
@ MMBSSessionStartRequest
MMBS Session Start Request message.
Definition: GtpLayer.h:577
@ CreateIndirectDataTunnelRequest
Create Indirect Data Tunnel Request message.
Definition: GtpLayer.h:549
@ ForwardRelocationRequest
Forward Relocation Request message.
Definition: GtpLayer.h:501
@ CreateForwardingResponse
Create Forwarding Response message.
Definition: GtpLayer.h:539
@ DownlinkDataNotification
Downlink Data Notification message.
Definition: GtpLayer.h:561
@ CreateSessionResponse
Create Session Response message.
Definition: GtpLayer.h:433
@ UpdatePDNConnectionRequest
Update PDN Connection Request message.
Definition: GtpLayer.h:569
@ UpdateBearerRequest
Update Bearer Request message.
Definition: GtpLayer.h:475
@ DeleteBearerResponse
Delete Bearer Response message.
Definition: GtpLayer.h:481
@ DeleteBearerCommand
Delete Bearer Command message.
Definition: GtpLayer.h:455
@ ForwardAccessNotification
Forward Access Notification message.
Definition: GtpLayer.h:509
@ PGWRestartNotification
PGW Restart Notification message.
Definition: GtpLayer.h:565
@ PGWDownlinkAcknowledge
PGW Downlink Acknowledge message.
Definition: GtpLayer.h:489
@ IdentificationRequest
Identification Request message.
Definition: GtpLayer.h:491
@ DetachNotification
Detach Notification message.
Definition: GtpLayer.h:519
@ ChangeNotificationRequest
Change Notification Request message.
Definition: GtpLayer.h:443
@ DeleteSessionResponse
Delete Session Response message.
Definition: GtpLayer.h:441
@ TraceSessionActivation
Trace Session Activation message.
Definition: GtpLayer.h:465
@ ModifyAccessBearersResponse
Modify Access Bearers Response message.
Definition: GtpLayer.h:575
@ ReleaseAccessBearersResponse
Release Access Bearers Response message.
Definition: GtpLayer.h:559
@ BearerResourceCommand
Bearer Resource Command message.
Definition: GtpLayer.h:459
@ ContextRequest
Context Request message.
Definition: GtpLayer.h:495
@ BearerResourceFailure
Bearer Resource Failure message.
Definition: GtpLayer.h:461
@ Unknown
Unknown message.
Definition: GtpLayer.h:423
@ UpdatePDNConnectionResponse
Update PDN Connection Response message.
Definition: GtpLayer.h:571
@ RANInformationRelay
RAN Information Relay message.
Definition: GtpLayer.h:525
@ ReleaseAccessBearersRequest
Release Access Bearers Request message.
Definition: GtpLayer.h:557
@ IdentificationResponse
Identification Response message.
Definition: GtpLayer.h:493
@ RemoteUEReportNotifications
Remote UE Report Notifications message.
Definition: GtpLayer.h:447
@ TraceSessionDeactivation
Trace Session Deactivation message.
Definition: GtpLayer.h:467
@ DeleteIndirectDataTunnelRequest
Delete Indirect Data Tunnel Request message.
Definition: GtpLayer.h:553
@ RelocationCancelRequest
Relocation Cancel Request message.
Definition: GtpLayer.h:513
@ DownlinkDataAcknowledge
Downlink Data Acknowledge message.
Definition: GtpLayer.h:563
@ ModifyBearerFailure
Modify Bearer Failure message.
Definition: GtpLayer.h:453
@ DeletePDNRequest
Delete PDN Request message.
Definition: GtpLayer.h:483
@ VersionNotSupported
Version Not Supported message.
Definition: GtpLayer.h:429
@ ForwardRelocationNotification
Forward Relocation Notification message.
Definition: GtpLayer.h:505
@ CreateBearerResponse
Create Bearer Response message.
Definition: GtpLayer.h:473
@ StopPagingIndication
Stop Paging Indication message.
Definition: GtpLayer.h:469
@ DeleteSessionRequest
Delete Session Request message.
Definition: GtpLayer.h:439
@ SuspendNotification
Suspend Notification message.
Definition: GtpLayer.h:541
@ ForwardRelocationResponse
Forward Relocation Response message.
Definition: GtpLayer.h:503
@ DeletePDNResponse
Delete PDN Response message.
Definition: GtpLayer.h:485
@ ModifyBearerResponse
Modify Bearer Response message.
Definition: GtpLayer.h:437
@ RelocationCancelResponse
Relocation Cancel Response message.
Definition: GtpLayer.h:515
@ MMBSSessionStopResponse
MMBS Session Stop Response message.
Definition: GtpLayer.h:587
@ PGWRestartAcknowledge
PGW Restart Acknowledge message.
Definition: GtpLayer.h:567
@ ContextResponse
Context Response message.
Definition: GtpLayer.h:497
@ MMBSSessionStartResponse
MMBS Session Start Response message.
Definition: GtpLayer.h:579
@ ResumeAcknowledge
Resume Acknowledge message.
Definition: GtpLayer.h:547
@ ModifyBearerRequest
Modify Bearer Request message.
Definition: GtpLayer.h:435
@ AlertMMENotification
Alert MME Notification message.
Definition: GtpLayer.h:527
@ ModifyAccessBearersRequest
Modify Access Bearers Request message.
Definition: GtpLayer.h:573
@ MMBSSessionStopRequest
MMBS Session Stop Request message.
Definition: GtpLayer.h:585
@ ForwardRelocationAcknowledge
Forward Relocation Acknowledge message.
Definition: GtpLayer.h:507
@ EchoRequest
Echo Request message.
Definition: GtpLayer.h:425
@ MMBSSessionUpdateResponse
MMBS Session Update Response message.
Definition: GtpLayer.h:583
@ UEActivityAcknowledge
UE Activity Acknowledge message.
Definition: GtpLayer.h:533
@ ConfigurationTransferTunnel
Configuration Transfer Tunnel message.
Definition: GtpLayer.h:517
@ DetachAcknowledge
Detach Acknowledge message.
Definition: GtpLayer.h:521
@ ChangeNotificationResponse
Change Notification Response message.
Definition: GtpLayer.h:445
@ UEActivityNotification
UE Activity Notification message.
Definition: GtpLayer.h:531
@ DownlinkDataNotificationFailure
Downlink Data Notification Failure message.
Definition: GtpLayer.h:463
@ ModifyBearerCommand
Modify Bearer Command message.
Definition: GtpLayer.h:451
@ CreateIndirectDataTunnelResponse
Create Indirect Data Tunnel Response message.
Definition: GtpLayer.h:551
@ ISRStatus
ISR Status message.
Definition: GtpLayer.h:535
@ UpdateBearerResponse
Update Bearer Response message.
Definition: GtpLayer.h:477
@ ResumeNotification
Resume Notification message.
Definition: GtpLayer.h:545
@ CSPaging
CS Paging message.
Definition: GtpLayer.h:523
@ DeleteBearerRequest
Delete Bearer Request message.
Definition: GtpLayer.h:479
@ ForwardAccessAcknowledge
Forward Access Acknowledge message.
Definition: GtpLayer.h:511
@ DeleteIndirectDataTunnelResponse
Delete Indirect Data Tunnel Response message.
Definition: GtpLayer.h:555
@ CreateSessionRequest
Create Session Request message.
Definition: GtpLayer.h:431
@ AlertMMEAcknowledge
Alert MME Acknowledge message.
Definition: GtpLayer.h:529
std::string toString() const
constexpr GtpV2MessageType(Value value)
Definition: GtpLayer.h:595
static GtpV2MessageType fromUintValue(uint8_t value)
Definition: TLVData.h:357
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelTransportLayer
Transport layer (layer 4)
Definition: ProtocolType.h:233
const ProtocolType GTPv1
GTPv1 protocol.
Definition: ProtocolType.h:134
const ProtocolType GTPv2
GTPv2 protocol.
Definition: ProtocolType.h:218
GtpV1MessageType
Definition: GtpLayer.h:65
@ GtpV1_MessageTypeUnknown
GTPv1 Message Type Unknown.
Definition: GtpLayer.h:67
@ GtpV1_MBMSNotificationResponse
MBMS Notification Response.
Definition: GtpLayer.h:155
@ GtpV1_DeletePDPContextResponse
Delete PDP Context Response.
Definition: GtpLayer.h:91
@ GtpV1_InitiatePDPContextActivationResponse
Initiate PDP Context Activation Response.
Definition: GtpLayer.h:95
@ GtpV1_RANInformationRelay
RAN Information Relay.
Definition: GtpLayer.h:151
@ GtpV1_MBMSSessionStopRequest
MBMS Session Stop Request.
Definition: GtpLayer.h:185
@ GtpV1_MBMSSessionUpdateRequest
MBMS Session Update Request.
Definition: GtpLayer.h:189
@ GtpV1_SupportedExtensionsHeaderNotification
Supported Extensions Header Notification.
Definition: GtpLayer.h:107
@ GtpV1_PDUNotificationRejectRequest
PDU Notification Reject Request.
Definition: GtpLayer.h:103
@ GtpV1_GPDU
G-PDU.
Definition: GtpLayer.h:203
@ GtpV1_MBMSSessionUpdateResponse
MBMS Session Update Response.
Definition: GtpLayer.h:191
@ GtpV1_DeletePDPContextRequest
Delete PDP Context Request.
Definition: GtpLayer.h:89
@ GtpV1_InitiatePDPContextActivationRequest
Initiate PDP Context Activation Request.
Definition: GtpLayer.h:93
@ GtpV1_PDUNotificationRequest
PDU Notification Request.
Definition: GtpLayer.h:99
@ GtpV1_EchoRequest
Echo Request.
Definition: GtpLayer.h:69
@ GtpV1_ForwardRelocationComplete
Forward Relocation Complete.
Definition: GtpLayer.h:135
@ GtpV1_MBMSRegistrationRequest
MBMS Registration Request.
Definition: GtpLayer.h:173
@ GtpV1_MBMSNotificationRejectRequest
MBMS Notification Reject Request.
Definition: GtpLayer.h:157
@ GtpV1_SGSNContextAcknowledge
SGSN Context Acknowledge.
Definition: GtpLayer.h:129
@ GtpV1_MBMSSessionStartRequest
MBMS Session Start Request.
Definition: GtpLayer.h:181
@ GtpV1_DeleteMBMSNotificationRequest
Delete MBMS Notification Request.
Definition: GtpLayer.h:169
@ GtpV1_ForwardRelocationResponse
Forward Relocation Response.
Definition: GtpLayer.h:133
@ GtpV1_NodeAliveResponse
Node Alive Response.
Definition: GtpLayer.h:77
@ GtpV1_UERegistrationRequest
UE Registration Request.
Definition: GtpLayer.h:147
@ GtpV1_ForwardSRNSContextAcknowledge
Forward SRNS Context Acknowledge.
Definition: GtpLayer.h:145
@ GtpV1_MBMSNotificationRejectResponse
MBMS Notification Reject Response.
Definition: GtpLayer.h:159
@ GtpV1_UERegistrationResponse
UE Registration Response.
Definition: GtpLayer.h:149
@ GtpV1_CreatePDPContextResponse
Create PDP Context Response.
Definition: GtpLayer.h:83
@ GtpV1_FailureReportResponse
Failure Report Response.
Definition: GtpLayer.h:115
@ GtpV1_NoteMSPresentResponse
Note MS Present Response.
Definition: GtpLayer.h:119
@ GtpV1_IdentificationRequest
Identification Request.
Definition: GtpLayer.h:121
@ GtpV1_MBMSDeRegistrationResponse
MBMS De-Registration Response.
Definition: GtpLayer.h:179
@ GtpV1_MSInfoChangeResponse
MS Info Change Response.
Definition: GtpLayer.h:195
@ GtpV1_ForwardRelocationCompleteAcknowledge
Forward Relocation Complete Acknowledge.
Definition: GtpLayer.h:143
@ GtpV1_UpdatePDPContextRequest
Update PDP Context Request.
Definition: GtpLayer.h:85
@ GtpV1_SendRoutingforGPRSRequest
Send Routing for GPRS Request.
Definition: GtpLayer.h:109
@ GtpV1_PDUNotificationRejectResponse
PDU Notification Reject Response.
Definition: GtpLayer.h:105
@ GtpV1_UpdatePDPContextResponse
Update PDP Context Response.
Definition: GtpLayer.h:87
@ GtpV1_SendRoutingforGPRSResponse
Send Routing for GPRS Response.
Definition: GtpLayer.h:111
@ GtpV1_VersionNotSupported
Version Not Supported.
Definition: GtpLayer.h:73
@ GtpV1_MSInfoChangeRequest
MS Info Change Request.
Definition: GtpLayer.h:193
@ GtpV1_ErrorIndication
Error Indication.
Definition: GtpLayer.h:97
@ GtpV1_UpdateMBMSNotificationResponse
Update MBMS Notification Response.
Definition: GtpLayer.h:167
@ GtpV1_RelocationCancelResponse
Relocation Cancel Response.
Definition: GtpLayer.h:139
@ GtpV1_DataRecordTransferRequest
Data Record Transfer Request.
Definition: GtpLayer.h:197
@ GtpV1_MBMSNotificationRequest
MBMS Notification Request.
Definition: GtpLayer.h:153
@ GtpV1_MBMSSessionStartResponse
MBMS Session Start Response.
Definition: GtpLayer.h:183
@ GtpV1_FailureReportRequest
Failure Report Request.
Definition: GtpLayer.h:113
@ GtpV1_CreateMBMSNotificationResponse
Create MBMS Notification Response.
Definition: GtpLayer.h:163
@ GtpV1_MBMSDeRegistrationRequest
MBMS De-Registration Request.
Definition: GtpLayer.h:177
@ GtpV1_CreateMBMSNotificationRequest
Create MBMS Notification Request.
Definition: GtpLayer.h:161
@ GtpV1_DataRecordTransferResponse
Data Record Transfer Response.
Definition: GtpLayer.h:199
@ GtpV1_MBMSSessionStopResponse
MBMS Session Stop Response.
Definition: GtpLayer.h:187
@ GtpV1_UpdateMBMSNotificationRequest
Update MBMS Notification Request.
Definition: GtpLayer.h:165
@ GtpV1_SGSNContextRequest
SGSN Context Request.
Definition: GtpLayer.h:125
@ GtpV1_RedirectionRequest
Redirection Request.
Definition: GtpLayer.h:79
@ GtpV1_EndMarker
End Marker.
Definition: GtpLayer.h:201
@ GtpV1_IdentificationResponse
Identification Response.
Definition: GtpLayer.h:123
@ GtpV1_EchoResponse
Echo Response.
Definition: GtpLayer.h:71
@ GtpV1_RelocationCancelRequest
Relocation Cancel Request.
Definition: GtpLayer.h:137
@ GtpV1_NodeAliveRequest
Node Alive Request.
Definition: GtpLayer.h:75
@ GtpV1_SGSNContextResponse
SGSN Context Response.
Definition: GtpLayer.h:127
@ GtpV1_ForwardRelocationRequest
Forward Relocation Request.
Definition: GtpLayer.h:131
@ GtpV1_NoteMSPresentRequest
Note MS Present Request.
Definition: GtpLayer.h:117
@ GtpV1_MBMSRegistrationResponse
MBMS Registration Response.
Definition: GtpLayer.h:175
@ GtpV1_DeleteMBMSNotificationResponse
Delete MBMS Notification Response.
Definition: GtpLayer.h:171
@ GtpV1_CreatePDPContextRequest
Create PDP Context Request.
Definition: GtpLayer.h:81
@ GtpV1_ForwardSRNSContext
Forward SRNS Context.
Definition: GtpLayer.h:141
@ GtpV1_PDUNotificationResponse
PDU Notification Response.
Definition: GtpLayer.h:101