2016-02-29 21:50:00 -08:00
|
|
|
/*
|
2016-03-25 12:59:40 -07: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-02-29 21:50:00 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-02-29 21:50:00 -08:00
|
|
|
*
|
2016-03-25 12:59:40 -07: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-02-29 21:50:00 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUAC_RDP_H
|
|
|
|
#define GUAC_RDP_H
|
|
|
|
|
2020-01-12 21:55:58 -08:00
|
|
|
#include "channels/audio-input/audio-buffer.h"
|
2019-12-23 12:48:22 -08:00
|
|
|
#include "channels/cliprdr.h"
|
2019-12-23 13:29:13 -08:00
|
|
|
#include "channels/disp.h"
|
2021-02-06 14:56:17 -08:00
|
|
|
#include "channels/rdpei.h"
|
2016-09-11 17:28:50 -07:00
|
|
|
#include "common/clipboard.h"
|
|
|
|
#include "common/display.h"
|
|
|
|
#include "common/list.h"
|
|
|
|
#include "common/surface.h"
|
2020-01-04 13:07:28 -08:00
|
|
|
#include "config.h"
|
2019-12-23 12:48:22 -08:00
|
|
|
#include "fs.h"
|
2020-01-04 11:43:32 -08:00
|
|
|
#include "keyboard.h"
|
2019-12-23 12:48:22 -08:00
|
|
|
#include "print-job.h"
|
|
|
|
#include "settings.h"
|
2016-02-29 21:50:00 -08:00
|
|
|
|
|
|
|
#ifdef ENABLE_COMMON_SSH
|
2017-02-27 14:28:23 -08:00
|
|
|
#include "common-ssh/sftp.h"
|
|
|
|
#include "common-ssh/ssh.h"
|
|
|
|
#include "common-ssh/user.h"
|
2016-02-29 21:50:00 -08:00
|
|
|
#endif
|
|
|
|
|
2020-01-04 13:07:28 -08:00
|
|
|
#include <freerdp/codec/color.h>
|
|
|
|
#include <freerdp/freerdp.h>
|
|
|
|
#include <guacamole/audio.h>
|
|
|
|
#include <guacamole/client.h>
|
2022-03-01 03:38:25 +00:00
|
|
|
#include <guacamole/recording.h>
|
2020-01-04 13:07:28 -08:00
|
|
|
#include <winpr/wtypes.h>
|
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RDP-specific client data.
|
|
|
|
*/
|
|
|
|
typedef struct guac_rdp_client {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The RDP client thread.
|
|
|
|
*/
|
|
|
|
pthread_t client_thread;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to the FreeRDP client instance handling the current connection.
|
|
|
|
*/
|
|
|
|
freerdp* rdp_inst;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All settings associated with the current or pending RDP connection.
|
|
|
|
*/
|
|
|
|
guac_rdp_settings* settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Button mask containing the OR'd value of all currently pressed buttons.
|
|
|
|
*/
|
|
|
|
int mouse_button_mask;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Foreground color for any future glyphs.
|
|
|
|
*/
|
|
|
|
uint32_t glyph_color;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The display.
|
|
|
|
*/
|
|
|
|
guac_common_display* display;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The surface that GDI operations should draw to. RDP messages exist which
|
|
|
|
* change this surface to allow drawing to occur off-screen.
|
|
|
|
*/
|
|
|
|
guac_common_surface* current_surface;
|
|
|
|
|
2021-09-02 17:07:58 -07:00
|
|
|
/**
|
|
|
|
* Whether the RDP server has reported that a new frame is in progress, and
|
|
|
|
* we are now receiving updates relevant to that frame.
|
|
|
|
*/
|
|
|
|
int in_frame;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of distinct frames received from the RDP server since last
|
|
|
|
* flush, if the RDP server supports reporting frame boundaries. If the RDP
|
|
|
|
* server does not support tracking frames, this will be zero.
|
|
|
|
*/
|
|
|
|
int frames_received;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The server timestamp of the end of the last frame received from the RDP
|
|
|
|
* server, as returned by guac_timestamp_current(), if the RDP server
|
|
|
|
* supports reporting frame boundaries. If the RDP server does not support
|
|
|
|
* tracking frames, this will be zero.
|
|
|
|
*/
|
|
|
|
guac_timestamp frame_start;
|
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
/**
|
2016-08-13 17:33:30 -07:00
|
|
|
* The current state of the keyboard with respect to the RDP session.
|
2016-02-29 21:50:00 -08:00
|
|
|
*/
|
2016-08-13 17:33:30 -07:00
|
|
|
guac_rdp_keyboard* keyboard;
|
2016-02-29 21:50:00 -08:00
|
|
|
|
|
|
|
/**
|
2019-10-11 17:01:26 -07:00
|
|
|
* The current state of the clipboard and the CLIPRDR channel.
|
2016-02-29 21:50:00 -08:00
|
|
|
*/
|
2019-10-11 17:01:26 -07:00
|
|
|
guac_rdp_clipboard* clipboard;
|
2016-02-29 21:50:00 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Audio output, if any.
|
|
|
|
*/
|
|
|
|
guac_audio_stream* audio;
|
|
|
|
|
|
|
|
/**
|
2016-04-18 00:32:51 -07:00
|
|
|
* Audio input buffer, if audio input is enabled.
|
|
|
|
*/
|
|
|
|
guac_rdp_audio_buffer* audio_input;
|
|
|
|
|
|
|
|
/**
|
2016-02-29 21:50:00 -08:00
|
|
|
* The filesystem being shared, if any.
|
|
|
|
*/
|
|
|
|
guac_rdp_fs* filesystem;
|
|
|
|
|
2017-02-14 00:02:17 -08:00
|
|
|
/**
|
|
|
|
* The currently-active print job, or NULL if no print job is active.
|
|
|
|
*/
|
|
|
|
guac_rdp_print_job* active_job;
|
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
#ifdef ENABLE_COMMON_SSH
|
|
|
|
/**
|
|
|
|
* The user and credentials used to authenticate for SFTP.
|
|
|
|
*/
|
|
|
|
guac_common_ssh_user* sftp_user;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The SSH session used for SFTP.
|
|
|
|
*/
|
|
|
|
guac_common_ssh_session* sftp_session;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An SFTP-based filesystem.
|
|
|
|
*/
|
|
|
|
guac_common_ssh_sftp_filesystem* sftp_filesystem;
|
|
|
|
#endif
|
|
|
|
|
2017-11-27 09:38:20 -08:00
|
|
|
/**
|
|
|
|
* The in-progress session recording, or NULL if no recording is in
|
|
|
|
* progress.
|
|
|
|
*/
|
2022-03-01 03:38:25 +00:00
|
|
|
guac_recording* recording;
|
2017-11-27 09:38:20 -08:00
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
/**
|
|
|
|
* Display size update module.
|
|
|
|
*/
|
|
|
|
guac_rdp_disp* disp;
|
|
|
|
|
2021-02-06 14:56:17 -08:00
|
|
|
/**
|
|
|
|
* Multi-touch support module (RDPEI).
|
|
|
|
*/
|
|
|
|
guac_rdp_rdpei* rdpei;
|
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
/**
|
|
|
|
* List of all available static virtual channels.
|
|
|
|
*/
|
|
|
|
guac_common_list* available_svc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Common attributes for locks.
|
|
|
|
*/
|
|
|
|
pthread_mutexattr_t attributes;
|
|
|
|
|
2020-04-30 17:44:59 -04:00
|
|
|
/**
|
|
|
|
* Lock which is used to synchronizes access to RDP data structures
|
|
|
|
* between user input and client threads. It prevents input handlers
|
|
|
|
* from running when RDP data structures are allocated or freed
|
|
|
|
* by the client thread.
|
|
|
|
*/
|
|
|
|
pthread_rwlock_t lock;
|
|
|
|
|
2021-04-07 17:13:48 -07:00
|
|
|
/**
|
|
|
|
* Lock which synchronizes the sending of each RDP message, ensuring
|
|
|
|
* attempts to send RDP messages never overlap.
|
|
|
|
*/
|
|
|
|
pthread_mutex_t message_lock;
|
|
|
|
|
2016-02-29 21:50:00 -08:00
|
|
|
} guac_rdp_client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client data that will remain accessible through the RDP context.
|
|
|
|
* This should generally include data commonly used by FreeRDP handlers.
|
|
|
|
*/
|
|
|
|
typedef struct rdp_freerdp_context {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The parent context. THIS MUST BE THE FIRST ELEMENT.
|
|
|
|
*/
|
|
|
|
rdpContext _p;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to the guac_client instance handling the RDP connection with
|
|
|
|
* this context.
|
|
|
|
*/
|
|
|
|
guac_client* client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current color palette, as received from the RDP server.
|
|
|
|
*/
|
|
|
|
UINT32 palette[256];
|
|
|
|
|
|
|
|
} rdp_freerdp_context;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RDP client thread. This thread runs throughout the duration of the client,
|
|
|
|
* existing as a single instance, shared by all users.
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* The guac_client to associate with an RDP session, once the RDP
|
|
|
|
* connection succeeds.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* NULL in all cases. The return value of this thread is expected to be
|
|
|
|
* ignored.
|
|
|
|
*/
|
|
|
|
void* guac_rdp_client_thread(void* data);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|