|
PcapPlusPlus
20.08
|
Go to the documentation of this file. 1 #ifndef PACKETPP_BGP_LAYER
2 #define PACKETPP_BGP_LAYER
81 static bool isBgpPort(uint16_t portSrc, uint16_t portDst) {
return portSrc == 179 || portDst == 179; }
124 BgpLayer(uint8_t* data,
size_t dataLen, Layer* prevLayer, Packet* packet) : Layer(data, dataLen, prevLayer, packet) { m_Protocol =
BGP; }
126 bgp_common_header* getBasicHeader()
const {
return (bgp_common_header*)m_Data; }
128 void setBgpFields(
size_t messageLen = 0);
146 #pragma pack(push, 1)
147 typedef struct : bgp_common_header
207 const std::vector<optional_parameter>& optionalParams = std::vector<optional_parameter>());
262 size_t optionalParamsToByteArray(
const std::vector<optional_parameter>& optionalParams, uint8_t* resultByteArr,
size_t maxByteArrSize);
329 path_attribute(uint8_t flagsVal, uint8_t typeVal, std::string dataAsHexString);
348 const std::vector<prefix_and_ip>& withdrawnRoutes = std::vector<prefix_and_ip>(),
349 const std::vector<path_attribute>& pathAttributes = std::vector<path_attribute>(),
350 const std::vector<prefix_and_ip>& nlri = std::vector<prefix_and_ip>());
451 void parsePrefixAndIPData(uint8_t* dataPtr,
size_t dataLen, std::vector<prefix_and_ip>& result);
453 size_t prefixAndIPDataToByteArray(
const std::vector<prefix_and_ip>& prefixAndIpData, uint8_t* resultByteArr,
size_t maxByteArrSize);
455 size_t pathAttributesToByteArray(
const std::vector<path_attribute>& pathAttributes, uint8_t* resultByteArr,
size_t maxByteArrSize);
473 #pragma pack(push, 1)
549 bool setNotificationData(
const uint8_t* newNotificationData,
size_t newNotificationDataLen);
567 void initMessageData(uint8_t errorCode, uint8_t errorSubCode,
const uint8_t* notificationData,
size_t notificationDataLen);
627 #pragma pack(push, 1)
628 typedef struct : bgp_common_header
669 #endif //PACKETPP_BGP_LAYER
OsiModelLayer
Definition: ProtocolType.h:233
bool setNotificationData(const uint8_t *newNotificationData, size_t newNotificationDataLen)
Definition: IpAddress.h:26
Definition: BgpLayer.h:577
IPv4Address getBgpId() const
Definition: BgpLayer.h:218
BgpMessageType
Definition: BgpLayer.h:35
@ RouteRefresh
Definition: BgpLayer.h:46
BgpUpdateMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:339
uint8_t type
Definition: BgpLayer.h:311
@ OsiModelApplicationLayer
Definition: ProtocolType.h:248
Definition: BgpLayer.h:166
uint8_t flags
Definition: BgpLayer.h:309
const ProtocolType BGP
Definition: ProtocolType.h:228
uint8_t * getNotificationData() const
BgpNotificationMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:490
uint8_t prefix
Definition: BgpLayer.h:284
prefix_and_ip()
Definition: BgpLayer.h:291
uint8_t errorSubCode
Definition: BgpLayer.h:479
@ Notification
Definition: BgpLayer.h:42
bool setNetworkLayerReachabilityInfo(const std::vector< prefix_and_ip > &nlri)
path_attribute()
Definition: BgpLayer.h:320
Definition: BgpLayer.h:272
bgp_route_refresh_message * getRouteRefreshHeader() const
Definition: BgpLayer.h:659
Definition: BgpLayer.h:306
Definition: BgpLayer.h:465
std::string getMessageTypeAsString() const
@ Update
Definition: BgpLayer.h:40
bool clearOptionalParameters()
size_t getOptionalParametersLength()
OsiModelLayer getOsiModelLayer() const
Definition: BgpLayer.h:110
bool setPathAttributes(const std::vector< path_attribute > &pathAttributes)
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:609
uint8_t errorCode
Definition: BgpLayer.h:477
Definition: BgpLayer.h:628
prefix_and_ip(uint8_t prefixVal, const std::string &ipAddrVal)
Definition: BgpLayer.h:298
static BgpLayer * parseBgpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:474
uint8_t length
Definition: BgpLayer.h:171
void getWithdrawnRoutes(std::vector< prefix_and_ip > &withdrawnRoutes)
bool clearPathAttributes()
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:447
uint8_t reserved
Definition: BgpLayer.h:633
void setBgpId(const IPv4Address &newBgpId)
void computeCalculateFields()
optional_parameter()
Definition: BgpLayer.h:178
bool clearWithdrawnRoutes()
std::string getNotificationDataAsHexString() const
void getOptionalParameters(std::vector< optional_parameter > &optionalParameters)
static bool isBgpPort(uint16_t portSrc, uint16_t portDst)
Definition: BgpLayer.h:81
uint8_t version
Definition: BgpLayer.h:150
size_t getHeaderLen() const
bgp_common_header bgp_keepalive_message
Definition: BgpLayer.h:585
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:258
The main namespace for the PcapPlusPlus lib.
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:663
uint8_t safi
Definition: BgpLayer.h:635
BgpOpenMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:196
virtual BgpMessageType getBgpMessageType() const =0
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:563
IPv4Address ipAddr
Definition: BgpLayer.h:286
size_t getNotificationDataLen() const
Definition: BgpLayer.h:138
bgp_keepalive_message * getKeepaliveHeader() const
Definition: BgpLayer.h:605
BgpRouteRefreshMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:646
uint16_t myAutonomousSystem
Definition: BgpLayer.h:152
size_t getNetworkLayerReachabilityInfoLength() const
bgp_common_header * getBasicMsgHeader() const
Definition: BgpLayer.h:356
uint8_t optionalParameterLength
Definition: BgpLayer.h:158
@ Keepalive
Definition: BgpLayer.h:44
bool setWithdrawnRoutes(const std::vector< prefix_and_ip > &withdrawnRoutes)
bgp_notification_message * getNotificationMsgHeader() const
Definition: BgpLayer.h:521
Definition: BgpLayer.h:28
void getPathAttributes(std::vector< path_attribute > &pathAttributes)
uint8_t type
Definition: BgpLayer.h:169
uint8_t length
Definition: BgpLayer.h:313
bool setOptionalParameters(const std::vector< optional_parameter > &optionalParameters)
BgpKeepaliveMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:594
uint8_t data[32]
Definition: BgpLayer.h:315
bgp_open_message * getOpenMsgHeader() const
Definition: BgpLayer.h:213
@ Open
Definition: BgpLayer.h:38
Definition: BgpLayer.h:619
BgpKeepaliveMessageLayer()
Definition: BgpLayer.h:281
std::string toString() const
size_t getPathAttributesLength() const
size_t getWithdrawnRoutesLength() const
uint8_t value[32]
Definition: BgpLayer.h:173
bool clearNetworkLayerReachabilityInfo()
uint16_t afi
Definition: BgpLayer.h:631
uint16_t holdTime
Definition: BgpLayer.h:154
void getNetworkLayerReachabilityInfo(std::vector< prefix_and_ip > &nlri)
Definition: BgpLayer.h:147
uint32_t bgpId
Definition: BgpLayer.h:156