[][src]Crate mrt_rs

The mrt-rs crate provides functionality to parse an MRT-formatted streams.

Examples

Reading a MRT file containing BPG messages

use std::fs::File;
use std::io::Cursor;
use std::io::Read;
use std::io::BufReader;
use mrt_rs::MRTReader;
use mrt_rs::MRTRecord;
use mrt_rs::BGP4MP;
use libflate::gzip::Decoder;

fn main() {
    // Open an MRT-formatted file.
    let file = File::open("res/updates.20190101.0000.gz").unwrap();

    // Decode the GZIP stream using BufReader for better performance.
    let mut decoder = Decoder::new(BufReader::new(file)).unwrap();

    // Create a new MRTReader with a Cursor such that we can keep track of the position.
   let mut reader = MRTReader { stream: decoder };

    // Keep reading entries till the end of the file has been reached.
    while let Ok(Some(record)) = reader.read() {
        match record {
            MRTRecord::BGP4MP(x) => match x {
                BGP4MP::MESSAGE(y) => println!("{:?}", y),
                BGP4MP::MESSAGE_AS4(y) => println!("{:?}", y),
                _ => continue,
            },
            _ => continue,
        }
    }
}

Structs

BGP4PLUS_MESSAGE

Represents the BGP_UPDATE, BGP_OPEN, BGP_NOTIFY and BGP_KEEPALIVE subtypes of IPv6 peers.

BGP4PLUS_STATE_CHANGE

Represents a state change in the BGP Finite State Machine (FSM).

BGP4PLUS_SYNC

Deprecated: Used to record RIB entries in a file.

BGP4MP_MESSAGE

Represents a BGP message (UPDATE, OPEN, NOTIFICATION and KEEPALIVE) using 16bit ASN.

BGP4MP_SNAPSHOT

Deprecated: Used to record BGP4MP messages in a file.

BGP4MP_STATE_CHANGE

Represents a state change in the BGP Finite State Machine (FSM).

BGP4MP_MESSAGE_AS4

Represents a BGP message (UPDATE, OPEN, NOTIFICATION and KEEPALIVE) using 32bit ASN.

BGP4MP_STATE_CHANGE_AS4

Represents a state change in the BGP Finite State Machine (FSM).

BGP_MESSAGE

Represents the BGP_UPDATE, BGP_OPEN, BGP_NOTIFY and BGP_KEEPALIVE subtypes.

BGP_STATE_CHANGE

Represents a state change in the BGP Finite State Machine (FSM).

BGP_SYNC

Deprecated: Used to record RIB entries in a file.

MRTHeader

Represents the MRT header accompanying every MRT record.

MRTReader

The MRTReader can read MRT records from an MRT-formatted stream.

OSPFv2

The OSPFv2 struct represents the data contained in an MRT record type of OSPFv2.

OSPFv3

The OSPFv3 struct represents the data contained in an MRT record type of OSPFv3 and OSPFv3_ET.

PEER_INDEX_TABLE

This record provides the BGP ID of the collector, an optional view name, and a list of indexed peers.

PeerEntry

Describes a peer from which BGP messages were received.

RIBEntry

Represents a route in the Routing Information Base (RIB)

RIB_AFI

Represents a collection of routes for a specific IP prefix.

RIP

The RIP struct represents the data contained in an MRT record type of RIP.

RIPNG

The RIP struct represents the data contained in an MRT record type of RIP.

TABLE_DUMP

Represents a RIB entry of a Routing Information Base.

Enums

BGP

The BGP enum represents all possible subtypes of the BGP record type.

BGP4PLUS

The BGPPLUS enum represents all possible subtypes of the BGPPLUS record type.

BGP4MP

The BGP4MP enum represents all possible subtypes of the BGP4MP record type.

MRTRecord

Represents a single MRT record.

TABLE_DUMP_V2

Used to store Routing Information Base (RIB) entries.