Re: [PATCH 02/11] Include length with virSocketAddr data

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

 



On 10/21/2010 12:17 PM, Daniel P. Berrange wrote:
Some operations on socket addresses need to know the length of
the sockaddr struct for the particular address family. This
info was being discarded when passing around virSocketAddr
instances. Turn it from a union into a struct containing
union+socklen_t fields, so length is always kept around.

* src/util/network.h: Add socklen_t field to virSocketAddr
* src/util/network.c, src/network/bridge_driver.c,
   src/conf/domain_conf.c: Update to take account of new
   struct definition.
---
  src/conf/domain_conf.c      |    2 +-
  src/network/bridge_driver.c |   10 +++---
  src/util/network.c          |   60 ++++++++++++++++++++++--------------------
  src/util/network.h          |   12 +++++---
  4 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/src/util/network.h b/src/util/network.h
index 5307c8c..ef92c9b 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -17,11 +17,15 @@
  # include<sys/socket.h>
  # include<netdb.h>

-typedef union {
-    struct sockaddr_storage stor;
-    struct sockaddr_in inet4;
-    struct sockaddr_in6 inet6;
+typedef struct {
+    union {
+        struct sockaddr_storage stor;
+        struct sockaddr_in inet4;
+        struct sockaddr_in6 inet6;
+    } data;
+    socklen_t len;
  } virSocketAddr;

ACK; and the rest of the patch is compiler-enforced fallout.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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