[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 1/6] qemu-xen-trad: sasl: expose vnc API to SASL auth
Expose minimum VNC API to support SASL auth. This is mainly the VncState structure and a subset of the API funcs. The layout of the file is modelled on the upstream QEMU vnc.h. Signed-off-by: Simon Waterman <watermansrdev@xxxxxxxxx> --- vnc.h | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 222 insertions(+), 9 deletions(-) diff --git a/vnc.h b/vnc.h index 6981606..66bed0c 100644 --- a/vnc.h +++ b/vnc.h @@ -1,5 +1,183 @@ -#ifndef __VNCTIGHT_H -#define __VNCTIGHT_H +/* + * QEMU VNC display driver + * + * Copyright (C) 2006 Anthony Liguori <anthony@xxxxxxxxxxxxx> + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2009 Red Hat, Inc + * + * 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 __QEMU_VNC_H +#define __QEMU_VNC_H + +#include "qemu-common.h" +#include "console.h" +#include "sysemu.h" + +// #define _VNC_DEBUG 1 + +#ifdef _VNC_DEBUG +#define VNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) + +#if defined(CONFIG_VNC_TLS) && _VNC_DEBUG >= 2 +/* Very verbose, so only enabled for _VNC_DEBUG >= 2 */ +static void vnc_debug_gnutls_log(int level, const char* str) { + VNC_DEBUG("%d %s", level, str); +} +#endif /* CONFIG_VNC_TLS && _VNC_DEBUG */ +#else +#define VNC_DEBUG(fmt, ...) do { } while (0) +#endif + +/***************************************************************************** + * + * Core data structures + * + *****************************************************************************/ + +typedef struct Buffer +{ + size_t capacity; + size_t offset; + uint8_t *buffer; +} Buffer; + +typedef struct VncState VncState; + +typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); + +typedef void VncWritePixels(VncState *vs, void *data, int size); + +typedef void VncSendHextileTile(VncState *vs, + int x, int y, int w, int h, + void *last_bg, + void *last_fg, + int *has_bg, int *has_fg); + +#include "vnc_keysym.h" +#include "keymaps.c" + +#ifdef CONFIG_VNC_TLS +#include <gnutls/gnutls.h> +#include <gnutls/x509.h> +#endif /* CONFIG_VNC_TLS */ + +#ifdef CONFIG_VNC_SASL +#include "vnc-auth-sasl.h" +#endif + +#define VNC_AUTH_CHALLENGE_SIZE 16 + +#define QUEUE_ALLOC_UNIT 10 + +typedef struct _QueueItem +{ + int x, y, w, h; + int32_t enc; + struct _QueueItem *next; +} QueueItem; + +typedef struct _Queue +{ + QueueItem *queue_start; + int start_count; + QueueItem *queue_end; + int end_count; +} Queue; + +struct VncState +{ + QEMUTimer *timer; + int timer_interval; + int64_t last_update_time; + int lsock; + int csock; + DisplayState *ds; + uint64_t *dirty_row; /* screen regions which are possibly dirty */ + int dirty_pixel_shift; + uint64_t *update_row; /* outstanding updates */ + int has_update; /* there's outstanding updates in the + * visible area */ + + int update_requested; /* the client requested an update */ + + uint8_t *old_data; + int has_resize; + int has_hextile; + int has_pointer_type_change; + int has_WMVi; + int absolute; + int last_x; + int last_y; + + int major; + int minor; + + char *display; + char *password; + int auth; +#ifdef CONFIG_VNC_TLS + int subauth; + int x509verify; + + char *x509cacert; + char *x509cacrl; + char *x509cert; + char *x509key; +#endif + char challenge[VNC_AUTH_CHALLENGE_SIZE]; + int switchbpp; + +#ifdef CONFIG_VNC_TLS + int wiremode; + gnutls_session_t tls_session; +#endif + +#ifdef CONFIG_VNC_SASL + VncStateSASL sasl; +#endif + + Buffer output; + Buffer input; + + Queue upqueue; + + kbd_layout_t *kbd_layout; + /* current output mode information */ + VncWritePixels *write_pixels; + VncSendHextileTile *send_hextile_tile; + DisplaySurface clientds, serverds; + + VncReadEvent *read_handler; + size_t read_handler_expect; + + int visible_x; + int visible_y; + int visible_w; + int visible_h; + + /* input */ + uint8_t modifiers_state[256]; +}; + +static VncState *vnc_state; /* needed for info vnc */ /***************************************************************************** * @@ -16,16 +194,12 @@ enum { VNC_AUTH_TIGHT = 16, VNC_AUTH_ULTRA = 17, VNC_AUTH_TLS = 18, - VNC_AUTH_VENCRYPT = 19 + VNC_AUTH_VENCRYPT = 19, + VNC_AUTH_SASL = 20, /* Supported in GTK-VNC & VINO */ }; #ifdef CONFIG_VNC_TLS enum { - VNC_WIREMODE_CLEAR, - VNC_WIREMODE_TLS, -}; - -enum { VNC_AUTH_VENCRYPT_PLAIN = 256, VNC_AUTH_VENCRYPT_TLSNONE = 257, VNC_AUTH_VENCRYPT_TLSVNC = 258, @@ -33,6 +207,8 @@ enum { VNC_AUTH_VENCRYPT_X509NONE = 260, VNC_AUTH_VENCRYPT_X509VNC = 261, VNC_AUTH_VENCRYPT_X509PLAIN = 262, + VNC_AUTH_VENCRYPT_X509SASL = 263, + VNC_AUTH_VENCRYPT_TLSSASL = 264, }; #define X509_CA_CERT_FILE "ca-cert.pem" @@ -111,4 +287,41 @@ enum { #define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB) #define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT) -#endif /* __VNCTIGHT_H */ +/***************************************************************************** + * + * Internal APIs + * + *****************************************************************************/ + +/* Event loop functions */ +void vnc_client_read(void *opaque); + +long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen); +long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen); + +/* Protocol I/O functions */ +void vnc_write(VncState *vs, const void *data, size_t len); +void vnc_write_u32(VncState *vs, uint32_t value); +void vnc_write_u8(VncState *vs, uint8_t value); +void vnc_flush(VncState *vs); +void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting); + +/* Buffer I/O functions */ +uint32_t read_u32(uint8_t *data, size_t offset); + +/* Protocol stage functions */ +void vnc_client_error(VncState *vs); +int vnc_client_io_error(VncState *vs, int ret, int last_errno); + +void start_client_init(VncState *vs); + +/* Buffer management */ +void buffer_reserve(Buffer *buffer, size_t len); +void buffer_append(Buffer *buffer, const void *data, size_t len); + +/* Misc helpers */ + +char *vnc_socket_local_addr(const char *format, int fd); +char *vnc_socket_remote_addr(const char *format, int fd); + +#endif /* __QEMU_VNC_H */ -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |