commit
b8388a65a2
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,330 @@
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2013 jay.sorg@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* smartcard redirection support, PCSC daemon standin
|
||||
* this will act like pcsc daemon
|
||||
*/
|
||||
|
||||
#define PCSC_STANDIN 1
|
||||
|
||||
#include "os_calls.h"
|
||||
#include "smartcard.h"
|
||||
#include "log.h"
|
||||
#include "irp.h"
|
||||
#include "devredir.h"
|
||||
#include "trans.h"
|
||||
|
||||
#if PCSC_STANDIN
|
||||
|
||||
/* module based logging */
|
||||
#define LOG_ERROR 0
|
||||
#define LOG_INFO 1
|
||||
#define LOG_DEBUG 2
|
||||
#define LOG_LEVEL LOG_ERROR
|
||||
|
||||
#define log_error(_params...) \
|
||||
{ \
|
||||
g_write("[%10.10u]: PCSC %s: %d : ERROR: ", \
|
||||
g_time3(), __func__, __LINE__); \
|
||||
g_writeln (_params); \
|
||||
}
|
||||
|
||||
#define log_always(_params...) \
|
||||
{ \
|
||||
g_write("[%10.10u]: PCSC %s: %d : ALWAYS: ", \
|
||||
g_time3(), __func__, __LINE__); \
|
||||
g_writeln (_params); \
|
||||
}
|
||||
|
||||
#define log_info(_params...) \
|
||||
{ \
|
||||
if (LOG_INFO <= LOG_LEVEL) \
|
||||
{ \
|
||||
g_write("[%10.10u]: PCSC %s: %d : ", \
|
||||
g_time3(), __func__, __LINE__); \
|
||||
g_writeln (_params); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define log_debug(_params...) \
|
||||
{ \
|
||||
if (LOG_DEBUG <= LOG_LEVEL) \
|
||||
{ \
|
||||
g_write("[%10.10u]: PCSC %s: %d : ", \
|
||||
g_time3(), __func__, __LINE__); \
|
||||
g_writeln (_params); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PCSCLITE_MSG_KEY_LEN 16
|
||||
#define PCSCLITE_MAX_MESSAGE_SIZE 2048
|
||||
|
||||
struct version_struct
|
||||
{
|
||||
tsi32 major; /**< IPC major \ref PROTOCOL_VERSION_MAJOR */
|
||||
tsi32 minor; /**< IPC minor \ref PROTOCOL_VERSION_MINOR */
|
||||
tui32 rv;
|
||||
};
|
||||
typedef struct version_struct version_struct;
|
||||
|
||||
struct rxSharedSegment
|
||||
{
|
||||
tui32 mtype; /** one of the \c pcsc_adm_commands */
|
||||
tui32 user_id;
|
||||
tui32 group_id;
|
||||
tui32 command; /** one of the \c pcsc_msg_commands */
|
||||
tui64 date;
|
||||
tui8 key[PCSCLITE_MSG_KEY_LEN]; /* 16 bytes */
|
||||
union _u
|
||||
{
|
||||
tui8 data[PCSCLITE_MAX_MESSAGE_SIZE];
|
||||
struct version_struct veStr;
|
||||
} u;
|
||||
};
|
||||
typedef struct rxSharedSegment sharedSegmentMsg, *psharedSegmentMsg;
|
||||
|
||||
#define RXSHAREDSEGMENT_BYTES 2088
|
||||
|
||||
extern int g_display_num; /* in chansrv.c */
|
||||
|
||||
/*****************************************************************************/
|
||||
struct pcsc_client
|
||||
{
|
||||
struct trans *con;
|
||||
};
|
||||
|
||||
static struct pcsc_client *g_head = 0;
|
||||
static struct pcsc_client *g_tail = 0;
|
||||
|
||||
static struct trans *g_lis = 0;
|
||||
static struct trans *g_con = 0; /* todo, remove this */
|
||||
|
||||
static char g_pcsc_directory[256] = "";
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
log_debug("scard_pcsc_get_wait_objs");
|
||||
|
||||
if (g_lis != 0)
|
||||
{
|
||||
trans_get_wait_objs(g_lis, objs, count);
|
||||
}
|
||||
if (g_con != 0)
|
||||
{
|
||||
trans_get_wait_objs(g_con, objs, count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_pcsc_check_wait_objs(void)
|
||||
{
|
||||
log_debug("scard_pcsc_check_wait_objs");
|
||||
|
||||
if (g_lis != 0)
|
||||
{
|
||||
trans_check_wait_objs(g_lis);
|
||||
}
|
||||
if (g_con != 0)
|
||||
{
|
||||
trans_check_wait_objs(g_con);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
scard_process_version(psharedSegmentMsg msg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
scard_process_msg(struct stream *s)
|
||||
{
|
||||
sharedSegmentMsg msg;
|
||||
int rv;
|
||||
|
||||
g_memset(&msg, 0, sizeof(msg));
|
||||
in_uint32_le(s, msg.mtype);
|
||||
in_uint32_le(s, msg.user_id);
|
||||
in_uint32_le(s, msg.group_id);
|
||||
in_uint32_le(s, msg.command);
|
||||
in_uint64_le(s, msg.date);
|
||||
|
||||
log_debug("scard_process_msg: mtype 0x%2.2x command 0x%2.2x",
|
||||
msg.mtype, msg.command);
|
||||
|
||||
rv = 0;
|
||||
switch (msg.mtype)
|
||||
{
|
||||
case 0xF8: /* CMD_VERSION */
|
||||
rv = scard_process_version(&msg);
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int DEFAULT_CC
|
||||
my_pcsc_trans_data_in(struct trans *trans)
|
||||
{
|
||||
struct stream *s;
|
||||
int id;
|
||||
int size;
|
||||
int error;
|
||||
|
||||
log_debug("my_pcsc_trans_data_in:");
|
||||
|
||||
if (trans == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_con)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
s = trans_get_in_s(trans);
|
||||
g_hexdump(s->p, 64);
|
||||
error = scard_process_msg(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* got a new connection from libpcsclite */
|
||||
int DEFAULT_CC
|
||||
my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
{
|
||||
log_debug("my_pcsc_trans_conn_in:");
|
||||
|
||||
if (trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_lis)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_con = new_trans;
|
||||
g_con->trans_data_in = my_pcsc_trans_data_in;
|
||||
g_con->header_size = RXSHAREDSEGMENT_BYTES;
|
||||
|
||||
log_debug("my_pcsc_trans_conn_in: sizeof sharedSegmentMsg is %d",
|
||||
sizeof(sharedSegmentMsg));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_pcsc_init(void)
|
||||
{
|
||||
char port[256];
|
||||
int error;
|
||||
|
||||
log_debug("scard_pcsc_init:");
|
||||
|
||||
if (g_lis == 0)
|
||||
{
|
||||
g_lis = trans_create(2, 8192, 8192);
|
||||
g_snprintf(g_pcsc_directory, 255, "/tmp/.xrdp/pcsc%d", g_display_num);
|
||||
if (g_directory_exist(g_pcsc_directory))
|
||||
{
|
||||
if (g_remove_dir(g_pcsc_directory) != 0)
|
||||
{
|
||||
log_error("scard_pcsc_init: g_remove_dir failed");
|
||||
}
|
||||
}
|
||||
if (g_create_dir(g_pcsc_directory) != 0)
|
||||
{
|
||||
log_error("scard_pcsc_init: g_create_dir failed");
|
||||
}
|
||||
g_chmod_hex(g_pcsc_directory, 0x1777);
|
||||
g_snprintf(port, 255, "%s/pcscd.comm", g_pcsc_directory);
|
||||
g_lis->trans_conn_in = my_pcsc_trans_conn_in;
|
||||
error = trans_listen(g_lis, port);
|
||||
if (error != 0)
|
||||
{
|
||||
log_error("scard_pcsc_init: trans_listen failed for port %s",
|
||||
port);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
scard_pcsc_deinit(void)
|
||||
{
|
||||
log_debug("scard_pcsc_deinit:");
|
||||
|
||||
if (g_lis != 0)
|
||||
{
|
||||
trans_delete(g_lis);
|
||||
g_lis = 0;
|
||||
if (g_remove_dir(g_pcsc_directory) != 0)
|
||||
{
|
||||
log_error("scard_pcsc_deinit: g_remove_dir failed");
|
||||
}
|
||||
g_pcsc_directory[0] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int APP_CC
|
||||
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int APP_CC
|
||||
scard_pcsc_check_wait_objs(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int APP_CC
|
||||
scard_pcsc_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int APP_CC
|
||||
scard_pcsc_deinit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2013 jay.sorg@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* smartcard redirection support, PCSC daemon standin
|
||||
*/
|
||||
|
||||
#ifndef _SMARTCARD_PCSC_H
|
||||
#define _SMARTCARD_PCSC_H
|
||||
|
||||
int APP_CC
|
||||
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout);
|
||||
int APP_CC
|
||||
scard_pcsc_check_wait_objs(void);
|
||||
int APP_CC
|
||||
scard_pcsc_init(void);
|
||||
int APP_CC
|
||||
scard_pcsc_deinit(void);
|
||||
|
||||
#endif /* end #ifndef _SMARTCARD_PCSC_H */
|
@ -0,0 +1,245 @@
|
||||
/*
|
||||
Copyright 2005-2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
Client connection to xrdp
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* this should be before all X11 .h files */
|
||||
#include <xorg-server.h>
|
||||
|
||||
/* all driver need this */
|
||||
#include <xf86.h>
|
||||
#include <xf86_OSproc.h>
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpDraw.h"
|
||||
#include "rdpClientCon.h"
|
||||
#include "rdpMisc.h"
|
||||
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
#define LTOUI32(_in) ((unsigned int)(_in))
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
rdpClientConGotConnection(ScreenPtr pScreen, rdpPtr dev)
|
||||
{
|
||||
rdpClientCon *clientCon;
|
||||
|
||||
LLOGLN(0, ("rdpClientConGotConnection:"));
|
||||
clientCon = (rdpClientCon *) g_malloc(sizeof(rdpClientCon), 1);
|
||||
make_stream(clientCon->in_s);
|
||||
init_stream(clientCon->in_s, 8192);
|
||||
make_stream(clientCon->out_s);
|
||||
init_stream(clientCon->out_s, 8192 * 4 + 100);
|
||||
if (dev->clientConTail == NULL)
|
||||
{
|
||||
dev->clientConHead = clientCon;
|
||||
dev->clientConTail = clientCon;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev->clientConTail->next = clientCon;
|
||||
dev->clientConTail = clientCon;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
rdpClientConGotData(ScreenPtr pScreen, rdpPtr dev, rdpClientCon *clientCon)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConGotData:"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
rdpClientConGotControlConnection(ScreenPtr pScreen, rdpPtr dev,
|
||||
rdpClientCon *clientCon)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConGotControlConnection:"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
rdpClientConGotControlData(ScreenPtr pScreen, rdpPtr dev,
|
||||
rdpClientCon *clientCon)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConGotControlData:"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpClientConCheck(ScreenPtr pScreen)
|
||||
{
|
||||
rdpPtr dev;
|
||||
rdpClientCon *clientCon;
|
||||
fd_set rfds;
|
||||
struct timeval time;
|
||||
int max;
|
||||
int sel;
|
||||
int count;
|
||||
|
||||
LLOGLN(10, ("rdpClientConCheck:"));
|
||||
dev = rdpGetDevFromScreen(pScreen);
|
||||
time.tv_sec = 0;
|
||||
time.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
count = 0;
|
||||
max = 0;
|
||||
if (dev->listen_sck > 0)
|
||||
{
|
||||
count++;
|
||||
FD_SET(LTOUI32(dev->listen_sck), &rfds);
|
||||
max = RDPMAX(dev->listen_sck, max);
|
||||
}
|
||||
clientCon = dev->clientConHead;
|
||||
while (clientCon != NULL)
|
||||
{
|
||||
if (clientCon->sck > 0)
|
||||
{
|
||||
count++;
|
||||
FD_SET(LTOUI32(clientCon->sck), &rfds);
|
||||
max = RDPMAX(clientCon->sck, max);
|
||||
}
|
||||
if (clientCon->sckControl > 0)
|
||||
{
|
||||
count++;
|
||||
FD_SET(LTOUI32(clientCon->sckControl), &rfds);
|
||||
max = RDPMAX(clientCon->sckControl, max);
|
||||
}
|
||||
if (clientCon->sckControlListener > 0)
|
||||
{
|
||||
count++;
|
||||
FD_SET(LTOUI32(clientCon->sckControlListener), &rfds);
|
||||
max = RDPMAX(clientCon->sckControlListener, max);
|
||||
}
|
||||
clientCon = clientCon->next;
|
||||
}
|
||||
if (count < 1)
|
||||
{
|
||||
sel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = select(max + 1, &rfds, 0, 0, &time);
|
||||
}
|
||||
if (sel < 1)
|
||||
{
|
||||
LLOGLN(10, ("rdpClientConCheck: no select"));
|
||||
return 0;
|
||||
}
|
||||
if (dev->listen_sck > 0)
|
||||
{
|
||||
if (FD_ISSET(LTOUI32(dev->listen_sck), &rfds))
|
||||
{
|
||||
rdpClientConGotConnection(pScreen, dev);
|
||||
}
|
||||
}
|
||||
clientCon = dev->clientConHead;
|
||||
while (clientCon != NULL)
|
||||
{
|
||||
if (clientCon->sck > 0)
|
||||
{
|
||||
if (FD_ISSET(LTOUI32(clientCon->sck), &rfds))
|
||||
{
|
||||
rdpClientConGotData(pScreen, dev, clientCon);
|
||||
}
|
||||
}
|
||||
if (clientCon->sckControlListener > 0)
|
||||
{
|
||||
if (FD_ISSET(LTOUI32(clientCon->sckControlListener), &rfds))
|
||||
{
|
||||
rdpClientConGotControlConnection(pScreen, dev, clientCon);
|
||||
}
|
||||
}
|
||||
if (clientCon->sckControl > 0)
|
||||
{
|
||||
if (FD_ISSET(LTOUI32(clientCon->sckControl), &rfds))
|
||||
{
|
||||
rdpClientConGotControlData(pScreen, dev, clientCon);
|
||||
}
|
||||
}
|
||||
clientCon = clientCon->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpClientConInit(rdpPtr dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!g_directory_exist("/tmp/.xrdp"))
|
||||
{
|
||||
if (!g_create_dir("/tmp/.xrdp"))
|
||||
{
|
||||
if (!g_directory_exist("/tmp/.xrdp"))
|
||||
{
|
||||
LLOGLN(0, ("rdpup_init: g_create_dir failed"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
g_chmod_hex("/tmp/.xrdp", 0x1777);
|
||||
}
|
||||
i = atoi(display);
|
||||
if (i < 1)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConInit: can not run at display < 1"));
|
||||
return 0;
|
||||
}
|
||||
g_sprintf(dev->uds_data, "/tmp/.xrdp/xrdp_display_%s", display);
|
||||
if (dev->listen_sck == 0)
|
||||
{
|
||||
unlink(dev->uds_data);
|
||||
dev->listen_sck = g_tcp_local_socket_stream();
|
||||
if (g_tcp_local_bind(dev->listen_sck, dev->uds_data) != 0)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConInit: g_tcp_local_bind failed"));
|
||||
return 1;
|
||||
}
|
||||
g_tcp_listen(dev->listen_sck);
|
||||
AddEnabledDevice(dev->listen_sck);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpClientConDeinit(rdpPtr dev)
|
||||
{
|
||||
LLOGLN(0, ("rdpClientConDeinit:"));
|
||||
if (dev->listen_sck != 0)
|
||||
{
|
||||
close(dev->listen_sck);
|
||||
unlink(dev->uds_data);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2005-2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
Client connection to xrdp
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _RDPCLIENTCON_H
|
||||
#define _RDPCLIENTCON_H
|
||||
|
||||
struct _rdpClientCon
|
||||
{
|
||||
int sck;
|
||||
int sckControlListener;
|
||||
int sckControl;
|
||||
struct stream *out_s;
|
||||
struct stream *in_s;
|
||||
struct _rdpClientCon *next;
|
||||
};
|
||||
|
||||
int
|
||||
rdpClientConCheck(ScreenPtr pScreen);
|
||||
int
|
||||
rdpClientConInit(rdpPtr dev);
|
||||
int
|
||||
rdpClientConDeinit(rdpPtr dev);
|
||||
|
||||
#endif
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
Copyright 2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* this should be before all X11 .h files */
|
||||
#include <xorg-server.h>
|
||||
|
||||
/* all driver need this */
|
||||
#include <xf86.h>
|
||||
#include <xf86_OSproc.h>
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpDraw.h"
|
||||
#include "rdpInput.h"
|
||||
#include "rdpMisc.h"
|
||||
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
#define MAX_INPUT_PROC 4
|
||||
|
||||
struct input_proc_list
|
||||
{
|
||||
int type;
|
||||
rdpInputEventProcPtr proc;
|
||||
};
|
||||
|
||||
static struct input_proc_list g_input_proc[MAX_INPUT_PROC];
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc)
|
||||
{
|
||||
if (type == 0)
|
||||
{
|
||||
g_input_proc[0].proc = proc;
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
g_input_proc[1].proc = proc;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpUnregisterInputCallback(rdpInputEventProcPtr proc)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < MAX_INPUT_PROC; index++)
|
||||
{
|
||||
if (g_input_proc[index].proc == proc)
|
||||
{
|
||||
g_input_proc[index].proc = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpInputKeyboardEvent(rdpPtr dev, int msg,
|
||||
long param1, long param2,
|
||||
long param3, long param4)
|
||||
{
|
||||
if (g_input_proc[0].proc != 0)
|
||||
{
|
||||
return g_input_proc[0].proc(dev, msg, param1, param2, param3, param4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
rdpInputMouseEvent(rdpPtr dev, int msg,
|
||||
long param1, long param2,
|
||||
long param3, long param4)
|
||||
{
|
||||
if (g_input_proc[1].proc != 0)
|
||||
{
|
||||
return g_input_proc[1].proc(dev, msg, param1, param2, param3, param4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* called when module loads */
|
||||
int
|
||||
rdpInputInit(void)
|
||||
{
|
||||
g_memset(g_input_proc, 0, sizeof(g_input_proc));
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
input
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _RDPINPUT_H
|
||||
#define _RDPINPUT_H
|
||||
|
||||
typedef int (*rdpInputEventProcPtr)(rdpPtr dev, int msg,
|
||||
long param1, long param2,
|
||||
long param3, long param4);
|
||||
|
||||
int
|
||||
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc);
|
||||
int
|
||||
rdpUnregisterInputCallback(rdpInputEventProcPtr proc);
|
||||
int
|
||||
rdpInputKeyboardEvent(rdpPtr dev, int msg,
|
||||
long param1, long param2,
|
||||
long param3, long param4);
|
||||
int
|
||||
rdpInputMouseEvent(rdpPtr dev, int msg,
|
||||
long param1, long param2,
|
||||
long param3, long param4);
|
||||
int
|
||||
rdpInputInit(void);
|
||||
|
||||
#endif
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
rdp module main
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __RDPMAIN_H
|
||||
#define __RDPMAIN_H
|
||||
|
||||
void
|
||||
xorgxrdpDownDown(ScreenPtr pScreen);
|
||||
|
||||
#endif
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright 2005-2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
pixmap calls
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* this should be before all X11 .h files */
|
||||
#include <xorg-server.h>
|
||||
|
||||
/* all driver need this */
|
||||
#include <xf86.h>
|
||||
#include <xf86_OSproc.h>
|
||||
|
||||
#include "rdp.h"
|
||||
#include "rdpDraw.h"
|
||||
|
||||
/******************************************************************************/
|
||||
#define LOG_LEVEL 1
|
||||
#define LLOGLN(_level, _args) \
|
||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||
|
||||
/*****************************************************************************/
|
||||
PixmapPtr
|
||||
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
||||
unsigned usage_hint)
|
||||
{
|
||||
rdpPtr dev;
|
||||
PixmapPtr rv;
|
||||
|
||||
LLOGLN(10, ("rdpCreatePixmap: width %d height %d depth %d",
|
||||
width, height, depth));
|
||||
dev = rdpGetDevFromScreen(pScreen);
|
||||
pScreen->CreatePixmap = dev->CreatePixmap;
|
||||
rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
|
||||
pScreen->CreatePixmap = rdpCreatePixmap;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
Bool
|
||||
rdpDestroyPixmap(PixmapPtr pPixmap)
|
||||
{
|
||||
Bool rv;
|
||||
ScreenPtr pScreen;
|
||||
rdpPtr dev;
|
||||
|
||||
LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt));
|
||||
pScreen = pPixmap->drawable.pScreen;
|
||||
dev = rdpGetDevFromScreen(pScreen);
|
||||
pScreen->DestroyPixmap = dev->DestroyPixmap;
|
||||
rv = pScreen->DestroyPixmap(pPixmap);
|
||||
pScreen->DestroyPixmap = rdpDestroyPixmap;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
Bool
|
||||
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
|
||||
int bitsPerPixel, int devKind, pointer pPixData)
|
||||
{
|
||||
Bool rv;
|
||||
ScreenPtr pScreen;
|
||||
rdpPtr dev;
|
||||
|
||||
LLOGLN(10, ("rdpModifyPixmapHeader:"));
|
||||
pScreen = pPixmap->drawable.pScreen;
|
||||
dev = rdpGetDevFromScreen(pScreen);
|
||||
pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader;
|
||||
rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
|
||||
devKind, pPixData);
|
||||
pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader;
|
||||
return rv;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2005-2013 Jay Sorg
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
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
|
||||
OPEN GROUP 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.
|
||||
|
||||
pixmap calls
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __RDPPIXMAP_H
|
||||
#define __RDPPIXAMP_H
|
||||
|
||||
PixmapPtr
|
||||
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
||||
unsigned usage_hint);
|
||||
Bool
|
||||
rdpDestroyPixmap(PixmapPtr pPixmap);
|
||||
Bool
|
||||
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
|
||||
int bitsPerPixel, int devKind, pointer pPixData);
|
||||
|
||||
#endif
|
Loading…
Reference in new issue