#routes #ip #networking

net-route

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

26 releases

0.4.4 Jun 13, 2024
0.4.2 Mar 8, 2024
0.2.8 Nov 4, 2023
0.2.5 Dec 21, 2022
0.2.0 Oct 18, 2022

#1474 in Network programming

Download history 74/week @ 2024-03-12 74/week @ 2024-03-19 53/week @ 2024-03-26 102/week @ 2024-04-02 53/week @ 2024-04-09 34/week @ 2024-04-16 30/week @ 2024-04-23 18/week @ 2024-04-30 3/week @ 2024-05-07 206/week @ 2024-05-14 40/week @ 2024-05-21 38/week @ 2024-05-28 23/week @ 2024-06-04 187/week @ 2024-06-11 110/week @ 2024-06-18 33/week @ 2024-06-25

356 downloads per month
Used in 4 crates

MIT license

79KB
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–18MB
~198K SLoC