1 #ifndef PACKETPP_BGP_LAYER 2 #define PACKETPP_BGP_LAYER 82 static bool isBgpPort(uint16_t portSrc, uint16_t portDst) {
return portSrc == 179 || portDst == 179; }
125 BgpLayer(uint8_t* data,
size_t dataLen,
Layer* prevLayer,
Packet* packet) :
Layer(data, dataLen, prevLayer, packet) { m_Protocol =
BGP; }
129 void setBgpFields(
size_t messageLen = 0);
147 #pragma pack(push, 1) 208 const std::vector<optional_parameter>& optionalParams = std::vector<optional_parameter>());
232 void getOptionalParameters(std::vector<optional_parameter>& optionalParameters);
237 size_t getOptionalParametersLength();
247 bool setOptionalParameters(
const std::vector<optional_parameter>& optionalParameters);
255 bool clearOptionalParameters();
263 size_t optionalParamsToByteArray(
const std::vector<optional_parameter>& optionalParams, uint8_t* resultByteArr,
size_t maxByteArrSize);
299 prefix_and_ip(uint8_t prefixVal,
const std::string& ipAddrVal): prefix(prefixVal), ipAddr(ipAddrVal) {}
330 path_attribute(uint8_t flagsVal, uint8_t typeVal,
const std::string& dataAsHexString);
349 const std::vector<prefix_and_ip>& withdrawnRoutes = std::vector<prefix_and_ip>(),
350 const std::vector<path_attribute>& pathAttributes = std::vector<path_attribute>(),
351 const std::vector<prefix_and_ip>& nlri = std::vector<prefix_and_ip>());
362 size_t getWithdrawnRoutesLength()
const;
368 void getWithdrawnRoutes(std::vector<prefix_and_ip>& withdrawnRoutes);
378 bool setWithdrawnRoutes(
const std::vector<prefix_and_ip>& withdrawnRoutes);
386 bool clearWithdrawnRoutes();
391 size_t getPathAttributesLength()
const;
397 void getPathAttributes(std::vector<path_attribute>& pathAttributes);
407 bool setPathAttributes(
const std::vector<path_attribute>& pathAttributes);
415 bool clearPathAttributes();
420 size_t getNetworkLayerReachabilityInfoLength()
const;
426 void getNetworkLayerReachabilityInfo(std::vector<prefix_and_ip>& nlri);
436 bool setNetworkLayerReachabilityInfo(
const std::vector<prefix_and_ip>& nlri);
444 bool clearNetworkLayerReachabilityInfo();
452 void parsePrefixAndIPData(uint8_t* dataPtr,
size_t dataLen, std::vector<prefix_and_ip>& result);
454 size_t prefixAndIPDataToByteArray(
const std::vector<prefix_and_ip>& prefixAndIpData, uint8_t* resultByteArr,
size_t maxByteArrSize);
456 size_t pathAttributesToByteArray(
const std::vector<path_attribute>& pathAttributes, uint8_t* resultByteArr,
size_t maxByteArrSize);
474 #pragma pack(push, 1) 528 size_t getNotificationDataLen()
const;
534 uint8_t* getNotificationData()
const;
540 std::string getNotificationDataAsHexString()
const;
550 bool setNotificationData(
const uint8_t* newNotificationData,
size_t newNotificationDataLen);
560 bool setNotificationData(
const std::string& newNotificationDataAsHexString);
568 void initMessageData(uint8_t errorCode, uint8_t errorSubCode,
const uint8_t* notificationData,
size_t notificationDataLen);
606 bgp_keepalive_message*
getKeepaliveHeader()
const {
return (bgp_keepalive_message*)getBasicHeader(); }
628 #pragma pack(push, 1) 670 #endif //PACKETPP_BGP_LAYER The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
uint8_t length
Definition: BgpLayer.h:314
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:610
uint16_t holdTime
Definition: BgpLayer.h:155
static bool isBgpPort(uint16_t portSrc, uint16_t portDst)
Definition: BgpLayer.h:82
prefix_and_ip()
Definition: BgpLayer.h:292
Definition: BgpLayer.h:307
Definition: BgpLayer.h:273
uint8_t prefix
Definition: BgpLayer.h:285
uint8_t type
Definition: BgpLayer.h:170
OsiModelLayer getOsiModelLayer() const
Definition: BgpLayer.h:111
size_t getHeaderLen() const
void computeCalculateFields()
Definition: BgpLayer.h:40
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:259
Definition: ProtocolType.h:348
std::string toString() const
BgpRouteRefreshMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:647
uint8_t optionalParameterLength
Definition: BgpLayer.h:159
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:564
Definition: BgpLayer.h:466
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:664
bgp_common_header bgp_keepalive_message
Definition: BgpLayer.h:586
uint8_t flags
Definition: BgpLayer.h:310
uint8_t safi
Definition: BgpLayer.h:636
BgpMessageType
Definition: BgpLayer.h:35
path_attribute()
Definition: BgpLayer.h:321
prefix_and_ip(uint8_t prefixVal, const std::string &ipAddrVal)
Definition: BgpLayer.h:299
Definition: BgpLayer.h:629
Definition: BgpLayer.h:46
uint8_t reserved
Definition: BgpLayer.h:634
Definition: BgpLayer.h:38
BgpUpdateMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:340
bgp_keepalive_message * getKeepaliveHeader() const
Definition: BgpLayer.h:606
uint8_t errorSubCode
Definition: BgpLayer.h:480
bgp_common_header * getBasicMsgHeader() const
Definition: BgpLayer.h:357
Definition: BgpLayer.h:139
IPv4Address getBgpId() const
Definition: BgpLayer.h:219
bgp_open_message * getOpenMsgHeader() const
Definition: BgpLayer.h:214
static BgpLayer * parseBgpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:148
std::string getMessageTypeAsString() const
bgp_notification_message * getNotificationMsgHeader() const
Definition: BgpLayer.h:522
Definition: IpAddress.h:42
Definition: BgpLayer.h:282
Definition: BgpLayer.h:28
Definition: BgpLayer.h:475
uint8_t version
Definition: BgpLayer.h:151
uint8_t length
Definition: BgpLayer.h:172
BgpOpenMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:197
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:448
IPv4Address ipAddr
Definition: BgpLayer.h:287
Definition: BgpLayer.h:578
Definition: BgpLayer.h:44
Definition: BgpLayer.h:620
optional_parameter()
Definition: BgpLayer.h:179
uint16_t myAutonomousSystem
Definition: BgpLayer.h:153
BgpNotificationMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:491
uint16_t afi
Definition: BgpLayer.h:632
bgp_route_refresh_message * getRouteRefreshHeader() const
Definition: BgpLayer.h:660
uint8_t type
Definition: BgpLayer.h:312
BgpKeepaliveMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:595
Definition: BgpLayer.h:167
Definition: BgpLayer.h:42
const ProtocolType BGP
Definition: ProtocolType.h:228
uint32_t bgpId
Definition: BgpLayer.h:157
virtual BgpMessageType getBgpMessageType() const =0
uint8_t errorCode
Definition: BgpLayer.h:478