Move to IOCOMPLETION function rather that duplicating header everywhere.

This commit is contained in:
Michael Jumper 2013-10-22 14:08:03 -07:00
parent 911746ae24
commit 22d0e496f5
7 changed files with 95 additions and 162 deletions

View File

@ -60,7 +60,7 @@
void guac_rdpdr_fs_process_create(guac_rdpdr_device* device, void guac_rdpdr_fs_process_create(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) { wStream* input_stream, int completion_id) {
wStream* output_stream = Stream_New(NULL, 21); wStream* output_stream;
int file_id; int file_id;
int desired_access, file_attributes; int desired_access, file_attributes;
@ -86,19 +86,13 @@ void guac_rdpdr_fs_process_create(guac_rdpdr_device* device,
file_id = guac_rdpdr_fs_open(device, path, desired_access, file_attributes, file_id = guac_rdpdr_fs_open(device, path, desired_access, file_attributes,
create_disposition, create_options); create_disposition, create_options);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
/* If no file IDs available, notify server */ /* If no file IDs available, notify server */
if (file_id == GUAC_RDPDR_FS_ENFILE) { if (file_id == GUAC_RDPDR_FS_ENFILE) {
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"File open refused - too many open files"); "File open refused - too many open files");
Stream_Write_UINT32(output_stream, STATUS_TOO_MANY_OPENED_FILES);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_TOO_MANY_OPENED_FILES, 5);
Stream_Write_UINT32(output_stream, 0); /* fileId */ Stream_Write_UINT32(output_stream, 0); /* fileId */
Stream_Write_UINT8(output_stream, 0); /* information */ Stream_Write_UINT8(output_stream, 0); /* information */
} }
@ -107,14 +101,17 @@ void guac_rdpdr_fs_process_create(guac_rdpdr_device* device,
else if (file_id == GUAC_RDPDR_FS_ENOENT) { else if (file_id == GUAC_RDPDR_FS_ENOENT) {
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"File open refused - does not exist: \"%s\"", path); "File open refused - does not exist: \"%s\"", path);
Stream_Write_UINT32(output_stream, STATUS_NO_SUCH_FILE);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_NO_SUCH_FILE, 5);
Stream_Write_UINT32(output_stream, 0); /* fileId */ Stream_Write_UINT32(output_stream, 0); /* fileId */
Stream_Write_UINT8(output_stream, 0); /* information */ Stream_Write_UINT8(output_stream, 0); /* information */
} }
/* Otherwise, open succeeded */ /* Otherwise, open succeeded */
else { else {
Stream_Write_UINT32(output_stream, STATUS_SUCCESS); output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_SUCCESS, 5);
Stream_Write_UINT32(output_stream, file_id); /* fileId */ Stream_Write_UINT32(output_stream, file_id); /* fileId */
Stream_Write_UINT8(output_stream, 0); /* information */ Stream_Write_UINT8(output_stream, 0); /* information */
} }
@ -142,21 +139,13 @@ void guac_rdpdr_fs_process_read(guac_rdpdr_device* device,
Stream_Read_UINT32(input_stream, length); Stream_Read_UINT32(input_stream, length);
Stream_Read_UINT64(input_stream, offset); Stream_Read_UINT64(input_stream, offset);
output_stream = Stream_New(NULL, 20 + sizeof(buffer));
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
/* If file is a directory, fail */ /* If file is a directory, fail */
if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) { if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) {
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"Refusing to read directory as a file"); "Refusing to read directory as a file");
Stream_Write_UINT32(output_stream, STATUS_FILE_IS_A_DIRECTORY);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_FILE_IS_A_DIRECTORY, 4);
Stream_Write_UINT32(output_stream, 0); /* Length */ Stream_Write_UINT32(output_stream, 0); /* Length */
} }
@ -177,13 +166,16 @@ void guac_rdpdr_fs_process_read(guac_rdpdr_device* device,
if (bytes_read < 0) { if (bytes_read < 0) {
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"Unable to read from file: %s", strerror(errno)); "Unable to read from file: %s", strerror(errno));
Stream_Write_UINT32(output_stream, STATUS_INVALID_PARAMETER);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_INVALID_PARAMETER, 4);
Stream_Write_UINT32(output_stream, 0); /* Length */ Stream_Write_UINT32(output_stream, 0); /* Length */
} }
/* Otherwise, send bytes read */ /* Otherwise, send bytes read */
else { else {
Stream_Write_UINT32(output_stream, STATUS_SUCCESS); output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_SUCCESS, 4+bytes_read);
Stream_Write_UINT32(output_stream, bytes_read); /* Length */ Stream_Write_UINT32(output_stream, bytes_read); /* Length */
Stream_Write(output_stream, buffer, bytes_read); /* ReadData */ Stream_Write(output_stream, buffer, bytes_read); /* ReadData */
} }
@ -213,21 +205,13 @@ void guac_rdpdr_fs_process_write(guac_rdpdr_device* device,
Stream_Read_UINT64(input_stream, offset); Stream_Read_UINT64(input_stream, offset);
Stream_Seek(input_stream, 20); /* Padding */ Stream_Seek(input_stream, 20); /* Padding */
output_stream = Stream_New(NULL, 21);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
/* If file is a directory, fail */ /* If file is a directory, fail */
if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) { if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) {
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"Refusing to write directory as a file"); "Refusing to write directory as a file");
Stream_Write_UINT32(output_stream, STATUS_FILE_IS_A_DIRECTORY);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_FILE_IS_A_DIRECTORY, 5);
Stream_Write_UINT32(output_stream, 0); /* Length */ Stream_Write_UINT32(output_stream, 0); /* Length */
Stream_Write_UINT8(output_stream, 0); /* Padding */ Stream_Write_UINT8(output_stream, 0); /* Padding */
} }
@ -246,14 +230,17 @@ void guac_rdpdr_fs_process_write(guac_rdpdr_device* device,
guac_client_log_error(device->rdpdr->client, guac_client_log_error(device->rdpdr->client,
"Unable to write to file %i: %s", file->fd, "Unable to write to file %i: %s", file->fd,
strerror(errno)); strerror(errno));
Stream_Write_UINT32(output_stream, STATUS_ACCESS_DENIED);
output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_ACCESS_DENIED, 5);
Stream_Write_UINT32(output_stream, 0); /* Length */ Stream_Write_UINT32(output_stream, 0); /* Length */
Stream_Write_UINT8(output_stream, 0); /* Padding */ Stream_Write_UINT8(output_stream, 0); /* Padding */
} }
/* Otherwise, send success */ /* Otherwise, send success */
else { else {
Stream_Write_UINT32(output_stream, STATUS_SUCCESS); output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_SUCCESS, 5);
Stream_Write_UINT32(output_stream, bytes_written); /* Length */ Stream_Write_UINT32(output_stream, bytes_written); /* Length */
Stream_Write_UINT8(output_stream, 0); /* Padding */ Stream_Write_UINT8(output_stream, 0); /* Padding */
} }
@ -267,19 +254,13 @@ void guac_rdpdr_fs_process_write(guac_rdpdr_device* device,
void guac_rdpdr_fs_process_close(guac_rdpdr_device* device, void guac_rdpdr_fs_process_close(guac_rdpdr_device* device,
wStream* input_stream, int file_id, int completion_id) { wStream* input_stream, int file_id, int completion_id) {
wStream* output_stream = Stream_New(NULL, 20); wStream* output_stream;
/* Close file */ /* Close file */
guac_rdpdr_fs_close(device, file_id); guac_rdpdr_fs_close(device, file_id);
/* Write header */ output_stream = guac_rdpdr_new_io_completion(device, completion_id,
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); STATUS_SUCCESS, 4);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write(output_stream, "\0\0\0\0", 4); /* Padding */ Stream_Write(output_stream, "\0\0\0\0", 4); /* Padding */
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
@ -412,19 +393,11 @@ void guac_rdpdr_fs_process_set_file_info(guac_rdpdr_device* device,
} }
void guac_rdpdr_fs_process_device_control(guac_rdpdr_device* device, wStream* input_stream, void guac_rdpdr_fs_process_device_control(guac_rdpdr_device* device,
int file_id, int completion_id) { wStream* input_stream, int file_id, int completion_id) {
wStream* output_stream = Stream_New(NULL, 60); wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_INVALID_PARAMETER, 4);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_INVALID_PARAMETER);
/* No content for now */ /* No content for now */
Stream_Write_UINT32(output_stream, 0); Stream_Write_UINT32(output_stream, 0);
@ -533,18 +506,11 @@ void guac_rdpdr_fs_process_query_directory(guac_rdpdr_device* device, wStream* i
* Handle errors as a lack of files. * Handle errors as a lack of files.
*/ */
output_stream = Stream_New(NULL, 21); output_stream = guac_rdpdr_new_io_completion(device, completion_id,
STATUS_NO_MORE_FILES, 5);
/* Write header */ Stream_Write_UINT32(output_stream, 0); /* Length */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); Stream_Write_UINT8(output_stream, 0); /* Padding */
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_NO_MORE_FILES);
Stream_Write_UINT32(output_stream, 0);
Stream_Write_UINT8(output_stream, 0);
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);

