Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/address_family.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT

use std::net::IpAddr;

use crate::AddressFamily;

impl From<IpAddr> for AddressFamily {
fn from(v: IpAddr) -> Self {
match v {
IpAddr::V4(_) => AddressFamily::Inet,
IpAddr::V6(_) => AddressFamily::Inet6,
}
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//! [rtnetlink_url]: https://docs.rs/rtnetlink

pub mod address;
mod address_family;
pub mod link;
pub mod neighbour;
pub mod neighbour_table;
Expand Down
11 changes: 10 additions & 1 deletion src/neighbour/address.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

use std::net::{Ipv4Addr, Ipv6Addr};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

use netlink_packet_core::{DecodeError, Emitable};

Expand Down Expand Up @@ -51,6 +51,15 @@ impl Emitable for NeighbourAddress {
}
}

impl From<IpAddr> for NeighbourAddress {
fn from(v: IpAddr) -> Self {
match v {
IpAddr::V4(a) => a.into(),
IpAddr::V6(a) => a.into(),
}
}
}

impl From<Ipv4Addr> for NeighbourAddress {
fn from(v: Ipv4Addr) -> Self {
Self::Inet(v)
Expand Down
Loading