mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
wfreerdp-server: generalized managed api callbacks, peer tracking bug fixes, code cleanup
This commit is contained in:
parent
5d0a53a3b3
commit
36394b3c23
@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* FreeRDP: A Remote Desktop Protocol Client
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
* FreeRDP Windows Server
|
* FreeRDP Windows Server
|
||||||
*
|
*
|
||||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -100,7 +100,7 @@ wfInfo* wf_info_init()
|
|||||||
{
|
{
|
||||||
wfInfo* wfi;
|
wfInfo* wfi;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OSVERSIONINFOEX osvi;
|
OSVERSIONINFOEX osvi;
|
||||||
SYSTEM_INFO si;
|
SYSTEM_INFO si;
|
||||||
BOOL bOsVersionInfoEx;
|
BOOL bOsVersionInfoEx;
|
||||||
@ -205,7 +205,6 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int peerId;
|
int peerId;
|
||||||
//todo: reject peer if we have WF_INFO_MAXPEERS connected
|
|
||||||
if (wfi->peerCount == WF_INFO_MAXPEERS)
|
if (wfi->peerCount == WF_INFO_MAXPEERS)
|
||||||
{
|
{
|
||||||
context->socketClose = TRUE;
|
context->socketClose = TRUE;
|
||||||
@ -240,7 +239,7 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
|||||||
|
|
||||||
wf_info_unlock(wfi);
|
wf_info_unlock(wfi);
|
||||||
|
|
||||||
wfreerdp_server_peer_connect_event(peerId);
|
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +263,7 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context)
|
|||||||
|
|
||||||
wf_info_unlock(wfi);
|
wf_info_unlock(wfi);
|
||||||
|
|
||||||
wfreerdp_server_peer_disconnect_event(peerId);
|
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
#define WF_INFO_DEFAULT_FPS 24
|
#define WF_INFO_DEFAULT_FPS 24
|
||||||
#define WF_INFO_MAXPEERS 2
|
#define WF_INFO_MAXPEERS 32
|
||||||
|
|
||||||
int wf_info_lock(wfInfo* wfi);
|
int wf_info_lock(wfInfo* wfi);
|
||||||
int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds);
|
int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
* FreeRDP Windows Server
|
* FreeRDP Windows Server
|
||||||
*
|
*
|
||||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -25,6 +26,8 @@
|
|||||||
#include <winpr/tchar.h>
|
#include <winpr/tchar.h>
|
||||||
#include <winpr/windows.h>
|
#include <winpr/windows.h>
|
||||||
#include <freerdp/utils/tcp.h>
|
#include <freerdp/utils/tcp.h>
|
||||||
|
#include <freerdp\listener.h>
|
||||||
|
//#include <libfreerdp\core\listener.h>
|
||||||
|
|
||||||
#include "wf_peer.h"
|
#include "wf_peer.h"
|
||||||
#include "wf_settings.h"
|
#include "wf_settings.h"
|
||||||
@ -32,18 +35,7 @@
|
|||||||
|
|
||||||
#include "wf_interface.h"
|
#include "wf_interface.h"
|
||||||
|
|
||||||
//todo: remove this
|
cbCallback cbEvent;
|
||||||
struct rdp_listener
|
|
||||||
{
|
|
||||||
freerdp_listener* instance;
|
|
||||||
|
|
||||||
int sockfds[5];
|
|
||||||
int num_sockfds;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
|
|
||||||
cbConEvent cbConnect;
|
|
||||||
cbConEvent cbDisconnect;
|
|
||||||
|
|
||||||
DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
||||||
{
|
{
|
||||||
@ -53,7 +45,6 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
|||||||
void* rfds[32];
|
void* rfds[32];
|
||||||
fd_set rfds_set;
|
fd_set rfds_set;
|
||||||
freerdp_listener* instance;
|
freerdp_listener* instance;
|
||||||
struct rdp_listener* listener;
|
|
||||||
wfInfo* wfi;
|
wfInfo* wfi;
|
||||||
|
|
||||||
wfi = wf_info_get_instance();
|
wfi = wf_info_get_instance();
|
||||||
@ -61,9 +52,8 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
|||||||
|
|
||||||
ZeroMemory(rfds, sizeof(rfds));
|
ZeroMemory(rfds, sizeof(rfds));
|
||||||
instance = (freerdp_listener*) lpParam;
|
instance = (freerdp_listener*) lpParam;
|
||||||
listener = (struct rdp_listener*) instance->listener;
|
|
||||||
|
|
||||||
while (listener->num_sockfds > 0)
|
while(wfi->force_all_disconnect == FALSE)
|
||||||
{
|
{
|
||||||
rcount = 0;
|
rcount = 0;
|
||||||
|
|
||||||
@ -151,8 +141,7 @@ wfServer* wfreerdp_server_new()
|
|||||||
server->port = 3389;
|
server->port = 3389;
|
||||||
}
|
}
|
||||||
|
|
||||||
cbConnect = NULL;
|
cbEvent = NULL;
|
||||||
cbDisconnect = NULL;
|
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
@ -212,7 +201,7 @@ FREERDP_API UINT32 wfreerdp_server_get_peer_hostname(int pId, wchar_t * dstStr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("nonexistent peer\n");
|
printf("nonexistent peer id=%d\n", pId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,25 +282,14 @@ FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb)
|
FREERDP_API void wfreerdp_server_register_callback_event(cbCallback cb)
|
||||||
{
|
{
|
||||||
cbConnect = cb;
|
cbEvent = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb)
|
void wfreerdp_server_peer_callback_event(int pId, UINT32 eType)
|
||||||
{
|
{
|
||||||
cbDisconnect = cb;
|
if (cbEvent)
|
||||||
}
|
cbEvent(pId, eType);
|
||||||
|
|
||||||
|
|
||||||
void wfreerdp_server_peer_connect_event(int pId)
|
|
||||||
{
|
|
||||||
if (cbConnect)
|
|
||||||
cbConnect(pId);
|
|
||||||
}
|
|
||||||
void wfreerdp_server_peer_disconnect_event(int pId)
|
|
||||||
{
|
|
||||||
if (cbDisconnect)
|
|
||||||
cbDisconnect(pId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* FreeRDP: A Remote Desktop Protocol Client
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
* FreeRDP Windows Server
|
* FreeRDP Windows Server
|
||||||
*
|
*
|
||||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
*
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
* you may not use this file except in compliance with the License.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* You may obtain a copy of the License at
|
* 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
|
*
|
||||||
*
|
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* See the License for the specific language governing permissions and
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* limitations under the License.
|
* See the License for the specific language governing permissions and
|
||||||
*/
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef WF_INTERFACE_H
|
#ifndef WF_INTERFACE_H
|
||||||
#define WF_INTERFACE_H
|
#define WF_INTERFACE_H
|
||||||
@ -29,6 +30,11 @@
|
|||||||
#include <freerdp/freerdp.h>
|
#include <freerdp/freerdp.h>
|
||||||
#include <freerdp/codec/rfx.h>
|
#include <freerdp/codec/rfx.h>
|
||||||
|
|
||||||
|
#define WF_SRV_CALLBACK_EVENT_CONNECT 1
|
||||||
|
#define WF_SRV_CALLBACK_EVENT_DISCONNECT 2
|
||||||
|
#define WF_SRV_CALLBACK_EVENT_ACTIVATE 4
|
||||||
|
#define WF_SRV_CALLBACK_EVENT_AUTH 8
|
||||||
|
|
||||||
typedef struct wf_info wfInfo;
|
typedef struct wf_info wfInfo;
|
||||||
typedef struct wf_peer_context wfPeerContext;
|
typedef struct wf_peer_context wfPeerContext;
|
||||||
|
|
||||||
@ -86,7 +92,7 @@ struct wf_server
|
|||||||
};
|
};
|
||||||
typedef struct wf_server wfServer;
|
typedef struct wf_server wfServer;
|
||||||
|
|
||||||
typedef void (__stdcall* cbConEvent) (int);
|
typedef void (__stdcall* cbCallback) (int, UINT32);
|
||||||
|
|
||||||
FREERDP_API BOOL wfreerdp_server_start(wfServer* server);
|
FREERDP_API BOOL wfreerdp_server_start(wfServer* server);
|
||||||
FREERDP_API BOOL wfreerdp_server_stop(wfServer* server);
|
FREERDP_API BOOL wfreerdp_server_stop(wfServer* server);
|
||||||
@ -103,10 +109,13 @@ FREERDP_API BOOL wfreerdp_server_peer_is_connected(int pId);
|
|||||||
FREERDP_API BOOL wfreerdp_server_peer_is_activated(int pId);
|
FREERDP_API BOOL wfreerdp_server_peer_is_activated(int pId);
|
||||||
FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId);
|
FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId);
|
||||||
|
|
||||||
FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb);
|
//FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb);
|
||||||
FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb);
|
//FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb);
|
||||||
|
FREERDP_API void wfreerdp_server_register_callback_event(cbCallback cb);
|
||||||
|
|
||||||
void wfreerdp_server_peer_connect_event(int pId);
|
//void wfreerdp_server_peer_connect_event(int pId);
|
||||||
void wfreerdp_server_peer_disconnect_event(int pId);
|
//void wfreerdp_server_peer_disconnect_event(int pId);
|
||||||
|
|
||||||
|
void wfreerdp_server_peer_callback_event(int pId, UINT32 eType);
|
||||||
|
|
||||||
#endif /* WF_INTERFACE_H */
|
#endif /* WF_INTERFACE_H */
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* FreeRDP: A Remote Desktop Protocol Client
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
* FreeRDP Windows Server
|
* FreeRDP Windows Server
|
||||||
*
|
*
|
||||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
*
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
* you may not use this file except in compliance with the License.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* You may obtain a copy of the License at
|
* 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
|
*
|
||||||
*
|
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* See the License for the specific language governing permissions and
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* limitations under the License.
|
* See the License for the specific language governing permissions and
|
||||||
*/
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -99,6 +100,8 @@ boolean wf_peer_activate(freerdp_peer* client)
|
|||||||
client->activated = true;
|
client->activated = true;
|
||||||
wf_update_peer_activate(wfi, context);
|
wf_update_peer_activate(wfi, context);
|
||||||
|
|
||||||
|
wfreerdp_server_peer_callback_event(((rdpContext*) context)->peer->pId, WF_SRV_CALLBACK_EVENT_ACTIVATE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +115,8 @@ boolean wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, b
|
|||||||
identity->User, identity->Domain, identity->Password);
|
identity->User, identity->Domain, identity->Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* FreeRDP: A Remote Desktop Protocol Client
|
* FreeRDP: A Remote Desktop Protocol Client
|
||||||
* FreeRDP Windows Server
|
* FreeRDP Windows Server
|
||||||
*
|
*
|
||||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
*
|
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
* you may not use this file except in compliance with the License.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* You may obtain a copy of the License at
|
* 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
|
*
|
||||||
*
|
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* See the License for the specific language governing permissions and
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* limitations under the License.
|
* See the License for the specific language governing permissions and
|
||||||
*/
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user