2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
|
|
4 |
Copyright (C) Matthew Chapman 1999-2005 |
Copyright (C) Matthew Chapman 1999-2005 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
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 |
8 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
9 |
(at your option) any later version. |
(at your option) any later version. |
10 |
|
|
11 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
150 |
extern RDPDR_DEVICE g_rdpdr_device[]; |
extern RDPDR_DEVICE g_rdpdr_device[]; |
151 |
|
|
152 |
static SERIAL_DEVICE * |
static SERIAL_DEVICE * |
153 |
get_serial_info(NTHANDLE handle) |
get_serial_info(RD_NTHANDLE handle) |
154 |
{ |
{ |
155 |
int index; |
int index; |
156 |
|
|
163 |
} |
} |
164 |
|
|
165 |
static BOOL |
static BOOL |
166 |
get_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd) |
get_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd) |
167 |
{ |
{ |
168 |
speed_t speed; |
speed_t speed; |
169 |
struct termios *ptermios; |
struct termios *ptermios; |
316 |
} |
} |
317 |
|
|
318 |
static void |
static void |
319 |
set_termios(SERIAL_DEVICE * pser_inf, NTHANDLE serial_fd) |
set_termios(SERIAL_DEVICE * pser_inf, RD_NTHANDLE serial_fd) |
320 |
{ |
{ |
321 |
speed_t speed; |
speed_t speed; |
322 |
|
|
553 |
return count; |
return count; |
554 |
} |
} |
555 |
|
|
556 |
static NTSTATUS |
static RD_NTSTATUS |
557 |
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, |
serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, |
558 |
uint32 flags_and_attributes, char *filename, NTHANDLE * handle) |
uint32 flags_and_attributes, char *filename, RD_NTHANDLE * handle) |
559 |
{ |
{ |
560 |
NTHANDLE serial_fd; |
RD_NTHANDLE serial_fd; |
561 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |
562 |
struct termios *ptermios; |
struct termios *ptermios; |
563 |
|
|
568 |
if (serial_fd == -1) |
if (serial_fd == -1) |
569 |
{ |
{ |
570 |
perror("open"); |
perror("open"); |
571 |
return STATUS_ACCESS_DENIED; |
return RD_STATUS_ACCESS_DENIED; |
572 |
} |
} |
573 |
|
|
574 |
if (!get_termios(pser_inf, serial_fd)) |
if (!get_termios(pser_inf, serial_fd)) |
575 |
{ |
{ |
576 |
printf("INFO: SERIAL %s access denied\n", g_rdpdr_device[device_id].name); |
printf("INFO: SERIAL %s access denied\n", g_rdpdr_device[device_id].name); |
577 |
fflush(stdout); |
fflush(stdout); |
578 |
return STATUS_ACCESS_DENIED; |
return RD_STATUS_ACCESS_DENIED; |
579 |
} |
} |
580 |
|
|
581 |
/* Store handle for later use */ |
/* Store handle for later use */ |
607 |
|
|
608 |
pser_inf->read_total_timeout_constant = 5; |
pser_inf->read_total_timeout_constant = 5; |
609 |
|
|
610 |
return STATUS_SUCCESS; |
return RD_STATUS_SUCCESS; |
611 |
} |
} |
612 |
|
|
613 |
static NTSTATUS |
static RD_NTSTATUS |
614 |
serial_close(NTHANDLE handle) |
serial_close(RD_NTHANDLE handle) |
615 |
{ |
{ |
616 |
int i = get_device_index(handle); |
int i = get_device_index(handle); |
617 |
if (i >= 0) |
if (i >= 0) |
618 |
g_rdpdr_device[i].handle = 0; |
g_rdpdr_device[i].handle = 0; |
619 |
|
|
620 |
rdpdr_abort_io(handle, 0, STATUS_TIMEOUT); |
rdpdr_abort_io(handle, 0, RD_STATUS_TIMEOUT); |
621 |
close(handle); |
close(handle); |
622 |
return STATUS_SUCCESS; |
return RD_STATUS_SUCCESS; |
623 |
} |
} |
624 |
|
|
625 |
static NTSTATUS |
static RD_NTSTATUS |
626 |
serial_read(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
serial_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
627 |
{ |
{ |
628 |
long timeout; |
long timeout; |
629 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |
678 |
hexdump(data, *result); |
hexdump(data, *result); |
679 |
#endif |
#endif |
680 |
|
|
681 |
return STATUS_SUCCESS; |
return RD_STATUS_SUCCESS; |
682 |
} |
} |
683 |
|
|
684 |
static NTSTATUS |
static RD_NTSTATUS |
685 |
serial_write(NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
serial_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) |
686 |
{ |
{ |
687 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |
688 |
|
|
695 |
|
|
696 |
DEBUG_SERIAL(("serial_write length %d, offset %d result %d\n", length, offset, *result)); |
DEBUG_SERIAL(("serial_write length %d, offset %d result %d\n", length, offset, *result)); |
697 |
|
|
698 |
return STATUS_SUCCESS; |
return RD_STATUS_SUCCESS; |
699 |
} |
} |
700 |
|
|
701 |
static NTSTATUS |
static RD_NTSTATUS |
702 |
serial_device_control(NTHANDLE handle, uint32 request, STREAM in, STREAM out) |
serial_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out) |
703 |
{ |
{ |
704 |
int flush_mask, purge_mask; |
int flush_mask, purge_mask; |
705 |
uint32 result, modemstate; |
uint32 result, modemstate; |
708 |
struct termios *ptermios; |
struct termios *ptermios; |
709 |
|
|
710 |
if ((request >> 16) != FILE_DEVICE_SERIAL_PORT) |
if ((request >> 16) != FILE_DEVICE_SERIAL_PORT) |
711 |
return STATUS_INVALID_PARAMETER; |
return RD_STATUS_INVALID_PARAMETER; |
712 |
|
|
713 |
pser_inf = get_serial_info(handle); |
pser_inf = get_serial_info(handle); |
714 |
ptermios = pser_inf->ptermios; |
ptermios = pser_inf->ptermios; |
904 |
if (flush_mask != 0) |
if (flush_mask != 0) |
905 |
tcflush(handle, flush_mask); |
tcflush(handle, flush_mask); |
906 |
if (purge_mask & SERIAL_PURGE_TXABORT) |
if (purge_mask & SERIAL_PURGE_TXABORT) |
907 |
rdpdr_abort_io(handle, 4, STATUS_CANCELLED); |
rdpdr_abort_io(handle, 4, RD_STATUS_CANCELLED); |
908 |
if (purge_mask & SERIAL_PURGE_RXABORT) |
if (purge_mask & SERIAL_PURGE_RXABORT) |
909 |
rdpdr_abort_io(handle, 3, STATUS_CANCELLED); |
rdpdr_abort_io(handle, 3, RD_STATUS_CANCELLED); |
910 |
break; |
break; |
911 |
case SERIAL_WAIT_ON_MASK: |
case SERIAL_WAIT_ON_MASK: |
912 |
DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n", |
DEBUG_SERIAL(("serial_ioctl -> SERIAL_WAIT_ON_MASK %X\n", |
918 |
out_uint32_le(out, result); |
out_uint32_le(out, result); |
919 |
break; |
break; |
920 |
} |
} |
921 |
return STATUS_PENDING; |
return RD_STATUS_PENDING; |
922 |
break; |
break; |
923 |
case SERIAL_SET_BREAK_ON: |
case SERIAL_SET_BREAK_ON: |
924 |
DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BREAK_ON\n")); |
DEBUG_SERIAL(("serial_ioctl -> SERIAL_SET_BREAK_ON\n")); |
939 |
break; |
break; |
940 |
default: |
default: |
941 |
unimpl("SERIAL IOCTL %d\n", request); |
unimpl("SERIAL IOCTL %d\n", request); |
942 |
return STATUS_INVALID_PARAMETER; |
return RD_STATUS_INVALID_PARAMETER; |
943 |
} |
} |
944 |
|
|
945 |
return STATUS_SUCCESS; |
return RD_STATUS_SUCCESS; |
946 |
} |
} |
947 |
|
|
948 |
BOOL |
BOOL |
949 |
serial_get_event(NTHANDLE handle, uint32 * result) |
serial_get_event(RD_NTHANDLE handle, uint32 * result) |
950 |
{ |
{ |
951 |
int index; |
int index; |
952 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |
1044 |
|
|
1045 |
/* Read timeout for a given file descripter (device) when adding fd's to select() */ |
/* Read timeout for a given file descripter (device) when adding fd's to select() */ |
1046 |
BOOL |
BOOL |
1047 |
serial_get_timeout(NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout) |
serial_get_timeout(RD_NTHANDLE handle, uint32 length, uint32 * timeout, uint32 * itv_timeout) |
1048 |
{ |
{ |
1049 |
int index; |
int index; |
1050 |
SERIAL_DEVICE *pser_inf; |
SERIAL_DEVICE *pser_inf; |