X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fnetdev.c;h=9a91e2f628706a15abfd6884dfbb2c4f71ef8658;hb=refs%2Fheads%2Ffor-nox%2F0.4;hp=746a3e2c09b02f2f0429876341e7e95877b97c12;hpb=b4518e78a0f62921723b44c7f63137839f08ef6c;p=sliver-openvswitch.git diff --git a/lib/netdev.c b/lib/netdev.c index 746a3e2c0..9a91e2f62 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -61,10 +61,11 @@ #include "fatal-signal.h" #include "list.h" #include "ofpbuf.h" -#include "openflow.h" +#include "openflow/openflow.h" #include "packets.h" #include "poll-loop.h" #include "socket-util.h" +#include "svec.h" #define THIS_MODULE VLM_netdev #include "vlog.h" @@ -145,6 +146,7 @@ get_ipv6_address(const char *name, struct in6_addr *in6) ifname) == 17 && !strcmp(name, ifname)) { + fclose(file); return; } } @@ -947,6 +949,27 @@ netdev_arp_lookup(const struct netdev *netdev, } return retval; } + +/* Initializes 'svec' with a list of the names of all known network devices. */ +void +netdev_enumerate(struct svec *svec) +{ + struct if_nameindex *names; + + svec_init(svec); + names = if_nameindex(); + if (names) { + size_t i; + + for (i = 0; names[i].if_name != NULL; i++) { + svec_add(svec, names[i].if_name); + } + if_freenameindex(names); + } else { + VLOG_WARN("could not obtain list of network device names: %s", + strerror(errno)); + } +} static void restore_all_flags(void *aux);