[PATCH v5 3/9] virsocketaddr: Introduce virSocketAddrSetIPv6Addr

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

 



This is a missing counterpart for virSocketAddrSetIPv4Addr()
and is going to be needed later in the tests.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virsocketaddr.c | 15 +++++++++++++++
 src/util/virsocketaddr.h |  1 +
 3 files changed, 17 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3ae18b8..640c6b3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2165,6 +2165,7 @@ virSocketAddrParseIPv4;
 virSocketAddrParseIPv6;
 virSocketAddrPrefixToNetmask;
 virSocketAddrSetIPv4Addr;
+virSocketAddrSetIPv6Addr;
 virSocketAddrSetPort;
 
 # util/virstats.h
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 900aa5b..b44d12e 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -189,6 +189,21 @@ virSocketAddrSetIPv4Addr(virSocketAddrPtr addr, uint32_t val)
 }
 
 /*
+ * virSocketAddrSetIPv6Addr:
+ * @addr: the location to store the result
+ * @val: the 128bit integer in host byte order representing the IPv6 address
+ *
+ * Set the IPv6 address given an integer in host order. This function does not
+ * touch any previously set port.
+ */
+void virSocketAddrSetIPv6Addr(virSocketAddrPtr addr, uint32_t val[4])
+{
+    addr->data.stor.ss_family = AF_INET6;
+    memcpy(addr->data.inet6.sin6_addr.s6_addr, val, 4 * sizeof(*val));
+    addr->len = sizeof(struct sockaddr_in6);
+}
+
+/*
  * virSocketAddrEqual:
  * @s1: the location of the one IP address
  * @s2: the location of the other IP address
diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h
index 9e2680a..9a6e1ec 100644
--- a/src/util/virsocketaddr.h
+++ b/src/util/virsocketaddr.h
@@ -85,6 +85,7 @@ int virSocketAddrParseIPv6(virSocketAddrPtr addr,
                            const char *val);
 
 void virSocketAddrSetIPv4Addr(virSocketAddrPtr s, uint32_t addr);
+void virSocketAddrSetIPv6Addr(virSocketAddrPtr s, uint32_t addr[4]);
 
 char *virSocketAddrFormat(const virSocketAddr *addr);
 char *virSocketAddrFormatFull(const virSocketAddr *addr,
-- 
2.4.10

--
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]