&ipconfig So far, I have the following functionality built out:
- Interface name: This is included in the
ifaddrs
struct - Whether the network is wired or wireless: Believe it or not, the easiest way to do this is checking for the existence of a directory (
/sys/class/net/interface_name/wireless
). Figuring out how that works is definitely on the to do list. - The IPv4 address: There are functions available to extract this from the
ifa_addr
member of theifaddrs
struct (specifically,inet_ntoa()
). I think rolling my own version if this function would be a good exercise. - The DNS suffixes: This was a little less obvious, because unlike in Windows, there are many different things that could be managing DNS in Linux. I decided the best way to do this in a universal fashion was to manually enumerate
/etc/resolv.conf
. This isn't the cleanest approach, but it does work on my test systems.