bgpstream_elem.h

Header file that exposes the public interface of a bgpstream elem.

Author
Chiara Orsini

Public Enums

enum bgpstream_elem_peerstate_t

Peer state encodes the state of the peer:

  • 0 - the state of the peer is unknown
  • [1-6] - the state encoded is one of the six FSM states described in RFC1771
  • [7-8] - inactive state in which all routes are cleared, more infor in quagga documentation http://goo.gl/NS9mSv

Values:

BGPSTREAM_ELEM_PEERSTATE_UNKNOWN = 0

Peer state unknown.

BGPSTREAM_ELEM_PEERSTATE_IDLE = 1

Peer state idle.

BGPSTREAM_ELEM_PEERSTATE_CONNECT = 2

Peer state connect.

BGPSTREAM_ELEM_PEERSTATE_ACTIVE = 3

Peer state active.

BGPSTREAM_ELEM_PEERSTATE_OPENSENT = 4

Peer state open-sent.

BGPSTREAM_ELEM_PEERSTATE_OPENCONFIRM = 5

Peer state open-confirm.

BGPSTREAM_ELEM_PEERSTATE_ESTABLISHED = 6

Peer state established.

BGPSTREAM_ELEM_PEERSTATE_CLEARING = 7

Peer state clearing.

BGPSTREAM_ELEM_PEERSTATE_DELETED = 8

Peer state clearing.

enum bgpstream_elem_type_t

Elem types.

Values:

BGPSTREAM_ELEM_TYPE_UNKNOWN = 0

Unknown.

BGPSTREAM_ELEM_TYPE_RIB = 1

RIB Entry.

BGPSTREAM_ELEM_TYPE_ANNOUNCEMENT = 2

Announcement.

BGPSTREAM_ELEM_TYPE_WITHDRAWAL = 3

Withdrawal.

BGPSTREAM_ELEM_TYPE_PEERSTATE = 4

Peer state change.

Public Data Structures

typedef struct struct_bgpstream_elem_t bgpstream_elem_t

A BGP Stream Elem object.

Public API Functions

bgpstream_elem_t *bgpstream_elem_create()

Create a new BGP Stream Elem instance.

Return
a pointer to an Elem instance if successful, NULL otherwise

void bgpstream_elem_destroy(bgpstream_elem_t *elem)

Destroy the given BGP Stream Elem instance.

Parameters
  • elem -

    pointer to a BGP Stream Elem instance to destroy

void bgpstream_elem_clear(bgpstream_elem_t *elem)

Clear the given BGP Stream Elem instance.

Parameters
  • elem -

    pointer to a BGP Stream Elem instance to clear

bgpstream_elem_t *bgpstream_elem_copy(bgpstream_elem_t *dst, bgpstream_elem_t *src)

Copy the given BGP Stream Elem to the given destination.

The dst elem must have been created using bgpstream_elem_create, or if being re-used, cleared using bgpstream_elem_clear before calling this function.

Return
pointer to dst if successful, NULL otherwise
Parameters
  • dst -

    pointer to an elem to copy into

  • src -

    pointer to an elem to copy from

int bgpstream_elem_type_snprintf(char *buf, size_t len, bgpstream_elem_type_t type)

Write the string representation of the elem type into the provided buffer.

Return
the number of characters that would have been written if len was unlimited
Parameters
  • buf -

    pointer to a char array

  • len -

    length of the char array

  • type -

    BGP Stream Elem type to convert to string

int bgpstream_elem_peerstate_snprintf(char *buf, size_t len, bgpstream_elem_peerstate_t state)

Write the string representation of the elem peerstate into the provided buffer.

Return
the number of characters that would have been written if len was unlimited
Parameters
  • buf -

    pointer to a char array

  • len -

    length of the char array

  • state -

    BGP Stream Elem peerstate to convert to string

char *bgpstream_elem_snprintf(char *buf, size_t len, const bgpstream_elem_t *elem)

Write the string representation of the elem into the provided buffer.

Return
pointer to the start of the buffer if successful, NULL otherwise
Parameters
  • buf -

    pointer to a char array

  • len -

    length of the char array

  • elem -

    pointer to a BGP Stream Elem to convert to string

struct struct_bgpstream_elem_t
#include <bgpstream_elem.h>

A BGP Stream Elem object.

Public Members

bgpstream_elem_type_t type

Type.

uint32_t timestamp

Epoch time when this elem was generated by the collector.

bgpstream_addr_storage_t peer_address

Peer IP address.

uint32_t peer_asnumber

Peer AS number.

bgpstream_pfx_storage_t prefix

IP prefix.

Available only for RIB, Announcement and Withdrawal elem types

bgpstream_addr_storage_t nexthop

Next hop.

Available only for RIB and Announcement elem types

bgpstream_as_path_t *aspath

AS path.

Available only for RIB and Announcement elem types

bgpstream_community_set_t *communities

Communities.

Available only for RIB and Announcement elem types

bgpstream_elem_peerstate_t old_state

Old peer state.

Available only for the Peer-state elem type

bgpstream_elem_peerstate_t new_state

New peer state.

Available only for the Peer-state elem type