libbgp
0.6
A C++ BGP Library.
|
The BgpRib6 (IPv6 BGP Routing Information Base) class. More...
#include <bgp-rib6.h>
Public Member Functions | |
BgpRib6 (BgpLogHandler *logger) | |
Construct a new BgpRib6 object with logging. More... | |
const BgpRib6Entry * | insert (BgpLogHandler *logger, const Prefix6 &route, const uint8_t nexthop_global[16], const uint8_t nexthop_linklocal[16], int32_t weight=0) |
Insert a local route into RIB. More... | |
const std::vector< BgpRib6Entry > | insert (BgpLogHandler *logger, const std::vector< Prefix6 > &routes, const uint8_t nexthop_global[16], const uint8_t nexthop_linklocal[16], int32_t weight=0) |
Insert local routes into RIB. More... | |
std::pair< const BgpRib6Entry *, bool > | insert (uint32_t src_router_id, const Prefix6 &route, const uint8_t nexthop_global[16], const uint8_t nexthop_linklocal[16], const std::vector< std::shared_ptr< BgpPathAttrib >> &attrib, int32_t weight, uint32_t ibgp_asn) |
Insert new entries into RIB. More... | |
std::pair< std::vector< BgpRib6Entry >, std::vector< Prefix6 > > | insert (uint32_t src_router_id, const std::vector< Prefix6 > &routes, const uint8_t nexthop_global[16], const uint8_t nexthop_linklocal[16], 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 BgpRib6Entry * > | withdraw (uint32_t src_router_id, const Prefix6 &route) |
Withdraw a route from RIB. More... | |
std::pair< std::vector< Prefix6 >, std::vector< BgpRib6Entry > > | discard (uint32_t src_router_id) |
Drop all routes from RIB that originated from a BGP speaker. More... | |
const BgpRib6Entry * | lookup (const uint8_t dest[16]) const |
Lookup a destination in RIB. More... | |
const BgpRib6Entry * | lookup (uint32_t src_router_id, const uint8_t dest[16]) const |
Scoped RIB lookup. More... | |
const rib6_t & | get () const |
Get the RIB. More... | |
The BgpRib6 (IPv6 BGP Routing Information Base) class.
Definition at line 98 of file bgp-rib6.h.
libbgp::BgpRib6::BgpRib6 | ( | BgpLogHandler * | logger | ) |
Construct a new BgpRib6 object with logging.
logger | Log handler to use. |
Definition at line 43 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< BgpRib6Entry >::attribs, libbgp::BgpRibEntry< T >::ibgp_peer_asn, libbgp::BgpRib6Entry::nexthop_global, libbgp::BgpRib6Entry::nexthop_linklocal, libbgp::BgpRib6Entry::route, libbgp::BgpRibEntry< BgpRib6Entry >::src, libbgp::BgpRibEntry< T >::src, libbgp::BgpRibEntry< BgpRib6Entry >::src_router_id, libbgp::BgpRibEntry< T >::status, libbgp::BgpRibEntry< T >::update_id, libbgp::BgpRibEntry< BgpRib6Entry >::update_id, libbgp::BgpRibEntry< BgpRib6Entry >::weight, and libbgp::BgpRibEntry< T >::weight.
std::pair< std::vector< Prefix6 >, std::vector< BgpRib6Entry > > libbgp::BgpRib6::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 403 of file bgp-rib6.cc.
const rib6_t & libbgp::BgpRib6::get | ( | ) | const |
const BgpRib6Entry * libbgp::BgpRib6::insert | ( | BgpLogHandler * | logger, |
const Prefix6 & | route, | ||
const uint8_t | nexthop_global[16], | ||
const uint8_t | nexthop_linklocal[16], | ||
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 | Route. |
nexthop_global | Global IPv6 address of nexthop. |
nexthop_linklocal | Link local IPv6 address of nexthop. (if none, use NULL) |
weight | weight of this entry. |
NULL | failed to insert. |
!=NULL | Inserted route entry. |
Definition at line 191 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< BgpRib6Entry >::attribs.
const std::vector< BgpRib6Entry > libbgp::BgpRib6::insert | ( | BgpLogHandler * | logger, |
const std::vector< Prefix6 > & | routes, | ||
const uint8_t | nexthop_global[16], | ||
const uint8_t | nexthop_linklocal[16], | ||
int32_t | weight = 0 |
||
) |
Insert local routes into RIB.
Same 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_global | Global IPv6 address of nexthop. |
nexthop_linklocal | Link local IPv6 address of nexthop. (if none, use NULL) |
weight | weight of this entry. |
Definition at line 242 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< BgpRib6Entry >::attribs.
std::pair< const BgpRib6Entry *, bool > libbgp::BgpRib6::insert | ( | uint32_t | src_router_id, |
const Prefix6 & | route, | ||
const uint8_t | nexthop_global[16], | ||
const uint8_t | nexthop_linklocal[16], | ||
const std::vector< std::shared_ptr< BgpPathAttrib >> & | attribs, | ||
int32_t | weight, | ||
uint32_t | ibgp_asn | ||
) |
Insert new entries into RIB.
src_router_id | Originating BGP speaker's ID in network bytes order. |
route | Route to be inserted. |
nexthop_global | Global IPv6 address of nexthop. |
nexthop_linklocal | Link local IPv6 address of nexthop. (if none, use NULL) |
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. |
<const | BgpRib6Entry*, true> inserted route is the new best route. const BgpRib6Entry* is the inserted route. |
<const | BgpRib6Entry*, false> inseted route replaced current best route, but new best route is NOT the inserted one. New best has been returned in const BgpRib6Entry*. |
<NULL,false> | inserted route is not the new best, and current best has not changed. |
Definition at line 290 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< BgpRib6Entry >::attribs, and libbgp::BgpRibEntry< BgpRib6Entry >::update_id.
std::pair< std::vector< BgpRib6Entry >, std::vector< Prefix6 > > libbgp::BgpRib6::insert | ( | uint32_t | src_router_id, |
const std::vector< Prefix6 > & | routes, | ||
const uint8_t | nexthop_global[16], | ||
const uint8_t | nexthop_linklocal[16], | ||
const std::vector< std::shared_ptr< BgpPathAttrib >> & | attribs, | ||
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 | List of routes. |
nexthop_global | Global IPv6 address of nexthop. |
nexthop_linklocal | Link local IPv6 address of nexthop. (if none, use NULL) |
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 312 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< BgpRib6Entry >::attribs, and libbgp::BgpRibEntry< BgpRib6Entry >::update_id.
const BgpRib6Entry * libbgp::BgpRib6::lookup | ( | const uint8_t | dest[16] | ) | const |
Lookup a destination in RIB.
dest | The destination address. |
NULL | no match found. |
BgpRib6Entry* | Matching entry. |
Definition at line 483 of file bgp-rib6.cc.
const BgpRib6Entry * libbgp::BgpRib6::lookup | ( | uint32_t | src_router_id, |
const uint8_t | dest[16] | ||
) | 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. |
NULL | no match found. |
BgpRib6Entry* | Matching entry. |
Definition at line 512 of file bgp-rib6.cc.
std::pair< bool, const BgpRib6Entry * > libbgp::BgpRib6::withdraw | ( | uint32_t | src_router_id, |
const Prefix6 & | route | ||
) |
Withdraw a route from RIB.
src_router_id | Originating BGP speaker's ID in network bytes order. |
route | Route. |
<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 | BgpRib6Entry*> if the route withdrawed and that changes the current best route. |
Definition at line 341 of file bgp-rib6.cc.
References libbgp::BgpRibEntry< T >::status.