qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v3 09/12] net: socket: use info_dict instead of info_str
Date: Thu, 15 Apr 2010 11:07:04 -0300	[thread overview]
Message-ID: <1271340427-12579-10-git-send-email-miguel.filho@gmail.com> (raw)
In-Reply-To: <1271340427-12579-1-git-send-email-miguel.filho@gmail.com>

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
 net/socket.c |   47 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 1c4e153..fa5d24d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -28,6 +28,10 @@
 #include "net.h"
 #include "qemu-char.h"
 #include "qemu-common.h"
+#include "qdict.h"
+#include "qstring.h"
+#include "qbool.h"
+#include "qint.h"
 #include "qemu-error.h"
 #include "qemu-option.h"
 #include "qemu_socket.h"
@@ -266,11 +270,14 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
     }
 
     nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);
-
-    snprintf(nc->info_str, sizeof(nc->info_str),
-	    "socket: fd=%d (%s mcast=%s:%d)",
-	    fd, is_connected ? "cloned" : "",
-	    inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+    
+    nc->info_dict = qdict_new();
+    qdict_put(nc->info_dict, "fd", qint_from_int(fd));
+    qdict_put(nc->info_dict, "host",
+        qstring_from_str(inet_ntoa(saddr.sin_addr)));
+    qdict_put(nc->info_dict, "service", qint_from_int(ntohs(saddr.sin_port)));
+    qdict_put(nc->info_dict, "family", qstring_from_str("ipv4"));
+    qdict_put(nc->info_dict, "cloned", qbool_from_int(is_connected));
 
     s = DO_UPCAST(NetSocketState, nc, nc);
 
@@ -306,8 +313,9 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
     NetSocketState *s;
 
     nc = qemu_new_net_client(&net_socket_info, vlan, NULL, model, name);
+    nc->info_dict = qdict_new();
 
-    snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
+    qdict_put(nc->info_dict, "fd", qint_from_int(fd));
 
     s = DO_UPCAST(NetSocketState, nc, nc);
 
@@ -366,9 +374,12 @@ static void net_socket_accept(void *opaque)
     if (!s1) {
         closesocket(fd);
     } else {
-        snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
-                 "socket: connection from %s:%d",
-                 inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+        s1->nc.info_dict = qdict_new();
+
+        qdict_put(s1->nc.info_dict, "host",
+            qstring_from_str(inet_ntoa(saddr.sin_addr)));
+        qdict_put(s1->nc.info_dict, "service", qint_from_int(ntohs(saddr.sin_port)));
+        qdict_put(s1->nc.info_dict, "family", qstring_from_str("ipv4"));
     }
 }
 
@@ -459,9 +470,12 @@ static int net_socket_connect_init(VLANState *vlan,
     s = net_socket_fd_init(vlan, model, name, fd, connected);
     if (!s)
         return -1;
-    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-             "socket: connect to %s:%d",
-             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+
+    s->nc.info_dict = qdict_new();
+    qdict_put(s->nc.info_dict, "host",
+        qstring_from_str(inet_ntoa(saddr.sin_addr)));
+    qdict_put(s->nc.info_dict, "service", qint_from_int(ntohs(saddr.sin_port)));
+    qdict_put(s->nc.info_dict, "family", qstring_from_str("ipv4"));
     return 0;
 }
 
@@ -487,10 +501,13 @@ static int net_socket_mcast_init(VLANState *vlan,
         return -1;
 
     s->dgram_dst = saddr;
+    
+    s->nc.info_dict = qdict_new();
+    qdict_put(s->nc.info_dict, "host",
+        qstring_from_str(inet_ntoa(saddr.sin_addr)));
+    qdict_put(s->nc.info_dict, "service", qint_from_int(ntohs(saddr.sin_port)));
+    qdict_put(s->nc.info_dict, "family", qstring_from_str("ipv4"));
 
-    snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-             "socket: mcast=%s:%d",
-             inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
     return 0;
 
 }
-- 
1.7.0.4

  parent reply	other threads:[~2010-04-15 14:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15 14:06 [Qemu-devel] [PATCH v3 00/12] Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 01/12] QObject API: add qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-04-23 21:04   ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 02/12] net: add qemu_nic_format_info_dict and VLANClientState->info_dict Miguel Di Ciurcio Filho
2010-04-23 21:05   ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 03/12] net: eepro100: replace qemu_format_nic_info_str by qemu_format_nic_info_dict Miguel Di Ciurcio Filho
2010-04-15 15:32   ` Richard Henderson
2010-04-15 14:06 ` [Qemu-devel] [PATCH v3 04/12] net: various devices: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 05/12] net: slirp: use info_dict instead of info_str Miguel Di Ciurcio Filho
2010-04-23 21:06   ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 06/12] net: tap/tap-win32: " Miguel Di Ciurcio Filho
2010-04-23 21:08   ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 07/12] net: vde: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 08/12] net: dump: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` Miguel Di Ciurcio Filho [this message]
2010-04-23 21:10   ` [Qemu-devel] Re: [PATCH v3 09/12] net: socket: " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 10/12] net: xen: " Miguel Di Ciurcio Filho
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 11/12] monitor/net: Convert do_info_network() to QObject/QMP Miguel Di Ciurcio Filho
2010-04-23 21:13   ` [Qemu-devel] " Luiz Capitulino
2010-04-15 14:07 ` [Qemu-devel] [PATCH v3 12/12] net: Remove info_str from VLANClientState, not needed anymore Miguel Di Ciurcio Filho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1271340427-12579-10-git-send-email-miguel.filho@gmail.com \
    --to=miguel.filho@gmail.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).