#routes #ip #networking

net-route

This crate provides a cross-platform interface for manipulating the routing table

27 releases

0.4.5 Nov 19, 2024
0.4.4 Jun 13, 2024
0.4.3 May 15, 2024
0.4.2 Mar 8, 2024
0.2.0 Oct 18, 2022

#1194 in Network programming

Download history 201/week @ 2024-09-22 29/week @ 2024-09-29 169/week @ 2024-10-06 191/week @ 2024-10-13 68/week @ 2024-10-20 265/week @ 2024-10-27 217/week @ 2024-11-03 243/week @ 2024-11-10 386/week @ 2024-11-17 146/week @ 2024-11-24 254/week @ 2024-12-01 195/week @ 2024-12-08 243/week @ 2024-12-15 226/week @ 2024-12-22 512/week @ 2024-12-29 336/week @ 2025-01-05

1,324 downloads per month
Used in 5 crates

MIT license

81KB
2K SLoC

Rust 1.5K SLoC // 0.0% comments C 747 SLoC // 0.1% comments

Net Route

This project aims to provide a high level interface for manipulating and observing the routing table on a variety of platforms.


lib.rs:

This project aims to provide a high level interface for manipulating and observing the routing table on a variety of platforms.

Examples

Adding a route

// route traffic destined for 10.14.0.0/24 to 192.1.2.1 using interface 9
let handle = Handle::new()?;
let route = Route::new("10.14.0.0".parse().unwrap(), 24)
    .with_ifindex(9)
    .with_gateway("192.1.2.1".parse().unwrap());
handle.add(&route).await

Listening to changes in the routing table

let handle = Handle::new()?;
let stream = handle.route_listen_stream();
futures::pin_mut!(stream);
while let Some(event) = stream.next().await {
    println!("{:?}", event);
}

Dependencies

~3–16MB
~199K SLoC