Create a shim virNetDevGetIPAddress API to just call the
virNetDevGetIPv4Address with the future being to add static
API's to get the IPv6 or IPv4 address
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/libvirt_private.syms | 2 +-
src/network/bridge_driver.c | 2 +-
src/util/virnetdev.c | 26 ++++++++++++++++++++++----
src/util/virnetdev.h | 2 +-
4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e0d5459..fcaf729 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1676,7 +1676,7 @@ virNetDevDelMulti;
virNetDevExists;
virNetDevGetFeatures;
virNetDevGetIndex;
-virNetDevGetIPv4Address;
+virNetDevGetIPAddress;
virNetDevGetLinkInfo;
virNetDevGetMAC;
virNetDevGetMTU;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9637371..281612a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -4569,7 +4569,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
}
if (dev_name) {
- if (virNetDevGetIPv4Address(dev_name, &addr) < 0)
+ if (virNetDevGetIPAddress(dev_name, &addr) < 0)
goto cleanup;
addrptr = &addr;
}
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 971db43..fd480e9 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1395,8 +1395,9 @@ int virNetDevClearIPAddress(const char *ifname,
* Returns 0 on success, -errno on failure.
*/
#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ)
-int virNetDevGetIPv4Address(const char *ifname,
- virSocketAddrPtr addr)
+static int
+virNetDevGetIPv4Address(const char *ifname,
+ virSocketAddrPtr addr)
{
int fd = -1;
int ret = -1;
@@ -1426,8 +1427,9 @@ int virNetDevGetIPv4Address(const char *ifname,
#else /* ! SIOCGIFADDR */
-int virNetDevGetIPv4Address(const char *ifname ATTRIBUTE_UNUSED,
- virSocketAddrPtr addr ATTRIBUTE_UNUSED)
+static int
+virNetDevGetIPv4Address(const char *ifname ATTRIBUTE_UNUSED,
+ virSocketAddrPtr addr ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Unable to get IPv4 address on this platform"));
@@ -1436,6 +1438,22 @@ int virNetDevGetIPv4Address(const char *ifname ATTRIBUTE_UNUSED,
#endif /* ! SIOCGIFADDR */
+/**
+ * virNetDevGetIPAddress:
+ * @ifname: name of the interface whose IP address we want
+ * @addr: filled with the IPv4 address
+ *
+ * This function gets the IPv4 address for the interface @ifname
+ * and stores it in @addr
+ *
+ * Returns 0 on success, -errno on failure.
+ */
+int
+virNetDevGetIPAddress(const char *ifname,
+ virSocketAddrPtr addr)
+{
+ return virNetDevGetIPv4Address(ifname, addr);
+}
/**
* virNetDevValidateConfig:
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 856127b..fb0fd46 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -103,7 +103,7 @@ int virNetDevClearIPAddress(const char *ifname,
virSocketAddr *addr,
unsigned int prefix)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
-int virNetDevGetIPv4Address(const char *ifname, virSocketAddrPtr addr)
+int virNetDevGetIPAddress(const char *ifname, virSocketAddrPtr addr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
--
2.1.0