80 static bool isBgpPort(uint16_t portSrc, uint16_t portDst)
82 return portSrc == 179 || portDst == 179;
130 :
Layer(data, dataLen, prevLayer, packet,
BGP)
133 bgp_common_header* getBasicHeader()
const
135 return (bgp_common_header*)m_Data;
138 void setBgpFields(
size_t messageLen = 0);
148 #pragma pack(push, 1)
204 :
BgpLayer(data, dataLen, prevLayer, packet)
216 const std::vector<optional_parameter>& optionalParams = std::vector<optional_parameter>());
281 size_t optionalParamsToByteArray(
const std::vector<optional_parameter>& optionalParams, uint8_t* resultByteArr,
282 size_t maxByteArrSize);
348 path_attribute(uint8_t flagsVal, uint8_t typeVal,
const std::string& dataAsHexString);
359 :
BgpLayer(data, dataLen, prevLayer, packet)
380 const std::vector<prefix_and_ip>& withdrawnRoutes = std::vector<prefix_and_ip>(),
381 const std::vector<path_attribute>& pathAttributes = std::vector<path_attribute>(),
382 const std::vector<prefix_and_ip>& nlri = std::vector<prefix_and_ip>());
489 void parsePrefixAndIPData(uint8_t* dataPtr,
size_t dataLen, std::vector<prefix_and_ip>& result);
491 size_t prefixAndIPDataToByteArray(
const std::vector<prefix_and_ip>& prefixAndIpData, uint8_t* resultByteArr,
492 size_t maxByteArrSize);
494 size_t pathAttributesToByteArray(
const std::vector<path_attribute>& pathAttributes, uint8_t* resultByteArr,
495 size_t maxByteArrSize);
505 #pragma pack(push, 1)
527 :
BgpLayer(data, dataLen, prevLayer, packet)
545 size_t notificationDataLen);
615 void initMessageData(uint8_t errorCode, uint8_t errorSubCode,
const uint8_t* notificationData,
616 size_t notificationDataLen);
640 :
BgpLayer(data, dataLen, prevLayer, packet)
673 #pragma pack(push, 1)
697 :
BgpLayer(data, dataLen, prevLayer, packet)
Definition: BgpLayer.h:624
bgp_common_header bgp_keepalive_message
Definition: BgpLayer.h:630
BgpKeepaliveMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:639
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:660
bgp_keepalive_message * getKeepaliveHeader() const
Definition: BgpLayer.h:653
BgpKeepaliveMessageLayer()
Definition: BgpLayer.h:28
std::string toString() const
static bool isBgpPort(uint16_t portSrc, uint16_t portDst)
Definition: BgpLayer.h:80
BgpMessageType
Definition: BgpLayer.h:34
@ RouteRefresh
Definition: BgpLayer.h:44
@ Update
Definition: BgpLayer.h:38
@ Keepalive
Definition: BgpLayer.h:42
@ Notification
Definition: BgpLayer.h:40
@ Open
Definition: BgpLayer.h:36
std::string getMessageTypeAsString() const
void computeCalculateFields()
size_t getHeaderLen() const
OsiModelLayer getOsiModelLayer() const
Definition: BgpLayer.h:112
static BgpLayer * parseBgpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
virtual BgpMessageType getBgpMessageType() const =0
Definition: BgpLayer.h:503
BgpNotificationMessageLayer(uint8_t errorCode, uint8_t errorSubCode)
BgpNotificationMessageLayer(uint8_t errorCode, uint8_t errorSubCode, const std::string ¬ificationData)
bool setNotificationData(const std::string &newNotificationDataAsHexString)
bgp_notification_message * getNotificationMsgHeader() const
Definition: BgpLayer.h:562
std::string getNotificationDataAsHexString() const
bool setNotificationData(const uint8_t *newNotificationData, size_t newNotificationDataLen)
BgpNotificationMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:526
BgpNotificationMessageLayer(uint8_t errorCode, uint8_t errorSubCode, const uint8_t *notificationData, size_t notificationDataLen)
size_t getNotificationDataLen() const
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:609
uint8_t * getNotificationData() const
Definition: BgpLayer.h:146
void getOptionalParameters(std::vector< optional_parameter > &optionalParameters)
BgpOpenMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:203
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:275
void setBgpId(const IPv4Address &newBgpId)
bool setOptionalParameters(const std::vector< optional_parameter > &optionalParameters)
BgpOpenMessageLayer(uint16_t myAutonomousSystem, uint16_t holdTime, const IPv4Address &bgpId, const std::vector< optional_parameter > &optionalParams=std::vector< optional_parameter >())
bool clearOptionalParameters()
bgp_open_message * getOpenMsgHeader() const
Definition: BgpLayer.h:223
IPv4Address getBgpId() const
Definition: BgpLayer.h:231
size_t getOptionalParametersLength()
Definition: BgpLayer.h:671
BgpRouteRefreshMessageLayer(uint16_t afi, uint8_t safi)
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:719
BgpRouteRefreshMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:696
bgp_route_refresh_message * getRouteRefreshHeader() const
Definition: BgpLayer.h:712
Definition: BgpLayer.h:290
bool clearPathAttributes()
bool clearNetworkLayerReachabilityInfo()
void getPathAttributes(std::vector< path_attribute > &pathAttributes)
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:483
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 >())
static bool isDataValid(const uint8_t *data, size_t dataSize)
void getWithdrawnRoutes(std::vector< prefix_and_ip > &withdrawnRoutes)
bool setPathAttributes(const std::vector< path_attribute > &pathAttributes)
bool setNetworkLayerReachabilityInfo(const std::vector< prefix_and_ip > &nlri)
size_t getNetworkLayerReachabilityInfoLength() const
bool setWithdrawnRoutes(const std::vector< prefix_and_ip > &withdrawnRoutes)
size_t getPathAttributesLength() const
bool clearWithdrawnRoutes()
size_t getWithdrawnRoutesLength() const
bgp_common_header * getBasicMsgHeader() const
Definition: BgpLayer.h:389
void getNetworkLayerReachabilityInfo(std::vector< prefix_and_ip > &nlri)
BgpUpdateMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:358
Definition: IpAddress.h:32
The main namespace for the PcapPlusPlus lib.
const ProtocolType BGP
Definition: ProtocolType.h:233
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelApplicationLayer
Definition: ProtocolType.h:368
Definition: BgpLayer.h:511
uint8_t errorSubCode
Definition: BgpLayer.h:515
uint8_t errorCode
Definition: BgpLayer.h:513
Definition: BgpLayer.h:154
uint16_t holdTime
Definition: BgpLayer.h:160
uint8_t version
Definition: BgpLayer.h:156
uint32_t bgpId
Definition: BgpLayer.h:162
uint16_t myAutonomousSystem
Definition: BgpLayer.h:158
uint8_t optionalParameterLength
Definition: BgpLayer.h:164
Definition: BgpLayer.h:173
optional_parameter(uint8_t typeVal, const std::string &valueAsHexString)
uint8_t type
Definition: BgpLayer.h:175
uint8_t length
Definition: BgpLayer.h:177
optional_parameter()
Definition: BgpLayer.h:184
uint8_t value[32]
Definition: BgpLayer.h:179
Definition: BgpLayer.h:679
uint8_t safi
Definition: BgpLayer.h:685
uint16_t afi
Definition: BgpLayer.h:681
uint8_t reserved
Definition: BgpLayer.h:683
Definition: BgpLayer.h:324
path_attribute()
Definition: BgpLayer.h:337
uint8_t type
Definition: BgpLayer.h:328
uint8_t flags
Definition: BgpLayer.h:326
uint8_t data[32]
Definition: BgpLayer.h:332
path_attribute(uint8_t flagsVal, uint8_t typeVal, const std::string &dataAsHexString)
uint8_t length
Definition: BgpLayer.h:330
Definition: BgpLayer.h:298
uint8_t prefix
Definition: BgpLayer.h:300
prefix_and_ip()
Definition: BgpLayer.h:307
prefix_and_ip(uint8_t prefixVal, const std::string &ipAddrVal)
Definition: BgpLayer.h:315
IPv4Address ipAddr
Definition: BgpLayer.h:302