From 08eb5625fcab73b46a7912dd482229031425ca51 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 25 Jul 2013 09:48:48 -0700 Subject: [PATCH] Add filesystem device. --- src/protocols/rdp/Makefile.am | 2 + src/protocols/rdp/guac_rdpdr/rdpdr_fs.c | 100 ++++++++++++++++++ src/protocols/rdp/guac_rdpdr/rdpdr_fs.h | 72 +++++++++++++ src/protocols/rdp/guac_rdpdr/rdpdr_messages.h | 6 ++ src/protocols/rdp/guac_rdpdr/rdpdr_service.c | 3 + src/protocols/rdp/guac_rdpdr/rdpdr_service.h | 1 + 6 files changed, 184 insertions(+) create mode 100644 src/protocols/rdp/guac_rdpdr/rdpdr_fs.c create mode 100644 src/protocols/rdp/guac_rdpdr/rdpdr_fs.h diff --git a/src/protocols/rdp/Makefile.am b/src/protocols/rdp/Makefile.am index cb0eee80..5f443db0 100644 --- a/src/protocols/rdp/Makefile.am +++ b/src/protocols/rdp/Makefile.am @@ -63,12 +63,14 @@ guacsnd_sources = \ guac_rdpsnd/rdpsnd_service.c guacdr_sources = \ + guac_rdpdr/rdpdr_fs.c \ guac_rdpdr/rdpdr_messages.c \ guac_rdpdr/rdpdr_printer.c \ guac_rdpdr/rdpdr_service.c noinst_HEADERS = \ compat/client-cliprdr.h \ + guac_rdpdr/rdpdr_fs.h \ guac_rdpdr/rdpdr_messages.h \ guac_rdpdr/rdpdr_printer.h \ guac_rdpdr/rdpdr_service.h \ diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c new file mode 100644 index 00000000..ee233be1 --- /dev/null +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c @@ -0,0 +1,100 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-rdp. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifdef ENABLE_WINPR +#include +#else +#include "compat/winpr-stream.h" +#endif + +#include "rdpdr_messages.h" +#include "rdpdr_fs.h" +#include "rdpdr_service.h" +#include "client.h" + +#include + +static void guac_rdpdr_device_fs_announce_handler(guac_rdpdr_device* device, + wStream* output_stream, int device_id) { + + /* Filesystem header */ + guac_client_log_info(device->rdpdr->client, "Sending filesystem"); + Stream_Write_UINT32(output_stream, RDPDR_DTYP_FILESYSTEM); + Stream_Write_UINT32(output_stream, device_id); + Stream_Write(output_stream, "GUAC\0\0\0\0", 8); /* DOS name */ + + /* Filesystem data */ + Stream_Write_UINT32(output_stream, GUAC_FILESYSTEM_NAME_LENGTH); + Stream_Write(output_stream, GUAC_FILESYSTEM_NAME, GUAC_FILESYSTEM_NAME_LENGTH); + +} + +static void guac_rdpdr_device_fs_iorequest_handler(guac_rdpdr_device* device, + wStream* input_stream, int file_id, int completion_id, int major_func, int minor_func) { + + guac_client_log_error(device->rdpdr->client, + "Unknown filesystem I/O request function: 0x%x/0x%x", + major_func, minor_func); + +} + +static void guac_rdpdr_device_fs_free_handler(guac_rdpdr_device* device) { + /* STUB */ +} + +void guac_rdpdr_register_fs(guac_rdpdrPlugin* rdpdr) { + + int id = rdpdr->devices_registered++; + + /* Get new device */ + guac_rdpdr_device* device = &(rdpdr->devices[id]); + + /* Init device */ + device->rdpdr = rdpdr; + device->device_id = id; + device->device_name = "Guacamole Filesystem"; + + /* Set handlers */ + device->announce_handler = guac_rdpdr_device_fs_announce_handler; + device->iorequest_handler = guac_rdpdr_device_fs_iorequest_handler; + device->free_handler = guac_rdpdr_device_fs_free_handler; + + /* Init data */ + /*device->data = malloc(sizeof(guac_rdpdr_fs_data));*/ + +} + diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h new file mode 100644 index 00000000..52d2e8ed --- /dev/null +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h @@ -0,0 +1,72 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-rdp. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __GUAC_RDPDR_FS_H +#define __GUAC_RDPDR_FS_H + +#ifdef ENABLE_WINPR +#include +#else +#include "compat/winpr-stream.h" +#endif + +#include + +/** + * The index of the blob to use when sending files. + */ +#define GUAC_RDPDR_FS_BLOB 1 + +#if 0 +/** + * Data specific to an instance of the printer device. + */ +typedef struct guac_rdpdr_fs_data { + + /* STUB */ + +} guac_rdpdr_fs_data; +#endif + +/** + * Registers a new filesystem device within the RDPDR plugin. This must be done + * before RDPDR connection finishes. + */ +void guac_rdpdr_register_fs(guac_rdpdrPlugin* rdpdr); + +#endif + diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_messages.h b/src/protocols/rdp/guac_rdpdr/rdpdr_messages.h index 8d2890f9..ba65e9e1 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_messages.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_messages.h @@ -95,6 +95,12 @@ #define GUAC_PRINTER_NAME "G\0u\0a\0c\0a\0m\0o\0l\0e\0\0\0" #define GUAC_PRINTER_NAME_LENGTH 20 +/** + * Name of the filesystem. + */ +#define GUAC_FILESYSTEM_NAME "G\0u\0a\0c\0a\0m\0o\0l\0e\0\0\0" +#define GUAC_FILESYSTEM_NAME_LENGTH 20 + /* * Capability types */ diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_service.c b/src/protocols/rdp/guac_rdpdr/rdpdr_service.c index 3ebfb703..1839272e 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_service.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_service.c @@ -54,6 +54,7 @@ #include "rdpdr_service.h" #include "rdpdr_messages.h" #include "rdpdr_printer.h" +#include "rdpdr_fs.h" #include "client.h" @@ -112,6 +113,8 @@ void guac_rdpdr_process_connect(rdpSvcPlugin* plugin) { if (client_data->settings.printing_enabled) guac_rdpdr_register_printer(rdpdr); + guac_rdpdr_register_fs(rdpdr); + /* Log that printing, etc. has been loaded */ guac_client_log_info(client, "guacdr connected."); diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_service.h b/src/protocols/rdp/guac_rdpdr/rdpdr_service.h index 09a9a60e..df6eb8bf 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_service.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_service.h @@ -47,6 +47,7 @@ #endif #include +#include typedef struct guac_rdpdrPlugin guac_rdpdrPlugin; typedef struct guac_rdpdr_device guac_rdpdr_device;