Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeighbourMessage, NeighbourAttribute is not re-exported from rtnetlink #82

Open
zdpk opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@zdpk
Copy link

zdpk commented Oct 21, 2024

Hello.

I tried to get the IP and MAC addresses from a Neighbour object and print them, similar to the ip neigh show command. However, I noticed that the match attr arm didn’t auto-complete.

This happens because NeighbourAttribute comes from the netlink_packet_route crate, and it’s not re-exported by rtnetlink.

Here’s my code:

    let (conn, handle, _) = rtnetlink::new_connection()?;

    tokio::spawn(conn);

    let mut neigh_entries = handle
        .neighbours()
        .get()
        .set_family(rtnetlink::IpVersion::V4)
        .execute();


    // extract ip & mac addresses for each neighbor entry
    while let Some(neigh) = neigh_entries.try_next().await? {
        neigh.attributes.iter().for_each(|attr| {
           // ✅ this point
           match attr {
            }
   }
}

It’s not usable even though it’s necessary for extracting IP and MAC addresses.

To match them, I have to explicitly add the netlink_packet_route crate and ensure the versions align.

I just want to understand the reasoning behind this. If it’s an intended design, why does it work this way?

I’m not arguing, I’m just a newbie who wants to understand the thoughts and philosophy of experts.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant