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_origin_type_t

BGP ORIGIN Path Attribute values.

Values:

BGPSTREAM_ELEM_BGP_UPDATE_ORIGIN_IGP = 0

IGP - Network Layer Reachability Information is interior to the originating AS.

BGPSTREAM_ELEM_BGP_UPDATE_ORIGIN_EGP = 1

EGP - Network Layer Reachability Information learned via the EGP protocol [RFC904].

BGPSTREAM_ELEM_BGP_UPDATE_ORIGIN_INCOMPLETE = 2

INCOMPLETE - Network Layer Reachability Information learned by some other means.

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.

typedef struct struct_bgpstream_annotations_t bgpstream_annotations_t
typedef struct bgpstream_elem_aggregator bgpstream_elem_aggregator_t

Elem aggregator object.

Public Data Structures

typedef struct bgpstream_elem bgpstream_elem_t

A BGP Stream Elem object.

Public API Functions

bgpstream_elem_t *bgpstream_elem_create(void)

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, const 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_annotations_t

Public Members

int rpki_active

RPKI active.

struct struct_rpki_config_t *cfg

RPKI validation configuration.

uint32_t timestamp

Record timestamp.

struct bgpstream_elem_aggregator
#include <bgpstream_elem.h>

Elem aggregator object.

Public Members

uint8_t has_aggregator

Boolean value to check if aggregator field is set.

uint32_t aggregator_asn

Aggregator ASN.

bgpstream_ip_addr_t aggregator_addr

Aggregator IP.

struct bgpstream_elem
#include <bgpstream_elem.h>

A BGP Stream Elem object.

Public Members

bgpstream_elem_type_t type

Type.

uint32_t orig_time_sec

Originated Time (seconds component).

For RIB records, this is the time the prefix was heard (e.g., https://tools.ietf.org/html/rfc6396#section-4.3.4); for BMP messages, this is the timestamp in the Peer Header (see https://tools.ietf.org/html/rfc7854#section-4.2). Care must be taken when using this value as it will often be zero (e.g., there is a bug in a Cisco implementation of BMP that does not set the time in the peer header), and even if it is set, its meaning is dependent on the data source.

NOTE: This is NOT the same as the time_sec field in the record. It MUST NOT be used in place of that field. If you are unsure about which time to use, then you probably want the timestamp in the record structure.

uint32_t orig_time_usec

Originated Time (microseconds component)

bgpstream_ip_addr_t peer_ip

Peer IP address.

This is the IP address that the peer used to connect to the collector (or router in the case of BMP).

uint32_t peer_asn

Peer AS number.

bgpstream_pfx_t prefix

IP prefix.

Available only for RIB, Announcement and Withdrawal elem types

bgpstream_ip_addr_t nexthop

Next hop.

Available only for RIB and Announcement elem types

bgpstream_as_path_t *as_path

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

bgpstream_annotations_t annotations

Annotations.

Annotations from other libraries

bgpstream_elem_origin_type_t origin

ORIGIN as-path attribute This attribute indicates where the update comes from: internal network (IGP), external network (EGP), or other means (INCOMPLETE).

uint32_t med

MED attribute.

uint32_t local_pref

LOCAL_PREF attribute.

uint8_t atomic_aggregate

Atomic aggregate attribute.

bgpstream_elem_aggregator_t aggregator

Atomic aggregate attribute.