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

The BgpRib4 (IPv4 BGP Routing Information Base) class. More...

#include <bgp-rib4.h>

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

Public Member Functions

 BgpRib4 (BgpLogHandler *logger)
 Construct a new BgpRib4 object with logging. More...
 
const BgpRib4Entryinsert (BgpLogHandler *logger, const Prefix4 &route, uint32_t nexthop, int32_t weight=0)
 Insert a local route into RIB. More...
 
const std::vector< BgpRib4Entryinsert (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 BgpRib4Entrylookup (uint32_t dest) const
 Lookup a destination in RIB. More...
 
const BgpRib4Entrylookup (uint32_t src_router_id, uint32_t dest) const
 Scoped RIB lookup. More...
 
const rib4_t & get () const
 Get the RIB. More...
 

Detailed Description

The BgpRib4 (IPv4 BGP Routing Information Base) class.

Examples:
route-event-bus.cc, and route-server.cc.

Definition at line 87 of file bgp-rib4.h.

Constructor & Destructor Documentation

◆ BgpRib4()

libbgp::BgpRib4::BgpRib4 ( BgpLogHandler logger)

Member Function Documentation

◆ discard()

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.

Parameters
src_router_idsrc_router_id Originating BGP speaker's ID in network bytes order.
Returns
std::pair<std::vector<Prefix4>, std::vector<BgpRib4Entry>> <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 414 of file bgp-rib4.cc.

◆ get()

const rib4_t & libbgp::BgpRib4::get ( ) const

Get the RIB.

Returns
const rib4_t& The RIB.

Definition at line 527 of file bgp-rib4.cc.

◆ insert() [1/4]

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.

Parameters
loggerPointer to logger for the created path attributes to use.
routePrefix4.
nexthopNexthop for the route.
weightweight of this entry.
Return values
NULLfailed to insert.
!=NULLInserted route.
Examples:
route-event-bus.cc, and route-filter.cc.

Definition at line 218 of file bgp-rib4.cc.

References libbgp::BgpRibEntry< BgpRib4Entry >::attribs, and libbgp::BgpPathAttribNexthop::next_hop.

◆ insert() [2/4]

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.

Parameters
loggerPointer to logger for the created path attributes to use.
routesRoutes.
nexthopNexthop for the route.
weightweight of this entry.
Returns
const std::vector<const BgpRib4Entry*> Inserted routes.

Definition at line 272 of file bgp-rib4.cc.

References libbgp::BgpRibEntry< BgpRib4Entry >::attribs, and libbgp::BgpPathAttribNexthop::next_hop.

◆ insert() [3/4]

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.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routePrefix4.
attribPath attribute.
weightweight of this entry.
ibgp_asnASN of the peer if the route is from an IBGP peer. 0 if not.
Returns
<const BgpRib4Entry*, bool> entry that should be send to peer. (NULL-able)

Definition at line 311 of file bgp-rib4.cc.

References libbgp::BgpRibEntry< BgpRib4Entry >::update_id.

◆ insert() [4/4]

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.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routesRoutes.
attribPath attribs.
weightweight of this entry.
ibgp_asnASN of the peer if the route is from an IBGP peer. 0 if not.
Returns
std::pair<std::vector<BgpRib4Entry>, std::vector<Prefix4>> pair of vectors. <updated_entries, unchanged_entries>.

Definition at line 327 of file bgp-rib4.cc.

References libbgp::BgpRibEntry< BgpRib4Entry >::update_id.

◆ lookup() [1/2]

const BgpRib4Entry * libbgp::BgpRib4::lookup ( uint32_t  dest) const

Lookup a destination in RIB.

Parameters
destThe destination address in network byte order.
Returns
const BgpRib4Entry* Matching entry.
Return values
NULLno match found.
BgpRib4Entry*Matching entry.

Definition at line 472 of file bgp-rib4.cc.

◆ lookup() [2/2]

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.

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

Definition at line 501 of file bgp-rib4.cc.

◆ withdraw()

std::pair< bool, const BgpRib4Entry * > libbgp::BgpRib4::withdraw ( uint32_t  src_router_id,
const Prefix4 route 
)

Withdraw a route from RIB.

Parameters
src_router_idOriginating BGP speaker's ID in network bytes order.
routePrefix4.
Returns
<bool, const BgpRib4Entry*> 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,constBgpRib4Entry*> if the route withdrawed and that changes the current best route.
Examples:
route-event-bus.cc.

Definition at line 353 of file bgp-rib4.cc.

References libbgp::BgpRibEntry< T >::status.


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