From: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, lcapitulino@redhat.com,
Miguel Di Ciurcio Filho <miguel.filho@gmail.com>,
avi@redhat.com
Subject: [Qemu-devel] [PATCH 6/8] net: socket: introduce info_dict
Date: Thu, 10 Jun 2010 18:37:03 -0300 [thread overview]
Message-ID: <1276205825-1922-7-git-send-email-miguel.filho@gmail.com> (raw)
In-Reply-To: <1276205825-1922-1-git-send-email-miguel.filho@gmail.com>
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net/socket.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 1c4e153..aad9eb8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -28,6 +28,7 @@
#include "net.h"
#include "qemu-char.h"
#include "qemu-common.h"
+#include "qjson.h"
#include "qemu-error.h"
#include "qemu-option.h"
#include "qemu_socket.h"
@@ -49,6 +50,15 @@ typedef struct NetSocketListenState {
int fd;
} NetSocketListenState;
+static QDict *net_socket_format_info_dict(const char *host,
+ int service,
+ const char *family,
+ int is_server)
+{
+ return qobject_to_qdict(qobject_from_jsonf("{'host': %s, 'family': %s, \
+ 'service': %d, 'server': %i }", host, family, service, is_server));
+}
+
/* XXX: we consider we can send the whole packet without blocking */
static ssize_t net_socket_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
@@ -369,6 +379,9 @@ static void net_socket_accept(void *opaque)
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 = net_socket_format_info_dict(inet_ntoa(saddr.sin_addr),
+ ntohs(saddr.sin_port), "ipv4", 1);
}
}
@@ -462,6 +475,10 @@ static int net_socket_connect_init(VLANState *vlan,
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 = net_socket_format_info_dict(inet_ntoa(saddr.sin_addr),
+ ntohs(saddr.sin_port), "ipv4", 0);
+
return 0;
}
@@ -491,6 +508,10 @@ static int net_socket_mcast_init(VLANState *vlan,
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: mcast=%s:%d",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+
+ s->nc.info_dict = net_socket_format_info_dict(inet_ntoa(saddr.sin_addr),
+ ntohs(saddr.sin_port), "ipv4", 0);
+
return 0;
}
--
1.7.1
next prev parent reply other threads:[~2010-06-10 21:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-10 21:36 [Qemu-devel] [PATCH 0/8] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
2010-06-10 21:36 ` [Qemu-devel] [PATCH 1/8] QObject API: introduce qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-06-10 21:36 ` [Qemu-devel] [PATCH 2/8] QMP: Introduce the documentation for query-netdev and info netdev Miguel Di Ciurcio Filho
2010-06-11 11:37 ` Markus Armbruster
2010-06-11 11:47 ` Miguel Di Ciurcio Filho
2010-06-16 17:39 ` [Qemu-devel] " Luiz Capitulino
2010-06-16 21:55 ` Miguel Di Ciurcio Filho
2010-06-10 21:37 ` [Qemu-devel] [PATCH 3/8] net: Introduce VLANClientState->info_dict Miguel Di Ciurcio Filho
2010-06-16 17:40 ` [Qemu-devel] " Luiz Capitulino
2010-06-10 21:37 ` [Qemu-devel] [PATCH 4/8] net: tap/tap-win32: introduce info_dict Miguel Di Ciurcio Filho
2010-06-16 17:41 ` [Qemu-devel] " Luiz Capitulino
2010-06-10 21:37 ` [Qemu-devel] [PATCH 5/8] net: vde: " Miguel Di Ciurcio Filho
2010-06-10 21:37 ` Miguel Di Ciurcio Filho [this message]
2010-06-10 21:37 ` [Qemu-devel] [PATCH 7/8] net: slirp: " Miguel Di Ciurcio Filho
2010-06-10 21:37 ` [Qemu-devel] [PATCH 8/8] monitor/net: introduce 'info netdev' with QMP support Miguel Di Ciurcio Filho
2010-06-16 17:44 ` [Qemu-devel] Re: [PATCH 0/8] QMP: Introduce query-netdev Luiz Capitulino
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=1276205825-1922-7-git-send-email-miguel.filho@gmail.com \
--to=miguel.filho@gmail.com \
--cc=armbru@redhat.com \
--cc=avi@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).