rdp.h (5362B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#ifndef GUAC_RDP_H 21#define GUAC_RDP_H 22 23#include "channels/audio-input/audio-buffer.h" 24#include "channels/cliprdr.h" 25#include "channels/disp.h" 26#include "channels/rdpei.h" 27#include "common/clipboard.h" 28#include "common/display.h" 29#include "common/list.h" 30#include "common/surface.h" 31#include "config.h" 32#include "fs.h" 33#include "keyboard.h" 34#include "print-job.h" 35#include "settings.h" 36 37#ifdef ENABLE_COMMON_SSH 38#include "common-ssh/sftp.h" 39#include "common-ssh/ssh.h" 40#include "common-ssh/user.h" 41#endif 42 43#include <freerdp/codec/color.h> 44#include <freerdp/freerdp.h> 45#include <guacamole/audio.h> 46#include <guacamole/client.h> 47#include <guacamole/recording.h> 48#include <winpr/wtypes.h> 49 50#include <pthread.h> 51#include <stdint.h> 52 53/** 54 * RDP-specific client data. 55 */ 56typedef struct guac_rdp_client { 57 58 /** 59 * The RDP client thread. 60 */ 61 pthread_t client_thread; 62 63 /** 64 * Pointer to the FreeRDP client instance handling the current connection. 65 */ 66 freerdp* rdp_inst; 67 68 /** 69 * All settings associated with the current or pending RDP connection. 70 */ 71 guac_rdp_settings* settings; 72 73 /** 74 * Button mask containing the OR'd value of all currently pressed buttons. 75 */ 76 int mouse_button_mask; 77 78 /** 79 * Foreground color for any future glyphs. 80 */ 81 uint32_t glyph_color; 82 83 /** 84 * The display. 85 */ 86 guac_common_display* display; 87 88 /** 89 * The surface that GDI operations should draw to. RDP messages exist which 90 * change this surface to allow drawing to occur off-screen. 91 */ 92 guac_common_surface* current_surface; 93 94 /** 95 * The current state of the keyboard with respect to the RDP session. 96 */ 97 guac_rdp_keyboard* keyboard; 98 99 /** 100 * The current state of the clipboard and the CLIPRDR channel. 101 */ 102 guac_rdp_clipboard* clipboard; 103 104 /** 105 * Audio output, if any. 106 */ 107 guac_audio_stream* audio; 108 109 /** 110 * Audio input buffer, if audio input is enabled. 111 */ 112 guac_rdp_audio_buffer* audio_input; 113 114 /** 115 * The filesystem being shared, if any. 116 */ 117 guac_rdp_fs* filesystem; 118 119 /** 120 * The currently-active print job, or NULL if no print job is active. 121 */ 122 guac_rdp_print_job* active_job; 123 124#ifdef ENABLE_COMMON_SSH 125 /** 126 * The user and credentials used to authenticate for SFTP. 127 */ 128 guac_common_ssh_user* sftp_user; 129 130 /** 131 * The SSH session used for SFTP. 132 */ 133 guac_common_ssh_session* sftp_session; 134 135 /** 136 * An SFTP-based filesystem. 137 */ 138 guac_common_ssh_sftp_filesystem* sftp_filesystem; 139#endif 140 141 /** 142 * The in-progress session recording, or NULL if no recording is in 143 * progress. 144 */ 145 guac_recording* recording; 146 147 /** 148 * Display size update module. 149 */ 150 guac_rdp_disp* disp; 151 152 /** 153 * Multi-touch support module (RDPEI). 154 */ 155 guac_rdp_rdpei* rdpei; 156 157 /** 158 * List of all available static virtual channels. 159 */ 160 guac_common_list* available_svc; 161 162 /** 163 * Common attributes for locks. 164 */ 165 pthread_mutexattr_t attributes; 166 167 /** 168 * Lock which is used to synchronizes access to RDP data structures 169 * between user input and client threads. It prevents input handlers 170 * from running when RDP data structures are allocated or freed 171 * by the client thread. 172 */ 173 pthread_rwlock_t lock; 174 175 /** 176 * Lock which synchronizes the sending of each RDP message, ensuring 177 * attempts to send RDP messages never overlap. 178 */ 179 pthread_mutex_t message_lock; 180 181} guac_rdp_client; 182 183/** 184 * Client data that will remain accessible through the RDP context. 185 * This should generally include data commonly used by FreeRDP handlers. 186 */ 187typedef struct rdp_freerdp_context { 188 189 /** 190 * The parent context. THIS MUST BE THE FIRST ELEMENT. 191 */ 192 rdpContext _p; 193 194 /** 195 * Pointer to the guac_client instance handling the RDP connection with 196 * this context. 197 */ 198 guac_client* client; 199 200 /** 201 * The current color palette, as received from the RDP server. 202 */ 203 UINT32 palette[256]; 204 205} rdp_freerdp_context; 206 207/** 208 * RDP client thread. This thread runs throughout the duration of the client, 209 * existing as a single instance, shared by all users. 210 * 211 * @param data 212 * The guac_client to associate with an RDP session, once the RDP 213 * connection succeeds. 214 * 215 * @return 216 * NULL in all cases. The return value of this thread is expected to be 217 * ignored. 218 */ 219void* guac_rdp_client_thread(void* data); 220 221#endif 222