PcapPlusPlus  20.08
pcpp::BgpLayer Class Referenceabstract

#include <BgpLayer.h>

Inheritance diagram for pcpp::BgpLayer:
pcpp::Layer pcpp::IDataContainer pcpp::BgpKeepaliveMessageLayer pcpp::BgpNotificationMessageLayer pcpp::BgpOpenMessageLayer pcpp::BgpRouteRefreshMessageLayer pcpp::BgpUpdateMessageLayer

Classes

struct  bgp_common_header
 

Public Types

enum  BgpMessageType {
  Open = 1, Update = 2, Notification = 3, Keepalive = 4,
  RouteRefresh = 5
}
 

Public Member Functions

virtual BgpMessageType getBgpMessageType () const =0
 
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
 

Static Public Member Functions

static bool isBgpPort (uint16_t portSrc, uint16_t portDst)
 
static BgpLayerparseBgpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 

Detailed Description

Represents Border Gateway Protocol (BGP) v4 protocol layer. This is an abstract class that cannot be instanciated, and contains functionality which is common to all BGP message types.

Member Enumeration Documentation

◆ BgpMessageType

An enum representing BGP message types

Enumerator
Open 

BGP OPEN message

Update 

BGP UPDATE message

Notification 

BGP NOTIFICATION message

Keepalive 

BGP KEEPALIVE message

RouteRefresh 

BGP ROUTE-REFRESH message

Member Function Documentation

◆ computeCalculateFields()

void pcpp::BgpLayer::computeCalculateFields ( )
virtual

Calculates the basic BGP fields:

  • Set marker to all ones
  • Set message type value
  • Set message length

Implements pcpp::Layer.

◆ getBgpMessageType()

virtual BgpMessageType pcpp::BgpLayer::getBgpMessageType ( ) const
pure virtual

◆ getHeaderLen()

size_t pcpp::BgpLayer::getHeaderLen ( ) const
virtual
Returns
The size of the BGP message

Implements pcpp::Layer.

◆ getMessageTypeAsString()

std::string pcpp::BgpLayer::getMessageTypeAsString ( ) const
Returns
BGP message type as string. Return value can be one of the following: "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH", "Unknown"

◆ getOsiModelLayer()

OsiModelLayer pcpp::BgpLayer::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ isBgpPort()

static bool pcpp::BgpLayer::isBgpPort ( uint16_t  portSrc,
uint16_t  portDst 
)
inlinestatic

A static method that checks whether a source or dest port match those associated with the BGP protocol

Parameters
[in]portSrcSource port number to check
[in]portDstDest port number to check

◆ parseBgpLayer()

static BgpLayer* pcpp::BgpLayer::parseBgpLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
static

A method that creates a BGP layer from 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
Returns
A newly allocated BGP layer of one of the following types (according to the message type): BgpOpenMessageLayer, BgpUpdateMessageLayer, BgpNotificationMessageLayer, BgpKeepaliveMessageLayer, BgpRouteRefreshMessageLayer

◆ parseNextLayer()

void pcpp::BgpLayer::parseNextLayer ( )
virtual

Multiple BGP messages can reside in a single packet, and the only layer that can come after a BGP message is another BGP message. This method checks for remaining data and parses it as another BGP layer

Implements pcpp::Layer.

◆ toString()

std::string pcpp::BgpLayer::toString ( ) const
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.