2013-12-29 04:53:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Glyptodon LLC
|
2012-11-02 10:14:25 +00:00
|
|
|
*
|
2013-12-29 04:53:12 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2012-11-02 10:14:25 +00:00
|
|
|
*
|
2013-12-29 04:53:12 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
2012-11-02 10:14:25 +00:00
|
|
|
*
|
2013-12-29 04:53:12 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2013-06-18 20:39:07 +00:00
|
|
|
#ifndef __GUAC_RDPDR_SERVICE_H
|
|
|
|
#define __GUAC_RDPDR_SERVICE_H
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2014-01-01 22:44:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <freerdp/utils/svc_plugin.h>
|
|
|
|
#include <guacamole/client.h>
|
|
|
|
|
2013-07-17 18:45:53 +00:00
|
|
|
#ifdef ENABLE_WINPR
|
|
|
|
#include <winpr/stream.h>
|
|
|
|
#else
|
|
|
|
#include "compat/winpr-stream.h"
|
|
|
|
#endif
|
|
|
|
|
2013-12-17 22:28:20 +00:00
|
|
|
/**
|
|
|
|
* The maximum number of bytes to allow for a device read.
|
|
|
|
*/
|
|
|
|
#define GUAC_RDP_MAX_READ_BUFFER 4194304
|
|
|
|
|
2013-07-24 22:52:46 +00:00
|
|
|
typedef struct guac_rdpdrPlugin guac_rdpdrPlugin;
|
|
|
|
typedef struct guac_rdpdr_device guac_rdpdr_device;
|
|
|
|
|
2013-07-25 01:28:20 +00:00
|
|
|
/**
|
|
|
|
* Handler for client device list announce. Each implementing device must write
|
|
|
|
* its announcement header and data to the given output stream.
|
|
|
|
*/
|
|
|
|
typedef void guac_rdpdr_device_announce_handler(guac_rdpdr_device* device, wStream* output_stream,
|
|
|
|
int device_id);
|
|
|
|
|
2013-07-24 22:52:46 +00:00
|
|
|
/**
|
|
|
|
* Handler for device I/O requests.
|
|
|
|
*/
|
|
|
|
typedef void guac_rdpdr_device_iorequest_handler(guac_rdpdr_device* device,
|
|
|
|
wStream* input_stream, int file_id, int completion_id, int major_func, int minor_func);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for cleaning up the dynamically-allocated portions of a device.
|
|
|
|
*/
|
|
|
|
typedef void guac_rdpdr_device_free_handler(guac_rdpdr_device* device);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Arbitrary device forwarded over the RDPDR channel.
|
|
|
|
*/
|
|
|
|
struct guac_rdpdr_device {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The RDPDR plugin owning this device.
|
|
|
|
*/
|
|
|
|
guac_rdpdrPlugin* rdpdr;
|
|
|
|
|
2013-07-25 05:20:29 +00:00
|
|
|
/**
|
|
|
|
* The ID assigned to this device by the RDPDR plugin.
|
|
|
|
*/
|
|
|
|
int device_id;
|
|
|
|
|
2013-07-24 22:52:46 +00:00
|
|
|
/**
|
|
|
|
* An arbitrary device name, used for logging purposes only.
|
|
|
|
*/
|
|
|
|
const char* device_name;
|
|
|
|
|
2013-07-25 01:28:20 +00:00
|
|
|
/**
|
|
|
|
* Handler which will be called when the RDPDR plugin is forming the client
|
|
|
|
* device announce list.
|
|
|
|
*/
|
|
|
|
guac_rdpdr_device_announce_handler* announce_handler;
|
|
|
|
|
2013-07-24 22:52:46 +00:00
|
|
|
/**
|
|
|
|
* Handler which should be called for every I/O request received.
|
|
|
|
*/
|
|
|
|
guac_rdpdr_device_iorequest_handler* iorequest_handler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handlel which should be called when the device is being free'd.
|
|
|
|
*/
|
|
|
|
guac_rdpdr_device_free_handler* free_handler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Arbitrary data, used internally by the handlers for this device.
|
|
|
|
*/
|
|
|
|
void* data;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
2013-06-18 20:39:07 +00:00
|
|
|
* Structure representing the current state of the Guacamole RDPDR plugin for
|
2012-11-02 10:14:25 +00:00
|
|
|
* FreeRDP.
|
|
|
|
*/
|
2013-07-24 22:52:46 +00:00
|
|
|
struct guac_rdpdrPlugin {
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
|
|
|
* The FreeRDP parts of this plugin. This absolutely MUST be first.
|
|
|
|
* FreeRDP depends on accessing this structure as if it were an instance
|
|
|
|
* of rdpSvcPlugin.
|
|
|
|
*/
|
|
|
|
rdpSvcPlugin plugin;
|
|
|
|
|
2013-06-18 21:02:38 +00:00
|
|
|
/**
|
|
|
|
* Reference to the client owning this instance of the RDPDR plugin.
|
|
|
|
*/
|
|
|
|
guac_client* client;
|
|
|
|
|
2013-06-28 18:26:28 +00:00
|
|
|
/**
|
2013-07-24 22:52:46 +00:00
|
|
|
* The number of devices registered within the devices array.
|
2013-06-28 18:26:28 +00:00
|
|
|
*/
|
2013-07-24 22:52:46 +00:00
|
|
|
int devices_registered;
|
2013-06-28 18:26:28 +00:00
|
|
|
|
2013-06-25 00:49:23 +00:00
|
|
|
/**
|
2013-07-24 22:52:46 +00:00
|
|
|
* Array of registered devices.
|
2013-06-25 00:49:23 +00:00
|
|
|
*/
|
2013-07-24 22:52:46 +00:00
|
|
|
guac_rdpdr_device devices[8];
|
2012-11-01 00:44:23 +00:00
|
|
|
|
2013-07-24 22:52:46 +00:00
|
|
|
};
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
|
|
|
* Handler called when this plugin is loaded by FreeRDP.
|
|
|
|
*/
|
2013-06-18 20:39:07 +00:00
|
|
|
void guac_rdpdr_process_connect(rdpSvcPlugin* plugin);
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
|
|
|
* Handler called when this plugin receives data along its designated channel.
|
|
|
|
*/
|
2013-06-18 20:39:07 +00:00
|
|
|
void guac_rdpdr_process_receive(rdpSvcPlugin* plugin,
|
2013-07-17 18:45:53 +00:00
|
|
|
wStream* input_stream);
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
|
|
|
* Handler called when this plugin is being unloaded.
|
|
|
|
*/
|
2013-06-18 20:39:07 +00:00
|
|
|
void guac_rdpdr_process_terminate(rdpSvcPlugin* plugin);
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2012-11-02 10:14:25 +00:00
|
|
|
/**
|
2013-06-18 20:39:07 +00:00
|
|
|
* Handler called when this plugin receives an event. For the sake of RDPDR,
|
2012-11-02 10:14:25 +00:00
|
|
|
* all events will be ignored and simply free'd.
|
|
|
|
*/
|
2013-07-17 18:45:53 +00:00
|
|
|
void guac_rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event);
|
2012-10-28 03:03:18 +00:00
|
|
|
|
2013-10-22 21:08:03 +00:00
|
|
|
/**
|
|
|
|
* Creates a new stream which contains the ommon DR_DEVICE_IOCOMPLETION header
|
|
|
|
* used for virtually all responses.
|
|
|
|
*/
|
|
|
|
wStream* guac_rdpdr_new_io_completion(guac_rdpdr_device* device,
|
|
|
|
int completion_id, int status, int size);
|
|
|
|
|
2013-12-18 06:46:15 +00:00
|
|
|
/**
|
|
|
|
* Begins streaming the given file to the user via a Guacamole file stream.
|
|
|
|
*/
|
2016-03-04 22:23:40 +00:00
|
|
|
void guac_rdpdr_start_download(guac_rdpdr_device* device, char* path);
|
2013-12-18 06:46:15 +00:00
|
|
|
|
2012-10-28 03:03:18 +00:00
|
|
|
#endif
|
|
|
|
|