libbgp  0.6
A C++ BGP Library.
Public Member Functions | List of all members
libbgp::BgpRib6 Class Reference

The BgpRib6 (IPv6 BGP Routing Information Base) class. More...

#include <bgp-rib6.h>

Inheritance diagram for libbgp::BgpRib6:
Inheritance graph
[legend]
Collaboration diagram for libbgp::BgpRib6:
Collaboration graph
[legend]

Public Member Functions

 BgpRib6 (BgpLogHandler *logger)
 Construct a new BgpRib6 object with logging. More...
 
const BgpRib6Entryinsert (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< BgpRib6Entryinsert (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 BgpRib6Entrylookup (const uint8_t dest[16]) const
 Lookup a destination in RIB. More...
 
const BgpRib6Entrylookup (uint32_t src_router_id, const uint8_t dest[16]) const
 Scoped RIB lookup. More...
 
const rib6_t & get () const
 Get the RIB. More...
 

Detailed Description

The BgpRib6 (IPv6 BGP Routing Information Base) class.

Definition at line 98 of file bgp-rib6.h.

Constructor & Destructor Documentation

◆ BgpRib6()

libbgp::BgpRib6::BgpRib6 ( BgpLogHandler logger)

Member Function Documentation

◆ discard()

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.

Parameters
src_router_idsrc_router_id Originating BGP speaker's ID in network bytes order.
Returns
std::pair<std::vector<Prefix6>, std::vector<BgpRib6Entry>> <dropped_routes, updated_routes> pair. dropped_routes should be send as withdrawn to peers, updated_routes should be send as update to peer.

Definition at line 403 of file bgp-rib6.cc.

◆ get()

const rib6_t & libbgp::BgpRib6::get ( ) const

Get the RIB.

Returns
const rib6_t& The RIB.

Definition at line 538 of file bgp-rib6.cc.

◆ insert() [1/4]

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.

Parameters
loggerPointer to logger for the created path attributes to use.
routeRoute.
nexthop_globalGlobal IPv6 address of nexthop.
nexthop_linklocalLink local IPv6 address of nexthop. (if none, use NULL)
weightweight of this entry.
Returns
const BgpRib6Entry* Inserted route entry.
Return values
NULLfailed to insert.
!=NULLInserted route entry.

Definition at line 191 of file bgp-rib6.cc.

References libbgp::BgpRibEntry< BgpRib6Entry >::attribs.

◆ insert() [2/4]

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.

Parameters
loggerPointer to logger for the created path attributes to use.
routesRoutes.
nexthop_globalGlobal IPv6 address of nexthop.
nexthop_linklocalLink local IPv6 address of nexthop. (if none, use NULL)
weightweight of this entry.
Returns
const std::vector<BgpRib6Entry*> Insert routes.

Definition at line 242 of file bgp-rib6.cc.

References libbgp::BgpRibEntry< BgpRib6Entry >::attribs.

◆ insert() [3/4]

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.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routeRoute to be inserted.
nexthop_globalGlobal IPv6 address of nexthop.
nexthop_linklocalLink local IPv6 address of nexthop. (if none, use NULL)
attribPath attribute.
weightweight of this entry.
ibgp_asnASN of the peer if the route is from an IBGP peer. 0 if not.
Returns
<const BgpRib6Entry*, bool> inserted info: <new_best_route, inserted_is_best>
Return values
<constBgpRib6Entry*, true> inserted route is the new best route. const BgpRib6Entry* is the inserted route.
<constBgpRib6Entry*, 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.

◆ insert() [4/4]

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.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routesList of routes.
nexthop_globalGlobal IPv6 address of nexthop.
nexthop_linklocalLink local IPv6 address of nexthop. (if none, use NULL)
attribPath attribute.
weightweight of this entry.
ibgp_asnASN of the peer if the route is from an IBGP peer. 0 if not.
Returns
<updated_routes, new_best_routes>

Definition at line 312 of file bgp-rib6.cc.

References libbgp::BgpRibEntry< BgpRib6Entry >::attribs, and libbgp::BgpRibEntry< BgpRib6Entry >::update_id.

◆ lookup() [1/2]

const BgpRib6Entry * libbgp::BgpRib6::lookup ( const uint8_t  dest[16]) const

Lookup a destination in RIB.

Parameters
destThe destination address.
Returns
const BgpRib6::BgpRib6Entry* Matching entry.
Return values
NULLno match found.
BgpRib6Entry*Matching entry.

Definition at line 483 of file bgp-rib6.cc.

◆ lookup() [2/2]

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.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
destThe destination address.
Returns
const BgpRib6::BgpRib6Entry* Matching entry.
Return values
NULLno match found.
BgpRib6Entry*Matching entry.

Definition at line 512 of file bgp-rib6.cc.

◆ withdraw()

std::pair< bool, const BgpRib6Entry * > libbgp::BgpRib6::withdraw ( uint32_t  src_router_id,
const Prefix6 route 
)

Withdraw a route from RIB.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routeRoute.
Returns
<bool, const BgpRib6Entry*> withdrawn information
Return values
<false,NULL>if the withdrawed route is no longer reachable.
<true,NULL>if the route withdrawed but still reachable with current best route.
<true,constBgpRib6Entry*> 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.


The documentation for this class was generated from the following files: