/* * New interface uses sysfs to find bridges */ static int new_foreach_bridge(int (*iterator)(const char *name, void *), void *arg) { struct sysfs_class_device *dev; struct dlist *devlist; int count = 0; if (!br_class_net) { dprintf("no class /sys/class/net\n"); return -EOPNOTSUPP; } devlist = sysfs_get_class_devices(br_class_net); if (!devlist) { dprintf("Can't read devices from sysfs\n"); return -errno; } dlist_for_each_data(devlist, dev, struct sysfs_class_device) { if (isbridge(dev)) { ++count; if (iterator(dev->name, arg)) break; } } return count; }
int kernel_interface_wireless(const char *ifname, int ifindex) { #ifndef SIOCGIWNAME #define SIOCGIWNAME 0x8B01 #endif struct ifreq req; int rc; if(isbridge(ifname, ifindex) != 0 || isbatman(ifname, ifindex) != 0) return -1; memset(&req, 0, sizeof(req)); strncpy(req.ifr_name, ifname, sizeof(req.ifr_name)); rc = ioctl(dgram_socket, SIOCGIWNAME, &req); if(rc < 0) { if(errno == EOPNOTSUPP || errno == EINVAL) rc = 0; else { perror("ioctl(SIOCGIWNAME)"); rc = -1; } } else { rc = 1; } return rc; }