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; }
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>());
231 void getOptionalParameters(std::vector<optional_parameter>& optionalParameters);
236 size_t getOptionalParametersLength();
246 bool setOptionalParameters(
const std::vector<optional_parameter>& optionalParameters);
254 bool clearOptionalParameters();
262 size_t optionalParamsToByteArray(
const std::vector<optional_parameter>& optionalParams, uint8_t* resultByteArr,
size_t maxByteArrSize);
298 prefix_and_ip(uint8_t prefixVal,
const std::string& ipAddrVal): prefix(prefixVal), ipAddr(ipAddrVal) {}
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>());
361 size_t getWithdrawnRoutesLength()
const;
367 void getWithdrawnRoutes(std::vector<prefix_and_ip>& withdrawnRoutes);
377 bool setWithdrawnRoutes(
const std::vector<prefix_and_ip>& withdrawnRoutes);
385 bool clearWithdrawnRoutes();
390 size_t getPathAttributesLength()
const;
396 void getPathAttributes(std::vector<path_attribute>& pathAttributes);
406 bool setPathAttributes(
const std::vector<path_attribute>& pathAttributes);
414 bool clearPathAttributes();
419 size_t getNetworkLayerReachabilityInfoLength()
const;
425 void getNetworkLayerReachabilityInfo(std::vector<prefix_and_ip>& nlri);
435 bool setNetworkLayerReachabilityInfo(
const std::vector<prefix_and_ip>& nlri);
443 bool clearNetworkLayerReachabilityInfo();
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) 527 size_t getNotificationDataLen()
const;
533 uint8_t* getNotificationData()
const;
539 std::string getNotificationDataAsHexString()
const;
549 bool setNotificationData(
const uint8_t* newNotificationData,
size_t newNotificationDataLen);
559 bool setNotificationData(
const std::string& newNotificationDataAsHexString);
567 void initMessageData(uint8_t errorCode, uint8_t errorSubCode,
const uint8_t* notificationData,
size_t notificationDataLen);
605 bgp_keepalive_message*
getKeepaliveHeader()
const {
return (bgp_keepalive_message*)getBasicHeader(); }
627 #pragma pack(push, 1) 669 #endif //PACKETPP_BGP_LAYER The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:253
uint8_t length
Definition: BgpLayer.h:313
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:609
uint16_t holdTime
Definition: BgpLayer.h:154
static bool isBgpPort(uint16_t portSrc, uint16_t portDst)
Definition: BgpLayer.h:81
prefix_and_ip()
Definition: BgpLayer.h:291
Definition: BgpLayer.h:306
Definition: BgpLayer.h:272
uint8_t prefix
Definition: BgpLayer.h:284
uint8_t type
Definition: BgpLayer.h:169
OsiModelLayer getOsiModelLayer() const
Definition: BgpLayer.h:110
size_t getHeaderLen() const
void computeCalculateFields()
Definition: BgpLayer.h:40
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:258
Definition: ProtocolType.h:268
std::string toString() const
BgpRouteRefreshMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:646
uint8_t optionalParameterLength
Definition: BgpLayer.h:158
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:563
Definition: BgpLayer.h:465
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:663
bgp_common_header bgp_keepalive_message
Definition: BgpLayer.h:585
uint8_t flags
Definition: BgpLayer.h:309
uint8_t safi
Definition: BgpLayer.h:635
BgpMessageType
Definition: BgpLayer.h:35
path_attribute()
Definition: BgpLayer.h:320
prefix_and_ip(uint8_t prefixVal, const std::string &ipAddrVal)
Definition: BgpLayer.h:298
Definition: BgpLayer.h:628
Definition: BgpLayer.h:46
uint8_t reserved
Definition: BgpLayer.h:633
Definition: BgpLayer.h:38
BgpUpdateMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:339
bgp_keepalive_message * getKeepaliveHeader() const
Definition: BgpLayer.h:605
uint8_t errorSubCode
Definition: BgpLayer.h:479
bgp_common_header * getBasicMsgHeader() const
Definition: BgpLayer.h:356
Definition: BgpLayer.h:138
IPv4Address getBgpId() const
Definition: BgpLayer.h:218
bgp_open_message * getOpenMsgHeader() const
Definition: BgpLayer.h:213
static BgpLayer * parseBgpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:147
std::string getMessageTypeAsString() const
bgp_notification_message * getNotificationMsgHeader() const
Definition: BgpLayer.h:521
Definition: IpAddress.h:26
Definition: BgpLayer.h:281
Definition: BgpLayer.h:28
Definition: BgpLayer.h:474
uint8_t version
Definition: BgpLayer.h:150
uint8_t length
Definition: BgpLayer.h:171
BgpOpenMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:196
BgpMessageType getBgpMessageType() const
Definition: BgpLayer.h:447
IPv4Address ipAddr
Definition: BgpLayer.h:286
Definition: BgpLayer.h:577
Definition: BgpLayer.h:44
Definition: BgpLayer.h:619
optional_parameter()
Definition: BgpLayer.h:178
uint16_t myAutonomousSystem
Definition: BgpLayer.h:152
BgpNotificationMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:490
uint16_t afi
Definition: BgpLayer.h:631
bgp_route_refresh_message * getRouteRefreshHeader() const
Definition: BgpLayer.h:659
uint8_t type
Definition: BgpLayer.h:311
BgpKeepaliveMessageLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: BgpLayer.h:594
Definition: BgpLayer.h:166
Definition: BgpLayer.h:42
const ProtocolType BGP
Definition: ProtocolType.h:228
uint32_t bgpId
Definition: BgpLayer.h:156
virtual BgpMessageType getBgpMessageType() const =0
uint8_t errorCode
Definition: BgpLayer.h:477