2016-04-17 16:20:14 +02:00
|
|
|
/****************************************************************************
|
2021-12-31 09:22:11 +01:00
|
|
|
* drivers/video/vnc/vnc_receiver.c
|
2016-04-17 16:20:14 +02:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2016-04-17 16:20:14 +02:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-04-17 16:20:14 +02:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-04-17 16:20:14 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2016-04-17 17:17:37 +02:00
|
|
|
#include <assert.h>
|
2016-04-17 16:20:14 +02:00
|
|
|
#include <errno.h>
|
2016-04-23 17:06:39 +02:00
|
|
|
|
|
|
|
#if defined(CONFIG_VNCSERVER_DEBUG) && !defined(CONFIG_DEBUG_GRAPHICS)
|
2016-06-11 22:14:08 +02:00
|
|
|
# undef CONFIG_DEBUG_ERROR
|
|
|
|
# undef CONFIG_DEBUG_WARN
|
2016-06-11 19:50:18 +02:00
|
|
|
# undef CONFIG_DEBUG_INFO
|
2019-03-17 18:34:45 +01:00
|
|
|
# undef CONFIG_DEBUG_GRAPHICS_ERROR
|
|
|
|
# undef CONFIG_DEBUG_GRAPHICS_WARN
|
|
|
|
# undef CONFIG_DEBUG_GRAPHICS_INFO
|
|
|
|
# define CONFIG_DEBUG_ERROR 1
|
|
|
|
# define CONFIG_DEBUG_WARN 1
|
|
|
|
# define CONFIG_DEBUG_INFO 1
|
|
|
|
# define CONFIG_DEBUG_GRAPHICS 1
|
|
|
|
# define CONFIG_DEBUG_GRAPHICS_ERROR 1
|
|
|
|
# define CONFIG_DEBUG_GRAPHICS_WARN 1
|
|
|
|
# define CONFIG_DEBUG_GRAPHICS_INFO 1
|
2016-04-23 17:06:39 +02:00
|
|
|
#endif
|
2016-04-17 17:17:37 +02:00
|
|
|
#include <debug.h>
|
|
|
|
|
2016-04-19 14:59:33 +02:00
|
|
|
#ifdef CONFIG_NET_SOCKOPTS
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
2016-04-17 17:17:37 +02:00
|
|
|
#include <nuttx/net/net.h>
|
|
|
|
#include <nuttx/video/rfb.h>
|
2016-04-22 20:48:27 +02:00
|
|
|
#include <nuttx/video/vnc.h>
|
2021-12-30 18:55:40 +01:00
|
|
|
#include <nuttx/input/mouse.h>
|
2016-04-17 16:20:14 +02:00
|
|
|
|
|
|
|
#include "vnc_server.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-04-17 21:35:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: vnc_read_remainder
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* After receiving the first byte of a client-to-server message, this
|
|
|
|
* reads in the remainder of the message.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* session - An instance of the session structure.
|
|
|
|
* msglen - The full length of the message
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* At present, always returns OK
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int vnc_read_remainder(FAR struct vnc_session_s *session, size_t msglen,
|
|
|
|
size_t offset)
|
|
|
|
{
|
|
|
|
ssize_t nrecvd;
|
|
|
|
size_t ntotal;
|
|
|
|
|
2019-09-11 16:56:56 +02:00
|
|
|
/* Loop until the rest of the message is received. */
|
2016-04-17 21:35:51 +02:00
|
|
|
|
|
|
|
for (ntotal = 0; ntotal < msglen; offset += nrecvd, ntotal += nrecvd)
|
|
|
|
{
|
|
|
|
/* Receive more of the message */
|
|
|
|
|
|
|
|
nrecvd = psock_recv(&session->connect, &session->inbuf[offset],
|
|
|
|
msglen - ntotal, 0);
|
|
|
|
if (nrecvd < 0)
|
|
|
|
{
|
2018-01-31 00:23:10 +01:00
|
|
|
gerr("ERROR: Receive message failed: %d\n", (int)nrecvd);
|
2018-01-31 18:31:12 +01:00
|
|
|
return (int)nrecvd;
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2016-04-17 16:20:14 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: vnc_receiver
|
|
|
|
*
|
|
|
|
* Description:
|
2016-04-17 21:35:51 +02:00
|
|
|
* This function handles all Client-to-Server messages.
|
2016-04-17 16:20:14 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* session - An instance of the session structure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* At present, always returns OK
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int vnc_receiver(FAR struct vnc_session_s *session)
|
|
|
|
{
|
2016-04-19 14:59:33 +02:00
|
|
|
#ifdef CONFIG_NET_SOCKOPTS
|
|
|
|
struct timeval tv;
|
|
|
|
#endif
|
2016-04-17 17:17:37 +02:00
|
|
|
ssize_t nrecvd;
|
2016-04-17 21:35:51 +02:00
|
|
|
int ret;
|
2016-04-17 17:17:37 +02:00
|
|
|
|
2016-04-19 02:55:36 +02:00
|
|
|
DEBUGASSERT(session);
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Receiver running for Display %d\n", session->display);
|
2016-04-19 02:55:36 +02:00
|
|
|
|
2016-04-19 14:59:33 +02:00
|
|
|
#ifdef CONFIG_NET_SOCKOPTS
|
|
|
|
/* Disable the receive timeout so that we will wait indefinitely for the
|
|
|
|
* next Client-to-Server message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
ret = psock_setsockopt(&session->connect, SOL_SOCKET, SO_RCVTIMEO,
|
|
|
|
&tv, sizeof(struct timeval));
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2018-01-31 00:23:10 +01:00
|
|
|
gerr("ERROR: Failed to disable receive timeout: %d\n", ret);
|
|
|
|
return ret;
|
2016-04-19 14:59:33 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-04-17 17:17:37 +02:00
|
|
|
/* Loop until the client disconnects or an unhandled error occurs */
|
|
|
|
|
|
|
|
for (; ; )
|
|
|
|
{
|
|
|
|
/* Set up to read one byte which should be the message type of the
|
|
|
|
* next Client-to-Server message. We will block here until the message
|
|
|
|
* is received.
|
|
|
|
*/
|
|
|
|
|
|
|
|
nrecvd = psock_recv(&session->connect, session->inbuf, 1, 0);
|
|
|
|
if (nrecvd < 0)
|
|
|
|
{
|
2018-01-31 00:23:10 +01:00
|
|
|
gerr("ERROR: Receive byte failed: %d\n", (int)nrecvd);
|
|
|
|
return (int)nrecvd;
|
2016-04-17 17:17:37 +02:00
|
|
|
}
|
|
|
|
|
2016-04-23 18:57:28 +02:00
|
|
|
/* A return value of zero means that the connection was gracefully
|
|
|
|
* closed by the VNC client.
|
2016-04-23 18:22:54 +02:00
|
|
|
*/
|
|
|
|
|
2016-04-23 18:57:28 +02:00
|
|
|
else if (nrecvd == 0)
|
|
|
|
{
|
2018-02-01 17:25:48 +01:00
|
|
|
gwarn("WARNING: Connection closed\n");
|
2016-04-23 18:57:28 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2016-04-17 17:17:37 +02:00
|
|
|
DEBUGASSERT(nrecvd == 1);
|
|
|
|
|
|
|
|
/* The single byte received should be the message type. Handle the
|
|
|
|
* message according to this message type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (session->inbuf[0])
|
|
|
|
{
|
|
|
|
case RFB_SETPIXELFMT_MSG: /* SetPixelFormat */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received SetPixelFormat\n");
|
2016-04-19 03:02:40 +02:00
|
|
|
|
2016-04-17 21:35:51 +02:00
|
|
|
/* Read the rest of the SetPixelFormat message */
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
2021-02-05 09:05:48 +01:00
|
|
|
sizeof(struct rfb_setpixelformat_s) - 1,
|
|
|
|
1);
|
2016-04-17 21:35:51 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read SetPixelFormat message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-20 17:47:02 +02:00
|
|
|
FAR struct rfb_setpixelformat_s *setformat =
|
|
|
|
(FAR struct rfb_setpixelformat_s *)session->inbuf;
|
|
|
|
|
|
|
|
ret = vnc_client_pixelformat(session, &setformat->format);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
/* We do not support this pixel format */
|
2021-02-05 09:05:48 +01:00
|
|
|
|
|
|
|
/* REVISIT:
|
|
|
|
* We are going to be putting garbage on the RFB
|
|
|
|
*/
|
2016-04-20 17:47:02 +02:00
|
|
|
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: PixelFormat not supported\n");
|
2016-04-20 17:47:02 +02:00
|
|
|
}
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RFB_SETENCODINGS_MSG: /* SetEncodings */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
FAR struct rfb_setencodings_s *encodings;
|
2016-04-23 18:22:54 +02:00
|
|
|
unsigned int nencodings;
|
2016-04-17 21:35:51 +02:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received SetEncodings\n");
|
2016-04-19 03:02:40 +02:00
|
|
|
|
2016-04-17 21:35:51 +02:00
|
|
|
/* Read the SetEncodings message without the following
|
|
|
|
* encodings.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
SIZEOF_RFB_SERVERINIT_S(0) - 1,
|
|
|
|
1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read SetEncodings message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Read the following encodings */
|
|
|
|
|
2021-02-05 09:05:48 +01:00
|
|
|
encodings = (FAR struct rfb_setencodings_s *)
|
|
|
|
session->inbuf;
|
|
|
|
|
2016-04-23 18:22:54 +02:00
|
|
|
nencodings = rfb_getbe16(encodings->nencodings);
|
2016-04-17 21:35:51 +02:00
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
nencodings * sizeof(uint32_t),
|
|
|
|
SIZEOF_RFB_SERVERINIT_S(0));
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read encodings: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-21 01:01:48 +02:00
|
|
|
/* Pick out any mutually supported encodings */
|
|
|
|
|
|
|
|
ret = vnc_client_encodings(session, encodings);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: vnc_set_encodings failed: %d\n", ret);
|
2016-04-21 01:01:48 +02:00
|
|
|
}
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RFB_FBUPDATEREQ_MSG: /* FramebufferUpdateRequest */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
FAR struct rfb_fbupdatereq_s *update;
|
2021-12-30 18:55:40 +01:00
|
|
|
struct fb_area_s rect;
|
2016-04-17 21:35:51 +02:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received FramebufferUpdateRequest\n");
|
2016-04-19 03:02:40 +02:00
|
|
|
|
2019-05-03 18:45:38 +02:00
|
|
|
/* Read the rest of the FramebufferUpdateRequest message */
|
2016-04-17 21:35:51 +02:00
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
sizeof(struct rfb_fbupdatereq_s) - 1,
|
|
|
|
1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2021-04-03 17:10:55 +02:00
|
|
|
gerr("ERROR: "
|
|
|
|
"Failed to read FramebufferUpdateRequest message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Enqueue the update */
|
|
|
|
|
|
|
|
update = (FAR struct rfb_fbupdatereq_s *)session->inbuf;
|
|
|
|
|
2021-12-30 18:55:40 +01:00
|
|
|
rect.x = rfb_getbe16(update->xpos);
|
|
|
|
rect.y = rfb_getbe16(update->ypos);
|
|
|
|
rect.w = rfb_getbe16(update->width);
|
|
|
|
rect.h = rfb_getbe16(update->height);
|
2016-04-17 21:35:51 +02:00
|
|
|
|
2016-04-23 18:22:54 +02:00
|
|
|
ret = vnc_update_rectangle(session, &rect, false);
|
2016-04-17 21:35:51 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to queue update: %d\n", ret);
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RFB_KEYEVENT_MSG: /* KeyEvent */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
FAR struct rfb_keyevent_s *keyevent;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received KeyEvent\n");
|
2016-04-19 03:02:40 +02:00
|
|
|
|
2016-04-17 21:35:51 +02:00
|
|
|
/* Read the rest of the KeyEvent message */
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
sizeof(struct rfb_keyevent_s) - 1,
|
|
|
|
1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read KeyEvent message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Inject the key press/release event into NX */
|
|
|
|
|
|
|
|
keyevent = (FAR struct rfb_keyevent_s *)session->inbuf;
|
2022-07-09 18:13:09 +02:00
|
|
|
#ifdef CONFIG_VNCSERVER_KBD
|
|
|
|
/* If uinput like virtual keyboard enabled, pass keycode to
|
|
|
|
* keyboard driver.
|
|
|
|
*
|
|
|
|
* This driver cannot be used with NX now,
|
|
|
|
* if vnc server works with NX, should not enable
|
|
|
|
* CONFIG_VNCSERVER_KBD.
|
|
|
|
*/
|
|
|
|
|
2023-12-04 03:03:24 +01:00
|
|
|
session->kbdout(session->arg, keyevent->down,
|
2022-07-09 18:13:09 +02:00
|
|
|
(FAR const uint8_t *)keyevent->key);
|
|
|
|
|
|
|
|
#else
|
2022-07-11 06:25:08 +02:00
|
|
|
vnc_key_map(session, rfb_getbe32(keyevent->key),
|
2016-04-17 21:35:51 +02:00
|
|
|
(bool)keyevent->down);
|
2022-07-09 18:13:09 +02:00
|
|
|
#endif
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RFB_POINTEREVENT_MSG: /* PointerEvent */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
FAR struct rfb_pointerevent_s *event;
|
|
|
|
uint8_t buttons;
|
2021-12-30 18:55:40 +01:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received PointerEvent\n");
|
2016-04-17 21:35:51 +02:00
|
|
|
|
|
|
|
/* Read the rest of the PointerEvent message */
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
sizeof(struct rfb_pointerevent_s) - 1,
|
|
|
|
1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read PointerEvent message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
2016-04-21 22:52:25 +02:00
|
|
|
else if (session->mouseout != NULL)
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
event = (FAR struct rfb_pointerevent_s *)session->inbuf;
|
|
|
|
|
|
|
|
/* Map buttons bitmap. Bits 0-7 are buttons 1-8, 0=up,
|
|
|
|
* 1=down. By convention Bit 0 = left button, Bit 1 =
|
|
|
|
* middle button, and Bit 2 = right button.
|
|
|
|
*/
|
|
|
|
|
|
|
|
buttons = 0;
|
|
|
|
if ((event->buttons & (1 << 0)) != 0)
|
|
|
|
{
|
2021-12-30 18:55:40 +01:00
|
|
|
buttons |= MOUSE_BUTTON_1;
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((event->buttons & (1 << 1)) != 0)
|
|
|
|
{
|
2021-12-30 18:55:40 +01:00
|
|
|
buttons |= MOUSE_BUTTON_2;
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((event->buttons & (1 << 2)) != 0)
|
|
|
|
{
|
2021-12-30 18:55:40 +01:00
|
|
|
buttons |= MOUSE_BUTTON_3;
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
|
2016-04-21 22:52:25 +02:00
|
|
|
session->mouseout(session->arg,
|
2021-12-30 18:55:40 +01:00
|
|
|
(fb_coord_t)rfb_getbe16(event->xpos),
|
|
|
|
(fb_coord_t)rfb_getbe16(event->ypos),
|
2016-04-21 22:52:25 +02:00
|
|
|
buttons);
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RFB_CLIENTCUTTEXT_MSG: /* ClientCutText */
|
2016-04-17 21:35:51 +02:00
|
|
|
{
|
|
|
|
FAR struct rfb_clientcuttext_s *cuttext;
|
|
|
|
uint32_t length;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Received ClientCutText\n");
|
2016-04-19 03:02:40 +02:00
|
|
|
|
2016-04-17 21:35:51 +02:00
|
|
|
/* Read the ClientCutText message without the following
|
|
|
|
* text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session,
|
|
|
|
SIZEOF_RFB_CLIENTCUTTEXT_S(0) - 1,
|
|
|
|
1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read ClientCutText message: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Read the following text */
|
|
|
|
|
|
|
|
cuttext = (FAR struct rfb_clientcuttext_s *)session->inbuf;
|
|
|
|
length = rfb_getbe32(cuttext->length);
|
|
|
|
|
|
|
|
ret = vnc_read_remainder(session, length,
|
|
|
|
SIZEOF_RFB_CLIENTCUTTEXT_S(0));
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Failed to read text: %d\n",
|
2016-04-17 21:35:51 +02:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-18 20:24:52 +02:00
|
|
|
/* REVISIT: ClientCutText is currently ignored */
|
2016-04-17 21:35:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-17 17:17:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-06-11 23:50:49 +02:00
|
|
|
gerr("ERROR: Unsynchronized, msgtype=%d\n", session->inbuf[0]);
|
2016-04-17 17:17:37 +02:00
|
|
|
return -EPROTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-17 16:20:14 +02:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
2016-04-21 01:01:48 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: vnc_client_encodings
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Pick out any mutually supported encodings from the Client-to-Server
|
|
|
|
* SetEncodings message
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* session - An instance of the session structure.
|
|
|
|
* encodings - The received SetEncodings message
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* At present, always returns OK
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int vnc_client_encodings(FAR struct vnc_session_s *session,
|
|
|
|
FAR struct rfb_setencodings_s *encodings)
|
|
|
|
{
|
|
|
|
uint32_t encoding;
|
|
|
|
unsigned int nencodings;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
DEBUGASSERT(session != NULL && encodings != NULL);
|
|
|
|
|
|
|
|
/* Assume that there are no common encodings (other than RAW) */
|
|
|
|
|
|
|
|
session->rre = false;
|
|
|
|
|
|
|
|
/* Loop for each client supported encoding */
|
|
|
|
|
2016-04-23 18:22:54 +02:00
|
|
|
nencodings = rfb_getbe16(encodings->nencodings);
|
2016-04-21 01:01:48 +02:00
|
|
|
for (i = 0; i < nencodings; i++)
|
|
|
|
{
|
|
|
|
/* Get the next encoding */
|
|
|
|
|
|
|
|
encoding = rfb_getbe32(&encodings->encodings[i << 2]);
|
|
|
|
|
2020-02-23 09:50:23 +01:00
|
|
|
/* Only a limited support for of RRE is available now. */
|
2016-04-21 01:01:48 +02:00
|
|
|
|
|
|
|
if (encoding == RFB_ENCODING_RRE)
|
|
|
|
{
|
|
|
|
session->rre = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 18:22:54 +02:00
|
|
|
session->change = true;
|
2016-04-21 01:01:48 +02:00
|
|
|
return OK;
|
|
|
|
}
|