rfb.c (320891) | rfb.c (336161) |
---|---|
1/*- 2 * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com> 3 * Copyright (c) 2015 Leon Dang 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com> 3 * Copyright (c) 2015 Leon Dang 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/rfb.c 320891 2017-07-11 06:39:12Z grehan $"); | 29__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/rfb.c 336161 2018-07-10 04:26:32Z araujo $"); |
30 31#include <sys/param.h> 32#include <sys/endian.h> 33#ifndef WITHOUT_CAPSICUM 34#include <sys/capsicum.h> 35#endif 36#include <sys/socket.h> 37#include <sys/select.h> --- 29 unchanged lines hidden (view full) --- 67 68static int rfb_debug = 0; 69#define DPRINTF(params) if (rfb_debug) printf params 70#define WPRINTF(params) printf params 71 72#define AUTH_LENGTH 16 73#define PASSWD_LENGTH 8 74 | 30 31#include <sys/param.h> 32#include <sys/endian.h> 33#ifndef WITHOUT_CAPSICUM 34#include <sys/capsicum.h> 35#endif 36#include <sys/socket.h> 37#include <sys/select.h> --- 29 unchanged lines hidden (view full) --- 67 68static int rfb_debug = 0; 69#define DPRINTF(params) if (rfb_debug) printf params 70#define WPRINTF(params) printf params 71 72#define AUTH_LENGTH 16 73#define PASSWD_LENGTH 8 74 |
75#define SECURITY_TYPE_NONE 1 76#define SECURITY_TYPE_VNC_AUTH 2 | 75#define SECURITY_TYPE_NONE 1 76#define SECURITY_TYPE_VNC_AUTH 2 |
77 | 77 |
78#define AUTH_FAILED_UNAUTH 1 79#define AUTH_FAILED_ERROR 2 | 78#define AUTH_FAILED_UNAUTH 1 79#define AUTH_FAILED_ERROR 2 |
80 81struct rfb_softc { 82 int sfd; 83 pthread_t tid; 84 85 int cfd; 86 87 int width, height; --- 45 unchanged lines hidden (view full) --- 133 uint8_t pad[3]; 134 struct rfb_pixfmt pixfmt; 135}; 136 137#define RFB_ENCODING_RAW 0 138#define RFB_ENCODING_ZLIB 6 139#define RFB_ENCODING_RESIZE -223 140 | 80 81struct rfb_softc { 82 int sfd; 83 pthread_t tid; 84 85 int cfd; 86 87 int width, height; --- 45 unchanged lines hidden (view full) --- 133 uint8_t pad[3]; 134 struct rfb_pixfmt pixfmt; 135}; 136 137#define RFB_ENCODING_RAW 0 138#define RFB_ENCODING_ZLIB 6 139#define RFB_ENCODING_RESIZE -223 140 |
141#define RFB_MAX_WIDTH 2000 142#define RFB_MAX_HEIGHT 1200 | 141#define RFB_MAX_WIDTH 2000 142#define RFB_MAX_HEIGHT 1200 |
143#define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4 144 145/* percentage changes to screen before sending the entire screen */ | 143#define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4 144 145/* percentage changes to screen before sending the entire screen */ |
146#define RFB_SEND_ALL_THRESH 25 | 146#define RFB_SEND_ALL_THRESH 25 |
147 148struct rfb_enc_msg { 149 uint8_t type; 150 uint8_t pad; 151 uint16_t numencs; 152}; 153 154struct rfb_updt_msg { --- 144 unchanged lines hidden (view full) --- 299} 300 301 302static int 303rfb_send_rect(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc, 304 int x, int y, int w, int h) 305{ 306 struct rfb_srvr_updt_msg supdt_msg; | 147 148struct rfb_enc_msg { 149 uint8_t type; 150 uint8_t pad; 151 uint16_t numencs; 152}; 153 154struct rfb_updt_msg { --- 144 unchanged lines hidden (view full) --- 299} 300 301 302static int 303rfb_send_rect(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc, 304 int x, int y, int w, int h) 305{ 306 struct rfb_srvr_updt_msg supdt_msg; |
307 struct rfb_srvr_rect_hdr srect_hdr; | 307 struct rfb_srvr_rect_hdr srect_hdr; |
308 unsigned long zlen; 309 ssize_t nwrite, total; 310 int err; 311 uint32_t *p; 312 uint8_t *zbufp; 313 314 /* 315 * Send a single rectangle of the given x, y, w h dimensions. --- 143 unchanged lines hidden (view full) --- 459 return (nwrite); 460 461 nwrite = stream_write(cfd, gc->data, 462 gc->width * gc->height * sizeof(uint32_t)); 463 464 return (nwrite); 465} 466 | 308 unsigned long zlen; 309 ssize_t nwrite, total; 310 int err; 311 uint32_t *p; 312 uint8_t *zbufp; 313 314 /* 315 * Send a single rectangle of the given x, y, w h dimensions. --- 143 unchanged lines hidden (view full) --- 459 return (nwrite); 460 461 nwrite = stream_write(cfd, gc->data, 462 gc->width * gc->height * sizeof(uint32_t)); 463 464 return (nwrite); 465} 466 |
467#define PIX_PER_CELL 32 | 467#define PIX_PER_CELL 32 |
468#define PIXCELL_SHIFT 5 | 468#define PIXCELL_SHIFT 5 |
469#define PIXCELL_MASK 0x1F | 469#define PIXCELL_MASK 0x1F |
470 471static int 472rfb_send_screen(struct rfb_softc *rc, int cfd, int all) 473{ 474 struct bhyvegc_image *gc_image; 475 ssize_t nwrite; 476 int x, y; 477 int celly, cellwidth; --- 246 unchanged lines hidden (view full) --- 724 prev_tv.tv_usec = 0; 725 while (rc->cfd >= 0) { 726 FD_ZERO(&rfds); 727 FD_SET(cfd, &rfds); 728 tv.tv_sec = 0; 729 tv.tv_usec = 10000; 730 731 err = select(cfd+1, &rfds, NULL, NULL, &tv); | 470 471static int 472rfb_send_screen(struct rfb_softc *rc, int cfd, int all) 473{ 474 struct bhyvegc_image *gc_image; 475 ssize_t nwrite; 476 int x, y; 477 int celly, cellwidth; --- 246 unchanged lines hidden (view full) --- 724 prev_tv.tv_usec = 0; 725 while (rc->cfd >= 0) { 726 FD_ZERO(&rfds); 727 FD_SET(cfd, &rfds); 728 tv.tv_sec = 0; 729 tv.tv_usec = 10000; 730 731 err = select(cfd+1, &rfds, NULL, NULL, &tv); |
732 if (err < 0) | 732 if (err < 0) |
733 return (NULL); 734 735 /* Determine if its time to push screen; ~24hz */ 736 gettimeofday(&tv, NULL); 737 tdiff = timeval_delta(&prev_tv, &tv); 738 if (tdiff > 40000) { 739 prev_tv.tv_sec = tv.tv_sec; 740 prev_tv.tv_usec = tv.tv_usec; --- 307 unchanged lines hidden --- | 733 return (NULL); 734 735 /* Determine if its time to push screen; ~24hz */ 736 gettimeofday(&tv, NULL); 737 tdiff = timeval_delta(&prev_tv, &tv); 738 if (tdiff > 40000) { 739 prev_tv.tv_sec = tv.tv_sec; 740 prev_tv.tv_usec = tv.tv_usec; --- 307 unchanged lines hidden --- |