bgpstream_record.h

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

Author
Chiara Orsini

Public Opaque Data Structures

typedef struct struct_BGPDUMP_ENTRY bgpstream_record_mrt_data_t

An opaque pointer to a BGPDUMP_ENTRY field.

Note
this is an internal data structure, it is not guaranteed that it will continue to conform to the public BGPDUMP_ENTRY structure. This is NOT for use in user code

Public Enums

enum bgpstream_record_dump_type_t

The type of the record.

Values:

BGPSTREAM_UPDATE = 0

The record contains data for a BGP Update message.

BGPSTREAM_RIB = 1

The record contains data for a BGP RIB message.

enum bgpstream_dump_position_t

The position of this record in the dump.

Values:

BGPSTREAM_DUMP_START = 0

This is the first record of the dump.

BGPSTREAM_DUMP_MIDDLE = 1

This is a record in the middle of the dump.

i.e. not the first or the last record of the dump

BGPSTREAM_DUMP_END = 2

This is the last record of the dump.

enum bgpstream_record_status_t

Status of the record.

Values:

BGPSTREAM_RECORD_STATUS_VALID_RECORD = 0

The record is valid and may be used.

BGPSTREAM_RECORD_STATUS_FILTERED_SOURCE = 1

Source is not empty, but no valid record was found.

BGPSTREAM_RECORD_STATUS_EMPTY_SOURCE = 2

Source has no entries.

BGPSTREAM_RECORD_STATUS_CORRUPTED_SOURCE = 3
BGPSTREAM_RECORD_STATUS_CORRUPTED_RECORD = 4

Public Data Structures

typedef struct struct_bgpstream_record_attributes_t bgpstream_record_attributes_t

Record attributes.

typedef struct struct_bgpstream_record_t bgpstream_record_t

Record structure.

Public API Functions

bgpstream_record_t *bgpstream_record_create()

Create a new BGP Stream Record instance for passing to bgpstream_get_next_record.

A Record may be reused for successive calls to bgpstream_get_next_record if records are processed independently of each other

Return
a pointer to a Record instance if successful, NULL otherwise

void bgpstream_record_destroy(bgpstream_record_t *record)

Destroy the given BGP Stream Record instance.

Parameters
  • record -

    pointer to a BGP Stream Record instance to destroy

void bgpstream_record_clear(bgpstream_record_t *record)

Clear the given BGP Stream Record instance.

Note
the record passed to bgpstream_get_next_record is automatically cleaned.
Parameters
  • record -

    pointer to a BGP Stream Record instance to clear

bgpstream_elem_t *bgpstream_record_get_next_elem(bgpstream_record_t *record)

Retrieve the next elem from the record.

The returned pointer is guaranteed to be valid until the record is re-used in a subsequent call to bgpstream_get_next_record, or is destroyed with bgpstream_record_destroy

Return
borrowed pointer to the next Elem in the record, NULL if there are no more Elems
Parameters
  • record -

    pointer to the BGP Stream Record to retrieve the elem from

void bgpstream_record_print_mrt_data(bgpstream_record_t *bs_record)

Dump the given record to stdout in bgpdump format.

See https://bitbucket.org/ripencc/bgpdump for more information about bgpdump

Parameters
  • record -

    pointer to a BGP Stream Record instance to dump

int bgpstream_record_dump_type_snprintf(char *buf, size_t len, bgpstream_record_dump_type_t dump_type)

Write the string representation of the record dump 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

  • dump_type -

    BGP Stream Record dump type to convert to string

int bgpstream_record_dump_pos_snprintf(char *buf, size_t len, bgpstream_dump_position_t dump_pos)

Write the string representation of the record dump position 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

  • dump_pos -

    BGP Stream Record dump position to convert to string

int bgpstream_record_status_snprintf(char *buf, size_t len, bgpstream_record_status_t status)

Write the string representation of the record status 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

  • status -

    BGP Stream Record status to convert to string

char *bgpstream_record_elem_snprintf(char *buf, size_t len, const bgpstream_record_t *bs_record, const bgpstream_elem_t *elem)

Write the string representation of the record/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 Record to convert to string

  • elem -

    pointer to a BGP Stream Elem to convert to string

struct struct_bgpstream_record_attributes_t
#include <bgpstream_record.h>

Record attributes.

Public Members

char dump_project[BGPSTREAM_UTILS_STR_NAME_LEN]

Project name.

char dump_collector[BGPSTREAM_UTILS_STR_NAME_LEN]

Collector name.

bgpstream_record_dump_type_t dump_type

Dump type.

long dump_time

Time that the BGP data was “aggregated”.

E.g. the start time of an MRT dump file

long record_time

Time from the MRT record.

I.e. the time this record was dumped

struct struct_bgpstream_record_t
#include <bgpstream_record.h>

Record structure.

Public Members

struct struct_bgpstream_t *bs

INTERNAL: pointer to the originating bgpstream instance.

bgpstream_record_mrt_data_t *bd_entry

INTERNAL: buffer containing the underlying MRT data for the record.

struct bgpstream_elem_generator *elem_generator

INTERNAL: state used to generate elems for get_next_elem.

bgpstream_record_attributes_t attributes

Collection of attributes pertaining to this record.

bgpstream_record_status_t status

Status of this record.

bgpstream_dump_position_t dump_pos

Position of this record in the dump.