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

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



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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


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