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

The BgpFsm class. More...

#include <bgp-fsm.h>

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

Public Member Functions

 BgpFsm (const BgpConfig &config)
 
uint32_t getAsn () const
 Get local ASN. More...
 
uint32_t getBgpId () const
 Get local BGP ID. More...
 
uint32_t getPeerAsn () const
 Get peer ASN. More...
 
uint32_t getPeerBgpId () const
 Get peer BGP ID. More...
 
uint16_t getHoldTimer () const
 Get the negotiated hold timer. More...
 
BgpRib4getRib4 () const
 Get the IPv4 Routing Information Base. More...
 
BgpRib6getRib6 () const
 Get the IPv6 Routing Information Base. More...
 
BgpState getState () const
 Get current FSM state. More...
 
int start ()
 send OPEN message to peer. (IDLE -> OpenSent) More...
 
int stop ()
 Stop the FSM. (Any -> Idle) More...
 
int run (const uint8_t *buffer, const size_t buffer_size)
 Run the FSM on buffer. More...
 
int tick ()
 Tick the clock (Check for time-based events) More...
 
int resetSoft ()
 Perform a soft reset. More...
 
void resetHard ()
 Perform a hard reset. More...
 

Additional Inherited Members

Detailed Description

The BgpFsm class.

Examples:
peer-and-print.cc, route-event-bus.cc, route-filter.cc, and route-server.cc.

Definition at line 44 of file bgp-fsm.h.

Member Function Documentation

◆ getAsn()

uint32_t libbgp::BgpFsm::getAsn ( ) const

Get local ASN.

Returns
uint32_t local ASN.

Definition at line 86 of file bgp-fsm.cc.

◆ getBgpId()

uint32_t libbgp::BgpFsm::getBgpId ( ) const

Get local BGP ID.

Returns
uint32_t local BGP ID in network btyes order.

Definition at line 90 of file bgp-fsm.cc.

◆ getHoldTimer()

uint16_t libbgp::BgpFsm::getHoldTimer ( ) const

Get the negotiated hold timer.

Returns
uint16_t negotiated hold timer.
Return values
0Hold timer was not negotiated yet.
>0negotiated hold timer.

Definition at line 102 of file bgp-fsm.cc.

◆ getPeerAsn()

uint32_t libbgp::BgpFsm::getPeerAsn ( ) const

Get peer ASN.

Returns
uint32_t peer ASN.
Return values
0Peer ASN unknow at this time.
>=0Peer ASN.
Examples:
route-server.cc.

Definition at line 94 of file bgp-fsm.cc.

◆ getPeerBgpId()

uint32_t libbgp::BgpFsm::getPeerBgpId ( ) const

Get peer BGP ID.

Returns
uint32_t peer BGP ID in network btyes order.
Return values
0Peer BGP ID unknow at this time.
>=0Peer BGP ID.

Definition at line 98 of file bgp-fsm.cc.

◆ getRib4()

BgpRib4 & libbgp::BgpFsm::getRib4 ( ) const

Get the IPv4 Routing Information Base.

Returns
BgpRib4& reference to the RIB.
Examples:
route-filter.cc.

Definition at line 106 of file bgp-fsm.cc.

◆ getRib6()

BgpRib6 & libbgp::BgpFsm::getRib6 ( ) const

Get the IPv6 Routing Information Base.

Returns
BgpRib6& reference to the RIB.

Definition at line 110 of file bgp-fsm.cc.

◆ getState()

BgpState libbgp::BgpFsm::getState ( ) const

Get current FSM state.

Returns
BgpState Current state.

Definition at line 114 of file bgp-fsm.cc.

◆ resetHard()

void libbgp::BgpFsm::resetHard ( )

Perform a hard reset.

Set FSM state to IDLE and clear the packet buffer.

Examples:
route-server.cc.

Definition at line 320 of file bgp-fsm.cc.

◆ resetSoft()

int libbgp::BgpFsm::resetSoft ( )

Perform a soft reset.

An Administrative Reset Notification will be sent to peer and FSM will go IDLE. This will also clear the BGP packet buffer.

Return values
-1Fatal Error. FSM is now in BROKEN state. error may be written to stderr with log handler.
0Success. Notification sent. FSM is now IDLE.

Definition at line 313 of file bgp-fsm.cc.

◆ run()

int libbgp::BgpFsm::run ( const uint8_t *  buffer,
const size_t  buffer_size 
)

Run the FSM on buffer.

Parameters
bufferPointer to buffer.
buffer_sizeSize of buffer.
Return values
-1Fatal error occured. FSM is now in BROKEN state and needs to be reset. error may be written to stderr with log handler.
0Protocol error occurred on the other side. Notification message was sent to peer and FSM is now IDLE state. error may be written to stderr with log handler.
1Success.
2Protocol error occurred on the local side. Got Notification message from peer and FSM is now IDLE state. error may be written to stderr with log handler.
3The packet passed in was incomplete. FSM will wait for more data.
Examples:
peer-and-print.cc, route-event-bus.cc, route-filter.cc, and route-server.cc.

Definition at line 179 of file bgp-fsm.cc.

◆ start()

int libbgp::BgpFsm::start ( )

send OPEN message to peer. (IDLE -> OpenSent)

Return values
0Failed to start. error may be written to stderr with log handler.
1open message sent.
Examples:
route-event-bus.cc, and route-filter.cc.

Definition at line 118 of file bgp-fsm.cc.

◆ stop()

int libbgp::BgpFsm::stop ( )

Stop the FSM. (Any -> Idle)

Return values
0Failed to stop. error may be written to stderr with log handler.
Examples:
peer-and-print.cc, route-event-bus.cc, and route-filter.cc.

Definition at line 157 of file bgp-fsm.cc.

◆ tick()

int libbgp::BgpFsm::tick ( )

Tick the clock (Check for time-based events)

tick() should be called regularly to check for time-based events like hold timer checks and keepalive message sending. BGP FSM will tick itself when run() is called but you should call tink() regularly to ensure the hold timer on the other side won't expire.

Return values
0Hold timer expired. Notification message was sent to the peer. FSM is now in IDLE state. error may be written to stderr with log handler.
1Success.
2Success, KEEPALIVE message sent to peer.
Examples:
peer-and-print.cc.

Definition at line 290 of file bgp-fsm.cc.


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