• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/usr.sbin/bhyve/

Lines Matching refs:rc

259 rfb_send_resize_update_msg(struct rfb_softc *rc, int cfd)
273 srect_hdr.width = htons(rc->width);
274 srect_hdr.height = htons(rc->height);
280 rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd)
289 rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
301 rc->enc_raw_ok = true;
304 if (!rc->enc_zlib_ok) {
305 deflateInit(&rc->zstream, Z_BEST_SPEED);
306 rc->enc_zlib_ok = true;
310 rc->enc_resize_ok = true;
338 rfb_send_update_header(struct rfb_softc *rc, int cfd, int numrects)
351 rfb_send_rect(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc,
373 if (rc->enc_zlib_ok) {
374 zbufp = rc->zbuf;
375 rc->zstream.total_in = 0;
376 rc->zstream.total_out = 0;
378 rc->zstream.next_in = (Bytef *)p;
379 rc->zstream.avail_in = w;
380 rc->zstream.next_out = (Bytef *)zbufp;
381 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16 -
382 rc->zstream.total_out;
383 rc->zstream.data_type = Z_BINARY;
386 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
389 rc->enc_zlib_ok = false;
390 deflateEnd(&rc->zstream);
393 zbufp = rc->zbuf + rc->zstream.total_out;
402 zlen = htonl(rc->zstream.total_out);
406 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
412 zbufp = rc->zbuf;
426 total = stream_write(cfd, rc->zbuf, total);
432 rfb_send_all(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc)
458 if (rc->enc_zlib_ok) {
459 rc->zstream.next_in = (Bytef *)gc->data;
460 rc->zstream.avail_in = gc->width * gc->height *
462 rc->zstream.next_out = (Bytef *)rc->zbuf;
463 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16;
464 rc->zstream.data_type = Z_BINARY;
466 rc->zstream.total_in = 0;
467 rc->zstream.total_out = 0;
470 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
473 rc->enc_zlib_ok = false;
474 deflateEnd(&rc->zstream);
484 zlen = htonl(rc->zstream.total_out);
488 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
509 rfb_send_screen(struct rfb_softc *rc, int cfd)
526 if (atomic_compare_exchange_strong(&rc->sending, &expected, true) == false)
532 if (atomic_exchange(&rc->pending, false) == false)
539 if (rc->crc_width != gc_image->width ||
540 rc->crc_height != gc_image->height) {
541 memset(rc->crc, 0, sizeof(uint32_t) *
544 rc->crc_width = gc_image->width;
545 rc->crc_height = gc_image->height;
549 if (rc->width != gc_image->width ||
550 rc->height != gc_image->height) {
551 rc->width = gc_image->width;
552 rc->height = gc_image->height;
553 if (rc->enc_resize_ok) {
554 rfb_send_resize_update_msg(rc, cfd);
555 rc->update_all = true;
560 if (atomic_exchange(&rc->update_all, false) == true) {
561 retval = rfb_send_all(rc, cfd, gc_image);
570 w = rc->crc_width;
571 h = rc->crc_height;
572 xcells = howmany(rc->crc_width, PIX_PER_CELL);
573 ycells = howmany(rc->crc_height, PIX_PER_CELL);
589 crc_p = rc->crc_tmp - xcells;
590 orig_crc = rc->crc - xcells;
592 memset(rc->crc_tmp, 0, sizeof(uint32_t) * xcells * ycells);
605 if (rc->hw_crc)
635 rc->pending = true;
641 retval = rfb_send_all(rc, cfd, gc_image);
645 rfb_send_update_header(rc, cfd, changes);
648 crc_p = rc->crc_tmp;
662 nwrite = rfb_send_rect(rc, cfd,
676 rc->sending = false;
683 rfb_recv_update_msg(struct rfb_softc *rc, int cfd)
689 rc->pending = true;
691 rc->update_all = true;
695 rfb_recv_key_msg(struct rfb_softc *rc, int cfd)
702 rc->input_detected = true;
706 rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd)
713 rc->input_detected = true;
717 rfb_recv_cuttext_msg(struct rfb_softc *rc, int cfd)
744 struct rfb_softc *rc;
752 rc = arg;
753 cfd = rc->cfd;
757 while (rc->cfd >= 0) {
774 input = atomic_exchange(&rc->input_detected, false);
779 if ((++rc->wrcount & 1) || input) {
780 if (rfb_send_screen(rc, cfd) <= 0) {
794 rfb_handle(struct rfb_softc *rc, int cfd)
815 rc->cfd = cfd;
836 if (rc->password) {
881 strncpy(keystr, rc->password, PASSWD_LENGTH);
964 if (!rc->zbuf) {
965 rc->zbuf = malloc(RFB_ZLIB_BUFSZ + 16);
966 assert(rc->zbuf != NULL);
969 perror = pthread_create(&tid, NULL, rfb_wr_thr, rc);
983 rfb_recv_set_pixfmt_msg(rc, cfd);
986 rfb_recv_set_encodings_msg(rc, cfd);
989 rfb_recv_update_msg(rc, cfd);
992 rfb_recv_key_msg(rc, cfd);
995 rfb_recv_ptr_msg(rc, cfd);
998 rfb_recv_cuttext_msg(rc, cfd);
1006 rc->cfd = -1;
1009 if (rc->enc_zlib_ok)
1010 deflateEnd(&rc->zstream);
1016 struct rfb_softc *rc;
1021 rc = arg;
1031 rc->enc_raw_ok = false;
1032 rc->enc_zlib_ok = false;
1033 rc->enc_resize_ok = false;
1035 cfd = accept(rc->sfd, NULL, NULL);
1036 if (rc->conn_wait) {
1037 pthread_mutex_lock(&rc->mtx);
1038 pthread_cond_signal(&rc->cond);
1039 pthread_mutex_unlock(&rc->mtx);
1040 rc->conn_wait = 0;
1042 rfb_handle(rc, cfd);
1067 struct rfb_softc *rc;
1076 rc = calloc(1, sizeof(struct rfb_softc));
1080 rc->crc = calloc(cnt, sizeof(uint32_t));
1081 rc->crc_tmp = calloc(cnt, sizeof(uint32_t));
1082 rc->crc_width = RFB_MAX_WIDTH;
1083 rc->crc_height = RFB_MAX_HEIGHT;
1084 rc->sfd = -1;
1086 rc->password = password;
1107 rc->sfd = socket(ai->ai_family, ai->ai_socktype, 0);
1108 if (rc->sfd < 0) {
1113 setsockopt(rc->sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
1115 if (bind(rc->sfd, ai->ai_addr, ai->ai_addrlen) < 0) {
1120 if (listen(rc->sfd, 1) < 0) {
1127 if (caph_rights_limit(rc->sfd, &rights) == -1)
1131 rc->hw_crc = sse42_supported();
1133 rc->conn_wait = wait;
1135 pthread_mutex_init(&rc->mtx, NULL);
1136 pthread_cond_init(&rc->cond, NULL);
1139 pthread_create(&rc->tid, NULL, rfb_thr, rc);
1140 pthread_set_name_np(rc->tid, "rfb");
1144 pthread_mutex_lock(&rc->mtx);
1145 pthread_cond_wait(&rc->cond, &rc->mtx);
1146 pthread_mutex_unlock(&rc->mtx);
1156 if (rc->sfd != -1)
1157 close(rc->sfd);
1158 free(rc->crc);
1159 free(rc->crc_tmp);
1160 free(rc);