EstebanBorai / network-interface

Retrieve system's Network Interfaces on Linux, macOS and Windows on a standardized manner
https://crates.io/crates/network-interface
Apache License 2.0
61 stars 28 forks source link

Add MAC Address to interface struct #7

Open tr3ysmith opened 2 years ago

tr3ysmith commented 2 years ago

I know this would require a different lookup in libc, but having the MAC hardware address included would be super helpful.

As I understand it, you have to call ioctl with this flagSIOCGIFHWADDR. I'm not very savvy with Rust and libc yet, but figured I'd ask!

EstebanBorai commented 2 years ago

Hi @tr3ysmith! Thanks so much for opening this feature request!

Thanks for pointing out an approach as well, is very appreciated. This crate attempts to provide the same features under the same API for Window, Linux and macOS. This means that the feature should be supported on the three environments.

I will dig into a Windows implementation as well to make sure we have all targets supported. Thanks again!

EstebanBorai commented 2 years ago

Hi @tr3ysmith I replaced the implementation on #8 with a new one in #10. This time Im using FFI to consume the LLADDR function to retrieve the MAC Address.

If you have any early feedback that would be awesome, thanks in advance!

tr3ysmith commented 2 years ago

@EstebanBorai Thanks so much! I'll give it a shot this week!! This is awesome!

EstebanBorai commented 2 years ago

@tr3ysmith thanks for your patience and time, I have updated the approach and also introduced the field for macOS I still have to work on providing support for Windows and Linux. If you have any input I'm glad to hear!

EstebanBorai commented 1 year ago

Hi @tr3ysmith!

Just wanted to share that support for MAC Addresses is now available for Linux and Macintosh! We still have to work on providing support to Windows anytime soon!

Keep you updated!

joaoantoniocardoso commented 1 year ago

Hello!

The available MAC address is (probably, I didn't check) the current, which can easily be changed, right?

Could we also add the permanent one? Here's how ethtool and macchanger get the permanent MAC address.

Thanks!

EstebanBorai commented 1 year ago

Hello!

The available MAC address is (probably, I didn't check) the current, which can easily be changed, right?

Could we also add the permanent one? Here's how ethtool and macchanger get the permanent MAC address.

Thanks!

Hi @joaoantoniocardoso!

Makes sense to me! Would you like to work on this?