Skip to content

Commit

Permalink
nib: Use iterator construction like in netif
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Aug 30, 2024
1 parent 899bffc commit 986e11e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/gnrc/nib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ impl ArState {
}

impl NcEntry {
/// Iterate over the Neighbor Cache.
#[doc(alias = "gnrc_ipv6_nib_nc_iter")]
pub fn all() -> impl Iterator<Item = Self> {
// If we add anything like all_nc_entries_on_interface():
// // Interfaces are positive numbers; MAX is clearly out of range and allows us to have an easier
// // input type
// let interface = interface.map(|i| {
// riot_sys::libc::c_uint::try_from(usize::from(i)).unwrap_or(riot_sys::libc::c_uint::MAX)
// });

any_nc_query(0)
}

pub fn l2addr(&self) -> &[u8] {
&self.0.l2addr[..self.0.l2addr_len as usize]
}
Expand Down Expand Up @@ -141,19 +154,6 @@ impl NcEntry {
}
}

/// Iterate over the Neighbor Cache.
#[doc(alias = "gnrc_ipv6_nib_nc_iter")]
pub fn all_nc_entries() -> impl Iterator<Item = NcEntry> {
// If we add anything like all_nc_entries_on_interface():
// // Interfaces are positive numbers; MAX is clearly out of range and allows us to have an easier
// // input type
// let interface = interface.map(|i| {
// riot_sys::libc::c_uint::try_from(usize::from(i)).unwrap_or(riot_sys::libc::c_uint::MAX)
// });

any_nc_query(0)
}

struct NcIterator {
interface: riot_sys::libc::c_uint,
state: *mut riot_sys::libc::c_void,
Expand Down

0 comments on commit 986e11e

Please sign in to comment.