From patchwork Tue May 18 17:07:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Di Ciurcio Filho X-Patchwork-Id: 52893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84E08B7D79 for ; Wed, 19 May 2010 03:23:30 +1000 (EST) Received: from localhost ([127.0.0.1]:43502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEQVX-0008R1-Gc for incoming@patchwork.ozlabs.org; Tue, 18 May 2010 13:23:07 -0400 Received: from [140.186.70.92] (port=38666 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEQRQ-0005nA-NT for qemu-devel@nongnu.org; Tue, 18 May 2010 13:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEQHQ-0005Vt-HS for qemu-devel@nongnu.org; Tue, 18 May 2010 13:08:36 -0400 Received: from mail-yw0-f184.google.com ([209.85.211.184]:51679) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEQHN-0005QE-3D for qemu-devel@nongnu.org; Tue, 18 May 2010 13:08:32 -0400 Received: by mail-yw0-f184.google.com with SMTP id 14so3433770ywh.25 for ; Tue, 18 May 2010 10:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=I7MwSlyIZ4g5W3mVb5+Ix/4UGwPRItRYSn3mjRK90vc=; b=XAyw16DQUkomOGr5oEWEpONSjBAg9MIVuoLywTY10cHq6Sujt6YekAhf9+7RVspQxE oxaISnB4RumM3Inz6M+tVWqPvQoMbAWVnrPh8gPdmTz5CkXAg1+a4wqAvK5h2gT0JLJo 5EsG8ItzgudLmjv/B7qlYXj0NpTLftOPd20ZE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=xSsUgJTUl0vjqlWTCvt1a6Y7NFnctjlbIVIYDGlq5SyL/ywWPIHvpktxgMFR+hl/K0 2lG8dBQEIXJ0QhL2S652VIZvIltgpo4ewR88xip4iwu+O8QuEPpKsQB6N/C1cin7iZwq Ty3PCsmPAvMBPx2GZ7smAbKdnWHr2gSCBwssQ= Received: by 10.151.129.5 with SMTP id g5mr8152352ybn.260.1274202508943; Tue, 18 May 2010 10:08:28 -0700 (PDT) Received: from localhost.localdomain (quake.ic.unicamp.br [143.106.7.51]) by mx.google.com with ESMTPS id k30sm58427272ybb.19.2010.05.18.10.08.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 18 May 2010 10:08:28 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Tue, 18 May 2010 14:07:48 -0300 Message-Id: <1274202469-9332-10-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274202469-9332-1-git-send-email-miguel.filho@gmail.com> References: <1274202469-9332-1-git-send-email-miguel.filho@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v4 09/10] net: socket: introduce info_dict X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Miguel Di Ciurcio Filho --- 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; }