I’m writing a kernel module that needs information about the local machine’s interfaces just like the ones retuned by a simple ‘ifconfig’ command, I’ve searched a lot for it, but couldn’t find anything
I’m writing a kernel module that needs information about the local machine’s interfaces just
Share
You can get all of that information through the
struct net_deviceone way or another.As Albert Veli said, you can get this
struct net_devicepointer using__dev_get_by_name().If you tell us what information you need specifically we might even be able to point you to the correct fields.
Finding the MAC address is fairly simple:
Finding the IP address is rather harder, but not impossible:
(None of this was compile tested, so typos are possible.)