Skip to contentSkip to conversation

: Small VNC related cleanup

PATCH Applied Luiz Capitulino 2 participants 5 messages Jan 20, 2010

lore
Share & tools
lore
#0 lore raw

cover : Small VNC related cleanup

This series makes VNC events code use inet_strfamily() from qemu-socket
instead of duplicating code, as suggested by Gerd.

Thanks.

#1 lore raw

PATCH 1/3 net: Make inet_strfamily() public

So that it can be used by other subsystems.

---
 qemu-sockets.c |    2 +-
 qemu_socket.h  |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
qemu-sockets.c +1 -1
index 8850516..720de22 100644
@@ -91,7 +91,7 @@ static void inet_setport(struct addrinfo *e, int port)
     }
 }
 
-static const char *inet_strfamily(int family)
+const char *inet_strfamily(int family)
 {
     switch (family) {
     case PF_INET6: return "ipv6";
qemu_socket.h +1 -0
index 86bdbf5..7ee46ac 100644
@@ -44,6 +44,7 @@ int inet_listen(const char *str, char *ostr, int olen,
 int inet_connect_opts(QemuOpts *opts);
 int inet_connect(const char *str, int socktype);
 int inet_dgram_opts(QemuOpts *opts);
+const char *inet_strfamily(int family);
 
 int unix_listen_opts(QemuOpts *opts);
 int unix_listen(const char *path, char *ostr, int olen);
Signature · 1 line
1.6.6
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] net: Make inet_strfamily() public

Quoted 4 lines · Luiz Capitulino

So that it can be used by other subsystems.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 31 lines
---
  qemu-sockets.c |    2 +-
  qemu_socket.h  |    1 +
  2 files changed, 2 insertions(+), 1 deletions(-)
qemu-sockets.c +1 -1
index 8850516..720de22 100644
@@ -91,7 +91,7 @@ static void inet_setport(struct addrinfo *e, int port)
      }
  }
 
-static const char *inet_strfamily(int family)
+const char *inet_strfamily(int family)
  {
      switch (family) {
      case PF_INET6: return "ipv6";
qemu_socket.h +1 -0
index 86bdbf5..7ee46ac 100644
@@ -44,6 +44,7 @@ int inet_listen(const char *str, char *ostr, int olen,
  int inet_connect_opts(QemuOpts *opts);
  int inet_connect(const char *str, int socktype);
  int inet_dgram_opts(QemuOpts *opts);
+const char *inet_strfamily(int family);
 
  int unix_listen_opts(QemuOpts *opts);
  int unix_listen(const char *path, char *ostr, int olen);
#3 lore raw

PATCH 2/3 net: inet_strfamily(): Better unknown family report

In reply to Luiz Capitulino

Returning "????" is a bit meaningless, let's call it "unknown".

---
 qemu-sockets.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-sockets.c +1 -1
index 720de22..d912fed 100644
@@ -98,7 +98,7 @@ const char *inet_strfamily(int family)
     case PF_INET:  return "ipv4";
     case PF_UNIX:  return "unix";
     }
-    return "????";
+    return "unknown";
 }
 
 static void inet_print_addrinfo(const char *tag, struct addrinfo *res)
Signature · 1 line
1.6.6
#4 lore raw

PATCH 3/3 vnc: Use inet_strfamily()

In reply to Luiz Capitulino
---
 vnc.c |   22 +---------------------
 1 files changed, 1 insertions(+), 21 deletions(-)
vnc.c +1 -21
index c7d6652..cc2a26e 100644
@@ -100,26 +100,6 @@ char *vnc_socket_remote_addr(const char *format, int fd) {
     return addr_to_string(format, &sa, salen);
 }
 
-static QString *get_sock_family(const struct sockaddr_storage *sa)
-{
-    const char *name;
-
-    switch (sa->ss_family)
-    {
-        case AF_INET:
-            name = "ipv4";
-            break;
-        case AF_INET6:
-            name = "ipv6";
-            break;
-        default:
-            name = "unknown";
-            break;
-    }
-
-    return qstring_from_str(name);
-}
-
 static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa,
                           socklen_t salen)
 {
@@ -138,7 +118,7 @@ static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa,
 
     qdict_put(qdict, "host", qstring_from_str(host));
     qdict_put(qdict, "service", qstring_from_str(serv));
-    qdict_put(qdict, "family", get_sock_family(sa));
+    qdict_put(qdict, "family",qstring_from_str(inet_strfamily(sa->ss_family)));
 
     return 0;
 }
Signature · 1 line
1.6.6