View File

@ -77,14 +77,8 @@ void guac_rdpdr_fs_process_query_both_directory_info(guac_rdpdr_device* device,
if (file == NULL) if (file == NULL)
return; return;
/* Write header */ output_stream = guac_rdpdr_new_io_completion(device, completion_id,
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); STATUS_SUCCESS, 4 + 69 + 24 + utf16_length + 2);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, Stream_Write_UINT32(output_stream,
69 + 24 + utf16_length + 2); /* Length */ 69 + 24 + utf16_length + 2); /* Length */

View File

@ -55,7 +55,7 @@
void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream* input_stream, void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream* input_stream,
int file_id, int completion_id) { int file_id, int completion_id) {
wStream* output_stream = Stream_New(NULL, 60); wStream* output_stream;
guac_rdpdr_fs_file* file; guac_rdpdr_fs_file* file;
/* Get file */ /* Get file */
@ -63,14 +63,8 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream*
if (file == NULL) if (file == NULL)
return; return;
/* Write header */ output_stream = guac_rdpdr_new_io_completion(device, completion_id,
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); STATUS_SUCCESS, 40);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 36); Stream_Write_UINT32(output_stream, 36);
Stream_Write_UINT64(output_stream, file->ctime); /* CreationTime */ Stream_Write_UINT64(output_stream, file->ctime); /* CreationTime */
@ -88,7 +82,7 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream*
void guac_rdpdr_fs_process_query_standard_info(guac_rdpdr_device* device, wStream* input_stream, void guac_rdpdr_fs_process_query_standard_info(guac_rdpdr_device* device, wStream* input_stream,
int file_id, int completion_id) { int file_id, int completion_id) {
wStream* output_stream = Stream_New(NULL, 60); wStream* output_stream;
guac_rdpdr_fs_file* file; guac_rdpdr_fs_file* file;
BOOL is_directory = FALSE; BOOL is_directory = FALSE;
@ -100,14 +94,8 @@ void guac_rdpdr_fs_process_query_standard_info(guac_rdpdr_device* device, wStrea
if (file->attributes & FILE_ATTRIBUTE_DIRECTORY) if (file->attributes & FILE_ATTRIBUTE_DIRECTORY)
is_directory = TRUE; is_directory = TRUE;
/* Write header */ output_stream = guac_rdpdr_new_io_completion(device, completion_id,
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); STATUS_SUCCESS, 26);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 22); Stream_Write_UINT32(output_stream, 22);
Stream_Write_UINT64(output_stream, file->size); /* AllocationSize */ Stream_Write_UINT64(output_stream, file->size); /* AllocationSize */
@ -139,18 +127,10 @@ void guac_rdpdr_fs_process_set_rename_info(guac_rdpdr_device* device,
void guac_rdpdr_fs_process_set_allocation_info(guac_rdpdr_device* device, void guac_rdpdr_fs_process_set_allocation_info(guac_rdpdr_device* device,
wStream* input_stream, int file_id, int completion_id, int length) { wStream* input_stream, int file_id, int completion_id, int length) {
wStream* output_stream = Stream_New(NULL, 60); wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 4);
/* Write header */ /* Currently do nothing, just respond */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
/* No content for now */
Stream_Write_UINT32(output_stream, length); Stream_Write_UINT32(output_stream, length);
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
@ -167,18 +147,10 @@ void guac_rdpdr_fs_process_set_disposition_info(guac_rdpdr_device* device,
void guac_rdpdr_fs_process_set_end_of_file_info(guac_rdpdr_device* device, void guac_rdpdr_fs_process_set_end_of_file_info(guac_rdpdr_device* device,
wStream* input_stream, int file_id, int completion_id, int length) { wStream* input_stream, int file_id, int completion_id, int length) {
wStream* output_stream = Stream_New(NULL, 60); wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 4);
/* Write header */ /* Currently do nothing, just respond */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
/* No content for now */
Stream_Write_UINT32(output_stream, length); Stream_Write_UINT32(output_stream, length);
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);

View File

@ -51,19 +51,11 @@
#include <freerdp/utils/svc_plugin.h> #include <freerdp/utils/svc_plugin.h>
void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream* input_stream, void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device,
int file_id, int completion_id) { wStream* input_stream, int file_id, int completion_id) {
wStream* output_stream = Stream_New(NULL, 38 + GUAC_FILESYSTEM_NAME_LENGTH); wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 21 + GUAC_FILESYSTEM_LABEL_LENGTH);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 17 + GUAC_FILESYSTEM_LABEL_LENGTH); Stream_Write_UINT32(output_stream, 17 + GUAC_FILESYSTEM_LABEL_LENGTH);
Stream_Write_UINT64(output_stream, 0); /* VolumeCreationTime */ Stream_Write_UINT64(output_stream, 0); /* VolumeCreationTime */

View File

@ -142,20 +142,14 @@ static int guac_rdpdr_create_print_process(guac_rdpdr_device* device) {
void guac_rdpdr_process_print_job_create(guac_rdpdr_device* device, void guac_rdpdr_process_print_job_create(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) { wStream* input_stream, int completion_id) {
guac_rdpdr_printer_data* printer_data = (guac_rdpdr_printer_data*) device->data; guac_rdpdr_printer_data* printer_data =
wStream* output_stream = Stream_New(NULL, 24); (guac_rdpdr_printer_data*) device->data;
wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 4);
/* No bytes received yet */ /* No bytes received yet */
printer_data->bytes_received = 0; printer_data->bytes_received = 0;
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 0); /* fileId */ Stream_Write_UINT32(output_stream, 0); /* fileId */
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
@ -169,7 +163,7 @@ void guac_rdpdr_process_print_job_write(guac_rdpdr_device* device,
int status=0, length; int status=0, length;
unsigned char* buffer; unsigned char* buffer;
wStream* output_stream = Stream_New(NULL, 24); wStream* output_stream;
Stream_Read_UINT32(input_stream, length); Stream_Read_UINT32(input_stream, length);
Stream_Seek(input_stream, 8); /* Offset */ Stream_Seek(input_stream, 8); /* Offset */
@ -244,16 +238,11 @@ void guac_rdpdr_process_print_job_write(guac_rdpdr_device* device,
} }
/* Write header */ output_stream = guac_rdpdr_new_io_completion(device, completion_id,
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE); status, 5);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, status);
Stream_Write_UINT32(output_stream, length); Stream_Write_UINT32(output_stream, length);
Stream_Write_UINT8(output_stream, 0); /* padding (stated as optional in spec, but requests fail without) */ Stream_Write_UINT8(output_stream, 0); /* Padding */
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
@ -262,8 +251,13 @@ void guac_rdpdr_process_print_job_write(guac_rdpdr_device* device,
void guac_rdpdr_process_print_job_close(guac_rdpdr_device* device, void guac_rdpdr_process_print_job_close(guac_rdpdr_device* device,
wStream* input_stream, int completion_id) { wStream* input_stream, int completion_id) {
guac_rdpdr_printer_data* printer_data = (guac_rdpdr_printer_data*) device->data; guac_rdpdr_printer_data* printer_data =
wStream* output_stream = Stream_New(NULL, 24); (guac_rdpdr_printer_data*) device->data;
wStream* output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 1);
Stream_Write_UINT32(output_stream, 0); /* padding*/
/* Close input and wait for output thread to finish */ /* Close input and wait for output thread to finish */
close(printer_data->printer_input); close(printer_data->printer_input);
@ -276,16 +270,6 @@ void guac_rdpdr_process_print_job_close(guac_rdpdr_device* device,
guac_client_log_info(device->rdpdr->client, "Print job closed"); guac_client_log_info(device->rdpdr->client, "Print job closed");
guac_protocol_send_end(device->rdpdr->client->socket, printer_data->stream); guac_protocol_send_end(device->rdpdr->client->socket, printer_data->stream);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 0); /* padding*/
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream); svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
} }

View File

@ -216,3 +216,21 @@ void guac_rdpdr_process_receive(rdpSvcPlugin* plugin,
} }
wStream* guac_rdpdr_new_io_completion(guac_rdpdr_device* device,
int completion_id, int status, int size) {
wStream* output_stream = Stream_New(NULL, 16+size);
/* Write header */
Stream_Write_UINT16(output_stream, RDPDR_CTYP_CORE);
Stream_Write_UINT16(output_stream, PAKID_CORE_DEVICE_IOCOMPLETION);
/* Write content */
Stream_Write_UINT32(output_stream, device->device_id);
Stream_Write_UINT32(output_stream, completion_id);
Stream_Write_UINT32(output_stream, status);
return output_stream;
}

View File

@ -167,5 +167,12 @@ void guac_rdpdr_process_terminate(rdpSvcPlugin* plugin);
*/ */
void guac_rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event); void guac_rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event);
/**
* 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);
#endif #endif