#include <GtpLayer.h>
|
| GtpV1Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet) |
|
| GtpV1Layer (GtpV1MessageType messageType, uint32_t teid) |
|
| GtpV1Layer (GtpV1MessageType messageType, uint32_t teid, bool setSeqNum, uint16_t seqNum, bool setNpduNum, uint8_t npduNum) |
|
gtpv1_header * | getHeader () const |
|
bool | getSequenceNumber (uint16_t &seqNumber) const |
|
bool | setSequenceNumber (const uint16_t seqNumber) |
|
bool | getNpduNumber (uint8_t &npduNum) const |
|
bool | setNpduNumber (const uint8_t npduNum) |
|
bool | getNextExtensionHeaderType (uint8_t &nextExtType) const |
|
GtpExtension | getNextExtension () const |
|
GtpExtension | addExtension (uint8_t extensionType, uint16_t extensionContent) |
|
GtpV1MessageType | getMessageType () const |
|
std::string | getMessageTypeAsString () const |
|
bool | isGTPUMessage () const |
|
bool | isGTPCMessage () const |
|
void | parseNextLayer () |
|
size_t | getHeaderLen () const |
|
void | computeCalculateFields () |
|
std::string | toString () const |
|
OsiModelLayer | getOsiModelLayer () const |
|
virtual | ~Layer () |
|
Layer * | getNextLayer () const |
|
Layer * | getPrevLayer () const |
|
ProtocolType | getProtocol () const |
|
uint8_t * | getData () const |
|
size_t | getDataLen () const |
|
uint8_t * | getLayerPayload () const |
|
size_t | getLayerPayloadSize () const |
|
bool | isAllocatedToPacket () const |
|
void | copyData (uint8_t *toArr) const |
|
uint8_t * | getDataPtr (size_t offset=0) const |
|
|
static bool | isGTPv1 (const uint8_t *data, size_t dataSize) |
|
static bool | isGTPv1Port (uint16_t port) |
|
A class representing the GTP v1 protocol.
◆ GtpV1Layer() [1/3]
pcpp::GtpV1Layer::GtpV1Layer |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
Layer * |
prevLayer, |
|
|
Packet * |
packet |
|
) |
| |
|
inline |
A constructor that creates the layer from an existing packet raw data
- Parameters
-
[in] | data | A pointer to the raw data |
[in] | dataLen | Size of the data in bytes |
[in] | prevLayer | A pointer to the previous layer |
[in] | packet | A pointer to the Packet instance where layer will be stored in |
◆ GtpV1Layer() [2/3]
A constructor that creates a new GTPv1 layer and sets the message type and the TEID value
- Parameters
-
[in] | messageType | The GTPv1 message type to be set in the newly created layer |
[in] | teid | The TEID value to be set in the newly created layer |
◆ GtpV1Layer() [3/3]
pcpp::GtpV1Layer::GtpV1Layer |
( |
GtpV1MessageType |
messageType, |
|
|
uint32_t |
teid, |
|
|
bool |
setSeqNum, |
|
|
uint16_t |
seqNum, |
|
|
bool |
setNpduNum, |
|
|
uint8_t |
npduNum |
|
) |
| |
A constructor that creates a new GTPv1 layer and sets various parameters
- Parameters
-
[in] | messageType | The GTPv1 message type to be set in the newly created layer |
[in] | teid | The TEID value to be set in the newly created layer |
[in] | setSeqNum | A flag indicating whether to set a sequence number. If set to "false" then the parameter "seqNum" will be ignored |
[in] | seqNum | The sequence number to be set in the newly created later. If "setSeqNum" is set to false this parameter will be ignored |
[in] | setNpduNum | A flag indicating whether to set the N-PDU number. If set to "false" then the parameter "npduNum" will be ignored |
[in] | npduNum | The N-PDU number to be set in the newly created later. If "setNpduNum" is set to false this parameter will be ignored |
◆ addExtension()
GtpExtension pcpp::GtpV1Layer::addExtension |
( |
uint8_t |
extensionType, |
|
|
uint16_t |
extensionContent |
|
) |
| |
Add a GTPv1 header extension. It is assumed that the extension is 4 bytes in legnth and its content is 2 bytes in length. If you need a different content size please reach out to me. This method takes care of extending the layer to make room for the new extension and also sets the relevant flags and fields
- Parameters
-
[in] | extensionType | The type of the new extension |
[in] | extensionContent | A 2-byte long content |
- Returns
- An object representing the newly added extension. If there was an error adding the extension a null object will be returned (meaning GtpExtension::isNull() will return "true") and a corresponding error message will be written to log
◆ computeCalculateFields()
void pcpp::GtpV1Layer::computeCalculateFields |
( |
| ) |
|
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
◆ getHeader()
- Returns
- The GTP v1 common header structure. Notice this points directly to the data, so every change will change the actual packet data
◆ getHeaderLen()
size_t pcpp::GtpV1Layer::getHeaderLen |
( |
| ) |
const |
|
virtual |
- Returns
- The size of the GTP header. For GTP-C packets the size is determined by the value of gtpv1_header::messageLength and for GTP-U the size only includes the GTP header itself (meaning the size of gtpv1_header plus the size of the optional fields such as sequence number, N-PDU or extensions if exist)
Implements pcpp::Layer.
◆ getMessageType()
- Returns
- The message type of this GTP packet
◆ getMessageTypeAsString()
std::string pcpp::GtpV1Layer::getMessageTypeAsString |
( |
| ) |
const |
- Returns
- A string representation of the packet's message type
◆ getNextExtension()
- Returns
- An object that represents the next extension header, if exists in the message. If there are no extensions an empty object is returned, meaning an object which GtpExtension::isNull() returns "true"
◆ getNextExtensionHeaderType()
bool pcpp::GtpV1Layer::getNextExtensionHeaderType |
( |
uint8_t & |
nextExtType | ) |
const |
Get the type of the next header extension if exists on the message (extensions are optional in GTP messages)
- Parameters
-
[out] | nextExtType | Set with the next header extension type if exists in layer. Otherwise remains unchanged |
- Returns
- True if the message contains header extensions, in which case nextExtType is set to the next header extension type. If there are no header extensions false is returned and nextExtType remains unchanged
◆ getNpduNumber()
bool pcpp::GtpV1Layer::getNpduNumber |
( |
uint8_t & |
npduNum | ) |
const |
Get the N-PDU number if exists on the message (N-PDU number is an optional field in GTP messages)
- Parameters
-
[out] | npduNum | Set with the N-PDU number value if exists in the layer. Otherwise remains unchanged |
- Returns
- True if the N-PDU number field exists in layer, in which case npduNum is set with the value. Or false otherwise
◆ getOsiModelLayer()
- Returns
- The OSI Model layer this protocol belongs to
Implements pcpp::Layer.
◆ getSequenceNumber()
bool pcpp::GtpV1Layer::getSequenceNumber |
( |
uint16_t & |
seqNumber | ) |
const |
Get the sequence number if exists on the message (sequence number is an optional field in GTP messages)
- Parameters
-
[out] | seqNumber | Set with the sequence number value if exists in the layer. Otherwise remains unchanged |
- Returns
- True if the sequence number field exists in layer, in which case seqNumber is set with the value. Or false otherwise
◆ isGTPCMessage()
bool pcpp::GtpV1Layer::isGTPCMessage |
( |
| ) |
const |
- Returns
- True if this is a GTP-C message, false otherwise
◆ isGTPUMessage()
bool pcpp::GtpV1Layer::isGTPUMessage |
( |
| ) |
const |
- Returns
- True if this is a GTP-U message, false otherwise
◆ isGTPv1()
static bool pcpp::GtpV1Layer::isGTPv1 |
( |
const uint8_t * |
data, |
|
|
size_t |
dataSize |
|
) |
| |
|
static |
A static method that takes a byte array and detects whether it is a GTP v1 message
- Parameters
-
[in] | data | A byte array |
[in] | dataSize | The byte array size (in bytes) |
- Returns
- True if the data is identified as GTP v1 message (GTP-C or GTP-U)
◆ isGTPv1Port()
static bool pcpp::GtpV1Layer::isGTPv1Port |
( |
uint16_t |
port | ) |
|
|
inlinestatic |
A static method that checks whether the port is considered as GTPv1
- Parameters
-
[in] | port | The port number to be checked |
- Returns
- True if the port matches those associated with the BGP protocol
◆ parseNextLayer()
void pcpp::GtpV1Layer::parseNextLayer |
( |
| ) |
|
|
virtual |
◆ setNpduNumber()
bool pcpp::GtpV1Layer::setNpduNumber |
( |
const uint8_t |
npduNum | ) |
|
Set an N-PDU number
- Parameters
-
[in] | npduNum | The N-PDU number to set |
- Returns
- True if the value was set successfully, false otherwise. In case of failure a corresponding error message will be written to log
◆ setSequenceNumber()
bool pcpp::GtpV1Layer::setSequenceNumber |
( |
const uint16_t |
seqNumber | ) |
|
Set a sequence number
- Parameters
-
[in] | seqNumber | The sequence number to set |
- Returns
- True if the value was set successfully, false otherwise. In case of failure a corresponding error message will be written to log
◆ toString()
std::string pcpp::GtpV1Layer::toString |
( |
| ) |
const |
|
virtual |
- Returns
- A string representation of the layer most important data (should look like the layer description in Wireshark)
Implements pcpp::Layer.