@@ -775,6 +775,12 @@ struct netdev_class {
* used to send and receive packets until a successful configuration is
* applied. */
int (*reconfigure)(struct netdev *netdev);
+
+ /* If the netdev class of 'netdev' supports peer option, returns the name
+ * of its peer as a malloc()'d string that the caller must free.
+ *
+ * If peer is not supported, returns NULL. */
+ char *(*get_peer_name)(const struct netdev *netdev);
/* ## -------------------- ## */
/* ## netdev_rxq Functions ## */
/* ## -------------------- ## */
@@ -913,6 +913,19 @@ netdev_get_name(const struct netdev *netdev)
return netdev->name;
}
+char *
+netdev_get_peer_name(const struct netdev *netdev)
+{
+ const struct netdev_class *class = netdev->netdev_class;
+ char *peer = NULL;
+
+ if (class->get_peer_name) {
+ peer = class->get_peer_name(netdev);
+ }
+
+ return peer;
+}
+
/* Retrieves the MTU of 'netdev'. The MTU is the maximum size of transmitted
* (and received) packets, in bytes, not including the hardware header; thus,
* this is typically 1500 bytes for Ethernet devices.
@@ -170,6 +170,7 @@ int netdev_get_numa_id(const struct netdev *);
/* Basic properties. */
const char *netdev_get_name(const struct netdev *);
+char *netdev_get_peer_name(const struct netdev *);
const char *netdev_get_type(const struct netdev *);
const char *netdev_get_type_from_name(const char *);
int netdev_get_mtu(const struct netdev *, int *mtup);