From patchwork Wed Sep 21 15:51:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonit Halperin X-Patchwork-Id: 115820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DA221B6F94 for ; Thu, 22 Sep 2011 02:48:32 +1000 (EST) Received: from localhost ([::1]:34992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6P5X-0000tp-D7 for incoming@patchwork.ozlabs.org; Wed, 21 Sep 2011 11:51:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6P5N-0000fH-82 for qemu-devel@nongnu.org; Wed, 21 Sep 2011 11:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6P5I-0000BK-R5 for qemu-devel@nongnu.org; Wed, 21 Sep 2011 11:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6P5I-0000B8-DL for qemu-devel@nongnu.org; Wed, 21 Sep 2011 11:51:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8LFpdDS006478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Sep 2011 11:51:39 -0400 Received: from dhcp-0-9.tlv.redhat.com (dhcp-3-166.tlv.redhat.com [10.35.3.166]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8LFpKuF029127; Wed, 21 Sep 2011 11:51:37 -0400 From: Yonit Halperin To: spice-devel@freedesktop.org Date: Wed, 21 Sep 2011 18:51:18 +0300 Message-Id: <1316620283-8330-9-git-send-email-yhalperi@redhat.com> In-Reply-To: <1316620283-8330-1-git-send-email-yhalperi@redhat.com> References: <1316620283-8330-1-git-send-email-yhalperi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Yonit Halperin , alevy@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com Subject: [Qemu-devel] [PATCH spice-server 08/13] server: move the linking of channels to a separate routine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Yonit Halperin --- server/reds.c | 68 +++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 42 insertions(+), 26 deletions(-) diff --git a/server/reds.c b/server/reds.c index bea0eb0..e7388a0 100644 --- a/server/reds.c +++ b/server/reds.c @@ -2612,12 +2612,48 @@ static void inputs_init() reds_register_channel(channel); } +static void reds_send_input_channel_insecure_warn() +{ + RedsOutItem *item; + SpiceMsgNotify notify; + char *mess = "keyboard channel is insecure"; + const int mess_len = strlen(mess); + + item = new_out_item(SPICE_MSG_NOTIFY); + + notify.time_stamp = get_time_stamp(); + notify.severity = SPICE_NOTIFY_SEVERITY_WARN; + notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH; + notify.what = SPICE_WARN_GENERAL; + notify.message_len = mess_len; + + spice_marshall_msg_notify(item->m, ¬ify); + spice_marshaller_add(item->m, (uint8_t *)mess, mess_len + 1); + + reds_push_pipe_item(item); +} + +static void reds_channel_do_link(Channel *channel, SpiceLinkMess *link_msg, RedsStream *stream) +{ + uint32_t *caps; + + ASSERT(channel); + ASSERT(link_msg); + ASSERT(stream); + + if (link_msg->channel_type == SPICE_CHANNEL_INPUTS && !stream->ssl) { + reds_send_input_channel_insecure_warn(); + } + caps = (uint32_t *)((uint8_t *)link_msg + link_msg->caps_offset); + channel->link(channel, stream, FALSE, link_msg->num_common_caps, + link_msg->num_common_caps ? caps : NULL, link_msg->num_channel_caps, + link_msg->num_channel_caps ? caps + link_msg->num_common_caps : NULL); +} + static void reds_handle_other_links(RedLinkInfo *link) { Channel *channel; - RedsStream *stream; SpiceLinkMess *link_mess; - uint32_t *caps; link_mess = link->link_mess; @@ -2635,36 +2671,16 @@ static void reds_handle_other_links(RedLinkInfo *link) } reds_send_link_result(link, SPICE_LINK_ERR_OK); + // TODO: if mig_target, where this call should be? here or only when the links are handled reds_show_new_channel(link, reds->link_id); - if (link_mess->channel_type == SPICE_CHANNEL_INPUTS && !link->stream->ssl) { - RedsOutItem *item; - SpiceMsgNotify notify; - char *mess = "keyboard channel is insecure"; - const int mess_len = strlen(mess); - - item = new_out_item(SPICE_MSG_NOTIFY); - - notify.time_stamp = get_time_stamp(); - notify.severity = SPICE_NOTIFY_SEVERITY_WARN; - notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH; - notify.what = SPICE_WARN_GENERAL; - notify.message_len = mess_len; + reds_stream_remove_watch(link->stream); - spice_marshall_msg_notify(item->m, ¬ify); - spice_marshaller_add(item->m, (uint8_t *)mess, mess_len + 1); + reds_channel_do_link(channel, link->link_mess, link->stream); + free(link_mess); - reds_push_pipe_item(item); - } - stream = link->stream; - reds_stream_remove_watch(stream); link->stream = NULL; link->link_mess = NULL; reds_link_free(link); - caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset); - channel->link(channel, stream, reds->mig_target, link_mess->num_common_caps, - link_mess->num_common_caps ? caps : NULL, link_mess->num_channel_caps, - link_mess->num_channel_caps ? caps + link_mess->num_common_caps : NULL); - free(link_mess); } static void reds_handle_link(RedLinkInfo *link)