X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetdev.c;h=6a95e1a4f1eeb9cb42281271b04e855694314f7f;hb=46415c9085ef6b7386943b1714754150487b6cff;hp=8d243e9e72f1a611ddd185d9e5210d0dd71cbf05;hpb=49a6a1636f849eba12fb444651ee818628426f0d;p=sliver-openvswitch.git diff --git a/lib/netdev.c b/lib/netdev.c index 8d243e9e7..6a95e1a4f 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -889,6 +889,33 @@ netdev_dev_get_name(const struct netdev_dev *netdev_dev) return netdev_dev->name; } +/* Returns the netdev_dev with 'name' or NULL if there is none. + * + * The caller must not free the returned value. */ +struct netdev_dev * +netdev_dev_from_name(const char *name) +{ + return shash_find_data(&netdev_dev_shash, name); +} + +/* Fills 'device_list' with devices that match 'class'. + * + * The caller is responsible for initializing and destroying 'device_list' + * but the contained netdev_devs must not be freed. */ +void +netdev_dev_get_devices(const struct netdev_class *class, + struct shash *device_list) +{ + struct shash_node *node; + SHASH_FOR_EACH (node, &netdev_dev_shash) { + struct netdev_dev *dev = node->data; + + if (dev->class == class) { + shash_add(device_list, node->name, node->data); + } + } +} + /* Initializes 'netdev' as a instance of the netdev_dev. * * This function adds 'netdev' to a netdev-owned linked list, so it is very