Line | Count | Source |
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/queue.h" |
31 | | #include "qemu/thread.h" |
32 | | #include "ui/clipboard.h" |
33 | | #include "ui/console.h" |
34 | | #include "qemu/audio-capture.h" |
35 | | #include "qemu/bitmap.h" |
36 | | #include "crypto/tlssession.h" |
37 | | #include "qemu/buffer.h" |
38 | | #include "io/channel-socket.h" |
39 | | #include "io/channel-tls.h" |
40 | | #include "io/net-listener.h" |
41 | | #include "authz/base.h" |
42 | | #include <zlib.h> |
43 | | |
44 | | #include "keymaps.h" |
45 | | #include "vnc-palette.h" |
46 | | #include "vnc-enc-zrle.h" |
47 | | #include "ui/kbd-state.h" |
48 | | |
49 | | /***************************************************************************** |
50 | | * |
51 | | * Core data structures |
52 | | * |
53 | | *****************************************************************************/ |
54 | | |
55 | | typedef struct VncState VncState; |
56 | | typedef struct VncJob VncJob; |
57 | | typedef struct VncJobQueue VncJobQueue; |
58 | | typedef struct VncRect VncRect; |
59 | | typedef struct VncRectEntry VncRectEntry; |
60 | | |
61 | | typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); |
62 | | |
63 | | typedef void VncWritePixels(VncState *vs, void *data, int size); |
64 | | |
65 | | typedef void VncSendHextileTile(VncState *vs, |
66 | | int x, int y, int w, int h, |
67 | | void *last_bg, |
68 | | void *last_fg, |
69 | | int *has_bg, int *has_fg); |
70 | | |
71 | | /* VNC_DIRTY_PIXELS_PER_BIT is the number of dirty pixels represented |
72 | | * by one bit in the dirty bitmap, should be a power of 2 */ |
73 | 0 | #define VNC_DIRTY_PIXELS_PER_BIT 16 |
74 | | |
75 | | /* VNC_MAX_WIDTH must be a multiple of VNC_DIRTY_PIXELS_PER_BIT. */ |
76 | | |
77 | | #define VNC_MAX_WIDTH ROUND_UP(5120, VNC_DIRTY_PIXELS_PER_BIT) |
78 | 0 | #define VNC_MAX_HEIGHT 2160 |
79 | | |
80 | | /* VNC_DIRTY_BITS is the number of bits in the dirty bitmap. */ |
81 | | #define VNC_DIRTY_BITS (VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT) |
82 | | |
83 | | /* VNC_DIRTY_BPL (BPL = bits per line) might be greater than |
84 | | * VNC_DIRTY_BITS due to alignment */ |
85 | 0 | #define VNC_DIRTY_BPL(x) (sizeof((x)->dirty) / VNC_MAX_HEIGHT * BITS_PER_BYTE) |
86 | | |
87 | 0 | #define VNC_STAT_RECT 64 |
88 | | #define VNC_STAT_COLS DIV_ROUND_UP(VNC_MAX_WIDTH, VNC_STAT_RECT) |
89 | | #define VNC_STAT_ROWS DIV_ROUND_UP(VNC_MAX_HEIGHT, VNC_STAT_RECT) |
90 | | |
91 | 0 | #define VNC_AUTH_CHALLENGE_SIZE 16 |
92 | | |
93 | | typedef struct VncDisplay VncDisplay; |
94 | | |
95 | | #include "vnc-auth-vencrypt.h" |
96 | | #ifdef CONFIG_VNC_SASL |
97 | | #include "vnc-auth-sasl.h" |
98 | | #endif |
99 | | #include "vnc-ws.h" |
100 | | |
101 | | struct VncRectStat |
102 | | { |
103 | | /* time of last 10 updates, to find update frequency */ |
104 | | struct timeval times[10]; |
105 | | int idx; |
106 | | |
107 | | double freq; /* Update frequency (in Hz) */ |
108 | | bool updated; /* Already updated during this refresh */ |
109 | | }; |
110 | | |
111 | | typedef struct VncRectStat VncRectStat; |
112 | | |
113 | | struct VncSurface |
114 | | { |
115 | | struct timeval last_freq_check; |
116 | | DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT], |
117 | | VNC_MAX_WIDTH / VNC_DIRTY_PIXELS_PER_BIT); |
118 | | VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS]; |
119 | | pixman_image_t *fb; |
120 | | pixman_format_code_t format; |
121 | | }; |
122 | | |
123 | | typedef enum VncShareMode { |
124 | | VNC_SHARE_MODE_CONNECTING = 1, |
125 | | VNC_SHARE_MODE_SHARED, |
126 | | VNC_SHARE_MODE_EXCLUSIVE, |
127 | | VNC_SHARE_MODE_DISCONNECTED, |
128 | | } VncShareMode; |
129 | | |
130 | | typedef enum VncSharePolicy { |
131 | | VNC_SHARE_POLICY_IGNORE = 1, |
132 | | VNC_SHARE_POLICY_ALLOW_EXCLUSIVE, |
133 | | VNC_SHARE_POLICY_FORCE_SHARED, |
134 | | } VncSharePolicy; |
135 | | |
136 | | struct VncDisplay |
137 | | { |
138 | | QTAILQ_HEAD(, VncState) clients; |
139 | | int num_connecting; |
140 | | int num_shared; |
141 | | int num_exclusive; |
142 | | int connections_limit; |
143 | | VncSharePolicy share_policy; |
144 | | QIONetListener *listener; |
145 | | QIONetListener *wslistener; |
146 | | DisplaySurface *ds; |
147 | | DisplayChangeListener dcl; |
148 | | kbd_layout_t *kbd_layout; |
149 | | int lock_key_sync; |
150 | | Notifier led_notifier; |
151 | | int ledstate; |
152 | | QKbdState *kbd; |
153 | | QemuMutex mutex; |
154 | | VncJobQueue *queue; |
155 | | |
156 | | int cursor_msize; |
157 | | uint8_t *cursor_mask; |
158 | | |
159 | | struct VncSurface guest; /* guest visible surface (aka ds->surface) */ |
160 | | pixman_image_t *server; /* vnc server surface */ |
161 | | int true_width; /* server surface width before rounding up */ |
162 | | |
163 | | char *id; |
164 | | QTAILQ_ENTRY(VncDisplay) next; |
165 | | char *password; |
166 | | time_t expires; |
167 | | int auth; |
168 | | int subauth; /* Used by VeNCrypt */ |
169 | | int ws_auth; /* Used by websockets */ |
170 | | int ws_subauth; /* Used by websockets */ |
171 | | bool lossy; |
172 | | bool non_adaptive; |
173 | | bool power_control; |
174 | | QCryptoTLSCreds *tlscreds; |
175 | | char *tlsauthzid; |
176 | | #ifdef CONFIG_VNC_SASL |
177 | | VncDisplaySASL sasl; |
178 | | #endif |
179 | | |
180 | | AudioBackend *audio_be; |
181 | | |
182 | | VMChangeStateEntry *vmstate_handler_entry; |
183 | | }; |
184 | | |
185 | | typedef struct VncTight { |
186 | | int type; |
187 | | uint8_t quality; |
188 | | uint8_t compression; |
189 | | uint8_t pixel24; |
190 | | Buffer tight; |
191 | | Buffer tmp; |
192 | | Buffer zlib; |
193 | | Buffer gradient; |
194 | | #ifdef CONFIG_VNC_JPEG |
195 | | Buffer jpeg; |
196 | | #endif |
197 | | #ifdef CONFIG_PNG |
198 | | Buffer png; |
199 | | #endif |
200 | | int levels[4]; |
201 | | z_stream stream[4]; |
202 | | } VncTight; |
203 | | |
204 | | typedef struct VncHextile { |
205 | | VncSendHextileTile *send_tile; |
206 | | } VncHextile; |
207 | | |
208 | | typedef struct VncZlib { |
209 | | Buffer zlib; |
210 | | Buffer tmp; |
211 | | z_stream stream; |
212 | | int level; |
213 | | } VncZlib; |
214 | | |
215 | | typedef struct VncZrle { |
216 | | int type; |
217 | | Buffer fb; |
218 | | Buffer zrle; |
219 | | Buffer tmp; |
220 | | Buffer zlib; |
221 | | z_stream stream; |
222 | | VncPalette palette; |
223 | | } VncZrle; |
224 | | |
225 | | typedef struct VncZywrle { |
226 | | int buf[VNC_ZRLE_TILE_WIDTH * VNC_ZRLE_TILE_HEIGHT]; |
227 | | } VncZywrle; |
228 | | |
229 | | struct VncRect |
230 | | { |
231 | | int x; |
232 | | int y; |
233 | | int w; |
234 | | int h; |
235 | | }; |
236 | | |
237 | | struct VncRectEntry |
238 | | { |
239 | | struct VncRect rect; |
240 | | QLIST_ENTRY(VncRectEntry) next; |
241 | | }; |
242 | | |
243 | | struct VncJob |
244 | | { |
245 | | VncState *vs; |
246 | | |
247 | | QLIST_HEAD(, VncRectEntry) rectangles; |
248 | | QTAILQ_ENTRY(VncJob) next; |
249 | | }; |
250 | | |
251 | | typedef enum { |
252 | | VNC_STATE_UPDATE_NONE, |
253 | | VNC_STATE_UPDATE_INCREMENTAL, |
254 | | VNC_STATE_UPDATE_FORCE, |
255 | | } VncStateUpdate; |
256 | | |
257 | 0 | #define VNC_MAGIC ((uint64_t)0x05b3f069b3d204bb) |
258 | | |
259 | | struct VncState |
260 | | { |
261 | | uint64_t magic; |
262 | | QIOChannelSocket *sioc; /* The underlying socket */ |
263 | | QIOChannel *ioc; /* The channel currently used for I/O */ |
264 | | guint ioc_tag; |
265 | | gboolean disconnecting; |
266 | | |
267 | | DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT], VNC_DIRTY_BITS); |
268 | | |
269 | | VncDisplay *vd; |
270 | | VncStateUpdate update; /* Most recent pending request from client */ |
271 | | VncStateUpdate job_update; /* Currently processed by job thread */ |
272 | | int has_dirty; |
273 | | uint32_t features; |
274 | | int absolute; |
275 | | int last_x; |
276 | | int last_y; |
277 | | uint32_t last_bmask; |
278 | | size_t client_width; /* limited to u16 by RFB proto */ |
279 | | size_t client_height; /* limited to u16 by RFB proto */ |
280 | | VncShareMode share_mode; |
281 | | |
282 | | uint32_t vnc_encoding; |
283 | | |
284 | | int major; |
285 | | int minor; |
286 | | |
287 | | int auth; |
288 | | int subauth; /* Used by VeNCrypt */ |
289 | | char challenge[VNC_AUTH_CHALLENGE_SIZE]; |
290 | | QCryptoTLSSession *tls; /* Borrowed pointer from channel, don't free */ |
291 | | #ifdef CONFIG_VNC_SASL |
292 | | VncStateSASL sasl; |
293 | | #endif |
294 | | bool encode_ws; |
295 | | bool websocket; |
296 | | |
297 | | #ifdef CONFIG_VNC |
298 | | VncClientInfo *info; |
299 | | #endif |
300 | | |
301 | | /* Job thread bottom half has put data for a forced update |
302 | | * into the output buffer. This offset points to the end of |
303 | | * the update data in the output buffer. This lets us determine |
304 | | * when a force update is fully sent to the client, allowing |
305 | | * us to process further forced updates. */ |
306 | | size_t force_update_offset; |
307 | | /* We allow multiple incremental updates or audio capture |
308 | | * samples to be queued in output buffer, provided the |
309 | | * buffer size doesn't exceed this threshold. The value |
310 | | * is calculating dynamically based on framebuffer size |
311 | | * and audio sample settings in vnc_update_throttle_offset() */ |
312 | | size_t throttle_output_offset; |
313 | | Buffer output; |
314 | | Buffer input; |
315 | | /* current output mode information */ |
316 | | VncWritePixels *write_pixels; |
317 | | PixelFormat client_pf; |
318 | | pixman_format_code_t client_format; |
319 | | int client_endian; /* G_LITTLE_ENDIAN or G_BIG_ENDIAN */ |
320 | | |
321 | | CaptureVoiceOut *audio_cap; |
322 | | struct audsettings as; |
323 | | |
324 | | VncReadEvent *read_handler; |
325 | | size_t read_handler_expect; |
326 | | |
327 | | bool abort; |
328 | | QemuMutex output_mutex; |
329 | | QEMUBH *bh; |
330 | | Buffer jobs_buffer; |
331 | | |
332 | | /* Encoding specific, if you add something here, don't forget to |
333 | | * update vnc_async_encoding_start() |
334 | | */ |
335 | | VncHextile hextile; |
336 | | VncZywrle zywrle; |
337 | | |
338 | | Notifier mouse_mode_notifier; |
339 | | |
340 | | QemuClipboardPeer cbpeer; |
341 | | QemuClipboardInfo *cbinfo; |
342 | | uint32_t cbpending; |
343 | | |
344 | | QTAILQ_ENTRY(VncState) next; |
345 | | }; |
346 | | |
347 | | typedef struct VncWorker { |
348 | | uint8_t lossy_rect[VNC_STAT_ROWS][VNC_STAT_COLS]; |
349 | | |
350 | | VncTight tight; |
351 | | VncZlib zlib; |
352 | | VncZrle zrle; |
353 | | } VncWorker; |
354 | | |
355 | | typedef struct VncConnection { |
356 | | VncState vs; |
357 | | VncWorker worker; |
358 | | } VncConnection; |
359 | | |
360 | | |
361 | | /***************************************************************************** |
362 | | * |
363 | | * Authentication modes |
364 | | * |
365 | | *****************************************************************************/ |
366 | | |
367 | | enum { |
368 | | VNC_AUTH_INVALID = 0, |
369 | | VNC_AUTH_NONE = 1, |
370 | | VNC_AUTH_VNC = 2, |
371 | | VNC_AUTH_RA2 = 5, |
372 | | VNC_AUTH_RA2NE = 6, |
373 | | VNC_AUTH_TIGHT = 16, |
374 | | VNC_AUTH_ULTRA = 17, |
375 | | VNC_AUTH_TLS = 18, /* Supported in GTK-VNC & VINO */ |
376 | | VNC_AUTH_VENCRYPT = 19, /* Supported in GTK-VNC & VeNCrypt */ |
377 | | VNC_AUTH_SASL = 20, /* Supported in GTK-VNC & VINO */ |
378 | | }; |
379 | | |
380 | | enum { |
381 | | VNC_AUTH_VENCRYPT_PLAIN = 256, |
382 | | VNC_AUTH_VENCRYPT_TLSNONE = 257, |
383 | | VNC_AUTH_VENCRYPT_TLSVNC = 258, |
384 | | VNC_AUTH_VENCRYPT_TLSPLAIN = 259, |
385 | | VNC_AUTH_VENCRYPT_X509NONE = 260, |
386 | | VNC_AUTH_VENCRYPT_X509VNC = 261, |
387 | | VNC_AUTH_VENCRYPT_X509PLAIN = 262, |
388 | | VNC_AUTH_VENCRYPT_X509SASL = 263, |
389 | | VNC_AUTH_VENCRYPT_TLSSASL = 264, |
390 | | }; |
391 | | |
392 | | |
393 | | /***************************************************************************** |
394 | | * |
395 | | * Encoding types |
396 | | * |
397 | | *****************************************************************************/ |
398 | | |
399 | 0 | #define VNC_ENCODING_RAW 0x00000000 |
400 | | #define VNC_ENCODING_COPYRECT 0x00000001 |
401 | | #define VNC_ENCODING_RRE 0x00000002 |
402 | | #define VNC_ENCODING_CORRE 0x00000004 |
403 | 0 | #define VNC_ENCODING_HEXTILE 0x00000005 |
404 | 0 | #define VNC_ENCODING_ZLIB 0x00000006 |
405 | 0 | #define VNC_ENCODING_TIGHT 0x00000007 |
406 | | #define VNC_ENCODING_ZLIBHEX 0x00000008 |
407 | | #define VNC_ENCODING_TRLE 0x0000000f |
408 | 0 | #define VNC_ENCODING_ZRLE 0x00000010 |
409 | 0 | #define VNC_ENCODING_ZYWRLE 0x00000011 |
410 | 0 | #define VNC_ENCODING_COMPRESSLEVEL0 0xFFFFFF00 /* -256 */ |
411 | 0 | #define VNC_ENCODING_QUALITYLEVEL0 0xFFFFFFE0 /* -32 */ |
412 | | #define VNC_ENCODING_XCURSOR 0xFFFFFF10 /* -240 */ |
413 | 0 | #define VNC_ENCODING_RICH_CURSOR 0xFFFFFF11 /* -239 */ |
414 | | #define VNC_ENCODING_POINTER_POS 0xFFFFFF18 /* -232 */ |
415 | | #define VNC_ENCODING_LASTRECT 0xFFFFFF20 /* -224 */ |
416 | 0 | #define VNC_ENCODING_DESKTOPRESIZE 0xFFFFFF21 /* -223 */ |
417 | 0 | #define VNC_ENCODING_POINTER_TYPE_CHANGE 0XFFFFFEFF /* -257 */ |
418 | 0 | #define VNC_ENCODING_EXT_KEY_EVENT 0XFFFFFEFE /* -258 */ |
419 | 0 | #define VNC_ENCODING_AUDIO 0XFFFFFEFD /* -259 */ |
420 | 0 | #define VNC_ENCODING_TIGHT_PNG 0xFFFFFEFC /* -260 */ |
421 | 0 | #define VNC_ENCODING_LED_STATE 0XFFFFFEFB /* -261 */ |
422 | 0 | #define VNC_ENCODING_DESKTOP_RESIZE_EXT 0XFFFFFECC /* -308 */ |
423 | 0 | #define VNC_ENCODING_XVP 0XFFFFFECB /* -309 */ |
424 | 0 | #define VNC_ENCODING_ALPHA_CURSOR 0XFFFFFEC6 /* -314 */ |
425 | 0 | #define VNC_ENCODING_WMVi 0x574D5669 |
426 | 0 | #define VNC_ENCODING_CLIPBOARD_EXT 0xc0a1e5ce |
427 | | |
428 | | /***************************************************************************** |
429 | | * |
430 | | * Other tight constants |
431 | | * |
432 | | *****************************************************************************/ |
433 | | |
434 | | /* |
435 | | * Vendors known by TightVNC: standard VNC/RealVNC, TridiaVNC, and TightVNC. |
436 | | */ |
437 | | |
438 | | #define VNC_TIGHT_CCB_RESET_MASK (0x0f) |
439 | | #define VNC_TIGHT_CCB_TYPE_MASK (0x0f << 4) |
440 | | #define VNC_TIGHT_CCB_TYPE_FILL (0x08 << 4) |
441 | | #define VNC_TIGHT_CCB_TYPE_JPEG (0x09 << 4) |
442 | | #define VNC_TIGHT_CCB_TYPE_PNG (0x0A << 4) |
443 | | #define VNC_TIGHT_CCB_BASIC_MAX (0x07 << 4) |
444 | | #define VNC_TIGHT_CCB_BASIC_ZLIB (0x03 << 4) |
445 | | #define VNC_TIGHT_CCB_BASIC_FILTER (0x04 << 4) |
446 | | |
447 | | /***************************************************************************** |
448 | | * |
449 | | * Features |
450 | | * |
451 | | *****************************************************************************/ |
452 | | |
453 | | enum VncFeatures { |
454 | | VNC_FEATURE_RESIZE, |
455 | | VNC_FEATURE_RESIZE_EXT, |
456 | | VNC_FEATURE_HEXTILE, |
457 | | VNC_FEATURE_POINTER_TYPE_CHANGE, |
458 | | VNC_FEATURE_WMVI, |
459 | | VNC_FEATURE_TIGHT, |
460 | | VNC_FEATURE_ZLIB, |
461 | | VNC_FEATURE_RICH_CURSOR, |
462 | | VNC_FEATURE_ALPHA_CURSOR, |
463 | | VNC_FEATURE_TIGHT_PNG, |
464 | | VNC_FEATURE_ZRLE, |
465 | | VNC_FEATURE_ZYWRLE, |
466 | | VNC_FEATURE_LED_STATE, |
467 | | VNC_FEATURE_XVP, |
468 | | VNC_FEATURE_CLIPBOARD_EXT, |
469 | | VNC_FEATURE_AUDIO, |
470 | | }; |
471 | | |
472 | | |
473 | | /* Client -> Server message IDs */ |
474 | 0 | #define VNC_MSG_CLIENT_SET_PIXEL_FORMAT 0 |
475 | 0 | #define VNC_MSG_CLIENT_SET_ENCODINGS 2 |
476 | 0 | #define VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST 3 |
477 | 0 | #define VNC_MSG_CLIENT_KEY_EVENT 4 |
478 | 0 | #define VNC_MSG_CLIENT_POINTER_EVENT 5 |
479 | 0 | #define VNC_MSG_CLIENT_CUT_TEXT 6 |
480 | | #define VNC_MSG_CLIENT_VMWARE_0 127 |
481 | | #define VNC_MSG_CLIENT_CALL_CONTROL 249 |
482 | 0 | #define VNC_MSG_CLIENT_XVP 250 |
483 | 0 | #define VNC_MSG_CLIENT_SET_DESKTOP_SIZE 251 |
484 | | #define VNC_MSG_CLIENT_TIGHT 252 |
485 | | #define VNC_MSG_CLIENT_GII 253 |
486 | | #define VNC_MSG_CLIENT_VMWARE_1 254 |
487 | 0 | #define VNC_MSG_CLIENT_QEMU 255 |
488 | | |
489 | | /* Server -> Client message IDs */ |
490 | 0 | #define VNC_MSG_SERVER_FRAMEBUFFER_UPDATE 0 |
491 | 0 | #define VNC_MSG_SERVER_SET_COLOUR_MAP_ENTRIES 1 |
492 | | #define VNC_MSG_SERVER_BELL 2 |
493 | 0 | #define VNC_MSG_SERVER_CUT_TEXT 3 |
494 | | #define VNC_MSG_SERVER_VMWARE_0 127 |
495 | | #define VNC_MSG_SERVER_CALL_CONTROL 249 |
496 | 0 | #define VNC_MSG_SERVER_XVP 250 |
497 | | #define VNC_MSG_SERVER_TIGHT 252 |
498 | | #define VNC_MSG_SERVER_GII 253 |
499 | | #define VNC_MSG_SERVER_VMWARE_1 254 |
500 | 0 | #define VNC_MSG_SERVER_QEMU 255 |
501 | | |
502 | | |
503 | | |
504 | | /* QEMU client -> server message IDs */ |
505 | 0 | #define VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT 0 |
506 | 0 | #define VNC_MSG_CLIENT_QEMU_AUDIO 1 |
507 | | |
508 | | /* QEMU server -> client message IDs */ |
509 | 0 | #define VNC_MSG_SERVER_QEMU_AUDIO 1 |
510 | | |
511 | | |
512 | | |
513 | | /* QEMU client -> server audio message IDs */ |
514 | 0 | #define VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE 0 |
515 | 0 | #define VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE 1 |
516 | 0 | #define VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT 2 |
517 | | |
518 | | /* QEMU server -> client audio message IDs */ |
519 | 0 | #define VNC_MSG_SERVER_QEMU_AUDIO_END 0 |
520 | 0 | #define VNC_MSG_SERVER_QEMU_AUDIO_BEGIN 1 |
521 | 0 | #define VNC_MSG_SERVER_QEMU_AUDIO_DATA 2 |
522 | | |
523 | | /* XVP server -> client status code */ |
524 | 0 | #define VNC_XVP_CODE_FAIL 0 |
525 | 0 | #define VNC_XVP_CODE_INIT 1 |
526 | | |
527 | | /* XVP client -> server action request */ |
528 | 0 | #define VNC_XVP_ACTION_SHUTDOWN 2 |
529 | 0 | #define VNC_XVP_ACTION_REBOOT 3 |
530 | 0 | #define VNC_XVP_ACTION_RESET 4 |
531 | | |
532 | | /* extended clipboard flags */ |
533 | 0 | #define VNC_CLIPBOARD_TEXT (1 << 0) |
534 | | #define VNC_CLIPBOARD_RTF (1 << 1) |
535 | | #define VNC_CLIPBOARD_HTML (1 << 2) |
536 | | #define VNC_CLIPBOARD_DIB (1 << 3) |
537 | | #define VNC_CLIPBOARD_FILES (1 << 4) |
538 | 0 | #define VNC_CLIPBOARD_CAPS (1 << 24) |
539 | 0 | #define VNC_CLIPBOARD_REQUEST (1 << 25) |
540 | | #define VNC_CLIPBOARD_PEEK (1 << 26) |
541 | 0 | #define VNC_CLIPBOARD_NOTIFY (1 << 27) |
542 | 0 | #define VNC_CLIPBOARD_PROVIDE (1 << 28) |
543 | | |
544 | | VncDisplay *vnc_display_new(const char *id, Error **errp); |
545 | | void vnc_display_free(VncDisplay *vd); |
546 | | |
547 | | /***************************************************************************** |
548 | | * |
549 | | * Internal APIs |
550 | | * |
551 | | *****************************************************************************/ |
552 | | |
553 | | /* Event loop functions */ |
554 | | gboolean vnc_client_io(QIOChannel *ioc, |
555 | | GIOCondition condition, |
556 | | void *opaque); |
557 | | |
558 | | size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen); |
559 | | size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen); |
560 | | |
561 | | /* Protocol I/O functions */ |
562 | | void vnc_write(VncState *vs, const void *data, size_t len); |
563 | | void vnc_write_u32(VncState *vs, uint32_t value); |
564 | | void vnc_write_s32(VncState *vs, int32_t value); |
565 | | void vnc_write_u16(VncState *vs, uint16_t value); |
566 | | void vnc_write_u8(VncState *vs, uint8_t value); |
567 | | void vnc_flush(VncState *vs); |
568 | | void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting); |
569 | | void vnc_start_protocol(VncState *vs); |
570 | | |
571 | | |
572 | | /* Buffer I/O functions */ |
573 | | uint32_t read_u32(uint8_t *data, size_t offset); |
574 | | |
575 | | /* Protocol stage functions */ |
576 | | void vnc_client_error(VncState *vs); |
577 | | size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error *err); |
578 | | |
579 | | void start_client_init(VncState *vs); |
580 | | void start_auth_vnc(VncState *vs); |
581 | | |
582 | | |
583 | | /* Misc helpers */ |
584 | | |
585 | 0 | static inline uint32_t vnc_has_feature(VncState *vs, int feature) { |
586 | 0 | return (vs->features & (1 << feature)); |
587 | 0 | } Unexecuted instantiation: vnc.c:vnc_has_feature Unexecuted instantiation: vnc-enc-zlib.c:vnc_has_feature Unexecuted instantiation: vnc-enc-hextile.c:vnc_has_feature Unexecuted instantiation: vnc-enc-tight.c:vnc_has_feature Unexecuted instantiation: vnc-enc-zrle.c:vnc_has_feature Unexecuted instantiation: vnc-auth-vencrypt.c:vnc_has_feature Unexecuted instantiation: vnc-ws.c:vnc_has_feature Unexecuted instantiation: vnc-jobs.c:vnc_has_feature Unexecuted instantiation: vnc-clipboard.c:vnc_has_feature Unexecuted instantiation: vnc-system.c:vnc_has_feature |
588 | | |
589 | | static inline void vnc_set_feature(VncState *vs, enum VncFeatures feature) |
590 | 0 | { |
591 | 0 | vs->features |= (1 << feature); |
592 | 0 | } Unexecuted instantiation: vnc.c:vnc_set_feature Unexecuted instantiation: vnc-enc-zlib.c:vnc_set_feature Unexecuted instantiation: vnc-enc-hextile.c:vnc_set_feature Unexecuted instantiation: vnc-enc-tight.c:vnc_set_feature Unexecuted instantiation: vnc-enc-zrle.c:vnc_set_feature Unexecuted instantiation: vnc-auth-vencrypt.c:vnc_set_feature Unexecuted instantiation: vnc-ws.c:vnc_set_feature Unexecuted instantiation: vnc-jobs.c:vnc_set_feature Unexecuted instantiation: vnc-clipboard.c:vnc_set_feature Unexecuted instantiation: vnc-system.c:vnc_set_feature |
593 | | |
594 | | /* Framebuffer */ |
595 | | void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, |
596 | | int32_t encoding); |
597 | | |
598 | | /* server fb is in PIXMAN_x8r8g8b8 */ |
599 | 0 | #define VNC_SERVER_FB_FORMAT PIXMAN_FORMAT(32, PIXMAN_TYPE_ARGB, 0, 8, 8, 8) |
600 | 0 | #define VNC_SERVER_FB_BITS (PIXMAN_FORMAT_BPP(VNC_SERVER_FB_FORMAT)) |
601 | 0 | #define VNC_SERVER_FB_BYTES ((VNC_SERVER_FB_BITS+7)/8) |
602 | | |
603 | | void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y); |
604 | | int vnc_server_fb_stride(VncDisplay *vd); |
605 | | |
606 | | void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v); |
607 | | double vnc_update_freq(VncState *vs, int x, int y, int w, int h); |
608 | | void vnc_sent_lossy_rect(VncWorker *worker, int x, int y, int w, int h); |
609 | | |
610 | | /* Encodings */ |
611 | | int vnc_send_framebuffer_update(VncState *vs, VncWorker *worker, |
612 | | int x, int y, int w, int h); |
613 | | |
614 | | int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
615 | | |
616 | | int vnc_hextile_send_framebuffer_update(VncState *vs, int x, |
617 | | int y, int w, int h); |
618 | | void vnc_hextile_set_pixel_conversion(VncState *vs, int generic); |
619 | | |
620 | | void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size); |
621 | | void vnc_zlib_zfree(void *x, void *addr); |
622 | | int vnc_zlib_send_framebuffer_update(VncState *vs, VncWorker *worker, |
623 | | int x, int y, int w, int h); |
624 | | void vnc_zlib_clear(VncWorker *worker); |
625 | | |
626 | | int vnc_tight_send_framebuffer_update(VncState *vs, VncWorker *worker, |
627 | | int x, int y, int w, int h); |
628 | | int vnc_tight_png_send_framebuffer_update(VncState *vs, VncWorker *worker, |
629 | | int x, int y, int w, int h); |
630 | | void vnc_tight_clear(VncWorker *worker); |
631 | | |
632 | | int vnc_zrle_send_framebuffer_update(VncState *vs, VncWorker *worker, |
633 | | int x, int y, int w, int h); |
634 | | int vnc_zywrle_send_framebuffer_update(VncState *vs, VncWorker *worker, |
635 | | int x, int y, int w, int h); |
636 | | void vnc_zrle_clear(VncWorker *worker); |
637 | | |
638 | | /* vnc-clipboard.c */ |
639 | | void vnc_server_cut_text_caps(VncState *vs); |
640 | | void vnc_client_cut_text(VncState *vs, size_t len, uint8_t *text); |
641 | | void vnc_client_cut_text_ext(VncState *vs, int32_t len, uint32_t flags, uint8_t *data); |
642 | | |
643 | | /* XVP events */ |
644 | | void vnc_action_shutdown(VncState *vs); |
645 | | void vnc_action_reset(VncState *vs); |
646 | | |
647 | | #endif /* QEMU_VNC_H */ |