diff options
Diffstat (limited to 'src/addr.rs')
-rw-r--r-- | src/addr.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/addr.rs b/src/addr.rs index ed68fcc..2c949f7 100644 --- a/src/addr.rs +++ b/src/addr.rs @@ -5,6 +5,7 @@ use std::net::IpAddr; use futures::{future, TryStreamExt}; use netlink_packet_route::{AddressMessage, AF_INET, AF_INET6, RT_SCOPE_LINK, RT_SCOPE_UNIVERSE}; +/// Flushes all addresses of an interface. pub async fn flush(link: String) -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); @@ -35,6 +36,7 @@ pub async fn flush(link: String) -> Result<()> { Ok(()) } +/// Flushes the IPv4 addresses of an interface. pub async fn flush4(link: String) -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); @@ -66,6 +68,7 @@ pub async fn flush4(link: String) -> Result<()> { Ok(()) } +/// Flushes the IPv6 addresses of an interface. pub async fn flush6(link: String) -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); @@ -97,6 +100,7 @@ pub async fn flush6(link: String) -> Result<()> { Ok(()) } +/// Flushes all global unicast IPv6 addresses from all interfaces. pub async fn flush6_global() -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); @@ -120,6 +124,7 @@ pub async fn flush6_global() -> Result<()> { Ok(()) } +/// Adds an IP address to an interface. pub async fn add(link: String, addr: IpAddr, prefix_len: u8) -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); @@ -140,6 +145,8 @@ pub async fn add(link: String, addr: IpAddr, prefix_len: u8) -> Result<()> { Ok(()) } +/// Adds a link-scope IP address to an interface. +/// This is especially useful with IPv6. pub async fn add_link_local(link: String, addr: IpAddr, prefix_len: u8) -> Result<()> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); |