Merge branch 'master' into next
[sliver-openvswitch.git] / lib / netdev-provider.h
index 4148c6c..1eb1b1e 100644 (file)
 #include "list.h"
 #include "shash.h"
 
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+struct arg {
+    char *key;
+    char *value;
+};
+
 /* A network device (e.g. an Ethernet device).
  *
  * This structure should be treated as opaque by network device
  * implementations. */
 struct netdev_dev {
     char *name;                         /* Name of network device. */
-    const struct netdev_class *class;   /* Functions to control this device. */
+    const struct netdev_class *netdev_class; /* Functions to control 
+                                                this device. */
     int ref_cnt;                        /* Times this devices was opened. */
     struct shash_node *node;            /* Pointer to element in global map. */
-    uint32_t args_hash;                 /* Hash of arguments for the device. */
+    struct arg *args;                   /* Argument list from last config. */
+    int n_args;                         /* Number of arguments in 'args'. */
 };
 
 void netdev_dev_init(struct netdev_dev *, const char *name,
@@ -42,11 +53,14 @@ void netdev_dev_init(struct netdev_dev *, const char *name,
 void netdev_dev_uninit(struct netdev_dev *, bool destroy);
 const char *netdev_dev_get_type(const struct netdev_dev *);
 const char *netdev_dev_get_name(const struct netdev_dev *);
+struct netdev_dev *netdev_dev_from_name(const char *name);
+void netdev_dev_get_devices(const struct netdev_class *,
+                            struct shash *device_list);
 
 static inline void netdev_dev_assert_class(const struct netdev_dev *netdev_dev,
-                                           const struct netdev_class *class)
+                                           const struct netdev_class *class_)
 {
-    assert(netdev_dev->class == class);
+    assert(netdev_dev->netdev_class == class_);
 }
 
 /* A instance of an open network device.
@@ -66,9 +80,9 @@ void netdev_uninit(struct netdev *, bool close);
 struct netdev_dev *netdev_get_dev(const struct netdev *);
 
 static inline void netdev_assert_class(const struct netdev *netdev,
-                                       const struct netdev_class *class)
+                                       const struct netdev_class *netdev_class)
 {
-    netdev_dev_assert_class(netdev_get_dev(netdev), class);
+    netdev_dev_assert_class(netdev_get_dev(netdev), netdev_class);
 }
 
 /* A network device notifier.
@@ -98,12 +112,12 @@ struct netdev_class {
      * the system. */
     const char *type;
 
-    /* Called only once, at program startup.  Returning an error from this
-     * function will prevent any network device in this class from being
-     * opened.
+    /* Called when the netdev provider is registered, typically at program
+     * startup.  Returning an error from this function will prevent any network
+     * device in this class from being opened.
      *
      * This function may be set to null if a network device class needs no
-     * initialization at program startup. */
+     * initialization at registration time. */
     int (*init)(void);
 
     /* Performs periodic work needed by netdevs of this class.  May be null if
@@ -349,4 +363,8 @@ extern const struct netdev_class netdev_linux_class;
 extern const struct netdev_class netdev_tap_class;
 extern const struct netdev_class netdev_gre_class;
 
+#ifdef  __cplusplus
+}
+#endif
+
 #endif /* netdev.h */