X-Git-Url: http://git.maemo.org/git/?p=qemu;a=blobdiff_plain;f=vnc.h;h=3ae95f3d7447b77db75849431c91424a3c9651e9;hp=e7467e147f6ee22e65ff6587e92538b4849fadc8;hb=HEAD;hpb=19a490bfca85165de1acd2d5c3964fb44615746d diff --git a/vnc.h b/vnc.h index e7467e1..3ae95f3 100644 --- a/vnc.h +++ b/vnc.h @@ -33,13 +33,16 @@ #include "audio/audio.h" #include -#ifdef CONFIG_VNC_TLS -#include -#include -#endif /* CONFIG_VNC_TLS */ - #include "keymaps.h" +// #define _VNC_DEBUG 1 + +#ifdef _VNC_DEBUG +#define VNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define VNC_DEBUG(fmt, ...) do { } while (0) +#endif + /***************************************************************************** * * Core data structures @@ -73,6 +76,15 @@ typedef void VncSendHextileTile(VncState *vs, typedef struct VncDisplay VncDisplay; +#ifdef CONFIG_VNC_TLS +#include "vnc-tls.h" +#include "vnc-auth-vencrypt.h" +#endif +#ifdef CONFIG_VNC_SASL +#include "vnc-auth-sasl.h" +#endif + + struct VncDisplay { int lsock; @@ -84,25 +96,32 @@ struct VncDisplay char *password; int auth; #ifdef CONFIG_VNC_TLS - int subauth; - int x509verify; - - char *x509cacert; - char *x509cacrl; - char *x509cert; - char *x509key; + int subauth; /* Used by VeNCrypt */ + VncDisplayTLS tls; +#endif +#ifdef CONFIG_VNC_SASL + VncDisplaySASL sasl; #endif }; +struct VncSurface +{ + uint32_t dirty[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS]; + DisplaySurface *ds; +}; + struct VncState { QEMUTimer *timer; int csock; + DisplayState *ds; + struct VncSurface guest; /* guest visible surface (aka ds->surface) */ + struct VncSurface server; /* vnc server surface */ + VncDisplay *vd; int need_update; - uint32_t dirty_row[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS]; - char *old_data; + int force_update; uint32_t features; int absolute; int last_x; @@ -116,10 +135,11 @@ struct VncState int minor; char challenge[VNC_AUTH_CHALLENGE_SIZE]; - #ifdef CONFIG_VNC_TLS - int wiremode; - gnutls_session_t tls_session; + VncStateTLS tls; +#endif +#ifdef CONFIG_VNC_SASL + VncStateSASL sasl; #endif Buffer output; @@ -127,7 +147,7 @@ struct VncState /* current output mode information */ VncWritePixels *write_pixels; VncSendHextileTile *send_hextile_tile; - DisplaySurface clientds, serverds; + DisplaySurface clientds; CaptureVoiceOut *audio_cap; struct audsettings as; @@ -159,14 +179,9 @@ enum { VNC_AUTH_RA2NE = 6, VNC_AUTH_TIGHT = 16, VNC_AUTH_ULTRA = 17, - VNC_AUTH_TLS = 18, - VNC_AUTH_VENCRYPT = 19 -}; - -#ifdef CONFIG_VNC_TLS -enum { - VNC_WIREMODE_CLEAR, - VNC_WIREMODE_TLS, + VNC_AUTH_TLS = 18, /* Supported in GTK-VNC & VINO */ + VNC_AUTH_VENCRYPT = 19, /* Supported in GTK-VNC & VeNCrypt */ + VNC_AUTH_SASL = 20, /* Supported in GTK-VNC & VINO */ }; enum { @@ -177,14 +192,10 @@ 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" -#define X509_CA_CRL_FILE "ca-crl.pem" -#define X509_SERVER_KEY_FILE "server-key.pem" -#define X509_SERVER_CERT_FILE "server-cert.pem" - -#endif /* CONFIG_VNC_TLS */ /***************************************************************************** * @@ -255,4 +266,54 @@ enum { #define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB) #define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT) + +/***************************************************************************** + * + * Internal APIs + * + *****************************************************************************/ + +/* Event loop functions */ +void vnc_client_read(void *opaque); +void vnc_client_write(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_s32(VncState *vs, int32_t value); +void vnc_write_u16(VncState *vs, uint16_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 */ +uint8_t read_u8(uint8_t *data, size_t offset); +uint16_t read_u16(uint8_t *data, size_t offset); +int32_t read_s32(uint8_t *data, size_t offset); +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); +void start_auth_vnc(VncState *vs); + +/* Buffer management */ +void buffer_reserve(Buffer *buffer, size_t len); +int buffer_empty(Buffer *buffer); +uint8_t *buffer_end(Buffer *buffer); +void buffer_reset(Buffer *buffer); +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 */