xref: /openbmc/qemu/include/chardev/char-socket.h (revision 838fc0a8769d7cc6edfe50451ba4e3368395f5c1)
1fa670c80SMarc-André Lureau /*
2fa670c80SMarc-André Lureau  * QEMU System Emulator
3fa670c80SMarc-André Lureau  *
4fa670c80SMarc-André Lureau  * Copyright (c) 2003-2008 Fabrice Bellard
5fa670c80SMarc-André Lureau  *
6fa670c80SMarc-André Lureau  * Permission is hereby granted, free of charge, to any person obtaining a copy
7fa670c80SMarc-André Lureau  * of this software and associated documentation files (the "Software"), to deal
8fa670c80SMarc-André Lureau  * in the Software without restriction, including without limitation the rights
9fa670c80SMarc-André Lureau  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10fa670c80SMarc-André Lureau  * copies of the Software, and to permit persons to whom the Software is
11fa670c80SMarc-André Lureau  * furnished to do so, subject to the following conditions:
12fa670c80SMarc-André Lureau  *
13fa670c80SMarc-André Lureau  * The above copyright notice and this permission notice shall be included in
14fa670c80SMarc-André Lureau  * all copies or substantial portions of the Software.
15fa670c80SMarc-André Lureau  *
16fa670c80SMarc-André Lureau  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17fa670c80SMarc-André Lureau  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18fa670c80SMarc-André Lureau  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19fa670c80SMarc-André Lureau  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20fa670c80SMarc-André Lureau  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21fa670c80SMarc-André Lureau  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22fa670c80SMarc-André Lureau  * THE SOFTWARE.
23fa670c80SMarc-André Lureau  */
249c092804SMarkus Armbruster 
259c092804SMarkus Armbruster #ifndef CHAR_SOCKET_H
269c092804SMarkus Armbruster #define CHAR_SOCKET_H
27fa670c80SMarc-André Lureau 
28fa670c80SMarc-André Lureau #include "io/channel-socket.h"
29fa670c80SMarc-André Lureau #include "io/channel-tls.h"
30fa670c80SMarc-André Lureau #include "io/net-listener.h"
31fa670c80SMarc-André Lureau #include "chardev/char.h"
32fa670c80SMarc-André Lureau #include "qom/object.h"
33fa670c80SMarc-André Lureau 
34fa670c80SMarc-André Lureau #define TCP_MAX_FDS 16
35fa670c80SMarc-André Lureau 
36fa670c80SMarc-André Lureau typedef struct {
37fa670c80SMarc-André Lureau     char buf[21];
38fa670c80SMarc-André Lureau     size_t buflen;
39fa670c80SMarc-André Lureau } TCPChardevTelnetInit;
40fa670c80SMarc-André Lureau 
41fa670c80SMarc-André Lureau typedef enum {
42fa670c80SMarc-André Lureau     TCP_CHARDEV_STATE_DISCONNECTED,
43fa670c80SMarc-André Lureau     TCP_CHARDEV_STATE_CONNECTING,
44fa670c80SMarc-André Lureau     TCP_CHARDEV_STATE_CONNECTED,
45fa670c80SMarc-André Lureau } TCPChardevState;
46fa670c80SMarc-André Lureau 
473e301c8dSMarc-André Lureau typedef ChardevClass SocketChardevClass;
483e301c8dSMarc-André Lureau 
49fa670c80SMarc-André Lureau struct SocketChardev {
50fa670c80SMarc-André Lureau     Chardev parent;
51fa670c80SMarc-André Lureau     QIOChannel *ioc; /* Client I/O channel */
52fa670c80SMarc-André Lureau     QIOChannelSocket *sioc; /* Client master channel */
53fa670c80SMarc-André Lureau     QIONetListener *listener;
54fa670c80SMarc-André Lureau     GSource *hup_source;
55fa670c80SMarc-André Lureau     QCryptoTLSCreds *tls_creds;
56fa670c80SMarc-André Lureau     char *tls_authz;
57fa670c80SMarc-André Lureau     TCPChardevState state;
58fa670c80SMarc-André Lureau     int max_size;
59fa670c80SMarc-André Lureau     int do_telnetopt;
60fa670c80SMarc-André Lureau     int do_nodelay;
61fa670c80SMarc-André Lureau     int *read_msgfds;
62fa670c80SMarc-André Lureau     size_t read_msgfds_num;
63fa670c80SMarc-André Lureau     int *write_msgfds;
64fa670c80SMarc-André Lureau     size_t write_msgfds_num;
65fa670c80SMarc-André Lureau     bool registered_yank;
66fa670c80SMarc-André Lureau 
67fa670c80SMarc-André Lureau     SocketAddress *addr;
68fa670c80SMarc-André Lureau     bool is_listen;
69fa670c80SMarc-André Lureau     bool is_telnet;
70fa670c80SMarc-André Lureau     bool is_tn3270;
71fa670c80SMarc-André Lureau     GSource *telnet_source;
72fa670c80SMarc-André Lureau     TCPChardevTelnetInit *telnet_init;
73fa670c80SMarc-André Lureau 
74fa670c80SMarc-André Lureau     bool is_websock;
75fa670c80SMarc-André Lureau 
76fa670c80SMarc-André Lureau     GSource *reconnect_timer;
77*c8e2b6b4SDaniil Tatianin     int64_t reconnect_time_ms;
78fa670c80SMarc-André Lureau     bool connect_err_reported;
79fa670c80SMarc-André Lureau 
80fa670c80SMarc-André Lureau     QIOTask *connect_task;
81fa670c80SMarc-André Lureau };
82fa670c80SMarc-André Lureau typedef struct SocketChardev SocketChardev;
83fa670c80SMarc-André Lureau 
84fa670c80SMarc-André Lureau DECLARE_INSTANCE_CHECKER(SocketChardev, SOCKET_CHARDEV,
85fa670c80SMarc-André Lureau                          TYPE_CHARDEV_SOCKET)
86fa670c80SMarc-André Lureau 
879c092804SMarkus Armbruster #endif /* CHAR_SOCKET_H */
88