return error;
}
+/* Parses 'netdev_name_', which is of the form [type@]name into its component
+ * pieces. 'name' and 'type' must be freed by the caller. */
+void
+netdev_parse_name(const char *netdev_name_, char **name, char **type)
+{
+ char *netdev_name = xstrdup(netdev_name_);
+ char *separator;
+
+ separator = strchr(netdev_name, '@');
+ if (separator) {
+ *separator = '\0';
+ *type = netdev_name;
+ *name = xstrdup(separator + 1);
+ } else {
+ *name = netdev_name;
+ *type = xstrdup("system");
+ }
+}
+
/* Attempts to set up 'netdev' for receiving packets with netdev_recv().
* Returns 0 if successful, otherwise a positive errno value. EOPNOTSUPP
* indicates that the network device does not implement packet reception
int netdev_enumerate(struct sset *);
+void netdev_parse_name(const char *netdev_name, char **name, char **type);
+
/* Options. */
int netdev_set_config(struct netdev *, const struct shash *args);
int netdev_get_config(const struct netdev *, struct shash *);
/* Add ports to the datapath if requested by the user. */
SSET_FOR_EACH (port, &s.ports) {
struct netdev *netdev;
+ char *name, *type;
- error = netdev_open(port, "system", &netdev);
+ netdev_parse_name(port, &name, &type);
+ error = netdev_open(name, type, &netdev);
if (error) {
VLOG_FATAL("%s: failed to open network device (%s)",
port, strerror(error));
}
+ free(name);
+ free(type);
error = ofproto_port_add(ofproto, netdev, NULL);
if (error) {