root / ui / vnc.h @ f8d3d128
History | View | Annotate | Download (16.8 kB)
1 | 19a490bf | aliguori | /*
|
---|---|---|---|
2 | 19a490bf | aliguori | * QEMU VNC display driver
|
3 | 19a490bf | aliguori | *
|
4 | 19a490bf | aliguori | * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
|
5 | 19a490bf | aliguori | * Copyright (C) 2006 Fabrice Bellard
|
6 | 19a490bf | aliguori | * Copyright (C) 2009 Red Hat, Inc
|
7 | 19a490bf | aliguori | *
|
8 | 19a490bf | aliguori | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 | 19a490bf | aliguori | * of this software and associated documentation files (the "Software"), to deal
|
10 | 19a490bf | aliguori | * in the Software without restriction, including without limitation the rights
|
11 | 19a490bf | aliguori | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 | 19a490bf | aliguori | * copies of the Software, and to permit persons to whom the Software is
|
13 | 19a490bf | aliguori | * furnished to do so, subject to the following conditions:
|
14 | 19a490bf | aliguori | *
|
15 | 19a490bf | aliguori | * The above copyright notice and this permission notice shall be included in
|
16 | 19a490bf | aliguori | * all copies or substantial portions of the Software.
|
17 | 19a490bf | aliguori | *
|
18 | 19a490bf | aliguori | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 | 19a490bf | aliguori | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 | 19a490bf | aliguori | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
21 | 19a490bf | aliguori | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 | 19a490bf | aliguori | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 | 19a490bf | aliguori | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 | 19a490bf | aliguori | * THE SOFTWARE.
|
25 | 19a490bf | aliguori | */
|
26 | 19a490bf | aliguori | |
27 | 19a490bf | aliguori | #ifndef __QEMU_VNC_H
|
28 | 19a490bf | aliguori | #define __QEMU_VNC_H
|
29 | 19a490bf | aliguori | |
30 | 19a490bf | aliguori | #include "qemu-common.h" |
31 | 41b4bef6 | Amit Shah | #include "qemu-queue.h" |
32 | bd023f95 | Corentin Chary | #ifdef CONFIG_VNC_THREAD
|
33 | bd023f95 | Corentin Chary | #include "qemu-thread.h" |
34 | bd023f95 | Corentin Chary | #endif
|
35 | 19a490bf | aliguori | #include "console.h" |
36 | 19a490bf | aliguori | #include "monitor.h" |
37 | 19a490bf | aliguori | #include "audio/audio.h" |
38 | bc2429b9 | Corentin Chary | #include "bitmap.h" |
39 | 19a490bf | aliguori | #include <zlib.h> |
40 | 6f9c78c1 | Corentin Chary | #include <stdbool.h> |
41 | 19a490bf | aliguori | |
42 | 19a490bf | aliguori | #include "keymaps.h" |
43 | 148954fa | Corentin Chary | #include "vnc-palette.h" |
44 | 148954fa | Corentin Chary | #include "vnc-enc-zrle.h" |
45 | 19a490bf | aliguori | |
46 | 5fb6c7a8 | aliguori | // #define _VNC_DEBUG 1
|
47 | 5fb6c7a8 | aliguori | |
48 | 5fb6c7a8 | aliguori | #ifdef _VNC_DEBUG
|
49 | 5fb6c7a8 | aliguori | #define VNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) |
50 | 5fb6c7a8 | aliguori | #else
|
51 | 5fb6c7a8 | aliguori | #define VNC_DEBUG(fmt, ...) do { } while (0) |
52 | 5fb6c7a8 | aliguori | #endif
|
53 | 5fb6c7a8 | aliguori | |
54 | 19a490bf | aliguori | /*****************************************************************************
|
55 | 19a490bf | aliguori | *
|
56 | 19a490bf | aliguori | * Core data structures
|
57 | 19a490bf | aliguori | *
|
58 | 19a490bf | aliguori | *****************************************************************************/
|
59 | 19a490bf | aliguori | |
60 | 19a490bf | aliguori | typedef struct Buffer |
61 | 19a490bf | aliguori | { |
62 | 19a490bf | aliguori | size_t capacity; |
63 | 19a490bf | aliguori | size_t offset; |
64 | 19a490bf | aliguori | uint8_t *buffer; |
65 | 19a490bf | aliguori | } Buffer; |
66 | 19a490bf | aliguori | |
67 | 19a490bf | aliguori | typedef struct VncState VncState; |
68 | bd023f95 | Corentin Chary | typedef struct VncJob VncJob; |
69 | bd023f95 | Corentin Chary | typedef struct VncRect VncRect; |
70 | bd023f95 | Corentin Chary | typedef struct VncRectEntry VncRectEntry; |
71 | 19a490bf | aliguori | |
72 | 19a490bf | aliguori | typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); |
73 | 19a490bf | aliguori | |
74 | d467b679 | Gerd Hoffmann | typedef void VncWritePixels(VncState *vs, struct PixelFormat *pf, void *data, int size); |
75 | 19a490bf | aliguori | |
76 | 19a490bf | aliguori | typedef void VncSendHextileTile(VncState *vs, |
77 | 19a490bf | aliguori | int x, int y, int w, int h, |
78 | 19a490bf | aliguori | void *last_bg,
|
79 | 19a490bf | aliguori | void *last_fg,
|
80 | 19a490bf | aliguori | int *has_bg, int *has_fg); |
81 | 19a490bf | aliguori | |
82 | 23bfe28f | Stefan Weil | /* VNC_MAX_WIDTH must be a multiple of 16. */
|
83 | 3f54bfbf | Brian Jackson | #define VNC_MAX_WIDTH 2560 |
84 | 19a490bf | aliguori | #define VNC_MAX_HEIGHT 2048 |
85 | 23bfe28f | Stefan Weil | |
86 | 23bfe28f | Stefan Weil | /* VNC_DIRTY_BITS is the number of bits in the dirty bitmap. */
|
87 | 23bfe28f | Stefan Weil | #define VNC_DIRTY_BITS (VNC_MAX_WIDTH / 16) |
88 | 19a490bf | aliguori | |
89 | 999342a0 | Corentin Chary | #define VNC_STAT_RECT 64 |
90 | 999342a0 | Corentin Chary | #define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT)
|
91 | 999342a0 | Corentin Chary | #define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT)
|
92 | 999342a0 | Corentin Chary | |
93 | 19a490bf | aliguori | #define VNC_AUTH_CHALLENGE_SIZE 16 |
94 | 19a490bf | aliguori | |
95 | 19a490bf | aliguori | typedef struct VncDisplay VncDisplay; |
96 | 19a490bf | aliguori | |
97 | 5fb6c7a8 | aliguori | #ifdef CONFIG_VNC_TLS
|
98 | 5fb6c7a8 | aliguori | #include "vnc-tls.h" |
99 | 5fb6c7a8 | aliguori | #include "vnc-auth-vencrypt.h" |
100 | 5fb6c7a8 | aliguori | #endif
|
101 | 2f9606b3 | aliguori | #ifdef CONFIG_VNC_SASL
|
102 | 2f9606b3 | aliguori | #include "vnc-auth-sasl.h" |
103 | 2f9606b3 | aliguori | #endif
|
104 | 2f9606b3 | aliguori | |
105 | 999342a0 | Corentin Chary | struct VncRectStat
|
106 | 999342a0 | Corentin Chary | { |
107 | 999342a0 | Corentin Chary | /* time of last 10 updates, to find update frequency */
|
108 | 999342a0 | Corentin Chary | struct timeval times[10]; |
109 | 999342a0 | Corentin Chary | int idx;
|
110 | 999342a0 | Corentin Chary | |
111 | 999342a0 | Corentin Chary | double freq; /* Update frequency (in Hz) */ |
112 | 999342a0 | Corentin Chary | bool updated; /* Already updated during this refresh */ |
113 | 999342a0 | Corentin Chary | }; |
114 | 999342a0 | Corentin Chary | |
115 | 999342a0 | Corentin Chary | typedef struct VncRectStat VncRectStat; |
116 | 999342a0 | Corentin Chary | |
117 | 1fc62412 | Stefano Stabellini | struct VncSurface
|
118 | 1fc62412 | Stefano Stabellini | { |
119 | 999342a0 | Corentin Chary | struct timeval last_freq_check;
|
120 | 23bfe28f | Stefan Weil | DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT], VNC_MAX_WIDTH / 16);
|
121 | 999342a0 | Corentin Chary | VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS]; |
122 | 1fc62412 | Stefano Stabellini | DisplaySurface *ds; |
123 | 1fc62412 | Stefano Stabellini | }; |
124 | 5fb6c7a8 | aliguori | |
125 | 8cf36489 | Gerd Hoffmann | typedef enum VncShareMode { |
126 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_MODE_CONNECTING = 1,
|
127 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_MODE_SHARED, |
128 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_MODE_EXCLUSIVE, |
129 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_MODE_DISCONNECTED, |
130 | 8cf36489 | Gerd Hoffmann | } VncShareMode; |
131 | 8cf36489 | Gerd Hoffmann | |
132 | 8cf36489 | Gerd Hoffmann | typedef enum VncSharePolicy { |
133 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_POLICY_IGNORE = 1,
|
134 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_POLICY_ALLOW_EXCLUSIVE, |
135 | 8cf36489 | Gerd Hoffmann | VNC_SHARE_POLICY_FORCE_SHARED, |
136 | 8cf36489 | Gerd Hoffmann | } VncSharePolicy; |
137 | 8cf36489 | Gerd Hoffmann | |
138 | 19a490bf | aliguori | struct VncDisplay
|
139 | 19a490bf | aliguori | { |
140 | 41b4bef6 | Amit Shah | QTAILQ_HEAD(, VncState) clients; |
141 | 8cf36489 | Gerd Hoffmann | int num_exclusive;
|
142 | 8cf36489 | Gerd Hoffmann | VncSharePolicy share_policy; |
143 | 703bc68f | Stefano Stabellini | QEMUTimer *timer; |
144 | 2430ffe4 | Stefano Stabellini | int timer_interval;
|
145 | 19a490bf | aliguori | int lsock;
|
146 | 19a490bf | aliguori | DisplayState *ds; |
147 | c227f099 | Anthony Liguori | kbd_layout_t *kbd_layout; |
148 | 3a0558b5 | Gerd Hoffmann | int lock_key_sync;
|
149 | bd023f95 | Corentin Chary | #ifdef CONFIG_VNC_THREAD
|
150 | bd023f95 | Corentin Chary | QemuMutex mutex; |
151 | bd023f95 | Corentin Chary | #endif
|
152 | 19a490bf | aliguori | |
153 | d467b679 | Gerd Hoffmann | QEMUCursor *cursor; |
154 | d467b679 | Gerd Hoffmann | int cursor_msize;
|
155 | d467b679 | Gerd Hoffmann | uint8_t *cursor_mask; |
156 | d467b679 | Gerd Hoffmann | |
157 | 1fc62412 | Stefano Stabellini | struct VncSurface guest; /* guest visible surface (aka ds->surface) */ |
158 | 1fc62412 | Stefano Stabellini | DisplaySurface *server; /* vnc server surface */
|
159 | 1fc62412 | Stefano Stabellini | |
160 | 19a490bf | aliguori | char *display;
|
161 | 19a490bf | aliguori | char *password;
|
162 | 3c9405a0 | Gerd Hoffmann | time_t expires; |
163 | 19a490bf | aliguori | int auth;
|
164 | 6f9c78c1 | Corentin Chary | bool lossy;
|
165 | 80e0c8c3 | Corentin Chary | bool non_adaptive;
|
166 | 19a490bf | aliguori | #ifdef CONFIG_VNC_TLS
|
167 | 5fb6c7a8 | aliguori | int subauth; /* Used by VeNCrypt */ |
168 | 5fb6c7a8 | aliguori | VncDisplayTLS tls; |
169 | 19a490bf | aliguori | #endif
|
170 | 76655d6d | aliguori | #ifdef CONFIG_VNC_SASL
|
171 | 76655d6d | aliguori | VncDisplaySASL sasl; |
172 | 76655d6d | aliguori | #endif
|
173 | 19a490bf | aliguori | }; |
174 | 19a490bf | aliguori | |
175 | d1af0e05 | Corentin Chary | typedef struct VncTight { |
176 | d1af0e05 | Corentin Chary | int type;
|
177 | d1af0e05 | Corentin Chary | uint8_t quality; |
178 | d1af0e05 | Corentin Chary | uint8_t compression; |
179 | d1af0e05 | Corentin Chary | uint8_t pixel24; |
180 | d1af0e05 | Corentin Chary | Buffer tight; |
181 | d1af0e05 | Corentin Chary | Buffer tmp; |
182 | d1af0e05 | Corentin Chary | Buffer zlib; |
183 | d1af0e05 | Corentin Chary | Buffer gradient; |
184 | d1af0e05 | Corentin Chary | #ifdef CONFIG_VNC_JPEG
|
185 | d1af0e05 | Corentin Chary | Buffer jpeg; |
186 | d1af0e05 | Corentin Chary | #endif
|
187 | d1af0e05 | Corentin Chary | #ifdef CONFIG_VNC_PNG
|
188 | d1af0e05 | Corentin Chary | Buffer png; |
189 | d1af0e05 | Corentin Chary | #endif
|
190 | d1af0e05 | Corentin Chary | int levels[4]; |
191 | d1af0e05 | Corentin Chary | z_stream stream[4];
|
192 | d1af0e05 | Corentin Chary | } VncTight; |
193 | d1af0e05 | Corentin Chary | |
194 | d1af0e05 | Corentin Chary | typedef struct VncHextile { |
195 | d1af0e05 | Corentin Chary | VncSendHextileTile *send_tile; |
196 | d1af0e05 | Corentin Chary | } VncHextile; |
197 | d1af0e05 | Corentin Chary | |
198 | d1af0e05 | Corentin Chary | typedef struct VncZlib { |
199 | d1af0e05 | Corentin Chary | Buffer zlib; |
200 | d1af0e05 | Corentin Chary | Buffer tmp; |
201 | d1af0e05 | Corentin Chary | z_stream stream; |
202 | d1af0e05 | Corentin Chary | int level;
|
203 | d1af0e05 | Corentin Chary | } VncZlib; |
204 | d1af0e05 | Corentin Chary | |
205 | 148954fa | Corentin Chary | typedef struct VncZrle { |
206 | 148954fa | Corentin Chary | int type;
|
207 | 148954fa | Corentin Chary | Buffer fb; |
208 | 148954fa | Corentin Chary | Buffer zrle; |
209 | 148954fa | Corentin Chary | Buffer tmp; |
210 | 148954fa | Corentin Chary | Buffer zlib; |
211 | 148954fa | Corentin Chary | z_stream stream; |
212 | 148954fa | Corentin Chary | VncPalette palette; |
213 | 148954fa | Corentin Chary | } VncZrle; |
214 | 148954fa | Corentin Chary | |
215 | 148954fa | Corentin Chary | typedef struct VncZywrle { |
216 | 148954fa | Corentin Chary | int buf[VNC_ZRLE_TILE_WIDTH * VNC_ZRLE_TILE_HEIGHT];
|
217 | 148954fa | Corentin Chary | } VncZywrle; |
218 | 148954fa | Corentin Chary | |
219 | bd023f95 | Corentin Chary | #ifdef CONFIG_VNC_THREAD
|
220 | bd023f95 | Corentin Chary | struct VncRect
|
221 | bd023f95 | Corentin Chary | { |
222 | bd023f95 | Corentin Chary | int x;
|
223 | bd023f95 | Corentin Chary | int y;
|
224 | bd023f95 | Corentin Chary | int w;
|
225 | bd023f95 | Corentin Chary | int h;
|
226 | bd023f95 | Corentin Chary | }; |
227 | bd023f95 | Corentin Chary | |
228 | bd023f95 | Corentin Chary | struct VncRectEntry
|
229 | bd023f95 | Corentin Chary | { |
230 | bd023f95 | Corentin Chary | struct VncRect rect;
|
231 | bd023f95 | Corentin Chary | QLIST_ENTRY(VncRectEntry) next; |
232 | bd023f95 | Corentin Chary | }; |
233 | bd023f95 | Corentin Chary | |
234 | bd023f95 | Corentin Chary | struct VncJob
|
235 | bd023f95 | Corentin Chary | { |
236 | bd023f95 | Corentin Chary | VncState *vs; |
237 | bd023f95 | Corentin Chary | |
238 | bd023f95 | Corentin Chary | QLIST_HEAD(, VncRectEntry) rectangles; |
239 | bd023f95 | Corentin Chary | QTAILQ_ENTRY(VncJob) next; |
240 | bd023f95 | Corentin Chary | }; |
241 | bd023f95 | Corentin Chary | #else
|
242 | bd023f95 | Corentin Chary | struct VncJob
|
243 | bd023f95 | Corentin Chary | { |
244 | bd023f95 | Corentin Chary | VncState *vs; |
245 | bd023f95 | Corentin Chary | int rectangles;
|
246 | bd023f95 | Corentin Chary | size_t saved_offset; |
247 | bd023f95 | Corentin Chary | }; |
248 | bd023f95 | Corentin Chary | #endif
|
249 | bd023f95 | Corentin Chary | |
250 | 19a490bf | aliguori | struct VncState
|
251 | 19a490bf | aliguori | { |
252 | 19a490bf | aliguori | int csock;
|
253 | 6baebed7 | aliguori | |
254 | 19a490bf | aliguori | DisplayState *ds; |
255 | 23bfe28f | Stefan Weil | DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT], VNC_DIRTY_BITS); |
256 | 7d964c9d | Corentin Chary | uint8_t **lossy_rect; /* Not an Array to avoid costly memcpy in
|
257 | 7d964c9d | Corentin Chary | * vnc-jobs-async.c */
|
258 | 6baebed7 | aliguori | |
259 | 19a490bf | aliguori | VncDisplay *vd; |
260 | 19a490bf | aliguori | int need_update;
|
261 | c522d0e2 | aliguori | int force_update;
|
262 | 19a490bf | aliguori | uint32_t features; |
263 | 19a490bf | aliguori | int absolute;
|
264 | 19a490bf | aliguori | int last_x;
|
265 | 19a490bf | aliguori | int last_y;
|
266 | 5862d195 | Gerd Hoffmann | int client_width;
|
267 | 5862d195 | Gerd Hoffmann | int client_height;
|
268 | 8cf36489 | Gerd Hoffmann | VncShareMode share_mode; |
269 | 19a490bf | aliguori | |
270 | 19a490bf | aliguori | uint32_t vnc_encoding; |
271 | 19a490bf | aliguori | |
272 | 19a490bf | aliguori | int major;
|
273 | 19a490bf | aliguori | int minor;
|
274 | 19a490bf | aliguori | |
275 | 7e7e2ebc | Daniel P. Berrange | int auth;
|
276 | 19a490bf | aliguori | char challenge[VNC_AUTH_CHALLENGE_SIZE];
|
277 | 19a490bf | aliguori | #ifdef CONFIG_VNC_TLS
|
278 | 7e7e2ebc | Daniel P. Berrange | int subauth; /* Used by VeNCrypt */ |
279 | 5fb6c7a8 | aliguori | VncStateTLS tls; |
280 | 19a490bf | aliguori | #endif
|
281 | 2f9606b3 | aliguori | #ifdef CONFIG_VNC_SASL
|
282 | 2f9606b3 | aliguori | VncStateSASL sasl; |
283 | 2f9606b3 | aliguori | #endif
|
284 | 19a490bf | aliguori | |
285 | 4a80dba3 | Luiz Capitulino | QObject *info; |
286 | 4a80dba3 | Luiz Capitulino | |
287 | 19a490bf | aliguori | Buffer output; |
288 | 19a490bf | aliguori | Buffer input; |
289 | 19a490bf | aliguori | /* current output mode information */
|
290 | 19a490bf | aliguori | VncWritePixels *write_pixels; |
291 | 6baebed7 | aliguori | DisplaySurface clientds; |
292 | 19a490bf | aliguori | |
293 | 19a490bf | aliguori | CaptureVoiceOut *audio_cap; |
294 | 19a490bf | aliguori | struct audsettings as;
|
295 | 19a490bf | aliguori | |
296 | 19a490bf | aliguori | VncReadEvent *read_handler; |
297 | 19a490bf | aliguori | size_t read_handler_expect; |
298 | 19a490bf | aliguori | /* input */
|
299 | 19a490bf | aliguori | uint8_t modifiers_state[256];
|
300 | 7ffb82ca | Gerd Hoffmann | QEMUPutLEDEntry *led; |
301 | 19a490bf | aliguori | |
302 | bd023f95 | Corentin Chary | bool abort;
|
303 | bd023f95 | Corentin Chary | #ifndef CONFIG_VNC_THREAD
|
304 | bd023f95 | Corentin Chary | VncJob job; |
305 | bd023f95 | Corentin Chary | #else
|
306 | bd023f95 | Corentin Chary | QemuMutex output_mutex; |
307 | bd023f95 | Corentin Chary | #endif
|
308 | bd023f95 | Corentin Chary | |
309 | bd023f95 | Corentin Chary | /* Encoding specific, if you add something here, don't forget to
|
310 | bd023f95 | Corentin Chary | * update vnc_async_encoding_start()
|
311 | bd023f95 | Corentin Chary | */
|
312 | d1af0e05 | Corentin Chary | VncTight tight; |
313 | d1af0e05 | Corentin Chary | VncZlib zlib; |
314 | d1af0e05 | Corentin Chary | VncHextile hextile; |
315 | 148954fa | Corentin Chary | VncZrle zrle; |
316 | 148954fa | Corentin Chary | VncZywrle zywrle; |
317 | 19a490bf | aliguori | |
318 | 37c34d9d | Anthony Liguori | Notifier mouse_mode_notifier; |
319 | 37c34d9d | Anthony Liguori | |
320 | 41b4bef6 | Amit Shah | QTAILQ_ENTRY(VncState) next; |
321 | 19a490bf | aliguori | }; |
322 | 19a490bf | aliguori | |
323 | e06679fb | aliguori | |
324 | e06679fb | aliguori | /*****************************************************************************
|
325 | e06679fb | aliguori | *
|
326 | e06679fb | aliguori | * Authentication modes
|
327 | e06679fb | aliguori | *
|
328 | e06679fb | aliguori | *****************************************************************************/
|
329 | e06679fb | aliguori | |
330 | e06679fb | aliguori | enum {
|
331 | e06679fb | aliguori | VNC_AUTH_INVALID = 0,
|
332 | e06679fb | aliguori | VNC_AUTH_NONE = 1,
|
333 | e06679fb | aliguori | VNC_AUTH_VNC = 2,
|
334 | e06679fb | aliguori | VNC_AUTH_RA2 = 5,
|
335 | e06679fb | aliguori | VNC_AUTH_RA2NE = 6,
|
336 | e06679fb | aliguori | VNC_AUTH_TIGHT = 16,
|
337 | e06679fb | aliguori | VNC_AUTH_ULTRA = 17,
|
338 | 2f9606b3 | aliguori | VNC_AUTH_TLS = 18, /* Supported in GTK-VNC & VINO */ |
339 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT = 19, /* Supported in GTK-VNC & VeNCrypt */ |
340 | 2f9606b3 | aliguori | VNC_AUTH_SASL = 20, /* Supported in GTK-VNC & VINO */ |
341 | e06679fb | aliguori | }; |
342 | e06679fb | aliguori | |
343 | e06679fb | aliguori | enum {
|
344 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_PLAIN = 256,
|
345 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSNONE = 257,
|
346 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSVNC = 258,
|
347 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSPLAIN = 259,
|
348 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509NONE = 260,
|
349 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509VNC = 261,
|
350 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509PLAIN = 262,
|
351 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT_X509SASL = 263,
|
352 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT_TLSSASL = 264,
|
353 | e06679fb | aliguori | }; |
354 | e06679fb | aliguori | |
355 | e06679fb | aliguori | |
356 | e06679fb | aliguori | /*****************************************************************************
|
357 | e06679fb | aliguori | *
|
358 | e06679fb | aliguori | * Encoding types
|
359 | e06679fb | aliguori | *
|
360 | e06679fb | aliguori | *****************************************************************************/
|
361 | e06679fb | aliguori | |
362 | e06679fb | aliguori | #define VNC_ENCODING_RAW 0x00000000 |
363 | e06679fb | aliguori | #define VNC_ENCODING_COPYRECT 0x00000001 |
364 | e06679fb | aliguori | #define VNC_ENCODING_RRE 0x00000002 |
365 | e06679fb | aliguori | #define VNC_ENCODING_CORRE 0x00000004 |
366 | e06679fb | aliguori | #define VNC_ENCODING_HEXTILE 0x00000005 |
367 | e06679fb | aliguori | #define VNC_ENCODING_ZLIB 0x00000006 |
368 | e06679fb | aliguori | #define VNC_ENCODING_TIGHT 0x00000007 |
369 | e06679fb | aliguori | #define VNC_ENCODING_ZLIBHEX 0x00000008 |
370 | e06679fb | aliguori | #define VNC_ENCODING_TRLE 0x0000000f |
371 | e06679fb | aliguori | #define VNC_ENCODING_ZRLE 0x00000010 |
372 | e06679fb | aliguori | #define VNC_ENCODING_ZYWRLE 0x00000011 |
373 | e06679fb | aliguori | #define VNC_ENCODING_COMPRESSLEVEL0 0xFFFFFF00 /* -256 */ |
374 | e06679fb | aliguori | #define VNC_ENCODING_QUALITYLEVEL0 0xFFFFFFE0 /* -32 */ |
375 | e06679fb | aliguori | #define VNC_ENCODING_XCURSOR 0xFFFFFF10 /* -240 */ |
376 | e06679fb | aliguori | #define VNC_ENCODING_RICH_CURSOR 0xFFFFFF11 /* -239 */ |
377 | e06679fb | aliguori | #define VNC_ENCODING_POINTER_POS 0xFFFFFF18 /* -232 */ |
378 | e06679fb | aliguori | #define VNC_ENCODING_LASTRECT 0xFFFFFF20 /* -224 */ |
379 | e06679fb | aliguori | #define VNC_ENCODING_DESKTOPRESIZE 0xFFFFFF21 /* -223 */ |
380 | e06679fb | aliguori | #define VNC_ENCODING_POINTER_TYPE_CHANGE 0XFFFFFEFF /* -257 */ |
381 | e06679fb | aliguori | #define VNC_ENCODING_EXT_KEY_EVENT 0XFFFFFEFE /* -258 */ |
382 | e06679fb | aliguori | #define VNC_ENCODING_AUDIO 0XFFFFFEFD /* -259 */ |
383 | efe556ad | Corentin Chary | #define VNC_ENCODING_TIGHT_PNG 0xFFFFFEFC /* -260 */ |
384 | e06679fb | aliguori | #define VNC_ENCODING_WMVi 0x574D5669 |
385 | e06679fb | aliguori | |
386 | e06679fb | aliguori | /*****************************************************************************
|
387 | e06679fb | aliguori | *
|
388 | e06679fb | aliguori | * Other tight constants
|
389 | e06679fb | aliguori | *
|
390 | e06679fb | aliguori | *****************************************************************************/
|
391 | e06679fb | aliguori | |
392 | e06679fb | aliguori | /*
|
393 | e06679fb | aliguori | * Vendors known by TightVNC: standard VNC/RealVNC, TridiaVNC, and TightVNC.
|
394 | e06679fb | aliguori | */
|
395 | e06679fb | aliguori | |
396 | e06679fb | aliguori | #define VNC_TIGHT_CCB_RESET_MASK (0x0f) |
397 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_MASK (0x0f << 4) |
398 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_FILL (0x08 << 4) |
399 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_JPEG (0x09 << 4) |
400 | efe556ad | Corentin Chary | #define VNC_TIGHT_CCB_TYPE_PNG (0x0A << 4) |
401 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_MAX (0x07 << 4) |
402 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_ZLIB (0x03 << 4) |
403 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_FILTER (0x04 << 4) |
404 | e06679fb | aliguori | |
405 | e06679fb | aliguori | /*****************************************************************************
|
406 | e06679fb | aliguori | *
|
407 | e06679fb | aliguori | * Features
|
408 | e06679fb | aliguori | *
|
409 | e06679fb | aliguori | *****************************************************************************/
|
410 | e06679fb | aliguori | |
411 | e06679fb | aliguori | #define VNC_FEATURE_RESIZE 0 |
412 | e06679fb | aliguori | #define VNC_FEATURE_HEXTILE 1 |
413 | e06679fb | aliguori | #define VNC_FEATURE_POINTER_TYPE_CHANGE 2 |
414 | e06679fb | aliguori | #define VNC_FEATURE_WMVI 3 |
415 | e06679fb | aliguori | #define VNC_FEATURE_TIGHT 4 |
416 | e06679fb | aliguori | #define VNC_FEATURE_ZLIB 5 |
417 | 753b4053 | aliguori | #define VNC_FEATURE_COPYRECT 6 |
418 | d467b679 | Gerd Hoffmann | #define VNC_FEATURE_RICH_CURSOR 7 |
419 | efe556ad | Corentin Chary | #define VNC_FEATURE_TIGHT_PNG 8 |
420 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZRLE 9 |
421 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZYWRLE 10 |
422 | e06679fb | aliguori | |
423 | e06679fb | aliguori | #define VNC_FEATURE_RESIZE_MASK (1 << VNC_FEATURE_RESIZE) |
424 | e06679fb | aliguori | #define VNC_FEATURE_HEXTILE_MASK (1 << VNC_FEATURE_HEXTILE) |
425 | e06679fb | aliguori | #define VNC_FEATURE_POINTER_TYPE_CHANGE_MASK (1 << VNC_FEATURE_POINTER_TYPE_CHANGE) |
426 | e06679fb | aliguori | #define VNC_FEATURE_WMVI_MASK (1 << VNC_FEATURE_WMVI) |
427 | e06679fb | aliguori | #define VNC_FEATURE_TIGHT_MASK (1 << VNC_FEATURE_TIGHT) |
428 | e06679fb | aliguori | #define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB) |
429 | 753b4053 | aliguori | #define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT) |
430 | d467b679 | Gerd Hoffmann | #define VNC_FEATURE_RICH_CURSOR_MASK (1 << VNC_FEATURE_RICH_CURSOR) |
431 | efe556ad | Corentin Chary | #define VNC_FEATURE_TIGHT_PNG_MASK (1 << VNC_FEATURE_TIGHT_PNG) |
432 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZRLE_MASK (1 << VNC_FEATURE_ZRLE) |
433 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZYWRLE_MASK (1 << VNC_FEATURE_ZYWRLE) |
434 | e06679fb | aliguori | |
435 | 5fb6c7a8 | aliguori | |
436 | 46a183da | Daniel P. Berrange | /* Client -> Server message IDs */
|
437 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_PIXEL_FORMAT 0 |
438 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_ENCODINGS 2 |
439 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST 3 |
440 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_KEY_EVENT 4 |
441 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_POINTER_EVENT 5 |
442 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_CUT_TEXT 6 |
443 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_VMWARE_0 127 |
444 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_CALL_CONTROL 249 |
445 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_XVP 250 |
446 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_DESKTOP_SIZE 251 |
447 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_TIGHT 252 |
448 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_GII 253 |
449 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_VMWARE_1 254 |
450 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU 255 |
451 | 46a183da | Daniel P. Berrange | |
452 | 46a183da | Daniel P. Berrange | /* Server -> Client message IDs */
|
453 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_FRAMEBUFFER_UPDATE 0 |
454 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_SET_COLOUR_MAP_ENTRIES 1 |
455 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_BELL 2 |
456 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_CUT_TEXT 3 |
457 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_VMWARE_0 127 |
458 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_CALL_CONTROL 249 |
459 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_XVP 250 |
460 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_TIGHT 252 |
461 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_GII 253 |
462 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_VMWARE_1 254 |
463 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU 255 |
464 | 46a183da | Daniel P. Berrange | |
465 | 46a183da | Daniel P. Berrange | |
466 | 46a183da | Daniel P. Berrange | |
467 | 46a183da | Daniel P. Berrange | /* QEMU client -> server message IDs */
|
468 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT 0 |
469 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO 1 |
470 | 46a183da | Daniel P. Berrange | |
471 | 46a183da | Daniel P. Berrange | /* QEMU server -> client message IDs */
|
472 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO 1 |
473 | 46a183da | Daniel P. Berrange | |
474 | 46a183da | Daniel P. Berrange | |
475 | 46a183da | Daniel P. Berrange | |
476 | 46a183da | Daniel P. Berrange | /* QEMU client -> server audio message IDs */
|
477 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE 0 |
478 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE 1 |
479 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT 2 |
480 | 46a183da | Daniel P. Berrange | |
481 | 46a183da | Daniel P. Berrange | /* QEMU server -> client audio message IDs */
|
482 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_END 0 |
483 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_BEGIN 1 |
484 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_DATA 2 |
485 | 46a183da | Daniel P. Berrange | |
486 | 46a183da | Daniel P. Berrange | |
487 | 5fb6c7a8 | aliguori | /*****************************************************************************
|
488 | 5fb6c7a8 | aliguori | *
|
489 | 5fb6c7a8 | aliguori | * Internal APIs
|
490 | 5fb6c7a8 | aliguori | *
|
491 | 5fb6c7a8 | aliguori | *****************************************************************************/
|
492 | 5fb6c7a8 | aliguori | |
493 | 5fb6c7a8 | aliguori | /* Event loop functions */
|
494 | 5fb6c7a8 | aliguori | void vnc_client_read(void *opaque); |
495 | 5fb6c7a8 | aliguori | void vnc_client_write(void *opaque); |
496 | 5fb6c7a8 | aliguori | |
497 | 2f9606b3 | aliguori | long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
|
498 | 2f9606b3 | aliguori | long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen); |
499 | 5fb6c7a8 | aliguori | |
500 | 5fb6c7a8 | aliguori | /* Protocol I/O functions */
|
501 | 5fb6c7a8 | aliguori | void vnc_write(VncState *vs, const void *data, size_t len); |
502 | 5fb6c7a8 | aliguori | void vnc_write_u32(VncState *vs, uint32_t value);
|
503 | 5fb6c7a8 | aliguori | void vnc_write_s32(VncState *vs, int32_t value);
|
504 | 5fb6c7a8 | aliguori | void vnc_write_u16(VncState *vs, uint16_t value);
|
505 | 5fb6c7a8 | aliguori | void vnc_write_u8(VncState *vs, uint8_t value);
|
506 | 5fb6c7a8 | aliguori | void vnc_flush(VncState *vs);
|
507 | 5fb6c7a8 | aliguori | void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting);
|
508 | 5fb6c7a8 | aliguori | |
509 | 5fb6c7a8 | aliguori | |
510 | 5fb6c7a8 | aliguori | /* Buffer I/O functions */
|
511 | 5fb6c7a8 | aliguori | uint8_t read_u8(uint8_t *data, size_t offset); |
512 | 5fb6c7a8 | aliguori | uint16_t read_u16(uint8_t *data, size_t offset); |
513 | 5fb6c7a8 | aliguori | int32_t read_s32(uint8_t *data, size_t offset); |
514 | 5fb6c7a8 | aliguori | uint32_t read_u32(uint8_t *data, size_t offset); |
515 | 5fb6c7a8 | aliguori | |
516 | 5fb6c7a8 | aliguori | /* Protocol stage functions */
|
517 | 5fb6c7a8 | aliguori | void vnc_client_error(VncState *vs);
|
518 | 2f9606b3 | aliguori | int vnc_client_io_error(VncState *vs, int ret, int last_errno); |
519 | 5fb6c7a8 | aliguori | |
520 | 5fb6c7a8 | aliguori | void start_client_init(VncState *vs);
|
521 | 5fb6c7a8 | aliguori | void start_auth_vnc(VncState *vs);
|
522 | 5fb6c7a8 | aliguori | |
523 | 2f9606b3 | aliguori | /* Buffer management */
|
524 | 2f9606b3 | aliguori | void buffer_reserve(Buffer *buffer, size_t len);
|
525 | 2f9606b3 | aliguori | int buffer_empty(Buffer *buffer);
|
526 | 2f9606b3 | aliguori | uint8_t *buffer_end(Buffer *buffer); |
527 | 2f9606b3 | aliguori | void buffer_reset(Buffer *buffer);
|
528 | 5d418e3b | Corentin Chary | void buffer_free(Buffer *buffer);
|
529 | 2f9606b3 | aliguori | void buffer_append(Buffer *buffer, const void *data, size_t len); |
530 | 2f9606b3 | aliguori | |
531 | 2f9606b3 | aliguori | |
532 | 2f9606b3 | aliguori | /* Misc helpers */
|
533 | 2f9606b3 | aliguori | |
534 | 2f9606b3 | aliguori | char *vnc_socket_local_addr(const char *format, int fd); |
535 | 2f9606b3 | aliguori | char *vnc_socket_remote_addr(const char *format, int fd); |
536 | 2f9606b3 | aliguori | |
537 | efe556ad | Corentin Chary | static inline uint32_t vnc_has_feature(VncState *vs, int feature) { |
538 | efe556ad | Corentin Chary | return (vs->features & (1 << feature)); |
539 | efe556ad | Corentin Chary | } |
540 | efe556ad | Corentin Chary | |
541 | 70a4568f | Corentin Chary | /* Framebuffer */
|
542 | 70a4568f | Corentin Chary | void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, |
543 | 70a4568f | Corentin Chary | int32_t encoding); |
544 | 70a4568f | Corentin Chary | |
545 | 70a4568f | Corentin Chary | void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v);
|
546 | 999342a0 | Corentin Chary | double vnc_update_freq(VncState *vs, int x, int y, int w, int h); |
547 | 7d964c9d | Corentin Chary | void vnc_sent_lossy_rect(VncState *vs, int x, int y, int w, int h); |
548 | 70a4568f | Corentin Chary | |
549 | 70a4568f | Corentin Chary | /* Encodings */
|
550 | bd023f95 | Corentin Chary | int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
551 | bd023f95 | Corentin Chary | |
552 | a885211e | Corentin Chary | int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
553 | 70a4568f | Corentin Chary | |
554 | a885211e | Corentin Chary | int vnc_hextile_send_framebuffer_update(VncState *vs, int x, |
555 | 70a4568f | Corentin Chary | int y, int w, int h); |
556 | 70a4568f | Corentin Chary | void vnc_hextile_set_pixel_conversion(VncState *vs, int generic); |
557 | 70a4568f | Corentin Chary | |
558 | 380282b0 | Corentin Chary | void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size); |
559 | 380282b0 | Corentin Chary | void vnc_zlib_zfree(void *x, void *addr); |
560 | a885211e | Corentin Chary | int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
561 | 161c4f20 | Corentin Chary | void vnc_zlib_clear(VncState *vs);
|
562 | 70a4568f | Corentin Chary | |
563 | 380282b0 | Corentin Chary | int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
564 | efe556ad | Corentin Chary | int vnc_tight_png_send_framebuffer_update(VncState *vs, int x, int y, |
565 | efe556ad | Corentin Chary | int w, int h); |
566 | 380282b0 | Corentin Chary | void vnc_tight_clear(VncState *vs);
|
567 | 380282b0 | Corentin Chary | |
568 | 148954fa | Corentin Chary | int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
569 | 148954fa | Corentin Chary | int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
570 | 148954fa | Corentin Chary | void vnc_zrle_clear(VncState *vs);
|
571 | 148954fa | Corentin Chary | |
572 | 19a490bf | aliguori | #endif /* __QEMU_VNC_H */ |