wok-6.x view busybox/stuff/busybox-1.23-fbvnc.u @ rev 17889
Up qemu-* (2.0.2)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Apr 02 17:18:25 2015 +0200 (2015-04-02) |
parents | |
children | dbf4eeed945f |
line source
1 text data bss dec hex filename
2 3118 0 0 3118 c2e util-linux/fbvnc.o
3 --- /dev/null
4 +++ busybox/util-linux/fbvnc.c
5 @@ -0,0 +1,551 @@
6 +/* vi: set sw=4 ts=4: */
7 +/*
8 + * A small linux framebuffer VNC viewer
9 + *
10 + * pascal.bellard@ads-lu.com
11 + *
12 + * Based on Ali Gholami Rudi's fbvnc.c
13 + * http://repo.or.cz/w/fbvnc.git
14 + *
15 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
16 + */
17 +
18 +//applet:IF_FBVNC(APPLET(fbvnc, BB_DIR_BIN, BB_SUID_DROP))
19 +
20 +//kbuild:lib-$(CONFIG_FBVNC) += fbvnc.o
21 +
22 +//config:config FBVNC
23 +//config: bool "fbvnc"
24 +//config: default n
25 +//config: depends on PLATFORM_LINUX
26 +//config: help
27 +//config: A linux framebuffer VNC viewer.
28 +
29 +//usage:#define fbvnc_trivial_usage
30 +//usage: "[VNC_SERVER] [PORT]"
31 +//usage:#define fbvnc_full_usage "\n\n"
32 +//usage: "A linux framebuffer VNC viewer."
33 +//usage: "\nTo exit, move mouse to upper left corner and press ESC."
34 +
35 +#include "libbb.h"
36 +#include "vnc.h"
37 +
38 +/* Stuff stolen from the kernel's fb.h */
39 +#define FB_ACTIVATE_ALL 64
40 +enum {
41 + FBIOGET_VSCREENINFO = 0x4600,
42 + FBIOPUT_VSCREENINFO = 0x4601,
43 + FBIOGET_FSCREENINFO = 0x4602,
44 + FBIOGETCMAP = 0x4604,
45 + FBIOPUTCMAP = 0x4605
46 +};
47 +
48 +struct fb_bitfield {
49 + uint32_t offset; /* beginning of bitfield */
50 + uint32_t length; /* length of bitfield */
51 + uint32_t msb_right; /* !=0: Most significant bit is right */
52 +};
53 +struct fb_var_screeninfo {
54 + uint32_t xres; /* visible resolution */
55 + uint32_t yres;
56 + uint32_t xres_virtual; /* virtual resolution */
57 + uint32_t yres_virtual;
58 + uint32_t xoffset; /* offset from virtual to visible */
59 + uint32_t yoffset; /* resolution */
60 +
61 + uint32_t bits_per_pixel;
62 + uint32_t grayscale; /* !=0 Graylevels instead of colors */
63 +
64 + struct fb_bitfield red; /* bitfield in fb mem if true color, */
65 + struct fb_bitfield green; /* else only length is significant */
66 + struct fb_bitfield blue;
67 + struct fb_bitfield transp; /* transparency */
68 +
69 + uint32_t nonstd; /* !=0 Non standard pixel format */
70 +
71 + uint32_t activate; /* see FB_ACTIVATE_x */
72 +
73 + uint32_t height; /* height of picture in mm */
74 + uint32_t width; /* width of picture in mm */
75 +
76 + uint32_t accel_flags; /* acceleration flags (hints) */
77 +
78 + /* Timing: All values in pixclocks, except pixclock (of course) */
79 + uint32_t pixclock; /* pixel clock in ps (pico seconds) */
80 + uint32_t left_margin; /* time from sync to picture */
81 + uint32_t right_margin; /* time from picture to sync */
82 + uint32_t upper_margin; /* time from sync to picture */
83 + uint32_t lower_margin;
84 + uint32_t hsync_len; /* length of horizontal sync */
85 + uint32_t vsync_len; /* length of vertical sync */
86 + uint32_t sync; /* see FB_SYNC_x */
87 + uint32_t vmode; /* see FB_VMODE_x */
88 + uint32_t reserved[6]; /* Reserved for future compatibility */
89 +};
90 +
91 +#define DEFAULTFBDEV FB_0
92 +
93 +struct fb_fix_screeninfo {
94 + char id[16]; /* identification string eg "TT Builtin" */
95 + unsigned long smem_start; /* Start of frame buffer mem */
96 + /* (physical address) */
97 + uint32_t smem_len; /* Length of frame buffer mem */
98 + uint32_t type; /* see FB_TYPE_* */
99 + uint32_t type_aux; /* Interleave for interleaved Planes */
100 + uint32_t visual; /* see FB_VISUAL_* */
101 + uint16_t xpanstep; /* zero if no hardware panning */
102 + uint16_t ypanstep; /* zero if no hardware panning */
103 + uint16_t ywrapstep; /* zero if no hardware ywrap */
104 + uint32_t line_length; /* length of a line in bytes */
105 + unsigned long mmio_start; /* Start of Memory Mapped I/O */
106 + /* (physical address) */
107 + uint32_t mmio_len; /* Length of Memory Mapped I/O */
108 + uint32_t accel; /* Indicate to driver which */
109 + /* specific chip/card we have */
110 + uint16_t reserved[3]; /* Reserved for future compatibility */
111 +};
112 +
113 +struct fb_cmap {
114 + uint32_t start; /* First entry */
115 + uint32_t len; /* Number of entries */
116 + uint16_t *red; /* Red values */
117 + uint16_t *green;
118 + uint16_t *blue;
119 + uint16_t *transp; /* transparency, can be NULL */
120 +};
121 +
122 +#define FB_VISUAL_TRUECOLOR 2 /* True color */
123 +
124 +#define COLORLEVELS (1 << 8)
125 +
126 +struct scroll_data {
127 + int size;
128 + int srv_size;
129 + int offset;
130 + int pos;
131 +};
132 +
133 +struct globals {
134 + struct termios term_orig;
135 + struct pollfd ufds[3];
136 +#define kbd_fd ufds[0].fd
137 +#define vnc_fd ufds[1].fd
138 +#define rat_fd ufds[2].fd
139 + struct scroll_data scroll[2];
140 +#define cols scroll[0].size
141 +#define srv_cols scroll[0].srv_size
142 +#define oc scroll[0].offset
143 +#define mc scroll[0].pos
144 +#define rows scroll[1].size
145 +#define srv_rows scroll[1].srv_size
146 +#define or scroll[1].offset
147 +#define mr scroll[1].pos
148 + int fb_fd;
149 + void *fb_ptr;
150 + int bpp;
151 + int nr, ng, nb;
152 + struct fb_var_screeninfo vinfo;
153 + struct fb_fix_screeninfo finfo;
154 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
155 +};
156 +
157 +#define G (*ptr_to_globals)
158 +#define INIT_G() do { \
159 + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
160 +} while (0)
161 +
162 +static int fb_len(void)
163 +{
164 + return G.finfo.line_length * G.vinfo.yres_virtual;
165 +}
166 +
167 +static void fb_ioctl_cmap(int fct, struct fb_cmap *cmap)
168 +{
169 + if (G.finfo.visual == FB_VISUAL_TRUECOLOR)
170 + return;
171 + cmap->start = 0;
172 + cmap->len = MAX(G.nr, MAX(G.ng, G.nb));
173 + cmap->transp = NULL;
174 + xioctl(G.fb_fd, fct, cmap);
175 +}
176 +
177 +static void fb_cmap_save(int save)
178 +{
179 + struct fb_cmap cmap;
180 +
181 + cmap.red = G.red;
182 + cmap.green = G.green;
183 + cmap.blue = G.blue;
184 + fb_ioctl_cmap(save ? FBIOGETCMAP : FBIOPUTCMAP, &cmap);
185 +}
186 +
187 +static void fb_build_cmap(unsigned short *color, int n)
188 +{
189 + int i, inc = 65535 / (n - 1);
190 +
191 + for (i = 0; n--; i += inc)
192 + *color++ = i;
193 +}
194 +
195 +static void fb_cmap(void)
196 +{
197 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
198 + struct fb_cmap cmap;
199 +
200 + fb_build_cmap(cmap.red = red, G.nr);
201 + fb_build_cmap(cmap.green = green, G.ng);
202 + fb_build_cmap(cmap.blue = blue, G.nb);
203 + fb_ioctl_cmap(FBIOPUTCMAP, &cmap);
204 +}
205 +
206 +static void fb_init(void)
207 +{
208 + G.fb_fd = xopen(DEFAULTFBDEV, O_RDWR);
209 + xioctl(G.fb_fd, FBIOGET_VSCREENINFO, &G.vinfo);
210 + xioctl(G.fb_fd, FBIOGET_FSCREENINFO, &G.finfo);
211 + close_on_exec_on(G.fb_fd);
212 + G.fb_ptr = mmap(NULL, fb_len(), PROT_READ | PROT_WRITE, MAP_SHARED, G.fb_fd, 0);
213 + if (G.fb_ptr == MAP_FAILED)
214 + bb_perror_msg_and_die("mmap");
215 + G.bpp = (G.vinfo.bits_per_pixel + 7) >> 3;
216 + G.nr = 1 << G.vinfo.red.length;
217 + G.nb = 1 << G.vinfo.blue.length;
218 + G.ng = 1 << G.vinfo.green.length;
219 + fb_cmap_save(1);
220 + fb_cmap();
221 +}
222 +
223 +static void fb_free(void)
224 +{
225 + fb_cmap_save(0);
226 + munmap(G.fb_ptr, fb_len());
227 + close(G.fb_fd);
228 +}
229 +
230 +#define fb_rows vinfo.yres
231 +#define fb_cols vinfo.xres
232 +
233 +static void fb_set(int r, int c, void *mem, int len)
234 +{
235 + memcpy(G.fb_ptr + (r + G.vinfo.yoffset) * G.finfo.line_length +
236 + (c + G.vinfo.xoffset) * G.bpp, mem, len * G.bpp);
237 +}
238 +
239 +#define line_buffer bb_common_bufsiz1
240 +#define MAXPIX (sizeof(line_buffer)/sizeof(uint32_t))
241 +
242 +static void skip(int len)
243 +{
244 + int n;
245 + while (len > 0 && (n = read(G.vnc_fd, line_buffer,
246 + MIN(len, sizeof(line_buffer)))) > 0)
247 + len -= n;
248 +}
249 +
250 +static void vnc_init(void)
251 +{
252 + struct vnc_client_init clientinit;
253 + struct vnc_server_init serverinit;
254 + struct vnc_client_pixelfmt pixfmt_cmd;
255 + int connstat = VNC_CONN_FAILED;
256 +
257 + write(G.vnc_fd, "RFB 003.003\n", 12);
258 + skip(12);
259 +
260 + xread(G.vnc_fd, &connstat, sizeof(connstat));
261 +
262 + if (ntohl(connstat) != VNC_CONN_NOAUTH)
263 + bb_perror_msg_and_die("vnc auth");
264 +
265 + clientinit.shared = 1;
266 + write(G.vnc_fd, &clientinit, sizeof(clientinit));
267 + read(G.vnc_fd, &serverinit, sizeof(serverinit));
268 +
269 + fb_init();
270 + G.srv_cols = ntohs(serverinit.w);
271 + G.srv_rows = ntohs(serverinit.h);
272 + G.cols = MIN(G.srv_cols, G.fb_cols);
273 + G.rows = MIN(G.srv_rows, G.fb_rows);
274 + G.mr = G.rows / 2;
275 + G.mc = G.cols / 2;
276 +
277 + skip(ntohl(serverinit.len));
278 + pixfmt_cmd.type = VNC_CLIENT_PIXFMT;
279 + pixfmt_cmd.format.bigendian = 0;
280 + pixfmt_cmd.format.truecolor = 1;
281 + pixfmt_cmd.format.bpp =
282 + pixfmt_cmd.format.depth = G.bpp << 3;
283 + pixfmt_cmd.format.rmax = htons(G.nr - 1);
284 + pixfmt_cmd.format.gmax = htons(G.ng - 1);
285 + pixfmt_cmd.format.bmax = htons(G.nb - 1);
286 + pixfmt_cmd.format.rshl = G.vinfo.red.offset;
287 + pixfmt_cmd.format.gshl = G.vinfo.green.offset;
288 + pixfmt_cmd.format.bshl = G.vinfo.blue.offset;
289 + write(G.vnc_fd, &pixfmt_cmd, sizeof(pixfmt_cmd));
290 +}
291 +
292 +static void vnc_refresh(int inc)
293 +{
294 + struct vnc_client_fbup fbup_req;
295 + fbup_req.type = VNC_CLIENT_FBUP;
296 + fbup_req.inc = inc;
297 + fbup_req.x = htons(G.oc);
298 + fbup_req.y = htons(G.or);
299 + fbup_req.w = htons(G.oc + G.cols);
300 + fbup_req.h = htons(G.or + G.rows);
301 + write(G.vnc_fd, &fbup_req, sizeof(fbup_req));
302 +}
303 +
304 +static void cleanup(void)
305 +{
306 + const char *reset = "\x1b[?25h" "\x1b[2J\x1b[H";
307 + fb_free();
308 + tcsetattr_stdin_TCSANOW(&G.term_orig);
309 + write(STDOUT_FILENO, reset, strlen(reset));
310 + if (ENABLE_FEATURE_CLEAN_UP) {
311 + close(G.vnc_fd);
312 + close(G.rat_fd);
313 + }
314 +}
315 +
316 +static void killed(int code) NORETURN;
317 +static void killed(int code)
318 +{
319 + cleanup();
320 + if (code > EXIT_FAILURE)
321 + kill_myself_with_sig(code);
322 + exit(code);
323 +}
324 +
325 +static void vnc_event(void)
326 +{
327 + struct vnc_rect uprect;
328 + union {
329 + struct vnc_server_fbup fbup;
330 + struct vnc_server_cuttext cuttext;
331 + struct vnc_server_colormap colormap;
332 + } msg;
333 + int n;
334 +
335 + switch (xread_char(G.vnc_fd)) {
336 + case VNC_SERVER_FBUP:
337 + xread(G.vnc_fd, &msg.fbup.pad, sizeof(msg.fbup) - 1);
338 + n = ntohs(msg.fbup.n);
339 + while (n--) {
340 + int x, y, w, h, l, i;
341 + xread(G.vnc_fd, &uprect, sizeof(uprect));
342 + if (uprect.enc != 0)
343 + killed(1);
344 + i = 0;
345 + x = ntohs(uprect.x) - G.oc;
346 + y = ntohs(uprect.y) - G.or;
347 + w = ntohs(uprect.w);
348 + h = ntohs(uprect.h);
349 + l = MIN(w, G.cols - x);
350 + if (x < 0) {
351 + l = MIN(w + x, G.cols);
352 + i = -x;
353 + x = 0;
354 + }
355 + for (; h--; y++) {
356 + int a, b, c = i;
357 + for (a = b = 0; w > b; b += a, c = 0) {
358 + int len;
359 + a = MIN(w - b, MAXPIX);
360 + len = MIN(a, l - b) - c;
361 + xread(G.vnc_fd, line_buffer, a * G.bpp);
362 + if (y >= 0 && y < G.rows && len > 0)
363 + fb_set(y, x + b,
364 + line_buffer + (c * G.bpp),
365 + len);
366 + }
367 + }
368 + }
369 + break;
370 + case VNC_SERVER_BELL:
371 + break;
372 + case VNC_SERVER_CUTTEXT:
373 + xread(G.vnc_fd, &msg.cuttext.pad1, sizeof(msg.cuttext) - 1);
374 + skip(ntohl(msg.cuttext.len));
375 + break;
376 + case VNC_SERVER_COLORMAP:
377 + xread(G.vnc_fd, &msg.colormap.pad, sizeof(msg.colormap) - 1);
378 + skip(ntohs(msg.colormap.n) * 3 * 2);
379 + break;
380 + default:
381 + killed(1);
382 + }
383 +}
384 +
385 +static int update_scroll(struct scroll_data *s)
386 +{
387 + int shift = s->size / 5;
388 + int max = s->srv_size - s->size;
389 + int status = 0;
390 + if (s->pos < s->offset) {
391 + if ((s->offset -= shift) < 0)
392 + s->offset = 0;
393 + }
394 + else if (s->pos >= s->offset + s->size && s->offset < max) {
395 + if ((s->offset += shift) > max)
396 + s->offset = max;
397 + }
398 + else status++;
399 + s->pos = MAX(s->offset, MIN(s->offset + s->size - 1, s->pos));
400 + return status;
401 +}
402 +
403 +static void rat_event(void)
404 +{
405 + signed char ie[3];
406 + struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT};
407 + int mask = 0;
408 + int refresh;
409 +
410 + xread(G.rat_fd, &ie, sizeof(ie));
411 + G.mc += ie[1];
412 + G.mr -= ie[2];
413 + refresh = 2 - update_scroll(&G.scroll[0]) - update_scroll(&G.scroll[1]);
414 + if (ie[0] & 0x01)
415 + mask |= VNC_BUTTON1_MASK;
416 + if (ie[0] & 0x04)
417 + mask |= VNC_BUTTON2_MASK;
418 + if (ie[0] & 0x02)
419 + mask |= VNC_BUTTON3_MASK;
420 + me.y = htons(G.mr);
421 + me.x = htons(G.mc);
422 + me.mask = mask;
423 + write(G.vnc_fd, &me, sizeof(me));
424 + if (refresh)
425 + vnc_refresh(0);
426 +}
427 +
428 +static int press(int key, int down)
429 +{
430 + struct vnc_client_keyevent ke = {VNC_CLIENT_KEYEVENT};
431 + ke.key = htonl(key);
432 + ke.down = down;
433 + return write(G.vnc_fd, &ke, sizeof(ke));
434 +}
435 +
436 +static void kbd_event(void)
437 +{
438 + char key[1024];
439 + int i, nr;
440 +
441 + if ((nr = read(0, key, sizeof(key))) <= 0 )
442 + killed(1);
443 + for (i = 0; i < nr; i++) {
444 + int k = -1;
445 + int mod[4];
446 + int nmod = 0;
447 + switch (key[i]) {
448 + case 0x08:
449 + case 0x7f:
450 + k = 0xff08;
451 + break;
452 + case 0x09:
453 + k = 0xff09;
454 + break;
455 + case 0x1b:
456 + if (G.oc + G.mc + G.or + G.mr == 0)
457 + killed(0);
458 + if (i + 2 < nr && key[i + 1] == '[') {
459 + if (key[i + 2] == 'A')
460 + k = 0xff52;
461 + if (key[i + 2] == 'B')
462 + k = 0xff54;
463 + if (key[i + 2] == 'C')
464 + k = 0xff53;
465 + if (key[i + 2] == 'D')
466 + k = 0xff51;
467 + if (key[i + 2] == 'H')
468 + k = 0xff50;
469 + if (k > 0) {
470 + i += 2;
471 + break;
472 + }
473 + }
474 + k = 0xff1b;
475 + if (i + 1 < nr) {
476 + mod[nmod++] = 0xffe9;
477 + k = key[++i];
478 + }
479 + break;
480 + case 0x0d:
481 + k = 0xff0d;
482 + break;
483 + case 0x0c: /* ^L: redraw */
484 + vnc_refresh(0);
485 + default:
486 + k = (unsigned char) key[i];
487 + }
488 + if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
489 + mod[nmod++] = 0xffe1;
490 + if (k >= 1 && k <= 26) {
491 + k += 'a' - 1;
492 + mod[nmod++] = 0xffe3;
493 + }
494 + if (k > 0) {
495 + int j;
496 + mod[nmod] = k;
497 + for (j = 0; j <= nmod; j++)
498 + press(mod[j], 1);
499 + press(k, 0);
500 + for (j = 0; j < nmod; j++)
501 + press(mod[j], 0);
502 + }
503 + }
504 +}
505 +
506 +static void term_setup(void)
507 +{
508 + struct termios termios;
509 + const char *init = "\x1b[?25l" "\x1b[2J\x1b[H" "** fbvnc **";
510 +
511 + write(STDOUT_FILENO, init, strlen(init));
512 + tcgetattr (STDIN_FILENO, &termios);
513 + G.term_orig = termios;
514 + cfmakeraw(&termios);
515 + tcsetattr_stdin_TCSANOW(&termios);
516 +}
517 +
518 +int fbvnc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
519 +int fbvnc_main(int argc, char **argv)
520 +{
521 + char *host = (char *) "127.0.0.1";
522 + int port, pending = 0;
523 +
524 + INIT_G();
525 + if (argc >= 2)
526 + host = argv[1];
527 + port = bb_lookup_port((argc >= 3) ? argv[2] : "vnc", "tcp", 5900);
528 + G.vnc_fd = create_and_connect_stream_or_die(host, port);
529 + vnc_init();
530 + G.rat_fd = open("/dev/input/mice", O_RDONLY);
531 + term_setup();
532 + atexit(cleanup);
533 + bb_signals(BB_FATAL_SIGS, killed);
534 +
535 + G.ufds[0].events =
536 + G.ufds[1].events =
537 + G.ufds[2].events = POLLIN;
538 + vnc_refresh(0);
539 + while (1) {
540 + int status = poll(G.ufds, 3, 500);
541 + if (status == -1 && errno != EINTR)
542 + killed(1);
543 + if (!status)
544 + continue;
545 + if (G.ufds[0].revents & POLLIN)
546 + kbd_event();
547 + if (G.ufds[1].revents & POLLIN) {
548 + vnc_event();
549 + pending = 0;
550 + }
551 + if (G.ufds[2].revents & POLLIN)
552 + rat_event();
553 + if (!pending++)
554 + vnc_refresh(1);
555 + }
556 +}
557 --- /dev/null
558 +++ busybox/util-linux/vnc.h
559 @@ -0,0 +1,122 @@
560 +#define VNC_CONN_FAILED 0
561 +#define VNC_CONN_NOAUTH 1
562 +#define VNC_CONN_AUTH 2
563 +
564 +#define VNC_AUTH_OK 0
565 +#define VNC_AUTH_FAILED 1
566 +#define VNC_AUTH_TOOMANY 2
567 +
568 +#define VNC_SERVER_FBUP 0
569 +#define VNC_SERVER_COLORMAP 1
570 +#define VNC_SERVER_BELL 2
571 +#define VNC_SERVER_CUTTEXT 3
572 +
573 +#define VNC_CLIENT_PIXFMT 0
574 +#define VNC_CLIENT_COLORMAP 1
575 +#define VNC_CLIENT_SETENC 2
576 +#define VNC_CLIENT_FBUP 3
577 +#define VNC_CLIENT_KEYEVENT 4
578 +#define VNC_CLIENT_RATEVENT 5
579 +#define VNC_CLIENT_CUTTEXT 6
580 +
581 +#define VNC_ENC_RAW 0
582 +#define VNC_ENC_COPYRECT 1
583 +#define VNC_ENC_RRE 2
584 +#define VNC_ENC_CORRE 4
585 +#define VNC_ENC_HEXTILE 5
586 +
587 +#define VNC_BUTTON1_MASK 0x1
588 +#define VNC_BUTTON2_MASK 0x2
589 +#define VNC_BUTTON3_MASK 0x4
590 +
591 +typedef unsigned char u8;
592 +typedef unsigned short u16;
593 +typedef unsigned int u32;
594 +
595 +struct vnc_pixelfmt {
596 + u8 bpp;
597 + u8 depth;
598 + u8 bigendian;
599 + u8 truecolor;
600 + u16 rmax;
601 + u16 gmax;
602 + u16 bmax;
603 + u8 rshl;
604 + u8 gshl;
605 + u8 bshl;
606 +
607 + u8 pad1;
608 + u16 pad2;
609 +};
610 +
611 +struct vnc_client_init {
612 + u8 shared;
613 +};
614 +
615 +struct vnc_server_init {
616 + u16 w;
617 + u16 h;
618 + struct vnc_pixelfmt fmt;
619 + u32 len;
620 + /* char name[len]; */
621 +};
622 +
623 +struct vnc_rect {
624 + u16 x, y;
625 + u16 w, h;
626 + u32 enc;
627 + /* rect bytes */
628 +};
629 +
630 +struct vnc_server_fbup {
631 + u8 type;
632 + u8 pad;
633 + u16 n;
634 + /* struct vnc_rect rects[n]; */
635 +};
636 +
637 +struct vnc_server_cuttext {
638 + u8 type;
639 + u8 pad1;
640 + u16 pad2;
641 + u32 len;
642 + /* char text[length] */
643 +};
644 +
645 +struct vnc_server_colormap {
646 + u8 type;
647 + u8 pad;
648 + u16 first;
649 + u16 n;
650 + /* u8 colors[n * 3 * 2]; */
651 +};
652 +
653 +struct vnc_client_pixelfmt {
654 + u8 type;
655 + u8 pad1;
656 + u16 pad2;
657 + struct vnc_pixelfmt format;
658 +};
659 +
660 +struct vnc_client_fbup {
661 + u8 type;
662 + u8 inc;
663 + u16 x;
664 + u16 y;
665 + u16 w;
666 + u16 h;
667 +};
668 +
669 +struct vnc_client_keyevent {
670 + u8 type;
671 + u8 down;
672 + u16 pad;
673 + u32 key;
674 +};
675 +
676 +struct vnc_client_ratevent {
677 + u8 type;
678 + u8 mask;
679 + u16 x;
680 + u16 y;
681 +};