Set/get broadcast address in TunInterface
Modelled after TunInterface's IPV4 logic. Uses SIOCGIFBRDADDR & SIOCSIFBRDADDR. View https://man7.org/linux/man-pages/man7/netdevice.7.html.
This commit is contained in:
parent
22e41203fb
commit
c8df4b860d
3 changed files with 39 additions and 0 deletions
|
|
@ -9,6 +9,21 @@ fn test_create() {
|
|||
TunInterface::new()?;
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[throws]
|
||||
#[cfg(not(any(target_os = "windows", target_vendor = "apple")))]
|
||||
fn test_set_get_broadcast_addr() {
|
||||
let tun = TunInterface::new()?;
|
||||
let addr = Ipv4Addr::new(10, 0, 0, 1);
|
||||
tun.set_ipv4_addr(addr)?;
|
||||
|
||||
let broadcast_addr = Ipv4Addr::new(255, 255, 255, 0);
|
||||
tun.set_broadcast_addr(broadcast_addr)?;
|
||||
let result = tun.broadcast_addr()?;
|
||||
|
||||
assert_eq!(broadcast_addr, result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[throws]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue