You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a link speed implementation for macOS and BSD derivates #158
At the moment, the link speed (transmit, receive) is only implemented for Android, Linux and Windows.
Because I need the link speed on macOS, I decided to write an implementation for it. On macOS I also added the Wi-Fi transmit rate. Additionally, there's now also a field indicating if the link speed was auto-negotiated.
My hope, that the code would be almost the same for the supported BSD derivates was lost quickly, after realizing that each derivate uses slightly different constants. Nevertheless, it should work now for FreeBSD, OpenBSD and NetBSD as well. To be honest, I did not have the time to test everything on all the supported BSD derivates.
As you are going to see, I did not find a better solution to handle the differences than using a lot of #[cfg(target_os = ...)] macros and defining constants for all different subtypes (using modules made the code a bit nicer at least). While I tried to figure out a solution using enums, I came to the conclusion that it would end up producing even more code and being less readable. Using the current way, one can at least reference the constants to the C source code and copy new values more easily. I left some commented C code just for reference to certain #defines for a better understanding what the code does.
The addresses for SIOCGIFXMEDIA or SIOCGIFMEDIA have been obtained by using a small C program:
Adding link speed support for macOS and the BSD variants would be a really valuable improvement for netdev, especially since platform coverage has been one of the goals of the crate.
Activity
Add BSD and macOS link speed implementation
Add BSD and macOS link speed implementation
shellrow commentedon Apr 28, 2026
Thanks!
Adding link speed support for macOS and the BSD variants would be a really valuable improvement for netdev, especially since platform coverage has been one of the goals of the crate.
I'll review the PR in detail soon.
Add BSD and macOS link speed implementation