-/* If 'netdev' is a VLAN network device (e.g. one created with vconfig(8)),
- * sets '*vlan_vid' to the VLAN VID associated with that device and returns 0.
- * Otherwise returns a errno value (specifically ENOENT if 'netdev_name' is the
- * name of a network device that is not a VLAN device) and sets '*vlan_vid' to
- * -1. */
-int
-netdev_get_vlan_vid(const struct netdev *netdev, int *vlan_vid)
-{
- int error = (netdev_get_dev(netdev)->netdev_class->get_vlan_vid
- ? netdev_get_dev(netdev)->netdev_class->get_vlan_vid(netdev,
- vlan_vid)
- : ENOENT);
- if (error) {
- *vlan_vid = 0;
- }
- return error;
-}
-
-/* Returns a network device that has 'in4' as its IP address, if one exists,
- * otherwise a null pointer. */
-struct netdev *
-netdev_find_dev_by_in4(const struct in_addr *in4)
-{
- struct netdev *netdev;
- struct sset dev_list = SSET_INITIALIZER(&dev_list);
- const char *name;
-
- netdev_enumerate(&dev_list);
- SSET_FOR_EACH (name, &dev_list) {
- struct in_addr dev_in4;
-
- if (!netdev_open_default(name, &netdev)
- && !netdev_get_in4(netdev, &dev_in4, NULL)
- && dev_in4.s_addr == in4->s_addr) {
- goto exit;
- }
- netdev_close(netdev);
- }
- netdev = NULL;
-
-exit:
- sset_destroy(&dev_list);
- return netdev;
-}
-\f
-/* Initializes 'netdev_dev' as a netdev device named 'name' of the specified
- * 'netdev_class'. This function is ordinarily called from a netdev provider's
- * 'create' function.
- *
- * 'args' should be the arguments that were passed to the netdev provider's
- * 'create'. If an empty set of arguments was passed, and 'name' is the name
- * of a network device that existed before the 'create' call, then 'args' may
- * instead be the configuration for that existing device.
- *
- * This function adds 'netdev_dev' to a netdev-owned shash, so it is
- * very important that 'netdev_dev' only be freed after calling
- * the refcount drops to zero. */
-void
-netdev_dev_init(struct netdev_dev *netdev_dev, const char *name,
- const struct shash *args,
- const struct netdev_class *netdev_class)
-{
- assert(!shash_find(&netdev_dev_shash, name));
-
- memset(netdev_dev, 0, sizeof *netdev_dev);
- netdev_dev->netdev_class = netdev_class;
- netdev_dev->name = xstrdup(name);
- netdev_dev->node = shash_add(&netdev_dev_shash, name, netdev_dev);
- smap_clone(&netdev_dev->args, args);
-}
-
-/* Undoes the results of initialization.