libbgp
0.6
A C++ BGP Library.
|
The BgpRib4 (IPv4 BGP Routing Information Base) class. More...
#include <bgp-rib4.h>
Public Member Functions | |
BgpRib4 (BgpLogHandler *logger) | |
Construct a new BgpRib4 object with logging. More... | |
const BgpRib4Entry * | insert (BgpLogHandler *logger, const Prefix4 &route, uint32_t nexthop, int32_t weight=0) |
Insert a local route into RIB. More... | |
const std::vector< BgpRib4Entry > | insert (BgpLogHandler *logger, const std::vector< Prefix4 > &routes, uint32_t nexthop, int32_t weight=0) |
Insert local routes into RIB. More... | |
std::pair< const BgpRib4Entry *, bool > | insert (uint32_t src_router_id, const Prefix4 &route, const std::vector< std::shared_ptr< BgpPathAttrib >> &attrib, int32_t weight, uint32_t ibgp_asn) |
Insert a new entry into RIB. More... | |
std::pair< std::vector< BgpRib4Entry >, std::vector< Prefix4 > > | insert (uint32_t src_router_id, const std::vector< Prefix4 > &routes, const std::vector< std::shared_ptr< BgpPathAttrib >> &attrib, int32_t weight, uint32_t ibgp_asn) |
Insert new entries into RIB. More... | |
std::pair< bool, const BgpRib4Entry * > | withdraw (uint32_t src_router_id, const Prefix4 &route) |
Withdraw a route from RIB. More... | |
std::pair< std::vector< Prefix4 >, std::vector< BgpRib4Entry > > | discard (uint32_t src_router_id) |
Drop all routes from RIB that originated from a BGP speaker. More... | |
const BgpRib4Entry * | lookup (uint32_t dest) const |
Lookup a destination in RIB. More... | |
const BgpRib4Entry * | lookup (uint32_t src_router_id, uint32_t dest) const |
Scoped RIB lookup. More... | |
const rib4_t & | get () const |
Get the RIB. More... | |
The BgpRib4 (IPv4 BGP Routing Information Base) class.
Definition at line 87 of file bgp-rib4.h.
libbgp::BgpRib4::BgpRib4 | ( | BgpLogHandler * | logger | ) |
Construct a new BgpRib4 object with logging.
logger | Log handler to use. |
Definition at line 55 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< T >::ibgp_peer_asn, libbgp::BgpRib4Entry::route, libbgp::BgpRibEntry< BgpRib4Entry >::src, libbgp::BgpRibEntry< T >::src, libbgp::BgpRibEntry< BgpRib4Entry >::src_router_id, libbgp::BgpRibEntry< T >::status, libbgp::BgpRibEntry< BgpRib4Entry >::update_id, libbgp::BgpRibEntry< T >::update_id, libbgp::BgpRibEntry< T >::weight, and libbgp::BgpRibEntry< BgpRib4Entry >::weight.
std::pair< std::vector< Prefix4 >, std::vector< BgpRib4Entry > > libbgp::BgpRib4::discard | ( | uint32_t | src_router_id | ) |
Drop all routes from RIB that originated from a BGP speaker.
src_router_id | src_router_id Originating BGP speaker's ID in network bytes order. |
Definition at line 414 of file bgp-rib4.cc.
const rib4_t & libbgp::BgpRib4::get | ( | ) | const |
const BgpRib4Entry * libbgp::BgpRib4::insert | ( | BgpLogHandler * | logger, |
const Prefix4 & | route, | ||
uint32_t | nexthop, | ||
int32_t | weight = 0 |
||
) |
Insert a local route into RIB.
Local routes are routes inserted to the RIB by user. The scope (src_router_id) of local routes are 0. This method will create necessary path attribues before inserting entry to RIB (AS_PATH, ORIGIN, NEXT_HOP).
The logger pointer passed in is for attribues. (so if a attribute failed to deserialize, it will print to the provided logger).
To remove an entry inserted with this method, use 0 as src_router_id
.
This SHOULD NOT be called when the any of the upper FSM is running.
logger | Pointer to logger for the created path attributes to use. |
route | Prefix4. |
nexthop | Nexthop for the route. |
weight | weight of this entry. |
NULL | failed to insert. |
!=NULL | Inserted route. |
Definition at line 218 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< BgpRib4Entry >::attribs, and libbgp::BgpPathAttribNexthop::next_hop.
const std::vector< BgpRib4Entry > libbgp::BgpRib4::insert | ( | BgpLogHandler * | logger, |
const std::vector< Prefix4 > & | routes, | ||
uint32_t | nexthop, | ||
int32_t | weight = 0 |
||
) |
Insert local routes into RIB.
ame as the other local insert, but this one insert mutiple routes.
This SHOULD NOT be called when the any of the upper FSM is running.
logger | Pointer to logger for the created path attributes to use. |
routes | Routes. |
nexthop | Nexthop for the route. |
weight | weight of this entry. |
Definition at line 272 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< BgpRib4Entry >::attribs, and libbgp::BgpPathAttribNexthop::next_hop.
std::pair< const BgpRib4Entry *, bool > libbgp::BgpRib4::insert | ( | uint32_t | src_router_id, |
const Prefix4 & | route, | ||
const std::vector< std::shared_ptr< BgpPathAttrib >> & | attrib, | ||
int32_t | weight, | ||
uint32_t | ibgp_asn | ||
) |
Insert a new entry into RIB.
src_router_id | Originating BGP speaker's ID in network bytes order. |
route | Prefix4. |
attrib | Path attribute. |
weight | weight of this entry. |
ibgp_asn | ASN of the peer if the route is from an IBGP peer. 0 if not. |
Definition at line 311 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< BgpRib4Entry >::update_id.
std::pair< std::vector< BgpRib4Entry >, std::vector< Prefix4 > > libbgp::BgpRib4::insert | ( | uint32_t | src_router_id, |
const std::vector< Prefix4 > & | routes, | ||
const std::vector< std::shared_ptr< BgpPathAttrib >> & | attrib, | ||
int32_t | weight, | ||
uint32_t | ibgp_asn | ||
) |
Insert new entries into RIB.
src_router_id | Originating BGP speaker's ID in network bytes order. |
routes | Routes. |
attrib | Path attribs. |
weight | weight of this entry. |
ibgp_asn | ASN of the peer if the route is from an IBGP peer. 0 if not. |
Definition at line 327 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< BgpRib4Entry >::update_id.
const BgpRib4Entry * libbgp::BgpRib4::lookup | ( | uint32_t | dest | ) | const |
Lookup a destination in RIB.
dest | The destination address in network byte order. |
NULL | no match found. |
BgpRib4Entry* | Matching entry. |
Definition at line 472 of file bgp-rib4.cc.
const BgpRib4Entry * libbgp::BgpRib4::lookup | ( | uint32_t | src_router_id, |
uint32_t | dest | ||
) | const |
Scoped RIB lookup.
Simular to lookup with only one argument but only lookup in routes from the given BGP speaker.
src_router_id | Originating BGP speaker's ID in network bytes order. |
dest | The destination address in network byte order. |
NULL | no match found. |
BgpRib4Entry* | Matching entry. |
Definition at line 501 of file bgp-rib4.cc.
std::pair< bool, const BgpRib4Entry * > libbgp::BgpRib4::withdraw | ( | uint32_t | src_router_id, |
const Prefix4 & | route | ||
) |
Withdraw a route from RIB.
src_router_id | Originating BGP speaker's ID in network bytes order. |
route | Prefix4. |
<false,NULL> | if the withdrawed route is no longer reachable. |
<true,NULL> | if the route withdrawed but still reachable with current best route. |
<true,const | BgpRib4Entry*> if the route withdrawed and that changes the current best route. |
Definition at line 353 of file bgp-rib4.cc.
References libbgp::BgpRibEntry< T >::status.