1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Copyright (C) Matthew Chapman 1999-2007 |
Copyright (C) Matthew Chapman 1999-2008 |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
64 |
extern DEVICE_FNS scard_fns; |
extern DEVICE_FNS scard_fns; |
65 |
#endif |
#endif |
66 |
extern FILEINFO g_fileinfo[]; |
extern FILEINFO g_fileinfo[]; |
67 |
extern BOOL g_notify_stamp; |
extern RD_BOOL g_notify_stamp; |
68 |
|
|
69 |
static VCHANNEL *rdpdr_channel; |
static VCHANNEL *rdpdr_channel; |
70 |
|
|
117 |
} |
} |
118 |
} |
} |
119 |
|
|
120 |
static BOOL |
static RD_BOOL |
121 |
rdpdr_handle_ok(int device, int handle) |
rdpdr_handle_ok(int device, int handle) |
122 |
{ |
{ |
123 |
switch (g_rdpdr_device[device].device_type) |
switch (g_rdpdr_device[device].device_type) |
138 |
} |
} |
139 |
|
|
140 |
/* Add a new io request to the table containing pending io requests so it won't block rdesktop */ |
/* Add a new io request to the table containing pending io requests so it won't block rdesktop */ |
141 |
static BOOL |
static RD_BOOL |
142 |
add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length, |
add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length, |
143 |
DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer, |
DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer, |
144 |
uint32 offset) |
uint32 offset) |
365 |
uint8 *buffer, *pst_buf; |
uint8 *buffer, *pst_buf; |
366 |
struct stream out; |
struct stream out; |
367 |
DEVICE_FNS *fns; |
DEVICE_FNS *fns; |
368 |
BOOL rw_blocking = True; |
RD_BOOL rw_blocking = True; |
369 |
RD_NTSTATUS status = RD_STATUS_INVALID_DEVICE_REQUEST; |
RD_NTSTATUS status = RD_STATUS_INVALID_DEVICE_REQUEST; |
370 |
|
|
371 |
in_uint32_le(s, device); |
in_uint32_le(s, device); |
429 |
|
|
430 |
if (length && (length / 2) < 256) |
if (length && (length / 2) < 256) |
431 |
{ |
{ |
432 |
rdp_in_unistr(s, filename, length); |
rdp_in_unistr(s, filename, sizeof(filename), length); |
433 |
convert_to_unix_filename(filename); |
convert_to_unix_filename(filename); |
434 |
} |
} |
435 |
else |
else |
622 |
in_uint8s(s, 0x17); |
in_uint8s(s, 0x17); |
623 |
if (length && length < 2 * 255) |
if (length && length < 2 * 255) |
624 |
{ |
{ |
625 |
rdp_in_unistr(s, filename, length); |
rdp_in_unistr(s, filename, sizeof(filename), |
626 |
|
length); |
627 |
convert_to_unix_filename(filename); |
convert_to_unix_filename(filename); |
628 |
} |
} |
629 |
else |
else |
646 |
|
|
647 |
in_uint32_le(s, info_level); /* notify mask */ |
in_uint32_le(s, info_level); /* notify mask */ |
648 |
|
|
|
g_notify_stamp = True; |
|
|
|
|
649 |
status = disk_create_notify(file, info_level); |
status = disk_create_notify(file, info_level); |
650 |
result = 0; |
result = 0; |
651 |
|
|
685 |
out.data = out.p = buffer; |
out.data = out.p = buffer; |
686 |
out.size = sizeof(buffer); |
out.size = sizeof(buffer); |
687 |
|
|
|
DEBUG_SCARD(("[SMART-CARD TRACE]\n")); |
|
|
DEBUG_SCARD(("device 0x%.8x\n", device)); |
|
|
DEBUG_SCARD(("file 0x%.8x\n", file)); |
|
|
DEBUG_SCARD(("id 0x%.8x\n", id)); |
|
688 |
#ifdef WITH_SCARD |
#ifdef WITH_SCARD |
689 |
scardSetInfo(device, id, bytes_out + 0x14); |
scardSetInfo(device, id, bytes_out + 0x14); |
690 |
#endif |
#endif |
691 |
status = fns->device_control(file, request, s, &out); |
status = fns->device_control(file, request, s, &out); |
692 |
result = buffer_len = out.p - out.data; |
result = buffer_len = out.p - out.data; |
693 |
|
|
|
DEBUG_SCARD(("[SMART-CARD TRACE] OUT 0x%.8x\n", status)); |
|
|
|
|
694 |
/* Serial SERIAL_WAIT_ON_MASK */ |
/* Serial SERIAL_WAIT_ON_MASK */ |
695 |
if (status == RD_STATUS_PENDING) |
if (status == RD_STATUS_PENDING) |
696 |
{ |
{ |
838 |
unimpl("RDPDR packet type %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]); |
unimpl("RDPDR packet type %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]); |
839 |
} |
} |
840 |
|
|
841 |
BOOL |
RD_BOOL |
842 |
rdpdr_init() |
rdpdr_init() |
843 |
{ |
{ |
844 |
if (g_num_devices > 0) |
if (g_num_devices > 0) |
854 |
|
|
855 |
/* Add file descriptors of pending io request to select() */ |
/* Add file descriptors of pending io request to select() */ |
856 |
void |
void |
857 |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout) |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, RD_BOOL * timeout) |
858 |
{ |
{ |
859 |
uint32 select_timeout = 0; /* Timeout value to be used for select() (in millisecons). */ |
uint32 select_timeout = 0; /* Timeout value to be used for select() (in millisecons). */ |
860 |
struct async_iorequest *iorq; |
struct async_iorequest *iorq; |
951 |
|
|
952 |
/* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */ |
/* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */ |
953 |
static void |
static void |
954 |
_rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out) |
_rdpdr_check_fds(fd_set * rfds, fd_set * wfds, RD_BOOL timed_out) |
955 |
{ |
{ |
956 |
RD_NTSTATUS status; |
RD_NTSTATUS status; |
957 |
uint32 result = 0; |
uint32 result = 0; |
1172 |
} |
} |
1173 |
|
|
1174 |
void |
void |
1175 |
rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out) |
rdpdr_check_fds(fd_set * rfds, fd_set * wfds, RD_BOOL timed_out) |
1176 |
{ |
{ |
1177 |
fd_set dummy; |
fd_set dummy; |
1178 |
|
|
1190 |
|
|
1191 |
|
|
1192 |
/* Abort a pending io request for a given handle and major */ |
/* Abort a pending io request for a given handle and major */ |
1193 |
BOOL |
RD_BOOL |
1194 |
rdpdr_abort_io(uint32 fd, uint32 major, RD_NTSTATUS status) |
rdpdr_abort_io(uint32 fd, uint32 major, RD_NTSTATUS status) |
1195 |
{ |
{ |
1196 |
uint32 result; |
uint32 result; |