From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F53FC433F5 for ; Fri, 17 Dec 2021 15:14:25 +0000 (UTC) Received: from localhost ([::1]:50026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myEwB-0003yp-Qi for qemu-devel@archiver.kernel.org; Fri, 17 Dec 2021 10:14:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myETX-0006GN-J9 for qemu-devel@nongnu.org; Fri, 17 Dec 2021 09:44:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myETV-0002h8-UP for qemu-devel@nongnu.org; Fri, 17 Dec 2021 09:44:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639752283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HfIbodvuKLf+0Hux9L/KexjKL4WEUJTO8nSSAZV7rLg=; b=Qwx0iH2maFFgXJk5pabM8WEYnDQpr8XLsbUkx5ngyOWvzRTlGB2afWiE+3bG7W1ZptN8oz PGLtOx8dlmw0cDAWNO5ZaK/ZAk8zo2voq8hA+y6xRTkwE7cf9coZ/16JRiJVwcMV8sUnZo IsgHOvAsTTSU2X4QySfZa8E3xqD4uCs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-x_0BXuIpP2ml4vdqbJF5Xg-1; Fri, 17 Dec 2021 09:44:39 -0500 X-MC-Unique: x_0BXuIpP2ml4vdqbJF5Xg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4CDF3100CCC4; Fri, 17 Dec 2021 14:44:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 076B45BE2C; Fri, 17 Dec 2021 14:44:36 +0000 (UTC) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL 32/36] chardev: make socket derivable Date: Fri, 17 Dec 2021 18:37:52 +0400 Message-Id: <20211217143756.1831099-33-marcandre.lureau@redhat.com> In-Reply-To: <20211217143756.1831099-1-marcandre.lureau@redhat.com> References: <20211217143756.1831099-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.718, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Signed-off-by: Marc-André Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- include/chardev/char-socket.h | 84 +++++++++++++++++++++++++++++++++++ chardev/char-socket.c | 58 +----------------------- 2 files changed, 85 insertions(+), 57 deletions(-) create mode 100644 include/chardev/char-socket.h diff --git a/include/chardev/char-socket.h b/include/chardev/char-socket.h new file mode 100644 index 000000000000..1a9274f2e3ac --- /dev/null +++ b/include/chardev/char-socket.h @@ -0,0 +1,84 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_SOCKET_H_ +#define CHAR_SOCKET_H_ + +#include "io/channel-socket.h" +#include "io/channel-tls.h" +#include "io/net-listener.h" +#include "chardev/char.h" +#include "qom/object.h" + +#define TCP_MAX_FDS 16 + +typedef struct { + char buf[21]; + size_t buflen; +} TCPChardevTelnetInit; + +typedef enum { + TCP_CHARDEV_STATE_DISCONNECTED, + TCP_CHARDEV_STATE_CONNECTING, + TCP_CHARDEV_STATE_CONNECTED, +} TCPChardevState; + +struct SocketChardev { + Chardev parent; + QIOChannel *ioc; /* Client I/O channel */ + QIOChannelSocket *sioc; /* Client master channel */ + QIONetListener *listener; + GSource *hup_source; + QCryptoTLSCreds *tls_creds; + char *tls_authz; + TCPChardevState state; + int max_size; + int do_telnetopt; + int do_nodelay; + int *read_msgfds; + size_t read_msgfds_num; + int *write_msgfds; + size_t write_msgfds_num; + bool registered_yank; + + SocketAddress *addr; + bool is_listen; + bool is_telnet; + bool is_tn3270; + GSource *telnet_source; + TCPChardevTelnetInit *telnet_init; + + bool is_websock; + + GSource *reconnect_timer; + int64_t reconnect_time; + bool connect_err_reported; + + QIOTask *connect_task; +}; +typedef struct SocketChardev SocketChardev; + +DECLARE_INSTANCE_CHECKER(SocketChardev, SOCKET_CHARDEV, + TYPE_CHARDEV_SOCKET) + +#endif /* CHAR_SOCKET_H_ */ diff --git a/chardev/char-socket.c b/chardev/char-socket.c index a2b02e021d6b..d619088232d3 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -25,9 +25,7 @@ #include "qemu/osdep.h" #include "chardev/char.h" #include "io/channel-socket.h" -#include "io/channel-tls.h" #include "io/channel-websock.h" -#include "io/net-listener.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h" @@ -37,61 +35,7 @@ #include "qemu/yank.h" #include "chardev/char-io.h" -#include "qom/object.h" - -/***********************************************************/ -/* TCP Net console */ - -#define TCP_MAX_FDS 16 - -typedef struct { - char buf[21]; - size_t buflen; -} TCPChardevTelnetInit; - -typedef enum { - TCP_CHARDEV_STATE_DISCONNECTED, - TCP_CHARDEV_STATE_CONNECTING, - TCP_CHARDEV_STATE_CONNECTED, -} TCPChardevState; - -struct SocketChardev { - Chardev parent; - QIOChannel *ioc; /* Client I/O channel */ - QIOChannelSocket *sioc; /* Client master channel */ - QIONetListener *listener; - GSource *hup_source; - QCryptoTLSCreds *tls_creds; - char *tls_authz; - TCPChardevState state; - int max_size; - int do_telnetopt; - int do_nodelay; - int *read_msgfds; - size_t read_msgfds_num; - int *write_msgfds; - size_t write_msgfds_num; - bool registered_yank; - - SocketAddress *addr; - bool is_listen; - bool is_telnet; - bool is_tn3270; - GSource *telnet_source; - TCPChardevTelnetInit *telnet_init; - - bool is_websock; - - GSource *reconnect_timer; - int64_t reconnect_time; - bool connect_err_reported; - - QIOTask *connect_task; -}; -typedef struct SocketChardev SocketChardev; - -DECLARE_INSTANCE_CHECKER(SocketChardev, SOCKET_CHARDEV, - TYPE_CHARDEV_SOCKET) +#include "chardev/char-socket.h" static gboolean socket_reconnect_timeout(gpointer opaque); static void tcp_chr_telnet_init(Chardev *chr); -- 2.34.1.8.g35151cf07204