[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 09/10] net: socket: introduce info_dict
From: |
Miguel Di Ciurcio Filho |
Subject: |
[Qemu-devel] [PATCH v4 09/10] net: socket: introduce info_dict |
Date: |
Tue, 18 May 2010 14:07:48 -0300 |
Signed-off-by: Miguel Di Ciurcio Filho <address@hidden>
---
net/socket.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 1c4e153..5be1b54 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,16 @@ 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("{ 'model': 'socket', \
+ '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 +380,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 +476,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 +509,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
- [Qemu-devel] [PATCH v4 0/10] Introduce 'info netdevices' with QMP support, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 10/10] monitor/net: introduce 'info netdevices' with QMP support, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 09/10] net: socket: introduce info_dict,
Miguel Di Ciurcio Filho <=
- [Qemu-devel] [PATCH v4 08/10] net: slirp: introduce info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 04/10] net: xen: introduce info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 07/10] net: dump: introduce info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 06/10] net: vde: introduce info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 05/10] net: tap/tap-win32: introduce info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 03/10] net: various devices: add qemu_format_nic_info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 02/10] net: introduce qemu_nic_format_info_dict and VLANClientState->info_dict, Miguel Di Ciurcio Filho, 2010/05/18
- [Qemu-devel] [PATCH v4 01/10] QObject API: introduce qdict_to_qstring() function, Miguel Di Ciurcio Filho, 2010/05/18