#routes #ip #networking

net-route

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

25 releases

0.4.3 May 15, 2024
0.4.2 Mar 8, 2024
0.4.1 Feb 26, 2024
0.2.8 Nov 4, 2023
0.2.0 Oct 18, 2022

#16 in #routes

Download history 14/week @ 2024-01-29 85/week @ 2024-02-05 221/week @ 2024-02-12 256/week @ 2024-02-19 298/week @ 2024-02-26 168/week @ 2024-03-04 79/week @ 2024-03-11 75/week @ 2024-03-18 41/week @ 2024-03-25 113/week @ 2024-04-01 58/week @ 2024-04-08 34/week @ 2024-04-15 32/week @ 2024-04-22 18/week @ 2024-04-29 2/week @ 2024-05-06 198/week @ 2024-05-13

252 downloads per month
Used in 3 crates

MIT license

77KB
2K SLoC

Rust 1K 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

~4–15MB
~182K SLoC