At minimum you should be able to steal code from ifconfig, since it enumerates interfaces and prints said info.