PcapPlusPlus  20.08
pcpp::BgpNotificationMessageLayer Class Reference

#include <BgpLayer.h>

Inheritance diagram for pcpp::BgpNotificationMessageLayer:
pcpp::BgpLayer pcpp::Layer pcpp::IDataContainer

Classes

struct  bgp_notification_message
 

Public Member Functions

 BgpNotificationMessageLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 BgpNotificationMessageLayer (uint8_t errorCode, uint8_t errorSubCode)
 
 BgpNotificationMessageLayer (uint8_t errorCode, uint8_t errorSubCode, const uint8_t *notificationData, size_t notificationDataLen)
 
 BgpNotificationMessageLayer (uint8_t errorCode, uint8_t errorSubCode, const std::string &notificationData)
 
bgp_notification_messagegetNotificationMsgHeader () const
 
size_t getNotificationDataLen () const
 
uint8_t * getNotificationData () const
 
std::string getNotificationDataAsHexString () const
 
bool setNotificationData (const uint8_t *newNotificationData, size_t newNotificationDataLen)
 
bool setNotificationData (const std::string &newNotificationDataAsHexString)
 
BgpMessageType getBgpMessageType () const
 
- Public Member Functions inherited from pcpp::BgpLayer
std::string getMessageTypeAsString () const
 
size_t getHeaderLen () const
 
void parseNextLayer ()
 
std::string toString () const
 
OsiModelLayer getOsiModelLayer () const
 
void computeCalculateFields ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () 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
 

Additional Inherited Members

- Public Types inherited from pcpp::BgpLayer
enum  BgpMessageType {
  Open = 1, Update = 2, Notification = 3, Keepalive = 4,
  RouteRefresh = 5
}
 
- Static Public Member Functions inherited from pcpp::BgpLayer
static bool isBgpPort (uint16_t portSrc, uint16_t portDst)
 
static BgpLayerparseBgpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 

Detailed Description

Represents a BGP v4 NOTIFICATION message

Constructor & Destructor Documentation

◆ BgpNotificationMessageLayer() [1/4]

pcpp::BgpNotificationMessageLayer::BgpNotificationMessageLayer ( 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]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ BgpNotificationMessageLayer() [2/4]

pcpp::BgpNotificationMessageLayer::BgpNotificationMessageLayer ( uint8_t  errorCode,
uint8_t  errorSubCode 
)

A c'tor that creates a new BGP NOTIFICATION message

Parameters
[in]errorCodeBGP notification error code
[in]errorSubCodeBGP notification error sub code

◆ BgpNotificationMessageLayer() [3/4]

pcpp::BgpNotificationMessageLayer::BgpNotificationMessageLayer ( uint8_t  errorCode,
uint8_t  errorSubCode,
const uint8_t *  notificationData,
size_t  notificationDataLen 
)

A c'tor that creates a new BGP Notification message

Parameters
[in]errorCodeBGP notification error code
[in]errorSubCodeBGP notification error sub code
[in]notificationDataA byte array that contains the notification data
[in]notificationDataLenThe size of the byte array that contains the notification data

◆ BgpNotificationMessageLayer() [4/4]

pcpp::BgpNotificationMessageLayer::BgpNotificationMessageLayer ( uint8_t  errorCode,
uint8_t  errorSubCode,
const std::string &  notificationData 
)

A c'tor that creates a new BGP Notification message

Parameters
[in]errorCodeBGP notification error code
[in]errorSubCodeBGP notification error sub code
[in]notificationDataA hex string that contains the notification data. This string will be converted to a byte array that will be added to the message. If the input isn't a valid hex string notification data will remain empty and an error will be printed to log

Member Function Documentation

◆ getBgpMessageType()

BgpMessageType pcpp::BgpNotificationMessageLayer::getBgpMessageType ( ) const
inlinevirtual
Returns
BGP message type

Implements pcpp::BgpLayer.

◆ getNotificationData()

uint8_t* pcpp::BgpNotificationMessageLayer::getNotificationData ( ) const
Returns
A pointer to the notification data. Notification data is a variable-length field used to diagnose the reason for the BGP NOTIFICATION

◆ getNotificationDataAsHexString()

std::string pcpp::BgpNotificationMessageLayer::getNotificationDataAsHexString ( ) const
Returns
A hex string which represents the notification data. Notification data is a variable-length field used to diagnose the reason for the BGP NOTIFICATION

◆ getNotificationDataLen()

size_t pcpp::BgpNotificationMessageLayer::getNotificationDataLen ( ) const
Returns
The size in [bytes] of the notification data. Notification data is a variable-length field used to diagnose the reason for the BGP NOTIFICATION

◆ getNotificationMsgHeader()

bgp_notification_message* pcpp::BgpNotificationMessageLayer::getNotificationMsgHeader ( ) const
inline

Get a pointer to the notification message data. Notice this points directly to the data, so any change will modify the actual packet data

Returns
A pointer to a bgp_notification_message structure containing the data

◆ setNotificationData() [1/2]

bool pcpp::BgpNotificationMessageLayer::setNotificationData ( const uint8_t *  newNotificationData,
size_t  newNotificationDataLen 
)

Set the notification data. This method will extend or shorten the existing layer to include the new notification data. If newNotificationData is NULL or newNotificationDataLen is zero then notification data will be set to none.

Parameters
[in]newNotificationDataA byte array containing the new notification data
[in]newNotificationDataLenThe size of the byte array
Returns
True if notification data was set successfully or false if any error occurred. In case of an error an appropriate error message will be printed to log

◆ setNotificationData() [2/2]

bool pcpp::BgpNotificationMessageLayer::setNotificationData ( const std::string &  newNotificationDataAsHexString)

Set the notification data. This method will extend or shorten the existing layer to include the new notification data. If newNotificationDataAsHexString is an empty string then notification data will be set to none.

Parameters
[in]newNotificationDataAsHexStringA hex string representing the new notification data. If the string is not a valid hex string no data will be changed and an error will be returned
Returns
True if notification data was set successfully or false if any error occurred or if the string is not a valid hex string. In case of an error an appropriate error message will be printed to log