PcapPlusPlus  21.05
pcpp::BgpUpdateMessageLayer Class Reference

#include <BgpLayer.h>

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

Classes

struct  path_attribute
 
struct  prefix_and_ip
 

Public Member Functions

 BgpUpdateMessageLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 BgpUpdateMessageLayer (const std::vector< prefix_and_ip > &withdrawnRoutes=std::vector< prefix_and_ip >(), const std::vector< path_attribute > &pathAttributes=std::vector< path_attribute >(), const std::vector< prefix_and_ip > &nlri=std::vector< prefix_and_ip >())
 
bgp_common_headergetBasicMsgHeader () const
 
size_t getWithdrawnRoutesLength () const
 
void getWithdrawnRoutes (std::vector< prefix_and_ip > &withdrawnRoutes)
 
bool setWithdrawnRoutes (const std::vector< prefix_and_ip > &withdrawnRoutes)
 
bool clearWithdrawnRoutes ()
 
size_t getPathAttributesLength () const
 
void getPathAttributes (std::vector< path_attribute > &pathAttributes)
 
bool setPathAttributes (const std::vector< path_attribute > &pathAttributes)
 
bool clearPathAttributes ()
 
size_t getNetworkLayerReachabilityInfoLength () const
 
void getNetworkLayerReachabilityInfo (std::vector< prefix_and_ip > &nlri)
 
bool setNetworkLayerReachabilityInfo (const std::vector< prefix_and_ip > &nlri)
 
bool clearNetworkLayerReachabilityInfo ()
 
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 UPDATE message

Constructor & Destructor Documentation

◆ BgpUpdateMessageLayer() [1/2]

pcpp::BgpUpdateMessageLayer::BgpUpdateMessageLayer ( 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

◆ BgpUpdateMessageLayer() [2/2]

pcpp::BgpUpdateMessageLayer::BgpUpdateMessageLayer ( const std::vector< prefix_and_ip > &  withdrawnRoutes = std::vector< prefix_and_ip >(),
const std::vector< path_attribute > &  pathAttributes = std::vector< path_attribute >(),
const std::vector< prefix_and_ip > &  nlri = std::vector< prefix_and_ip >() 
)

A c'tor that creates a new BGP UPDATE message

Parameters
[in]withdrawnRoutesA vector of withdrawn routes data. If left empty (which is the default value) no withdrawn route information will be written to the message
[in]pathAttributesA vector of path attributes data. If left empty (which is the default value) no path attribute information will be written to the message
[in]nlriA vector of network layer reachability data. If left empty (which is the default value) no reachability information will be written to the message

Member Function Documentation

◆ clearNetworkLayerReachabilityInfo()

bool pcpp::BgpUpdateMessageLayer::clearNetworkLayerReachabilityInfo ( )

Clear all NLRI data currently in the message. This is equivalent to calling setNetworkLayerReachabilityInfo() with an empty vector as a parameter

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

◆ clearPathAttributes()

bool pcpp::BgpUpdateMessageLayer::clearPathAttributes ( )

Clear all Path Attributes data currently in the message. This is equivalent to calling setPathAttributes() with an empty vector as a parameter

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

◆ clearWithdrawnRoutes()

bool pcpp::BgpUpdateMessageLayer::clearWithdrawnRoutes ( )

Clear all Withdrawn Routes data currently in the message. This is equivalent to calling setWithdrawnRoutes() with an empty vector as a parameter

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

◆ getBasicMsgHeader()

bgp_common_header* pcpp::BgpUpdateMessageLayer::getBasicMsgHeader ( ) const
inline

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

Returns
A pointer to a bgp_common_header structure containing the data

◆ getBgpMessageType()

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

Implements pcpp::BgpLayer.

◆ getNetworkLayerReachabilityInfo()

void pcpp::BgpUpdateMessageLayer::getNetworkLayerReachabilityInfo ( std::vector< prefix_and_ip > &  nlri)

Get a vector of the Network Layer Reachability Info currently in the message

Parameters
[out]nlriA reference to a vector the NLRI data will be written to

◆ getNetworkLayerReachabilityInfoLength()

size_t pcpp::BgpUpdateMessageLayer::getNetworkLayerReachabilityInfoLength ( ) const
Returns
The size in [bytes] of the Network Layer Reachability Info

◆ getPathAttributes()

void pcpp::BgpUpdateMessageLayer::getPathAttributes ( std::vector< path_attribute > &  pathAttributes)

Get a vector of the Path Attributes currently in the message

Parameters
[out]pathAttributesA reference to a vector the Path Attributes data will be written to

◆ getPathAttributesLength()

size_t pcpp::BgpUpdateMessageLayer::getPathAttributesLength ( ) const
Returns
The size in [bytes] of the Path Attributes data

◆ getWithdrawnRoutes()

void pcpp::BgpUpdateMessageLayer::getWithdrawnRoutes ( std::vector< prefix_and_ip > &  withdrawnRoutes)

Get a vector of the Withdrawn Routes currently in the message

Parameters
[out]withdrawnRoutesA reference to a vector the Withdrawn Routes data will be written to

◆ getWithdrawnRoutesLength()

size_t pcpp::BgpUpdateMessageLayer::getWithdrawnRoutesLength ( ) const
Returns
The size in [bytes] of the Withdrawn Routes data

◆ setNetworkLayerReachabilityInfo()

bool pcpp::BgpUpdateMessageLayer::setNetworkLayerReachabilityInfo ( const std::vector< prefix_and_ip > &  nlri)

Set NLRI data in this message. This method will override any existing NLRI data in the message. If the input is an empty vector all NLRI data will be removed. This method autmatically sets the bgp_common_header::length field in the message

Parameters
[in]nlriNew NLRI data to set in the message
Returns
True if all NLRI data was set successfully or false otherwise. In case of an error an appropriate message will be printed to log

◆ setPathAttributes()

bool pcpp::BgpUpdateMessageLayer::setPathAttributes ( const std::vector< path_attribute > &  pathAttributes)

Set Path Attributes in this message. This method will override any existing Path Attributes in the message. If the input is an empty vector all Path Attributes will be removed. This method autmatically sets the bgp_common_header::length and the Path Attributes length fields in the message

Parameters
[in]pathAttributesNew Path Attributes to set in the message
Returns
True if all Path Attributes were set successfully or false otherwise. In case of an error an appropriate message will be printed to log

◆ setWithdrawnRoutes()

bool pcpp::BgpUpdateMessageLayer::setWithdrawnRoutes ( const std::vector< prefix_and_ip > &  withdrawnRoutes)

Set Withdrawn Routes in this message. This method will override any existing Withdrawn Routes in the message. If the input is an empty vector all Withdrawn Routes will be removed. This method autmatically sets the bgp_common_header::length and the Withdrawn Routes length fields in the message

Parameters
[in]withdrawnRoutesNew Withdrawn Routes to set in the message
Returns
True if all Withdrawn Routes were set successfully or false otherwise. In case of an error an appropriate message will be printed to log