bgp

BGP management module.

Border Gateway Protocol (BGP) is a standardized exterior gateway routing protocol designed to exchange routing and reachability information among autonomous systems (AS). In EOS, BGP follows RFC4271.

This module provides APIs to query BGP information including BGP peer state.

An example of the API usage is in examples/BgpAgent.cpp

namespace eos
class bgp_peer_handler : public eos::base_handler<bgp_mgr, bgp_peer_handler>
#include <bgp.h>

The BGP peer handler.

This class provides handler APIs to react to a BGP peer’s session state change.

Public Functions

explicit bgp_peer_handler(bgp_mgr *mgr)
inline bgp_mgr *get_bgp_mgr() const
void watch_all_peers(bool)

Register to receive notifications when any peer changes state.

void watch_peer(bgp_peer_key_t const &peer_key, bool)

Register to receive notifications when the specified peer changes state.

virtual void on_peer_state(bgp_peer_key_t const &peer_key, bgp_peer_state_t peer_state)

Called when BGP peer state change.

virtual void on_peer_set(bgp_peer_key_t const &peer_key)

Called when a BGP peer is created.

virtual void on_peer_del(bgp_peer_key_t const &peer_key)

Called when a BGP peer is deleted.

class bgp_mgr : public eos::base_mgr<bgp_peer_handler, bgp_peer_key_t>
#include <bgp.h>

A manager of BGP configurations.

Public Functions

virtual ~bgp_mgr()
virtual bool exists(bgp_peer_key_t const &peer_key) const = 0

Test for existence of a BGP peer.

virtual bgp_peer_state_t peer_state(bgp_peer_key_t const &peer_key) const = 0

Returns the state of a peer session.

If the given peer does not have a valid status or it didn’t match any peers in the system, this would returns PEER_UNKNOWN;

Protected Functions

bgp_mgr()

Private Members

bgp_mgr

Friends

friend class bgp_peer_handler

Type definitions in bgp

namespace eos

Typedefs

typedef uint32_t bgp_asn_t

Enums

enum bgp_peer_state_t

The operational state of a BGP peer session.

Values:

enumerator PEER_UNKNOWN
enumerator PEER_IDLE
enumerator PEER_CONNECT
enumerator PEER_ACTIVE
enumerator PEER_OPENSENT
enumerator PEER_OPENCONFIRM
enumerator PEER_ESTABLISHED
class bgp_peer_key_t
#include <bgp.h>

The BGP peer key which consists of the peer address and the VRF itresides in.

Public Functions

bgp_peer_key_t()
explicit bgp_peer_key_t(std::string const &vrf_name, ip_addr_t const &peer_addr)
bgp_peer_key_t(const bgp_peer_key_t &other)
bgp_peer_key_t &operator=(bgp_peer_key_t const &other)
bgp_peer_key_t(bgp_peer_key_t &&other) noexcept
bgp_peer_key_t &operator=(bgp_peer_key_t &&other) noexcept
std::string vrf_name() const

Getter for ‘vrf_name’: VRF name.

void vrf_name_is(std::string const &vrf_name)

Setter for ‘vrf_name’.

void vrf_name_is(std::string &&vrf_name)

Moving Setter for ‘vrf_name’.

ip_addr_t peer_addr() const

Getter for ‘peer_addr’: BGP peer address.

void peer_addr_is(ip_addr_t const &peer_addr)

Setter for ‘peer_addr’.

void peer_addr_is(ip_addr_t &&peer_addr)

Moving Setter for ‘peer_addr’.

bool operator==(bgp_peer_key_t const &other) const
bool operator!=(bgp_peer_key_t const &other) const
bool operator<(bgp_peer_key_t const &other) const
uint32_t hash() const

The hash function for type bgp_peer_key_t.

void mix_me(hash_mix &h) const

The hash mix function for type bgp_peer_key_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Public Static Functions

static inline void *operator new(std::size_t, void *ptr)
static void *operator new(std::size_t)
static void operator delete(void*) noexcept

Private Members

std::shared_ptr<bgp_peer_key_impl_t> pimpl

Friends

friend std::ostream &operator<<(std::ostream &os, const bgp_peer_key_t &obj)

A utility stream operator that adds a string representation of bgp_peer_key_t to the ostream.