🚧 Routing!

This commit is contained in:
Malted 2023-09-16 22:27:24 +01:00
parent e643d9dd41
commit 337425446b
No known key found for this signature in database
6 changed files with 288 additions and 2 deletions

25
tun/tests/routing.rs Normal file
View file

@ -0,0 +1,25 @@
use fehler::throws;
use std::io::Error;
use std::net::{IpAddr, Ipv4Addr};
use tun::routing::{Route, add_route};
use tun::TunInterface;
#[test]
#[throws]
fn test_create() -> std::io::Result<()> {
let tun = TunInterface::new()?;
let name = tun.name()?;
println!("Interface name: {name}");
let addr = Ipv4Addr::new(10, 0, 0, 1);
tun.set_ipv4_addr(addr)?;
let dest = IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8));
let route = Route::new(dest, 24, &tun)?;
add_route(route)?;
loop {}
Ok(())
}