wok-6.x view busybox/stuff/busybox-1.27-fbvnc.u @ rev 23353

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