2014-03-04 00:18:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Glyptodon LLC
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _GUAC_RDP_STREAM_H
|
|
|
|
#define _GUAC_RDP_STREAM_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2015-07-06 06:14:18 +00:00
|
|
|
#include "guac_json.h"
|
2014-03-04 00:18:14 +00:00
|
|
|
#include "rdp_svc.h"
|
|
|
|
|
2016-03-01 05:50:00 +00:00
|
|
|
#include <guacamole/user.h>
|
2014-06-11 01:45:14 +00:00
|
|
|
#include <guacamole/protocol.h>
|
|
|
|
#include <guacamole/stream.h>
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The transfer status of a file being downloaded.
|
|
|
|
*/
|
|
|
|
typedef struct guac_rdp_download_status {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The file ID of the file being downloaded.
|
|
|
|
*/
|
|
|
|
int file_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current position within the file.
|
|
|
|
*/
|
|
|
|
uint64_t offset;
|
|
|
|
|
|
|
|
} guac_rdp_download_status;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure which represents the current state of an upload.
|
|
|
|
*/
|
|
|
|
typedef struct guac_rdp_upload_status {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The overall offset within the file that the next write should
|
|
|
|
* occur at.
|
|
|
|
*/
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the file being written to.
|
|
|
|
*/
|
|
|
|
int file_id;
|
|
|
|
|
|
|
|
} guac_rdp_upload_status;
|
|
|
|
|
2015-07-06 06:14:18 +00:00
|
|
|
/**
|
|
|
|
* The current state of a directory listing operation.
|
|
|
|
*/
|
|
|
|
typedef struct guac_rdp_ls_status {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The filesystem associated with the directory being listed.
|
|
|
|
*/
|
|
|
|
guac_rdp_fs* fs;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The file ID of the directory being listed.
|
|
|
|
*/
|
|
|
|
int file_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The absolute path of the directory being listed.
|
|
|
|
*/
|
|
|
|
char directory_name[GUAC_RDP_FS_MAX_PATH];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current state of the JSON directory object being written.
|
|
|
|
*/
|
|
|
|
guac_common_json_state json_state;
|
|
|
|
|
|
|
|
} guac_rdp_ls_status;
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* All available stream types.
|
|
|
|
*/
|
|
|
|
typedef enum guac_rdp_stream_type {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An in-progress file upload.
|
|
|
|
*/
|
|
|
|
GUAC_RDP_UPLOAD_STREAM,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An in-progress file download.
|
|
|
|
*/
|
|
|
|
GUAC_RDP_DOWNLOAD_STREAM,
|
|
|
|
|
2015-07-06 06:14:18 +00:00
|
|
|
/**
|
|
|
|
* An in-progress stream of a directory listing.
|
|
|
|
*/
|
|
|
|
GUAC_RDP_LS_STREAM,
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* The inbound half of a static virtual channel.
|
|
|
|
*/
|
2014-04-08 02:22:53 +00:00
|
|
|
GUAC_RDP_INBOUND_SVC_STREAM,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An inbound stream of clipboard data.
|
|
|
|
*/
|
|
|
|
GUAC_RDP_INBOUND_CLIPBOARD_STREAM
|
2014-03-04 00:18:14 +00:00
|
|
|
|
|
|
|
} guac_rdp_stream_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable-typed stream data.
|
|
|
|
*/
|
|
|
|
typedef struct guac_rdp_stream {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of this stream.
|
|
|
|
*/
|
|
|
|
guac_rdp_stream_type type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The file upload status. Only valid for GUAC_RDP_UPLOAD_STREAM.
|
|
|
|
*/
|
|
|
|
guac_rdp_upload_status upload_status;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The file upload status. Only valid for GUAC_RDP_DOWNLOAD_STREAM.
|
|
|
|
*/
|
|
|
|
guac_rdp_download_status download_status;
|
|
|
|
|
2015-07-06 06:14:18 +00:00
|
|
|
/**
|
|
|
|
* The directory list status. Only valid for GUAC_RDP_LS_STREAM.
|
|
|
|
*/
|
|
|
|
guac_rdp_ls_status ls_status;
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* Associated SVC instance. Only valid for GUAC_RDP_INBOUND_SVC_STREAM.
|
|
|
|
*/
|
|
|
|
guac_rdp_svc* svc;
|
|
|
|
|
|
|
|
} guac_rdp_stream;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for inbound files related to file uploads.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user creating the file stream.
|
|
|
|
* @param stream The newly-created file stream.
|
|
|
|
* @param mimetype The mimetype of the file being received.
|
|
|
|
* @param filename The name of the file being received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_upload_file_handler(guac_user* user, guac_stream* stream,
|
2014-03-04 00:18:14 +00:00
|
|
|
char* mimetype, char* filename);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for inbound pipes related to static virtual channels.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user creating the pipe stream.
|
|
|
|
* @param stream The newly-created pipe stream.
|
|
|
|
* @param mimetype The mimetype of the pipe being received.
|
|
|
|
* @param name The name of the pipe being received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_svc_pipe_handler(guac_user* user, guac_stream* stream,
|
2014-03-04 00:18:14 +00:00
|
|
|
char* mimetype, char* name);
|
|
|
|
|
2014-04-08 02:22:53 +00:00
|
|
|
/**
|
|
|
|
* Handler for inbound clipboard data.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user creating the clipboard stream.
|
|
|
|
* @param stream The newly-created clipboard stream.
|
|
|
|
* @param mimetype The mimetype of the clipboard data being received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-04-08 02:22:53 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_clipboard_handler(guac_user* user, guac_stream* stream,
|
2014-04-08 02:22:53 +00:00
|
|
|
char* mimetype);
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* Handler for stream data related to file uploads.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user sending data.
|
|
|
|
* @param stream The file stream receiving the given data.
|
|
|
|
* @param data The received data.
|
|
|
|
* @param length The number of bytes received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_upload_blob_handler(guac_user* user, guac_stream* stream,
|
2014-03-04 00:18:14 +00:00
|
|
|
void* data, int length);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for stream data related to static virtual channels.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user sending data.
|
|
|
|
* @param stream The pipe stream receiving the given data.
|
|
|
|
* @param data The received data.
|
|
|
|
* @param length The number of bytes received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_svc_blob_handler(guac_user* user, guac_stream* stream,
|
2014-03-04 00:18:14 +00:00
|
|
|
void* data, int length);
|
|
|
|
|
2014-04-08 02:22:53 +00:00
|
|
|
/**
|
|
|
|
* Handler for stream data related to clipboard.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user sending data.
|
|
|
|
* @param stream The clipboard stream receiving the given data.
|
|
|
|
* @param data The received data.
|
|
|
|
* @param length The number of bytes received.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-04-08 02:22:53 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_clipboard_blob_handler(guac_user* user, guac_stream* stream,
|
2014-04-08 02:22:53 +00:00
|
|
|
void* data, int length);
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* Handler for end-of-stream related to file uploads.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user closing the stream.
|
|
|
|
* @param stream The file stream being closed.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_upload_end_handler(guac_user* user, guac_stream* stream);
|
2014-03-04 00:18:14 +00:00
|
|
|
|
2014-04-08 02:22:53 +00:00
|
|
|
/**
|
|
|
|
* Handler for end-of-stream related to clipboard.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user closing the stream.
|
|
|
|
* @param stream The clipboard stream being closed.
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-04-08 02:22:53 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_clipboard_end_handler(guac_user* user, guac_stream* stream);
|
2014-04-08 02:22:53 +00:00
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
/**
|
|
|
|
* Handler for acknowledgements of receipt of data related to file downloads.
|
2016-03-01 05:50:00 +00:00
|
|
|
*
|
|
|
|
* @param user The user acknowledging data receipt.
|
|
|
|
* @param stream The file stream associated with the data being acknowledged.
|
|
|
|
* @param message An arbitrary human-readable message acknowledging receipt.
|
|
|
|
* @param status
|
|
|
|
* The status code representing whether the data was received successfully.
|
|
|
|
*
|
|
|
|
* @return Zero if successful, non-zero if an error occurs.
|
2014-03-04 00:18:14 +00:00
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_download_ack_handler(guac_user* user, guac_stream* stream,
|
2014-03-04 00:18:14 +00:00
|
|
|
char* message, guac_protocol_status status);
|
|
|
|
|
2015-07-06 06:14:18 +00:00
|
|
|
/**
|
|
|
|
* Handler for ack messages received due to receipt of a "body" or "blob"
|
|
|
|
* instruction associated with a directory list operation.
|
|
|
|
*
|
2016-03-01 05:50:00 +00:00
|
|
|
* @param user
|
|
|
|
* The user receiving the ack message.
|
2015-07-06 06:14:18 +00:00
|
|
|
*
|
|
|
|
* @param stream
|
|
|
|
* The Guacamole protocol stream associated with the received ack message.
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* An arbitrary human-readable message describing the nature of the
|
|
|
|
* success or failure denoted by this ack message.
|
|
|
|
*
|
|
|
|
* @param status
|
|
|
|
* The status code associated with this ack message, which may indicate
|
|
|
|
* success or an error.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Zero on success, non-zero on error.
|
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_ls_ack_handler(guac_user* user, guac_stream* stream,
|
2015-07-06 06:14:18 +00:00
|
|
|
char* message, guac_protocol_status status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for get messages. In context of downloads and the filesystem exposed
|
|
|
|
* via the Guacamole protocol, get messages request the body of a file within
|
|
|
|
* the filesystem.
|
|
|
|
*
|
2016-03-01 05:50:00 +00:00
|
|
|
* @param user
|
|
|
|
* The user receiving the get message.
|
2015-07-06 06:14:18 +00:00
|
|
|
*
|
|
|
|
* @param object
|
|
|
|
* The Guacamole protocol object associated with the get request itself.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* The name of the input stream (file) being requested.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Zero on success, non-zero on error.
|
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_download_get_handler(guac_user* user, guac_object* object,
|
2015-07-06 06:14:18 +00:00
|
|
|
char* name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for put messages. In context of uploads and the filesystem exposed
|
|
|
|
* via the Guacamole protocol, put messages request write access to a file
|
|
|
|
* within the filesystem.
|
|
|
|
*
|
2016-03-01 05:50:00 +00:00
|
|
|
* @param user
|
|
|
|
* The user receiving the put message.
|
2015-07-06 06:14:18 +00:00
|
|
|
*
|
|
|
|
* @param object
|
|
|
|
* The Guacamole protocol object associated with the put request itself.
|
|
|
|
*
|
|
|
|
* @param stream
|
2016-03-01 05:50:00 +00:00
|
|
|
* The Guacamole protocol stream along which the user will be sending
|
2015-07-06 06:14:18 +00:00
|
|
|
* file data.
|
|
|
|
*
|
|
|
|
* @param mimetype
|
|
|
|
* The mimetype of the data being send along the stream.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* The name of the input stream (file) being requested.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Zero on success, non-zero on error.
|
|
|
|
*/
|
2016-03-01 05:50:00 +00:00
|
|
|
int guac_rdp_upload_put_handler(guac_user* user, guac_object* object,
|
2015-07-06 06:14:18 +00:00
|
|
|
guac_stream* stream, char* mimetype, char* name);
|
|
|
|
|
2014-03-04 00:18:14 +00:00
|
|
|
#endif
|
|
|
|
|