PcapPlusPlus  21.05
pcpp::BgpOpenMessageLayer Class Reference

#include <BgpLayer.h>

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


struct  bgp_open_message
struct  optional_parameter

Public Member Functions

 BgpOpenMessageLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 BgpOpenMessageLayer (uint16_t myAutonomousSystem, uint16_t holdTime, const IPv4Address &bgpId, const std::vector< optional_parameter > &optionalParams=std::vector< optional_parameter >())
bgp_open_messagegetOpenMsgHeader () const
IPv4Address getBgpId () const
void setBgpId (const IPv4Address &newBgpId)
void getOptionalParameters (std::vector< optional_parameter > &optionalParameters)
size_t getOptionalParametersLength ()
bool setOptionalParameters (const std::vector< optional_parameter > &optionalParameters)
bool clearOptionalParameters ()
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 OPEN message

Constructor & Destructor Documentation

◆ BgpOpenMessageLayer() [1/2]

pcpp::BgpOpenMessageLayer::BgpOpenMessageLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 

A constructor that creates the layer from an existing packet raw data

[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

◆ BgpOpenMessageLayer() [2/2]

pcpp::BgpOpenMessageLayer::BgpOpenMessageLayer ( uint16_t  myAutonomousSystem,
uint16_t  holdTime,
const IPv4Address bgpId,
const std::vector< optional_parameter > &  optionalParams = std::vector< optional_parameter >() 

A c'tor that creates a new BGP OPEN message

[in]myAutonomousSystemThe Autonomous System number of the sender
[in]holdTimeThe number of seconds the sender proposes for the value of the Hold Timer
[in]bgpIdThe BGP Identifier of the sender
[in]optionalParamsA vector of optional parameters. This parameter is optional and if not provided no parameters will be set on the message

Member Function Documentation

◆ clearOptionalParameters()

bool pcpp::BgpOpenMessageLayer::clearOptionalParameters ( )

Clear all optional parameters currently in the message. This is equivalent to calling setOptionalParameters() with an empty vector as a parameter

True if all optional parameters were successfully cleared or false otherwise. In case of an error an appropriate message will be printed to log

◆ getBgpId()

IPv4Address pcpp::BgpOpenMessageLayer::getBgpId ( ) const
The BGP identifier as IPv4Address object

◆ getBgpMessageType()

BgpMessageType pcpp::BgpOpenMessageLayer::getBgpMessageType ( ) const
BGP message type

Implements pcpp::BgpLayer.

◆ getOpenMsgHeader()

bgp_open_message* pcpp::BgpOpenMessageLayer::getOpenMsgHeader ( ) const

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

A pointer to a bgp_open_message structure containing the data

◆ getOptionalParameters()

void pcpp::BgpOpenMessageLayer::getOptionalParameters ( std::vector< optional_parameter > &  optionalParameters)

Get a vector of the optional paramters in the message

[out]optionalParametersThe vector where the optional parameters will be written to. This method doesn't remove any existing data on this vector before pushing data to it

◆ getOptionalParametersLength()

size_t pcpp::BgpOpenMessageLayer::getOptionalParametersLength ( )
The length in [bytes] of the optional paramters data in the message

◆ setBgpId()

void pcpp::BgpOpenMessageLayer::setBgpId ( const IPv4Address newBgpId)

Set the BGP identifier

[in]newBgpIdBGP identifier to set. If value is not a valid IPv4 address it won't be set

◆ setOptionalParameters()

bool pcpp::BgpOpenMessageLayer::setOptionalParameters ( const std::vector< optional_parameter > &  optionalParameters)

Set optional parameters in the message. This method will override all existing optional parameters currently in the message. If the input is an empty vector all optional parameters will be cleared. This method autmatically sets the bgp_common_header::length and the bgp_open_message::optionalParameterLength fields on the message

[in]optionalParametersA vector of new optional parameters to set in the message
True if all optional parameters were set successfully or false otherwise. In case of an error an appropriate message will be printed to log