For general scanning there is both the BSD ioctl (which is a pain as you must guess the largest size), or /proc/net/dev (just cat it). For the state of an interface you use a struct ifreq filled in and do SIOCGIFFLAGS and test IFF_RUNNING and IFF_UP