wok-6.x view busybox/stuff/busybox-1.23-fbvnc.u @ rev 19621
dhcp: vlan support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Jan 10 16:46:56 2017 +0100 (2017-01-10) |
parents | 2be6ee0ddc5a |
children |
line source
1 text data bss dec hex filename
2 3122 0 0 3122 c32 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, press any mouse button 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 + char rat_buttons;
149 + int fb_fd;
150 + void *fb_ptr;
151 + int bpp;
152 + int nr, ng, nb;
153 + struct fb_var_screeninfo vinfo;
154 + struct fb_fix_screeninfo finfo;
155 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
156 +};
157 +
158 +#define G (*ptr_to_globals)
159 +#define INIT_G() do { \
160 + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
161 +} while (0)
162 +
163 +static int fb_len(void)
164 +{
165 + return G.finfo.line_length * G.vinfo.yres_virtual;
166 +}
167 +
168 +static void fb_ioctl_cmap(int fct, struct fb_cmap *cmap)
169 +{
170 + if (G.finfo.visual == FB_VISUAL_TRUECOLOR)
171 + return;
172 + cmap->start = 0;
173 + cmap->len = MAX(G.nr, MAX(G.ng, G.nb));
174 + cmap->transp = NULL;
175 + xioctl(G.fb_fd, fct, cmap);
176 +}
177 +
178 +static void fb_cmap_save(int save)
179 +{
180 + struct fb_cmap cmap;
181 +
182 + cmap.red = G.red;
183 + cmap.green = G.green;
184 + cmap.blue = G.blue;
185 + fb_ioctl_cmap(save ? FBIOGETCMAP : FBIOPUTCMAP, &cmap);
186 +}
187 +
188 +static void fb_build_cmap(unsigned short *color, int n)
189 +{
190 + int i, inc = 65535 / (n - 1);
191 +
192 + for (i = 0; n--; i += inc)
193 + *color++ = i;
194 +}
195 +
196 +static void fb_cmap(void)
197 +{
198 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
199 + struct fb_cmap cmap;
200 +
201 + fb_build_cmap(cmap.red = red, G.nr);
202 + fb_build_cmap(cmap.green = green, G.ng);
203 + fb_build_cmap(cmap.blue = blue, G.nb);
204 + fb_ioctl_cmap(FBIOPUTCMAP, &cmap);
205 +}
206 +
207 +static void fb_init(void)
208 +{
209 + G.fb_fd = xopen(DEFAULTFBDEV, O_RDWR);
210 + xioctl(G.fb_fd, FBIOGET_VSCREENINFO, &G.vinfo);
211 + xioctl(G.fb_fd, FBIOGET_FSCREENINFO, &G.finfo);
212 + close_on_exec_on(G.fb_fd);
213 + G.fb_ptr = mmap(NULL, fb_len(), PROT_READ | PROT_WRITE, MAP_SHARED, G.fb_fd, 0);
214 + if (G.fb_ptr == MAP_FAILED)
215 + bb_perror_msg_and_die("mmap");
216 + G.bpp = (G.vinfo.bits_per_pixel + 7) >> 3;
217 + G.nr = 1 << G.vinfo.red.length;
218 + G.nb = 1 << G.vinfo.blue.length;
219 + G.ng = 1 << G.vinfo.green.length;
220 + fb_cmap_save(1);
221 + fb_cmap();
222 +}
223 +
224 +static void fb_free(void)
225 +{
226 + fb_cmap_save(0);
227 + munmap(G.fb_ptr, fb_len());
228 + close(G.fb_fd);
229 +}
230 +
231 +#define fb_rows vinfo.yres
232 +#define fb_cols vinfo.xres
233 +
234 +static void fb_set(int r, int c, void *mem, int len)
235 +{
236 + memcpy(G.fb_ptr + (r + G.vinfo.yoffset) * G.finfo.line_length +
237 + (c + G.vinfo.xoffset) * G.bpp, mem, len * G.bpp);
238 +}
239 +
240 +#define line_buffer bb_common_bufsiz1
241 +#define MAXPIX (sizeof(line_buffer)/sizeof(uint32_t))
242 +
243 +static void skip(int len)
244 +{
245 + int n;
246 + while (len > 0 && (n = read(G.vnc_fd, line_buffer,
247 + MIN(len, sizeof(line_buffer)))) > 0)
248 + len -= n;
249 +}
250 +
251 +static void vnc_init(void)
252 +{
253 + struct vnc_client_init clientinit;
254 + struct vnc_server_init serverinit;
255 + struct vnc_client_pixelfmt pixfmt_cmd;
256 + int connstat = VNC_CONN_FAILED;
257 +
258 + write(G.vnc_fd, "RFB 003.003\n", 12);
259 + skip(12);
260 +
261 + xread(G.vnc_fd, &connstat, sizeof(connstat));
262 +
263 + if (ntohl(connstat) != VNC_CONN_NOAUTH)
264 + bb_perror_msg_and_die("vnc auth");
265 +
266 + clientinit.shared = 1;
267 + write(G.vnc_fd, &clientinit, sizeof(clientinit));
268 + read(G.vnc_fd, &serverinit, sizeof(serverinit));
269 +
270 + fb_init();
271 + G.srv_cols = ntohs(serverinit.w);
272 + G.srv_rows = ntohs(serverinit.h);
273 + G.cols = MIN(G.srv_cols, G.fb_cols);
274 + G.rows = MIN(G.srv_rows, G.fb_rows);
275 + G.mr = G.rows / 2;
276 + G.mc = G.cols / 2;
277 +
278 + skip(ntohl(serverinit.len));
279 + pixfmt_cmd.type = VNC_CLIENT_PIXFMT;
280 + pixfmt_cmd.format.bigendian = 0;
281 + pixfmt_cmd.format.truecolor = 1;
282 + pixfmt_cmd.format.bpp =
283 + pixfmt_cmd.format.depth = G.bpp << 3;
284 + pixfmt_cmd.format.rmax = htons(G.nr - 1);
285 + pixfmt_cmd.format.gmax = htons(G.ng - 1);
286 + pixfmt_cmd.format.bmax = htons(G.nb - 1);
287 + pixfmt_cmd.format.rshl = G.vinfo.red.offset;
288 + pixfmt_cmd.format.gshl = G.vinfo.green.offset;
289 + pixfmt_cmd.format.bshl = G.vinfo.blue.offset;
290 + write(G.vnc_fd, &pixfmt_cmd, sizeof(pixfmt_cmd));
291 +}
292 +
293 +static void vnc_refresh(int inc)
294 +{
295 + struct vnc_client_fbup fbup_req;
296 + fbup_req.type = VNC_CLIENT_FBUP;
297 + fbup_req.inc = inc;
298 + fbup_req.x = htons(G.oc);
299 + fbup_req.y = htons(G.or);
300 + fbup_req.w = htons(G.oc + G.cols);
301 + fbup_req.h = htons(G.or + G.rows);
302 + write(G.vnc_fd, &fbup_req, sizeof(fbup_req));
303 +}
304 +
305 +static void cleanup(void)
306 +{
307 +#define RESETSTR "\x1b[?25h\x1b[2J\x1b[H"
308 + fb_free();
309 + tcsetattr_stdin_TCSANOW(&G.term_orig);
310 + write(STDOUT_FILENO, RESETSTR, sizeof(RESETSTR));
311 + if (ENABLE_FEATURE_CLEAN_UP) {
312 + close(G.vnc_fd);
313 + close(G.rat_fd);
314 + }
315 +}
316 +
317 +static void killed(int code) NORETURN;
318 +static void killed(int code)
319 +{
320 + cleanup();
321 + if (code > EXIT_FAILURE)
322 + kill_myself_with_sig(code);
323 + exit(code);
324 +}
325 +
326 +static void vnc_event(void)
327 +{
328 + struct vnc_rect uprect;
329 + union {
330 + struct vnc_server_fbup fbup;
331 + struct vnc_server_cuttext cuttext;
332 + struct vnc_server_colormap colormap;
333 + } msg;
334 + int n;
335 +
336 + switch (xread_char(G.vnc_fd)) {
337 + case VNC_SERVER_FBUP:
338 + xread(G.vnc_fd, &msg.fbup.pad, sizeof(msg.fbup) - 1);
339 + n = ntohs(msg.fbup.n);
340 + while (n--) {
341 + int x, y, w, h, l, i;
342 + xread(G.vnc_fd, &uprect, sizeof(uprect));
343 + if (uprect.enc != 0)
344 + killed(1);
345 + i = 0;
346 + x = ntohs(uprect.x) - G.oc;
347 + y = ntohs(uprect.y) - G.or;
348 + w = ntohs(uprect.w);
349 + h = ntohs(uprect.h);
350 + l = MIN(w, G.cols - x);
351 + if (x < 0) {
352 + l = MIN(w + x, G.cols);
353 + i = -x;
354 + x = 0;
355 + }
356 + for (; h--; y++) {
357 + int a, b, c = i;
358 + for (a = b = 0; w > b; b += a, c = 0) {
359 + int len;
360 + a = MIN(w - b, MAXPIX);
361 + len = MIN(a, l - b) - c;
362 + xread(G.vnc_fd, line_buffer, a * G.bpp);
363 + if (y >= 0 && y < G.rows && len > 0)
364 + fb_set(y, x + b,
365 + line_buffer + (c * G.bpp),
366 + len);
367 + }
368 + }
369 + }
370 + break;
371 + case VNC_SERVER_BELL:
372 + break;
373 + case VNC_SERVER_CUTTEXT:
374 + xread(G.vnc_fd, &msg.cuttext.pad1, sizeof(msg.cuttext) - 1);
375 + skip(ntohl(msg.cuttext.len));
376 + break;
377 + case VNC_SERVER_COLORMAP:
378 + xread(G.vnc_fd, &msg.colormap.pad, sizeof(msg.colormap) - 1);
379 + skip(ntohs(msg.colormap.n) * 3 * 2);
380 + break;
381 + default:
382 + killed(1);
383 + }
384 +}
385 +
386 +static int update_scroll(struct scroll_data *s)
387 +{
388 + int shift = s->size / 5;
389 + int max = s->srv_size - s->size;
390 + int status = 0;
391 + if (s->pos < s->offset) {
392 + if ((s->offset -= shift) < 0)
393 + s->offset = 0;
394 + }
395 + else if (s->pos >= s->offset + s->size && s->offset < max) {
396 + if ((s->offset += shift) > max)
397 + s->offset = max;
398 + }
399 + else status++;
400 + s->pos = MAX(s->offset, MIN(s->offset + s->size - 1, s->pos));
401 + return status;
402 +}
403 +
404 +static void rat_event(void)
405 +{
406 + static u8 btn2vnc[8] = {
407 + 0, VNC_BUTTON1_MASK, VNC_BUTTON3_MASK,
408 + VNC_BUTTON1_MASK + VNC_BUTTON3_MASK, VNC_BUTTON2_MASK,
409 + VNC_BUTTON1_MASK + VNC_BUTTON2_MASK,
410 + VNC_BUTTON2_MASK + VNC_BUTTON3_MASK,
411 + VNC_BUTTON1_MASK + VNC_BUTTON2_MASK + VNC_BUTTON3_MASK
412 + };
413 + signed char ie[4];
414 + struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT};
415 + int refresh;
416 +
417 + xread(G.rat_fd, &ie, sizeof(ie));
418 + G.mc += ie[1];
419 + G.mr -= ie[2];
420 + refresh = 2 - update_scroll(&G.scroll[0]) - update_scroll(&G.scroll[1]);
421 + me.mask = btn2vnc[(int)(G.rat_buttons = ie[0] & 7)];
422 + if (ie[3] > 0) /* wheel up */
423 + me.mask |= VNC_BUTTON4_MASK;
424 + if (ie[3] < 0) /* wheel down */
425 + me.mask |= VNC_BUTTON5_MASK;
426 + me.y = htons(G.mr);
427 + me.x = htons(G.mc);
428 + write(G.vnc_fd, &me, sizeof(me));
429 + if (refresh)
430 + vnc_refresh(0);
431 +}
432 +
433 +static int press(int key, int down)
434 +{
435 + struct vnc_client_keyevent ke = {VNC_CLIENT_KEYEVENT};
436 + ke.key = htonl(key);
437 + ke.down = down;
438 + return write(G.vnc_fd, &ke, sizeof(ke));
439 +}
440 +
441 +static void kbd_event(void)
442 +{
443 + char key[1024];
444 + int i, nr;
445 +
446 + if ((nr = read(0, key, sizeof(key))) <= 0 )
447 + killed(1);
448 + for (i = 0; i < nr; i++) {
449 + int j, k;
450 + int mod[4];
451 + int nmod;
452 +
453 + k = nmod = 0;
454 + switch (key[i]) {
455 + case 0x08:
456 + case 0x7f:
457 + k = 0xff08;
458 + break;
459 + case 0x1b:
460 + if (G.rat_buttons)
461 + killed(0);
462 + if (i + 2 < nr && key[i + 1] == '[') {
463 + static const char arr2vnc[] = "HDACB";
464 + char *p = strchr(arr2vnc, key[i + 2]);
465 +
466 + if (p) {
467 + k = p - arr2vnc + 0xff50;
468 + i += 2;
469 + break;
470 + }
471 + }
472 + if (i + 1 < nr) {
473 + mod[nmod++] = 0xffe9;
474 + i++;
475 + }
476 + case 0x09:
477 + case 0x0d:
478 + k = 0xff00;
479 + goto getkey;
480 + case 0x0c: /* Mouse button + ^L: redraw */
481 + if (G.rat_buttons) {
482 + vnc_refresh(0);
483 + continue;
484 + }
485 + default:
486 + getkey:
487 + k += (unsigned char) key[i];
488 + }
489 + if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
490 + mod[nmod++] = 0xffe1;
491 + if (k >= 1 && k <= 26) {
492 + k += 'a' - 1;
493 + mod[nmod++] = 0xffe3;
494 + }
495 + mod[nmod] = k;
496 + for (j = 0; j <= nmod; j++)
497 + press(mod[j], 1);
498 + press(k, 0);
499 + for (j = 0; j < nmod; j++)
500 + press(mod[j], 0);
501 + }
502 +}
503 +
504 +static void term_setup(void)
505 +{
506 + struct termios termios;
507 +#define INITSTR "\x1b[?25l\x1b[2J\x1b[H** fbvnc **"
508 +
509 + write(STDOUT_FILENO, INITSTR, sizeof(INITSTR));
510 + tcgetattr (STDIN_FILENO, &termios);
511 + G.term_orig = termios;
512 + cfmakeraw(&termios);
513 + tcsetattr_stdin_TCSANOW(&termios);
514 +}
515 +
516 +int fbvnc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
517 +int fbvnc_main(int argc, char **argv)
518 +{
519 + char *host = (char *) "127.0.0.1";
520 + int port, pending = 0;
521 +
522 + INIT_G();
523 + if (argc >= 2)
524 + host = argv[1];
525 + port = bb_lookup_port((argc >= 3) ? argv[2] : "vnc", "tcp", 5900);
526 + G.vnc_fd = create_and_connect_stream_or_die(host, port);
527 + vnc_init();
528 + G.rat_fd = open("/dev/input/mice", O_RDWR);
529 + write(G.rat_fd, "\xf3\xc8\xf3\x64\xf3\x50", 6); /* for using mouse wheel */
530 + read(G.rat_fd, line_buffer, 1);
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,124 @@
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 0x01
588 +#define VNC_BUTTON2_MASK 0x02
589 +#define VNC_BUTTON3_MASK 0x04
590 +#define VNC_BUTTON4_MASK 0x10
591 +#define VNC_BUTTON5_MASK 0x08
592 +
593 +typedef unsigned char u8;
594 +typedef unsigned short u16;
595 +typedef unsigned int u32;
596 +
597 +struct vnc_pixelfmt {
598 + u8 bpp;
599 + u8 depth;
600 + u8 bigendian;
601 + u8 truecolor;
602 + u16 rmax;
603 + u16 gmax;
604 + u16 bmax;
605 + u8 rshl;
606 + u8 gshl;
607 + u8 bshl;
608 +
609 + u8 pad1;
610 + u16 pad2;
611 +};
612 +
613 +struct vnc_client_init {
614 + u8 shared;
615 +};
616 +
617 +struct vnc_server_init {
618 + u16 w;
619 + u16 h;
620 + struct vnc_pixelfmt fmt;
621 + u32 len;
622 + /* char name[len]; */
623 +};
624 +
625 +struct vnc_rect {
626 + u16 x, y;
627 + u16 w, h;
628 + u32 enc;
629 + /* rect bytes */
630 +};
631 +
632 +struct vnc_server_fbup {
633 + u8 type;
634 + u8 pad;
635 + u16 n;
636 + /* struct vnc_rect rects[n]; */
637 +};
638 +
639 +struct vnc_server_cuttext {
640 + u8 type;
641 + u8 pad1;
642 + u16 pad2;
643 + u32 len;
644 + /* char text[length] */
645 +};
646 +
647 +struct vnc_server_colormap {
648 + u8 type;
649 + u8 pad;
650 + u16 first;
651 + u16 n;
652 + /* u8 colors[n * 3 * 2]; */
653 +};
654 +
655 +struct vnc_client_pixelfmt {
656 + u8 type;
657 + u8 pad1;
658 + u16 pad2;
659 + struct vnc_pixelfmt format;
660 +};
661 +
662 +struct vnc_client_fbup {
663 + u8 type;
664 + u8 inc;
665 + u16 x;
666 + u16 y;
667 + u16 w;
668 + u16 h;
669 +};
670 +
671 +struct vnc_client_keyevent {
672 + u8 type;
673 + u8 down;
674 + u16 pad;
675 + u32 key;
676 +};
677 +
678 +struct vnc_client_ratevent {
679 + u8 type;
680 + u8 mask;
681 + u16 x;
682 + u16 y;
683 +};