root / ui / vnc.h @ e4ebcc1a
History | View | Annotate | Download (16.3 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 | 19a490bf | aliguori | struct VncDisplay
|
126 | 19a490bf | aliguori | { |
127 | 41b4bef6 | Amit Shah | QTAILQ_HEAD(, VncState) clients; |
128 | 703bc68f | Stefano Stabellini | QEMUTimer *timer; |
129 | 2430ffe4 | Stefano Stabellini | int timer_interval;
|
130 | 19a490bf | aliguori | int lsock;
|
131 | 19a490bf | aliguori | DisplayState *ds; |
132 | c227f099 | Anthony Liguori | kbd_layout_t *kbd_layout; |
133 | 3a0558b5 | Gerd Hoffmann | int lock_key_sync;
|
134 | bd023f95 | Corentin Chary | #ifdef CONFIG_VNC_THREAD
|
135 | bd023f95 | Corentin Chary | QemuMutex mutex; |
136 | bd023f95 | Corentin Chary | #endif
|
137 | 19a490bf | aliguori | |
138 | d467b679 | Gerd Hoffmann | QEMUCursor *cursor; |
139 | d467b679 | Gerd Hoffmann | int cursor_msize;
|
140 | d467b679 | Gerd Hoffmann | uint8_t *cursor_mask; |
141 | d467b679 | Gerd Hoffmann | |
142 | 1fc62412 | Stefano Stabellini | struct VncSurface guest; /* guest visible surface (aka ds->surface) */ |
143 | 1fc62412 | Stefano Stabellini | DisplaySurface *server; /* vnc server surface */
|
144 | 1fc62412 | Stefano Stabellini | |
145 | 19a490bf | aliguori | char *display;
|
146 | 19a490bf | aliguori | char *password;
|
147 | 3c9405a0 | Gerd Hoffmann | time_t expires; |
148 | 19a490bf | aliguori | int auth;
|
149 | 6f9c78c1 | Corentin Chary | bool lossy;
|
150 | 80e0c8c3 | Corentin Chary | bool non_adaptive;
|
151 | 19a490bf | aliguori | #ifdef CONFIG_VNC_TLS
|
152 | 5fb6c7a8 | aliguori | int subauth; /* Used by VeNCrypt */ |
153 | 5fb6c7a8 | aliguori | VncDisplayTLS tls; |
154 | 19a490bf | aliguori | #endif
|
155 | 76655d6d | aliguori | #ifdef CONFIG_VNC_SASL
|
156 | 76655d6d | aliguori | VncDisplaySASL sasl; |
157 | 76655d6d | aliguori | #endif
|
158 | 19a490bf | aliguori | }; |
159 | 19a490bf | aliguori | |
160 | d1af0e05 | Corentin Chary | typedef struct VncTight { |
161 | d1af0e05 | Corentin Chary | int type;
|
162 | d1af0e05 | Corentin Chary | uint8_t quality; |
163 | d1af0e05 | Corentin Chary | uint8_t compression; |
164 | d1af0e05 | Corentin Chary | uint8_t pixel24; |
165 | d1af0e05 | Corentin Chary | Buffer tight; |
166 | d1af0e05 | Corentin Chary | Buffer tmp; |
167 | d1af0e05 | Corentin Chary | Buffer zlib; |
168 | d1af0e05 | Corentin Chary | Buffer gradient; |
169 | d1af0e05 | Corentin Chary | #ifdef CONFIG_VNC_JPEG
|
170 | d1af0e05 | Corentin Chary | Buffer jpeg; |
171 | d1af0e05 | Corentin Chary | #endif
|
172 | d1af0e05 | Corentin Chary | #ifdef CONFIG_VNC_PNG
|
173 | d1af0e05 | Corentin Chary | Buffer png; |
174 | d1af0e05 | Corentin Chary | #endif
|
175 | d1af0e05 | Corentin Chary | int levels[4]; |
176 | d1af0e05 | Corentin Chary | z_stream stream[4];
|
177 | d1af0e05 | Corentin Chary | } VncTight; |
178 | d1af0e05 | Corentin Chary | |
179 | d1af0e05 | Corentin Chary | typedef struct VncHextile { |
180 | d1af0e05 | Corentin Chary | VncSendHextileTile *send_tile; |
181 | d1af0e05 | Corentin Chary | } VncHextile; |
182 | d1af0e05 | Corentin Chary | |
183 | d1af0e05 | Corentin Chary | typedef struct VncZlib { |
184 | d1af0e05 | Corentin Chary | Buffer zlib; |
185 | d1af0e05 | Corentin Chary | Buffer tmp; |
186 | d1af0e05 | Corentin Chary | z_stream stream; |
187 | d1af0e05 | Corentin Chary | int level;
|
188 | d1af0e05 | Corentin Chary | } VncZlib; |
189 | d1af0e05 | Corentin Chary | |
190 | 148954fa | Corentin Chary | typedef struct VncZrle { |
191 | 148954fa | Corentin Chary | int type;
|
192 | 148954fa | Corentin Chary | Buffer fb; |
193 | 148954fa | Corentin Chary | Buffer zrle; |
194 | 148954fa | Corentin Chary | Buffer tmp; |
195 | 148954fa | Corentin Chary | Buffer zlib; |
196 | 148954fa | Corentin Chary | z_stream stream; |
197 | 148954fa | Corentin Chary | VncPalette palette; |
198 | 148954fa | Corentin Chary | } VncZrle; |
199 | 148954fa | Corentin Chary | |
200 | 148954fa | Corentin Chary | typedef struct VncZywrle { |
201 | 148954fa | Corentin Chary | int buf[VNC_ZRLE_TILE_WIDTH * VNC_ZRLE_TILE_HEIGHT];
|
202 | 148954fa | Corentin Chary | } VncZywrle; |
203 | 148954fa | Corentin Chary | |
204 | bd023f95 | Corentin Chary | #ifdef CONFIG_VNC_THREAD
|
205 | bd023f95 | Corentin Chary | struct VncRect
|
206 | bd023f95 | Corentin Chary | { |
207 | bd023f95 | Corentin Chary | int x;
|
208 | bd023f95 | Corentin Chary | int y;
|
209 | bd023f95 | Corentin Chary | int w;
|
210 | bd023f95 | Corentin Chary | int h;
|
211 | bd023f95 | Corentin Chary | }; |
212 | bd023f95 | Corentin Chary | |
213 | bd023f95 | Corentin Chary | struct VncRectEntry
|
214 | bd023f95 | Corentin Chary | { |
215 | bd023f95 | Corentin Chary | struct VncRect rect;
|
216 | bd023f95 | Corentin Chary | QLIST_ENTRY(VncRectEntry) next; |
217 | bd023f95 | Corentin Chary | }; |
218 | bd023f95 | Corentin Chary | |
219 | bd023f95 | Corentin Chary | struct VncJob
|
220 | bd023f95 | Corentin Chary | { |
221 | bd023f95 | Corentin Chary | VncState *vs; |
222 | bd023f95 | Corentin Chary | |
223 | bd023f95 | Corentin Chary | QLIST_HEAD(, VncRectEntry) rectangles; |
224 | bd023f95 | Corentin Chary | QTAILQ_ENTRY(VncJob) next; |
225 | bd023f95 | Corentin Chary | }; |
226 | bd023f95 | Corentin Chary | #else
|
227 | bd023f95 | Corentin Chary | struct VncJob
|
228 | bd023f95 | Corentin Chary | { |
229 | bd023f95 | Corentin Chary | VncState *vs; |
230 | bd023f95 | Corentin Chary | int rectangles;
|
231 | bd023f95 | Corentin Chary | size_t saved_offset; |
232 | bd023f95 | Corentin Chary | }; |
233 | bd023f95 | Corentin Chary | #endif
|
234 | bd023f95 | Corentin Chary | |
235 | 19a490bf | aliguori | struct VncState
|
236 | 19a490bf | aliguori | { |
237 | 19a490bf | aliguori | int csock;
|
238 | 6baebed7 | aliguori | |
239 | 19a490bf | aliguori | DisplayState *ds; |
240 | 23bfe28f | Stefan Weil | DECLARE_BITMAP(dirty[VNC_MAX_HEIGHT], VNC_DIRTY_BITS); |
241 | 7d964c9d | Corentin Chary | uint8_t **lossy_rect; /* Not an Array to avoid costly memcpy in
|
242 | 7d964c9d | Corentin Chary | * vnc-jobs-async.c */
|
243 | 6baebed7 | aliguori | |
244 | 19a490bf | aliguori | VncDisplay *vd; |
245 | 19a490bf | aliguori | int need_update;
|
246 | c522d0e2 | aliguori | int force_update;
|
247 | 19a490bf | aliguori | uint32_t features; |
248 | 19a490bf | aliguori | int absolute;
|
249 | 19a490bf | aliguori | int last_x;
|
250 | 19a490bf | aliguori | int last_y;
|
251 | 5862d195 | Gerd Hoffmann | int client_width;
|
252 | 5862d195 | Gerd Hoffmann | int client_height;
|
253 | 19a490bf | aliguori | |
254 | 19a490bf | aliguori | uint32_t vnc_encoding; |
255 | 19a490bf | aliguori | |
256 | 19a490bf | aliguori | int major;
|
257 | 19a490bf | aliguori | int minor;
|
258 | 19a490bf | aliguori | |
259 | 19a490bf | aliguori | char challenge[VNC_AUTH_CHALLENGE_SIZE];
|
260 | 19a490bf | aliguori | #ifdef CONFIG_VNC_TLS
|
261 | 5fb6c7a8 | aliguori | VncStateTLS tls; |
262 | 19a490bf | aliguori | #endif
|
263 | 2f9606b3 | aliguori | #ifdef CONFIG_VNC_SASL
|
264 | 2f9606b3 | aliguori | VncStateSASL sasl; |
265 | 2f9606b3 | aliguori | #endif
|
266 | 19a490bf | aliguori | |
267 | 4a80dba3 | Luiz Capitulino | QObject *info; |
268 | 4a80dba3 | Luiz Capitulino | |
269 | 19a490bf | aliguori | Buffer output; |
270 | 19a490bf | aliguori | Buffer input; |
271 | 19a490bf | aliguori | /* current output mode information */
|
272 | 19a490bf | aliguori | VncWritePixels *write_pixels; |
273 | 6baebed7 | aliguori | DisplaySurface clientds; |
274 | 19a490bf | aliguori | |
275 | 19a490bf | aliguori | CaptureVoiceOut *audio_cap; |
276 | 19a490bf | aliguori | struct audsettings as;
|
277 | 19a490bf | aliguori | |
278 | 19a490bf | aliguori | VncReadEvent *read_handler; |
279 | 19a490bf | aliguori | size_t read_handler_expect; |
280 | 19a490bf | aliguori | /* input */
|
281 | 19a490bf | aliguori | uint8_t modifiers_state[256];
|
282 | 7ffb82ca | Gerd Hoffmann | QEMUPutLEDEntry *led; |
283 | 19a490bf | aliguori | |
284 | bd023f95 | Corentin Chary | bool abort;
|
285 | bd023f95 | Corentin Chary | #ifndef CONFIG_VNC_THREAD
|
286 | bd023f95 | Corentin Chary | VncJob job; |
287 | bd023f95 | Corentin Chary | #else
|
288 | bd023f95 | Corentin Chary | QemuMutex output_mutex; |
289 | bd023f95 | Corentin Chary | #endif
|
290 | bd023f95 | Corentin Chary | |
291 | bd023f95 | Corentin Chary | /* Encoding specific, if you add something here, don't forget to
|
292 | bd023f95 | Corentin Chary | * update vnc_async_encoding_start()
|
293 | bd023f95 | Corentin Chary | */
|
294 | d1af0e05 | Corentin Chary | VncTight tight; |
295 | d1af0e05 | Corentin Chary | VncZlib zlib; |
296 | d1af0e05 | Corentin Chary | VncHextile hextile; |
297 | 148954fa | Corentin Chary | VncZrle zrle; |
298 | 148954fa | Corentin Chary | VncZywrle zywrle; |
299 | 19a490bf | aliguori | |
300 | 37c34d9d | Anthony Liguori | Notifier mouse_mode_notifier; |
301 | 37c34d9d | Anthony Liguori | |
302 | 41b4bef6 | Amit Shah | QTAILQ_ENTRY(VncState) next; |
303 | 19a490bf | aliguori | }; |
304 | 19a490bf | aliguori | |
305 | e06679fb | aliguori | |
306 | e06679fb | aliguori | /*****************************************************************************
|
307 | e06679fb | aliguori | *
|
308 | e06679fb | aliguori | * Authentication modes
|
309 | e06679fb | aliguori | *
|
310 | e06679fb | aliguori | *****************************************************************************/
|
311 | e06679fb | aliguori | |
312 | e06679fb | aliguori | enum {
|
313 | e06679fb | aliguori | VNC_AUTH_INVALID = 0,
|
314 | e06679fb | aliguori | VNC_AUTH_NONE = 1,
|
315 | e06679fb | aliguori | VNC_AUTH_VNC = 2,
|
316 | e06679fb | aliguori | VNC_AUTH_RA2 = 5,
|
317 | e06679fb | aliguori | VNC_AUTH_RA2NE = 6,
|
318 | e06679fb | aliguori | VNC_AUTH_TIGHT = 16,
|
319 | e06679fb | aliguori | VNC_AUTH_ULTRA = 17,
|
320 | 2f9606b3 | aliguori | VNC_AUTH_TLS = 18, /* Supported in GTK-VNC & VINO */ |
321 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT = 19, /* Supported in GTK-VNC & VeNCrypt */ |
322 | 2f9606b3 | aliguori | VNC_AUTH_SASL = 20, /* Supported in GTK-VNC & VINO */ |
323 | e06679fb | aliguori | }; |
324 | e06679fb | aliguori | |
325 | e06679fb | aliguori | enum {
|
326 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_PLAIN = 256,
|
327 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSNONE = 257,
|
328 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSVNC = 258,
|
329 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_TLSPLAIN = 259,
|
330 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509NONE = 260,
|
331 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509VNC = 261,
|
332 | e06679fb | aliguori | VNC_AUTH_VENCRYPT_X509PLAIN = 262,
|
333 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT_X509SASL = 263,
|
334 | 2f9606b3 | aliguori | VNC_AUTH_VENCRYPT_TLSSASL = 264,
|
335 | e06679fb | aliguori | }; |
336 | e06679fb | aliguori | |
337 | e06679fb | aliguori | |
338 | e06679fb | aliguori | /*****************************************************************************
|
339 | e06679fb | aliguori | *
|
340 | e06679fb | aliguori | * Encoding types
|
341 | e06679fb | aliguori | *
|
342 | e06679fb | aliguori | *****************************************************************************/
|
343 | e06679fb | aliguori | |
344 | e06679fb | aliguori | #define VNC_ENCODING_RAW 0x00000000 |
345 | e06679fb | aliguori | #define VNC_ENCODING_COPYRECT 0x00000001 |
346 | e06679fb | aliguori | #define VNC_ENCODING_RRE 0x00000002 |
347 | e06679fb | aliguori | #define VNC_ENCODING_CORRE 0x00000004 |
348 | e06679fb | aliguori | #define VNC_ENCODING_HEXTILE 0x00000005 |
349 | e06679fb | aliguori | #define VNC_ENCODING_ZLIB 0x00000006 |
350 | e06679fb | aliguori | #define VNC_ENCODING_TIGHT 0x00000007 |
351 | e06679fb | aliguori | #define VNC_ENCODING_ZLIBHEX 0x00000008 |
352 | e06679fb | aliguori | #define VNC_ENCODING_TRLE 0x0000000f |
353 | e06679fb | aliguori | #define VNC_ENCODING_ZRLE 0x00000010 |
354 | e06679fb | aliguori | #define VNC_ENCODING_ZYWRLE 0x00000011 |
355 | e06679fb | aliguori | #define VNC_ENCODING_COMPRESSLEVEL0 0xFFFFFF00 /* -256 */ |
356 | e06679fb | aliguori | #define VNC_ENCODING_QUALITYLEVEL0 0xFFFFFFE0 /* -32 */ |
357 | e06679fb | aliguori | #define VNC_ENCODING_XCURSOR 0xFFFFFF10 /* -240 */ |
358 | e06679fb | aliguori | #define VNC_ENCODING_RICH_CURSOR 0xFFFFFF11 /* -239 */ |
359 | e06679fb | aliguori | #define VNC_ENCODING_POINTER_POS 0xFFFFFF18 /* -232 */ |
360 | e06679fb | aliguori | #define VNC_ENCODING_LASTRECT 0xFFFFFF20 /* -224 */ |
361 | e06679fb | aliguori | #define VNC_ENCODING_DESKTOPRESIZE 0xFFFFFF21 /* -223 */ |
362 | e06679fb | aliguori | #define VNC_ENCODING_POINTER_TYPE_CHANGE 0XFFFFFEFF /* -257 */ |
363 | e06679fb | aliguori | #define VNC_ENCODING_EXT_KEY_EVENT 0XFFFFFEFE /* -258 */ |
364 | e06679fb | aliguori | #define VNC_ENCODING_AUDIO 0XFFFFFEFD /* -259 */ |
365 | efe556ad | Corentin Chary | #define VNC_ENCODING_TIGHT_PNG 0xFFFFFEFC /* -260 */ |
366 | e06679fb | aliguori | #define VNC_ENCODING_WMVi 0x574D5669 |
367 | e06679fb | aliguori | |
368 | e06679fb | aliguori | /*****************************************************************************
|
369 | e06679fb | aliguori | *
|
370 | e06679fb | aliguori | * Other tight constants
|
371 | e06679fb | aliguori | *
|
372 | e06679fb | aliguori | *****************************************************************************/
|
373 | e06679fb | aliguori | |
374 | e06679fb | aliguori | /*
|
375 | e06679fb | aliguori | * Vendors known by TightVNC: standard VNC/RealVNC, TridiaVNC, and TightVNC.
|
376 | e06679fb | aliguori | */
|
377 | e06679fb | aliguori | |
378 | e06679fb | aliguori | #define VNC_TIGHT_CCB_RESET_MASK (0x0f) |
379 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_MASK (0x0f << 4) |
380 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_FILL (0x08 << 4) |
381 | e06679fb | aliguori | #define VNC_TIGHT_CCB_TYPE_JPEG (0x09 << 4) |
382 | efe556ad | Corentin Chary | #define VNC_TIGHT_CCB_TYPE_PNG (0x0A << 4) |
383 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_MAX (0x07 << 4) |
384 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_ZLIB (0x03 << 4) |
385 | e06679fb | aliguori | #define VNC_TIGHT_CCB_BASIC_FILTER (0x04 << 4) |
386 | e06679fb | aliguori | |
387 | e06679fb | aliguori | /*****************************************************************************
|
388 | e06679fb | aliguori | *
|
389 | e06679fb | aliguori | * Features
|
390 | e06679fb | aliguori | *
|
391 | e06679fb | aliguori | *****************************************************************************/
|
392 | e06679fb | aliguori | |
393 | e06679fb | aliguori | #define VNC_FEATURE_RESIZE 0 |
394 | e06679fb | aliguori | #define VNC_FEATURE_HEXTILE 1 |
395 | e06679fb | aliguori | #define VNC_FEATURE_POINTER_TYPE_CHANGE 2 |
396 | e06679fb | aliguori | #define VNC_FEATURE_WMVI 3 |
397 | e06679fb | aliguori | #define VNC_FEATURE_TIGHT 4 |
398 | e06679fb | aliguori | #define VNC_FEATURE_ZLIB 5 |
399 | 753b4053 | aliguori | #define VNC_FEATURE_COPYRECT 6 |
400 | d467b679 | Gerd Hoffmann | #define VNC_FEATURE_RICH_CURSOR 7 |
401 | efe556ad | Corentin Chary | #define VNC_FEATURE_TIGHT_PNG 8 |
402 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZRLE 9 |
403 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZYWRLE 10 |
404 | e06679fb | aliguori | |
405 | e06679fb | aliguori | #define VNC_FEATURE_RESIZE_MASK (1 << VNC_FEATURE_RESIZE) |
406 | e06679fb | aliguori | #define VNC_FEATURE_HEXTILE_MASK (1 << VNC_FEATURE_HEXTILE) |
407 | e06679fb | aliguori | #define VNC_FEATURE_POINTER_TYPE_CHANGE_MASK (1 << VNC_FEATURE_POINTER_TYPE_CHANGE) |
408 | e06679fb | aliguori | #define VNC_FEATURE_WMVI_MASK (1 << VNC_FEATURE_WMVI) |
409 | e06679fb | aliguori | #define VNC_FEATURE_TIGHT_MASK (1 << VNC_FEATURE_TIGHT) |
410 | e06679fb | aliguori | #define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB) |
411 | 753b4053 | aliguori | #define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT) |
412 | d467b679 | Gerd Hoffmann | #define VNC_FEATURE_RICH_CURSOR_MASK (1 << VNC_FEATURE_RICH_CURSOR) |
413 | efe556ad | Corentin Chary | #define VNC_FEATURE_TIGHT_PNG_MASK (1 << VNC_FEATURE_TIGHT_PNG) |
414 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZRLE_MASK (1 << VNC_FEATURE_ZRLE) |
415 | 148954fa | Corentin Chary | #define VNC_FEATURE_ZYWRLE_MASK (1 << VNC_FEATURE_ZYWRLE) |
416 | e06679fb | aliguori | |
417 | 5fb6c7a8 | aliguori | |
418 | 46a183da | Daniel P. Berrange | /* Client -> Server message IDs */
|
419 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_PIXEL_FORMAT 0 |
420 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_ENCODINGS 2 |
421 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST 3 |
422 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_KEY_EVENT 4 |
423 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_POINTER_EVENT 5 |
424 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_CUT_TEXT 6 |
425 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_VMWARE_0 127 |
426 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_CALL_CONTROL 249 |
427 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_XVP 250 |
428 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_SET_DESKTOP_SIZE 251 |
429 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_TIGHT 252 |
430 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_GII 253 |
431 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_VMWARE_1 254 |
432 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU 255 |
433 | 46a183da | Daniel P. Berrange | |
434 | 46a183da | Daniel P. Berrange | /* Server -> Client message IDs */
|
435 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_FRAMEBUFFER_UPDATE 0 |
436 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_SET_COLOUR_MAP_ENTRIES 1 |
437 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_BELL 2 |
438 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_CUT_TEXT 3 |
439 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_VMWARE_0 127 |
440 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_CALL_CONTROL 249 |
441 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_XVP 250 |
442 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_TIGHT 252 |
443 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_GII 253 |
444 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_VMWARE_1 254 |
445 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU 255 |
446 | 46a183da | Daniel P. Berrange | |
447 | 46a183da | Daniel P. Berrange | |
448 | 46a183da | Daniel P. Berrange | |
449 | 46a183da | Daniel P. Berrange | /* QEMU client -> server message IDs */
|
450 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT 0 |
451 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO 1 |
452 | 46a183da | Daniel P. Berrange | |
453 | 46a183da | Daniel P. Berrange | /* QEMU server -> client message IDs */
|
454 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO 1 |
455 | 46a183da | Daniel P. Berrange | |
456 | 46a183da | Daniel P. Berrange | |
457 | 46a183da | Daniel P. Berrange | |
458 | 46a183da | Daniel P. Berrange | /* QEMU client -> server audio message IDs */
|
459 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE 0 |
460 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE 1 |
461 | 46a183da | Daniel P. Berrange | #define VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT 2 |
462 | 46a183da | Daniel P. Berrange | |
463 | 46a183da | Daniel P. Berrange | /* QEMU server -> client audio message IDs */
|
464 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_END 0 |
465 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_BEGIN 1 |
466 | 46a183da | Daniel P. Berrange | #define VNC_MSG_SERVER_QEMU_AUDIO_DATA 2 |
467 | 46a183da | Daniel P. Berrange | |
468 | 46a183da | Daniel P. Berrange | |
469 | 5fb6c7a8 | aliguori | /*****************************************************************************
|
470 | 5fb6c7a8 | aliguori | *
|
471 | 5fb6c7a8 | aliguori | * Internal APIs
|
472 | 5fb6c7a8 | aliguori | *
|
473 | 5fb6c7a8 | aliguori | *****************************************************************************/
|
474 | 5fb6c7a8 | aliguori | |
475 | 5fb6c7a8 | aliguori | /* Event loop functions */
|
476 | 5fb6c7a8 | aliguori | void vnc_client_read(void *opaque); |
477 | 5fb6c7a8 | aliguori | void vnc_client_write(void *opaque); |
478 | 5fb6c7a8 | aliguori | |
479 | 2f9606b3 | aliguori | long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
|
480 | 2f9606b3 | aliguori | long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen); |
481 | 5fb6c7a8 | aliguori | |
482 | 5fb6c7a8 | aliguori | /* Protocol I/O functions */
|
483 | 5fb6c7a8 | aliguori | void vnc_write(VncState *vs, const void *data, size_t len); |
484 | 5fb6c7a8 | aliguori | void vnc_write_u32(VncState *vs, uint32_t value);
|
485 | 5fb6c7a8 | aliguori | void vnc_write_s32(VncState *vs, int32_t value);
|
486 | 5fb6c7a8 | aliguori | void vnc_write_u16(VncState *vs, uint16_t value);
|
487 | 5fb6c7a8 | aliguori | void vnc_write_u8(VncState *vs, uint8_t value);
|
488 | 5fb6c7a8 | aliguori | void vnc_flush(VncState *vs);
|
489 | 5fb6c7a8 | aliguori | void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting);
|
490 | 5fb6c7a8 | aliguori | |
491 | 5fb6c7a8 | aliguori | |
492 | 5fb6c7a8 | aliguori | /* Buffer I/O functions */
|
493 | 5fb6c7a8 | aliguori | uint8_t read_u8(uint8_t *data, size_t offset); |
494 | 5fb6c7a8 | aliguori | uint16_t read_u16(uint8_t *data, size_t offset); |
495 | 5fb6c7a8 | aliguori | int32_t read_s32(uint8_t *data, size_t offset); |
496 | 5fb6c7a8 | aliguori | uint32_t read_u32(uint8_t *data, size_t offset); |
497 | 5fb6c7a8 | aliguori | |
498 | 5fb6c7a8 | aliguori | /* Protocol stage functions */
|
499 | 5fb6c7a8 | aliguori | void vnc_client_error(VncState *vs);
|
500 | 2f9606b3 | aliguori | int vnc_client_io_error(VncState *vs, int ret, int last_errno); |
501 | 5fb6c7a8 | aliguori | |
502 | 5fb6c7a8 | aliguori | void start_client_init(VncState *vs);
|
503 | 5fb6c7a8 | aliguori | void start_auth_vnc(VncState *vs);
|
504 | 5fb6c7a8 | aliguori | |
505 | 2f9606b3 | aliguori | /* Buffer management */
|
506 | 2f9606b3 | aliguori | void buffer_reserve(Buffer *buffer, size_t len);
|
507 | 2f9606b3 | aliguori | int buffer_empty(Buffer *buffer);
|
508 | 2f9606b3 | aliguori | uint8_t *buffer_end(Buffer *buffer); |
509 | 2f9606b3 | aliguori | void buffer_reset(Buffer *buffer);
|
510 | 5d418e3b | Corentin Chary | void buffer_free(Buffer *buffer);
|
511 | 2f9606b3 | aliguori | void buffer_append(Buffer *buffer, const void *data, size_t len); |
512 | 2f9606b3 | aliguori | |
513 | 2f9606b3 | aliguori | |
514 | 2f9606b3 | aliguori | /* Misc helpers */
|
515 | 2f9606b3 | aliguori | |
516 | 2f9606b3 | aliguori | char *vnc_socket_local_addr(const char *format, int fd); |
517 | 2f9606b3 | aliguori | char *vnc_socket_remote_addr(const char *format, int fd); |
518 | 2f9606b3 | aliguori | |
519 | efe556ad | Corentin Chary | static inline uint32_t vnc_has_feature(VncState *vs, int feature) { |
520 | efe556ad | Corentin Chary | return (vs->features & (1 << feature)); |
521 | efe556ad | Corentin Chary | } |
522 | efe556ad | Corentin Chary | |
523 | 70a4568f | Corentin Chary | /* Framebuffer */
|
524 | 70a4568f | Corentin Chary | void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, |
525 | 70a4568f | Corentin Chary | int32_t encoding); |
526 | 70a4568f | Corentin Chary | |
527 | 70a4568f | Corentin Chary | void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v);
|
528 | 999342a0 | Corentin Chary | double vnc_update_freq(VncState *vs, int x, int y, int w, int h); |
529 | 7d964c9d | Corentin Chary | void vnc_sent_lossy_rect(VncState *vs, int x, int y, int w, int h); |
530 | 70a4568f | Corentin Chary | |
531 | 70a4568f | Corentin Chary | /* Encodings */
|
532 | bd023f95 | Corentin Chary | int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
533 | bd023f95 | Corentin Chary | |
534 | a885211e | Corentin Chary | int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
535 | 70a4568f | Corentin Chary | |
536 | a885211e | Corentin Chary | int vnc_hextile_send_framebuffer_update(VncState *vs, int x, |
537 | 70a4568f | Corentin Chary | int y, int w, int h); |
538 | 70a4568f | Corentin Chary | void vnc_hextile_set_pixel_conversion(VncState *vs, int generic); |
539 | 70a4568f | Corentin Chary | |
540 | 380282b0 | Corentin Chary | void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size); |
541 | 380282b0 | Corentin Chary | void vnc_zlib_zfree(void *x, void *addr); |
542 | a885211e | Corentin Chary | int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
543 | 161c4f20 | Corentin Chary | void vnc_zlib_clear(VncState *vs);
|
544 | 70a4568f | Corentin Chary | |
545 | 380282b0 | Corentin Chary | int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
546 | efe556ad | Corentin Chary | int vnc_tight_png_send_framebuffer_update(VncState *vs, int x, int y, |
547 | efe556ad | Corentin Chary | int w, int h); |
548 | 380282b0 | Corentin Chary | void vnc_tight_clear(VncState *vs);
|
549 | 380282b0 | Corentin Chary | |
550 | 148954fa | Corentin Chary | int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
551 | 148954fa | Corentin Chary | int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); |
552 | 148954fa | Corentin Chary | void vnc_zrle_clear(VncState *vs);
|
553 | 148954fa | Corentin Chary | |
554 | 19a490bf | aliguori | #endif /* __QEMU_VNC_H */ |