diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-14 19:26:51 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-14 19:33:03 +0100 |
commit | d8f38a82885a42a7af2c0ea9de542251762f7970 (patch) | |
tree | 819c96084c4ff1d67a9014e4e786b4182e618f8a /src/addr.rs | |
parent | ec284b5f1543e54c64ac4c812370c35c1ce345d5 (diff) |
add documentation
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); |