[PATCH v2 1/9] socketaddr: Add isNumeric flag to virSocketAddrParseInternal

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

 



Adjust virSocketAddrParseInternal to take a boolean 'isNumeric' in order
to determine whether to set "ai_flags = AI_NUMERICHOST;" - IOW - expect
a numeric IP Address of sorts in the 'val' to be resolved.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virsocketaddr.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 67ed330..0e9a39c 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2014 Red Hat, Inc.
+ * Copyright (C) 2009-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -80,6 +80,7 @@ static int
 virSocketAddrParseInternal(struct addrinfo **res,
                            const char *val,
                            int family,
+                           bool isNumeric,
                            bool reportError)
 {
     struct addrinfo hints;
@@ -92,7 +93,8 @@ virSocketAddrParseInternal(struct addrinfo **res,
 
     memset(&hints, 0, sizeof(hints));
     hints.ai_family = family;
-    hints.ai_flags = AI_NUMERICHOST;
+    if (isNumeric)
+        hints.ai_flags = AI_NUMERICHOST;
     if ((err = getaddrinfo(val, NULL, &hints, res)) != 0) {
         if (reportError)
             virReportError(VIR_ERR_SYSTEM_ERROR,
@@ -121,7 +123,7 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char *val, int family)
     int len;
     struct addrinfo *res;
 
-    if (virSocketAddrParseInternal(&res, val, family, true) < 0)
+    if (virSocketAddrParseInternal(&res, val, family, true, true) < 0)
         return -1;
 
     if (res == NULL) {
@@ -878,7 +880,7 @@ virSocketAddrNumericFamily(const char *address)
     struct addrinfo *res;
     unsigned short family;
 
-    if (virSocketAddrParseInternal(&res, address, AF_UNSPEC, false) < 0)
+    if (virSocketAddrParseInternal(&res, address, AF_UNSPEC, true, false) < 0)
         return -1;
 
     family = res->ai_addr->sa_family;
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]