[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 2/2] lib/uknetdev: Get the ipaddr, gw_addr and subnet



The user of uknetdev can pass the ipaddr, gw_addr and subnet as a
library argument. The library argument can be retrieved from the
network stack using uk_netdev_einfo_get function. The library
arguments are retrieved only if the driver does not support the
uk_netdev_einfo_get callback.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 lib/uknetdev/netdev.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/uknetdev/netdev.c b/lib/uknetdev/netdev.c
index 6dc6771..8a51d17 100644
--- a/lib/uknetdev/netdev.c
+++ b/lib/uknetdev/netdev.c
@@ -229,6 +229,25 @@ void uk_netdev_info_get(struct uk_netdev *dev,
                                      dev_info->max_tx_queues);
 }
 
+static const void *_netdev_einfo_get(struct uk_netdev *dev,
+                               enum uk_netdev_einfo_type einfo)
+{
+       switch (einfo) {
+       case UK_NETDEV_IPV4_ADDR_STR:
+               uk_pr_debug("ip_addr: %s\n", dev->_config->ipv4_addr);
+               return dev->_config->ipv4_addr;
+       case UK_NETDEV_IPV4_MASK_STR:
+               uk_pr_debug("netmask: %s\n", dev->_config->net_mask);
+               return dev->_config->net_mask;
+       case UK_NETDEV_IPV4_GW_STR:
+               uk_pr_debug("Gateway: %s\n", dev->_config->gw_addr);
+               return dev->_config->gw_addr;
+       default:
+               uk_pr_warn("Option %d not yet supported\n", einfo);
+       }
+       return NULL;
+}
+
 const void *uk_netdev_einfo_get(struct uk_netdev *dev,
                                enum uk_netdev_einfo_type einfo)
 {
@@ -237,6 +256,8 @@ const void *uk_netdev_einfo_get(struct uk_netdev *dev,
 
        if (!dev->ops->einfo_get) {
                /* driver does not provide any extra configuration */
+               if (dev->_config)
+                       return _netdev_einfo_get(dev, einfo);
                return NULL;
        }
        return dev->ops->einfo_get(dev, einfo);
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.