xrdp/vnc/vnc.h

198 lines
6.9 KiB
C
Raw Normal View History

/**
* xrdp: A Remote Desktop Protocol server.
*
2015-07-12 11:07:10 +03:00
* Copyright (C) Jay Sorg 2004-2015
*
* Licensed 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* libvnc
*/
2004-11-28 07:56:58 +03:00
#ifndef VNC_H
#define VNC_H
2004-11-28 07:56:58 +03:00
/* include other h files */
2005-01-07 04:05:30 +03:00
#include "arch.h"
2004-11-28 07:56:58 +03:00
#include "parse.h"
2005-01-07 04:05:30 +03:00
#include "os_calls.h"
2009-08-15 06:49:13 +04:00
#include "defines.h"
#include "guid.h"
#include "ms-rdpbcgr.h"
2009-08-15 06:49:13 +04:00
2019-04-10 09:55:02 +03:00
#define CURRENT_MOD_VER 4
2004-11-28 07:56:58 +03:00
/* Screen used for ExtendedDesktopSize / Set DesktopSize */
struct vnc_screen
{
int id;
int x;
int y;
int width;
int height;
int flags;
};
struct vnc_screen_layout
{
int total_width;
int total_height;
unsigned int count;
/* For comparison, screens are sorted in x, y, width, height) order */
struct vnc_screen s[CLIENT_MONITOR_DATA_MAXIMUM_MONITORS];
};
/**
* Keep track of resize status at start of connection
*/
enum vnc_resize_status
{
VRS_WAITING_FOR_FIRST_UPDATE,
VRS_WAITING_FOR_RESIZE_CONFIRM,
VRS_DONE
};
enum vnc_resize_support_status
{
VRSS_NOT_SUPPORTED,
VRSS_SUPPORTED,
VRSS_UNKNOWN
};
struct source_info;
/* Defined in vnc_clip.c */
struct vnc_clipboard_data;
/* Defined in xrdp_client_info.h */
struct monitor_info;
2004-11-28 07:56:58 +03:00
struct vnc
{
int size; /* size of this struct */
int version; /* internal version */
/* client functions */
int (*mod_start)(struct vnc *v, int w, int h, int bpp);
int (*mod_connect)(struct vnc *v);
int (*mod_event)(struct vnc *v, int msg, long param1, long param2,
long param3, long param4);
int (*mod_signal)(struct vnc *v);
int (*mod_end)(struct vnc *v);
int (*mod_set_param)(struct vnc *v, const char *name, const char *value);
int (*mod_session_change)(struct vnc *v, int, int);
int (*mod_get_wait_objs)(struct vnc *v, tbus *read_objs, int *rcount,
tbus *write_objs, int *wcount, int *timeout);
int (*mod_check_wait_objs)(struct vnc *v);
int (*mod_frame_ack)(struct vnc *v, int flags, int frame_id);
int (*mod_suppress_output)(struct vnc *v, int suppress,
int left, int top, int right, int bottom);
int (*mod_server_monitor_resize)(struct vnc *v,
int width, int height,
int num_monitors,
const struct monitor_info *monitors,
int *in_progress);
int (*mod_server_monitor_full_invalidate)(struct vnc *v,
2021-05-08 19:58:11 +03:00
int width, int height);
int (*mod_server_version_message)(struct vnc *v);
tintptr mod_dumby[100 - 14]; /* align, 100 minus the number of mod
2019-04-10 04:24:24 +03:00
functions above */
/* server functions */
int (*server_begin_update)(struct vnc *v);
int (*server_end_update)(struct vnc *v);
int (*server_fill_rect)(struct vnc *v, int x, int y, int cx, int cy);
int (*server_screen_blt)(struct vnc *v, int x, int y, int cx, int cy,
int srcx, int srcy);
int (*server_paint_rect)(struct vnc *v, int x, int y, int cx, int cy,
char *data, int width, int height, int srcx, int srcy);
int (*server_set_cursor)(struct vnc *v, int x, int y, char *data, char *mask);
int (*server_palette)(struct vnc *v, int *palette);
int (*server_msg)(struct vnc *v, const char *msg, int code);
Rework transport connect logic There are a number of ways the existing transport connect logic in trans_connect could be improved for POSIX compatibility, and also slightly tidied up:- 1) The same socket is re-used for multiple connect attempts following failure which isn't behaviour defined by POSIX.1-2017 (although it works on Linux). 2) An asynchronous connect is started, and then after a short delay connect() is called again on the same socket. POSIX.1-2017 is clear that in this situation EALREADY is returned before the connection is established, but is silent on the behaviour expected when the connection is established. Returning success is an option, but so is returning EISCONN. The current code assumes the connect() call will succeed. 3) The code contains two virtually identical, quite complex loops for TCP and UNIX sockets, differing only in the calls to create a socket and connect it. 4) trans_connect() contains looping and retry logic, but this isn't seen as sufficient by the chansrv connect code in xrdp/xrdp_mm.c and the Xorg connect code in xup/xup.c. Both of these implement their own looping and retry logic on top of the logic in trans_connect(), resulting in slightly unpredictable behaviour with regard to timeouts. 5) A socket number can technically be zero, but in a couple of places this isn't allowed for. This PR attempts to correct the implementation of trans_connect(), and also to simplify the areas it is called from. As part of the PR, the signature of the server_is_term member of the xrdp module interface is changed to match the signature expected by the is_term member of a struct trans. This allows for trans_connect() in xrdp modules to directly access g_is_term() within the main xrdp executable. At the moment this functionality is only used by the xup module.
2022-03-31 16:33:06 +03:00
int (*server_is_term)(void);
int (*server_set_clip)(struct vnc *v, int x, int y, int cx, int cy);
int (*server_reset_clip)(struct vnc *v);
int (*server_set_fgcolor)(struct vnc *v, int fgcolor);
int (*server_set_bgcolor)(struct vnc *v, int bgcolor);
int (*server_set_opcode)(struct vnc *v, int opcode);
int (*server_set_mixmode)(struct vnc *v, int mixmode);
int (*server_set_brush)(struct vnc *v, int x_origin, int y_origin,
int style, char *pattern);
int (*server_set_pen)(struct vnc *v, int style,
int width);
int (*server_draw_line)(struct vnc *v, int x1, int y1, int x2, int y2);
int (*server_add_char)(struct vnc *v, int font, int character,
int offset, int baseline,
int width, int height, char *data);
int (*server_draw_text)(struct vnc *v, int font,
int flags, int mixmode, int clip_left, int clip_top,
int clip_right, int clip_bottom,
int box_left, int box_top,
int box_right, int box_bottom,
int x, int y, char *data, int data_len);
int (*client_monitor_resize)(struct vnc *v, int width, int height,
int num_monitors,
const struct monitor_info *monitors);
int (*server_monitor_resize_done)(struct vnc *v);
int (*server_get_channel_count)(struct vnc *v);
int (*server_query_channel)(struct vnc *v, int index,
char *channel_name,
int *channel_flags);
int (*server_get_channel_id)(struct vnc *v, const char *name);
int (*server_send_to_channel)(struct vnc *v, int channel_id,
char *data, int data_len,
int total_data_len, int flags);
int (*server_bell_trigger)(struct vnc *v);
int (*server_chansrv_in_use)(struct vnc *v);
tintptr server_dumby[100 - 28]; /* align, 100 minus the number of server
2015-07-11 07:57:04 +03:00
functions above */
/* common */
tintptr handle; /* pointer to self as long */
tintptr wm;
tintptr painter;
struct source_info *si;
/* mod data */
int server_bpp;
char mod_name[256];
int mod_mouse_state;
int palette[256];
int vnc_desktop;
char username[256];
char password[256];
char ip[256];
char port[256];
int sck_closed;
int shift_state; /* 0 up, 1 down */
int keylayout;
int clip_chanid;
struct vnc_clipboard_data *vc;
int delay_ms;
struct trans *trans;
struct guid guid;
int suppress_output;
unsigned int enabled_encodings_mask;
/* Resizeable support */
int multimon_configured;
struct vnc_screen_layout client_layout;
struct vnc_screen_layout server_layout;
enum vnc_resize_status resize_status;
enum vnc_resize_support_status resize_supported;
2004-11-28 07:56:58 +03:00
};
/*
* Functions
*/
int
lib_send_copy(struct vnc *v, struct stream *s);
int
skip_trans_bytes(struct trans *trans, unsigned int bytes);
#endif /* VNC_H */