From patchwork Fri Jan 8 21:47:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 42538 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 17165B7C0C for ; Sat, 9 Jan 2010 08:56:17 +1100 (EST) Received: from localhost ([127.0.0.1]:35463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTMnV-0005dU-LR for incoming@patchwork.ozlabs.org; Fri, 08 Jan 2010 16:55:09 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTMgJ-0002tc-DU for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTMgE-0002pv-Fu for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:42 -0500 Received: from [199.232.76.173] (port=58798 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTMgE-0002po-BL for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15637) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTMgD-0007fq-PH for qemu-devel@nongnu.org; Fri, 08 Jan 2010 16:47:38 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08LlarD000476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Jan 2010 16:47:36 -0500 Received: from localhost (vpn-11-153.rdu.redhat.com [10.11.11.153]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o08LlZ4u032729; Fri, 8 Jan 2010 16:47:36 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 8 Jan 2010 19:47:13 -0200 Message-Id: <1262987236-2943-5-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1262987236-2943-1-git-send-email-lcapitulino@redhat.com> References: <1262987236-2943-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 4/7] VNC: Add 'family' key 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 It contains the socket adress family name, like "ipv4" or "ipv6". This is useful for clients so that they can interpret the 'host' key reliably. Signed-off-by: Luiz Capitulino --- vnc.c | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/vnc.c b/vnc.c index 7b77ffc..a6e54f3 100644 --- a/vnc.c +++ b/vnc.c @@ -100,6 +100,26 @@ 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) { @@ -118,6 +138,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)); return 0; } @@ -294,6 +315,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) * * - "enabled": true or false * - "host": server's IP address + * - "family": address family ("ipv4" or "ipv6") * - "service": server's port number * - "auth": authentication method * - "clients": a QList of all connected clients @@ -308,7 +330,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) * Example: * * { "enabled": true, "host": "0.0.0.0", "service": "50402", "auth": "vnc", - * "clients": [ { "host": "127.0.0.1", "service": "50401" } ] } + * "family": "ipv4", "clients": [ { "host": "127.0.0.1", "service": "50401"}]} */ void do_info_vnc(Monitor *mon, QObject **ret_data) {