diff options
author | Alon Levy <alevy@redhat.com> | 2012-10-19 11:27:57 +0200 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2012-10-25 12:33:02 +0200 |
commit | 63bb37276e028ab1b1c156c9e7907bf22b6d5952 (patch) | |
tree | 4f4d91513179b61ffb433af28a92fe7352fdf8c9 /server/reds-private.h | |
parent | 2c85436dc6c2e9febecfb84c579e7a50a4a6bd6b (diff) | |
download | spice-63bb37276e028ab1b1c156c9e7907bf22b6d5952.tar.gz spice-63bb37276e028ab1b1c156c9e7907bf22b6d5952.tar.xz spice-63bb37276e028ab1b1c156c9e7907bf22b6d5952.zip |
server: add websockets support via libwebsockets
New API: spice_server_set_ws_ports
This adds an optional dependency on libwebsockets. You need to get my
patched 0.0.3 version here:
git://people.freedesktop.org/~alon/libwebsockets
There is no qemu patches yet, to test change in reds.c the default value
of spice_ws_port to 5959 (for the default of spice-html5).
For testing there is an online client at
http://spice-space.org/spice-html5/spice.html
Known issues:
1. The tester (server/tests/test_display_no_ssl) gets into dropping all
data after a few seconds, I think it's an issue with the implemented
watches, but haven't figured it out.
2. libwebsocket's read interface is inverted to what our code expects,
i.e. there is no libwebsocket_read, so there is an additional copy
involved (see RedsWebSocket). This can be fixed.
3. Listening on a separate port. Since the headers are different, we
could listen on the same port (first three bytes RED/GET). I don't know
if we want to?
Todos:
1. SSL not implemented yet. Needs some thought as to how.
2. Serve spice-html5 when accessed as a http server. Nice to have.
Diffstat (limited to 'server/reds-private.h')
-rw-r--r-- | server/reds-private.h | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/server/reds-private.h b/server/reds-private.h index 3db6565b..a5903b31 100644 --- a/server/reds-private.h +++ b/server/reds-private.h @@ -4,6 +4,16 @@ #include <time.h> #include <spice/protocol.h> +#include <spice/stats.h> + +#if USE_LIBWEBSOCKETS +#include <libwebsockets.h> +#endif + +#include "reds.h" +#include "char_device.h" +#include "agent-msg-filter.h" +#include "main_channel.h" #define MIGRATE_TIMEOUT (1000 * 10) /* 10sec */ #define MM_TIMER_GRANULARITY_MS (1000 / 30) @@ -34,10 +44,6 @@ typedef struct VDIReadBuf { uint8_t data[SPICE_AGENT_MAX_DATA_SIZE]; } VDIReadBuf; -static VDIReadBuf *vdi_port_read_buf_get(void); -static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf); -static void vdi_port_read_buf_unref(VDIReadBuf *buf); - enum { VDI_PORT_READ_STATE_READ_HEADER, VDI_PORT_READ_STATE_GET_BUFF, @@ -125,9 +131,19 @@ typedef struct RedsClientMonitorsConfig { int buffer_pos; } RedsClientMonitorsConfig; +#ifdef USE_LIBWEBSOCKETS +#define REDS_MAX_WEBSOCKETS 32 +#endif + typedef struct RedsState { int listen_socket; int secure_listen_socket; +#ifdef USE_LIBWEBSOCKETS + struct libwebsocket_context *ws_context; + RedsWebSocket ws[REDS_MAX_WEBSOCKETS]; + int ws_in_service_fd; + int ws_count; +#endif SpiceWatch *listen_watch; SpiceWatch *secure_listen_watch; VDIPortState agent_state; @@ -179,4 +195,27 @@ typedef struct RedsState { RedsClientMonitorsConfig client_monitors_config; } RedsState; +typedef struct AsyncRead { + RedsStream *stream; + void *opaque; + uint8_t *now; + uint8_t *end; + void (*done)(void *opaque); + void (*error)(void *opaque, int err); +} AsyncRead; + +typedef struct RedLinkInfo { + RedsStream *stream; + AsyncRead asyc_read; + SpiceLinkHeader link_header; + SpiceLinkMess *link_mess; + int mess_pos; + TicketInfo tiTicketing; + SpiceLinkAuthMechanism auth_mechanism; + int skip_auth; +} RedLinkInfo; + +RedLinkInfo *spice_server_add_client_create_link(SpiceServer *s, int socket, int skip_auth); +void reds_handle_new_link(RedLinkInfo *link); + #endif |