Commit 19a490bfca85165de1acd2d5c3964fb44615746d
1 parent
0483755a
Move VNC structs into header file ("Daniel P. Berrange")
This patch moves the definitions of VncState and VncDisplay structs out into a vnc.h header file. This is to allow the code for TLS and SASL auth mechanisms to be moved out of the main vnc.c file. vnc.c | 109 ------------------------------------------------ vnc.h | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 148 insertions(+), 110 deletions(-) Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6722 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
149 additions
and
111 deletions
vnc.c
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | * |
4 | 4 | * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> |
5 | 5 | * Copyright (C) 2006 Fabrice Bellard |
6 | + * Copyright (C) 2009 Red Hat, Inc | |
6 | 7 | * |
7 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | 9 | * of this software and associated documentation files (the "Software"), to deal |
... | ... | @@ -23,26 +24,16 @@ |
23 | 24 | * THE SOFTWARE. |
24 | 25 | */ |
25 | 26 | |
26 | -#include "qemu-common.h" | |
27 | -#include "monitor.h" | |
28 | -#include "console.h" | |
27 | +#include "vnc.h" | |
29 | 28 | #include "sysemu.h" |
30 | 29 | #include "qemu_socket.h" |
31 | 30 | #include "qemu-timer.h" |
32 | -#include "audio/audio.h" | |
33 | -#include <zlib.h> | |
34 | 31 | |
35 | 32 | #define VNC_REFRESH_INTERVAL (1000 / 30) |
36 | 33 | |
37 | -#include "vnc.h" | |
38 | 34 | #include "vnc_keysym.h" |
39 | 35 | #include "d3des.h" |
40 | 36 | |
41 | -#ifdef CONFIG_VNC_TLS | |
42 | -#include <gnutls/gnutls.h> | |
43 | -#include <gnutls/x509.h> | |
44 | -#endif /* CONFIG_VNC_TLS */ | |
45 | - | |
46 | 37 | // #define _VNC_DEBUG 1 |
47 | 38 | |
48 | 39 | #ifdef _VNC_DEBUG |
... | ... | @@ -65,103 +56,6 @@ static void vnc_debug_gnutls_log(int level, const char* str) { |
65 | 56 | } \ |
66 | 57 | } |
67 | 58 | |
68 | -typedef struct Buffer | |
69 | -{ | |
70 | - size_t capacity; | |
71 | - size_t offset; | |
72 | - uint8_t *buffer; | |
73 | -} Buffer; | |
74 | - | |
75 | -typedef struct VncState VncState; | |
76 | - | |
77 | -typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); | |
78 | - | |
79 | -typedef void VncWritePixels(VncState *vs, void *data, int size); | |
80 | - | |
81 | -typedef void VncSendHextileTile(VncState *vs, | |
82 | - int x, int y, int w, int h, | |
83 | - void *last_bg, | |
84 | - void *last_fg, | |
85 | - int *has_bg, int *has_fg); | |
86 | - | |
87 | -#define VNC_MAX_WIDTH 2048 | |
88 | -#define VNC_MAX_HEIGHT 2048 | |
89 | -#define VNC_DIRTY_WORDS (VNC_MAX_WIDTH / (16 * 32)) | |
90 | - | |
91 | -#define VNC_AUTH_CHALLENGE_SIZE 16 | |
92 | - | |
93 | -typedef struct VncDisplay VncDisplay; | |
94 | - | |
95 | -struct VncDisplay | |
96 | -{ | |
97 | - int lsock; | |
98 | - DisplayState *ds; | |
99 | - VncState *clients; | |
100 | - kbd_layout_t *kbd_layout; | |
101 | - | |
102 | - char *display; | |
103 | - char *password; | |
104 | - int auth; | |
105 | -#ifdef CONFIG_VNC_TLS | |
106 | - int subauth; | |
107 | - int x509verify; | |
108 | - | |
109 | - char *x509cacert; | |
110 | - char *x509cacrl; | |
111 | - char *x509cert; | |
112 | - char *x509key; | |
113 | -#endif | |
114 | -}; | |
115 | - | |
116 | -struct VncState | |
117 | -{ | |
118 | - QEMUTimer *timer; | |
119 | - int csock; | |
120 | - DisplayState *ds; | |
121 | - VncDisplay *vd; | |
122 | - int need_update; | |
123 | - uint32_t dirty_row[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS]; | |
124 | - char *old_data; | |
125 | - uint32_t features; | |
126 | - int absolute; | |
127 | - int last_x; | |
128 | - int last_y; | |
129 | - | |
130 | - uint32_t vnc_encoding; | |
131 | - uint8_t tight_quality; | |
132 | - uint8_t tight_compression; | |
133 | - | |
134 | - int major; | |
135 | - int minor; | |
136 | - | |
137 | - char challenge[VNC_AUTH_CHALLENGE_SIZE]; | |
138 | - | |
139 | -#ifdef CONFIG_VNC_TLS | |
140 | - int wiremode; | |
141 | - gnutls_session_t tls_session; | |
142 | -#endif | |
143 | - | |
144 | - Buffer output; | |
145 | - Buffer input; | |
146 | - /* current output mode information */ | |
147 | - VncWritePixels *write_pixels; | |
148 | - VncSendHextileTile *send_hextile_tile; | |
149 | - DisplaySurface clientds, serverds; | |
150 | - | |
151 | - CaptureVoiceOut *audio_cap; | |
152 | - struct audsettings as; | |
153 | - | |
154 | - VncReadEvent *read_handler; | |
155 | - size_t read_handler_expect; | |
156 | - /* input */ | |
157 | - uint8_t modifiers_state[256]; | |
158 | - | |
159 | - Buffer zlib; | |
160 | - Buffer zlib_tmp; | |
161 | - z_stream zlib_stream[4]; | |
162 | - | |
163 | - VncState *next; | |
164 | -}; | |
165 | 59 | |
166 | 60 | static VncDisplay *vnc_display; /* needed for info vnc */ |
167 | 61 | static DisplayChangeListener *dcl; | ... | ... |
vnc.h
1 | -#ifndef __VNCTIGHT_H | |
2 | -#define __VNCTIGHT_H | |
1 | +/* | |
2 | + * QEMU VNC display driver | |
3 | + * | |
4 | + * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> | |
5 | + * Copyright (C) 2006 Fabrice Bellard | |
6 | + * Copyright (C) 2009 Red Hat, Inc | |
7 | + * | |
8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
9 | + * of this software and associated documentation files (the "Software"), to deal | |
10 | + * in the Software without restriction, including without limitation the rights | |
11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
12 | + * copies of the Software, and to permit persons to whom the Software is | |
13 | + * furnished to do so, subject to the following conditions: | |
14 | + * | |
15 | + * The above copyright notice and this permission notice shall be included in | |
16 | + * all copies or substantial portions of the Software. | |
17 | + * | |
18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
21 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
24 | + * THE SOFTWARE. | |
25 | + */ | |
26 | + | |
27 | +#ifndef __QEMU_VNC_H | |
28 | +#define __QEMU_VNC_H | |
29 | + | |
30 | +#include "qemu-common.h" | |
31 | +#include "console.h" | |
32 | +#include "monitor.h" | |
33 | +#include "audio/audio.h" | |
34 | +#include <zlib.h> | |
35 | + | |
36 | +#ifdef CONFIG_VNC_TLS | |
37 | +#include <gnutls/gnutls.h> | |
38 | +#include <gnutls/x509.h> | |
39 | +#endif /* CONFIG_VNC_TLS */ | |
40 | + | |
41 | +#include "keymaps.h" | |
42 | + | |
43 | +/***************************************************************************** | |
44 | + * | |
45 | + * Core data structures | |
46 | + * | |
47 | + *****************************************************************************/ | |
48 | + | |
49 | +typedef struct Buffer | |
50 | +{ | |
51 | + size_t capacity; | |
52 | + size_t offset; | |
53 | + uint8_t *buffer; | |
54 | +} Buffer; | |
55 | + | |
56 | +typedef struct VncState VncState; | |
57 | + | |
58 | +typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); | |
59 | + | |
60 | +typedef void VncWritePixels(VncState *vs, void *data, int size); | |
61 | + | |
62 | +typedef void VncSendHextileTile(VncState *vs, | |
63 | + int x, int y, int w, int h, | |
64 | + void *last_bg, | |
65 | + void *last_fg, | |
66 | + int *has_bg, int *has_fg); | |
67 | + | |
68 | +#define VNC_MAX_WIDTH 2048 | |
69 | +#define VNC_MAX_HEIGHT 2048 | |
70 | +#define VNC_DIRTY_WORDS (VNC_MAX_WIDTH / (16 * 32)) | |
71 | + | |
72 | +#define VNC_AUTH_CHALLENGE_SIZE 16 | |
73 | + | |
74 | +typedef struct VncDisplay VncDisplay; | |
75 | + | |
76 | +struct VncDisplay | |
77 | +{ | |
78 | + int lsock; | |
79 | + DisplayState *ds; | |
80 | + VncState *clients; | |
81 | + kbd_layout_t *kbd_layout; | |
82 | + | |
83 | + char *display; | |
84 | + char *password; | |
85 | + int auth; | |
86 | +#ifdef CONFIG_VNC_TLS | |
87 | + int subauth; | |
88 | + int x509verify; | |
89 | + | |
90 | + char *x509cacert; | |
91 | + char *x509cacrl; | |
92 | + char *x509cert; | |
93 | + char *x509key; | |
94 | +#endif | |
95 | +}; | |
96 | + | |
97 | +struct VncState | |
98 | +{ | |
99 | + QEMUTimer *timer; | |
100 | + int csock; | |
101 | + DisplayState *ds; | |
102 | + VncDisplay *vd; | |
103 | + int need_update; | |
104 | + uint32_t dirty_row[VNC_MAX_HEIGHT][VNC_DIRTY_WORDS]; | |
105 | + char *old_data; | |
106 | + uint32_t features; | |
107 | + int absolute; | |
108 | + int last_x; | |
109 | + int last_y; | |
110 | + | |
111 | + uint32_t vnc_encoding; | |
112 | + uint8_t tight_quality; | |
113 | + uint8_t tight_compression; | |
114 | + | |
115 | + int major; | |
116 | + int minor; | |
117 | + | |
118 | + char challenge[VNC_AUTH_CHALLENGE_SIZE]; | |
119 | + | |
120 | +#ifdef CONFIG_VNC_TLS | |
121 | + int wiremode; | |
122 | + gnutls_session_t tls_session; | |
123 | +#endif | |
124 | + | |
125 | + Buffer output; | |
126 | + Buffer input; | |
127 | + /* current output mode information */ | |
128 | + VncWritePixels *write_pixels; | |
129 | + VncSendHextileTile *send_hextile_tile; | |
130 | + DisplaySurface clientds, serverds; | |
131 | + | |
132 | + CaptureVoiceOut *audio_cap; | |
133 | + struct audsettings as; | |
134 | + | |
135 | + VncReadEvent *read_handler; | |
136 | + size_t read_handler_expect; | |
137 | + /* input */ | |
138 | + uint8_t modifiers_state[256]; | |
139 | + | |
140 | + Buffer zlib; | |
141 | + Buffer zlib_tmp; | |
142 | + z_stream zlib_stream[4]; | |
143 | + | |
144 | + VncState *next; | |
145 | +}; | |
146 | + | |
3 | 147 | |
4 | 148 | /***************************************************************************** |
5 | 149 | * |
... | ... | @@ -111,4 +255,4 @@ enum { |
111 | 255 | #define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB) |
112 | 256 | #define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT) |
113 | 257 | |
114 | -#endif /* __VNCTIGHT_H */ | |
258 | +#endif /* __QEMU_VNC_H */ | ... | ... |