1 个不稳定版本

0.0.0 2020年2月9日

7#mrt

CC0 许可证

59KB
1K SLoC

bgpdump

bgpdump 是一个基于 Rust 的多线程路由工具包,它扩展了 mrt-rs 库,包括对 BGP 路径属性的解析。


lib.rs:

mrt-rs crate 提供了解析 MRT 格式流的函数。

示例

读取包含 BPG 消息的 MRT 文件

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,
        }
    }
}

依赖

~120KB