1 unstable release

0.0.0 Feb 9, 2020

#7 in #mrt

CC0 license

59KB
1K SLoC

bgpdump

A Multi-Threaded Routing Toolkit in Rust that expands on the mrt-rs library to include the parsing of BGP Path Attributes.


lib.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 mrt_rs::{Reader, Record};
use mrt_rs::bgp4mp::BGP4MP;

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

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

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

Dependencies

~120KB