[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH v2 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 85429a8b..8fc7444e 100644 --- a/lib/uknetdev/netdev.c +++ b/lib/uknetdev/netdev.c @@ -231,6 +231,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->ipv4_net_mask); + return dev->_config->ipv4_net_mask; + case UK_NETDEV_IPV4_GW_STR: + uk_pr_debug("Gateway: %s\n", dev->_config->ipv4_gw_addr); + return dev->_config->ipv4_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) { @@ -239,6 +258,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.20.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |