X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fnetdev.c;h=0074de025a4438da2d5933a0d218ffae2cc341fd;hb=a75531e53e03d9fe9915f8041759601c07e47914;hp=9fba077b6982c9f31e5db6cd1b5c54b1c61ed93f;hpb=26ce31583b1654a3acaaf6de8e9567e327fbc104;p=sliver-openvswitch.git diff --git a/lib/netdev.c b/lib/netdev.c index 9fba077b6..0074de025 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -359,6 +359,25 @@ netdev_enumerate(struct sset *sset) 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