freerdp: remove tcp, uds utils
This commit is contained in:
parent
8c98cbc247
commit
ddedc574f3
include/freerdp/utils
libfreerdp
server
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* TCP Utils
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_TCP_UTILS_H
|
||||
#define FREERDP_TCP_UTILS_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API int freerdp_tcp_connect(const char* hostname, int port);
|
||||
FREERDP_API int freerdp_tcp_read(int sockfd, BYTE* data, int length);
|
||||
FREERDP_API int freerdp_tcp_write(int sockfd, BYTE* data, int length);
|
||||
FREERDP_API int freerdp_tcp_wait_read(int sockfd);
|
||||
FREERDP_API int freerdp_tcp_wait_write(int sockfd);
|
||||
FREERDP_API int freerdp_tcp_disconnect(int sockfd);
|
||||
|
||||
FREERDP_API int freerdp_tcp_set_no_delay(int sockfd, BOOL no_delay);
|
||||
|
||||
FREERDP_API int freerdp_wsa_startup(void);
|
||||
FREERDP_API int freerdp_wsa_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_TCP_UTILS_H */
|
@ -1,36 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Unix Domain Socket Utils
|
||||
*
|
||||
* Copyright 2012 Vic Lee
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_UTILS_UDS_H
|
||||
#define FREERDP_UTILS_UDS_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API int freerdp_uds_connect(const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_UTILS_UDS_H */
|
@ -21,11 +21,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
@ -22,12 +22,12 @@
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winsock.h>
|
||||
|
||||
#include "info.h"
|
||||
#include "certificate.h"
|
||||
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
|
||||
#include "peer.h"
|
||||
|
||||
@ -648,11 +648,19 @@ void freerdp_peer_context_free(freerdp_peer* client)
|
||||
|
||||
freerdp_peer* freerdp_peer_new(int sockfd)
|
||||
{
|
||||
UINT32 option_value;
|
||||
socklen_t option_len;
|
||||
freerdp_peer* client;
|
||||
|
||||
client = (freerdp_peer*) calloc(1, sizeof(freerdp_peer));
|
||||
|
||||
freerdp_tcp_set_no_delay(sockfd, TRUE);
|
||||
if (!client)
|
||||
return NULL;
|
||||
|
||||
option_value = TRUE;
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void*) &option_value, option_len);
|
||||
|
||||
if (client)
|
||||
{
|
||||
|
@ -32,7 +32,8 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winsock.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -65,11 +66,19 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#define close(_fd) closesocket(_fd)
|
||||
|
||||
#endif
|
||||
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/utils/uds.h>
|
||||
|
||||
#include <winpr/stream.h>
|
||||
|
||||
#include "tcp.h"
|
||||
@ -490,6 +499,38 @@ void tcp_get_mac_address(rdpTcp* tcp)
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); */
|
||||
}
|
||||
|
||||
int uds_connect(const char* path)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
int status;
|
||||
int sockfd;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if (sockfd == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
|
||||
status = connect(sockfd, (struct sockaddr *) &addr, sizeof(addr));
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "connect");
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sockfd;
|
||||
#else /* ifndef _WIN32 */
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout)
|
||||
{
|
||||
int status;
|
||||
@ -504,7 +545,7 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout)
|
||||
|
||||
if (tcp->ipcSocket)
|
||||
{
|
||||
tcp->sockfd = freerdp_uds_connect(hostname);
|
||||
tcp->sockfd = uds_connect(hostname);
|
||||
|
||||
if (tcp->sockfd < 0)
|
||||
return FALSE;
|
||||
@ -685,8 +726,13 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout)
|
||||
|
||||
BOOL tcp_disconnect(rdpTcp* tcp)
|
||||
{
|
||||
freerdp_tcp_disconnect(tcp->sockfd);
|
||||
tcp->sockfd = -1;
|
||||
if (tcp->sockfd != -1)
|
||||
{
|
||||
shutdown(tcp->sockfd, SHUT_RDWR);
|
||||
close(tcp->sockfd);
|
||||
|
||||
tcp->sockfd = -1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/error.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/utils/ringbuffer.h>
|
||||
|
||||
#include <openssl/bio.h>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <winpr/ssl.h>
|
||||
|
||||
#include <winpr/stream.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/utils/ringbuffer.h>
|
||||
|
||||
#include <freerdp/log.h>
|
||||
|
@ -24,9 +24,7 @@ set(${MODULE_PREFIX}_SRCS
|
||||
profiler.c
|
||||
ringbuffer.c
|
||||
signal.c
|
||||
stopwatch.c
|
||||
tcp.c
|
||||
uds.c)
|
||||
stopwatch.c)
|
||||
|
||||
if(NOT WIN32)
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} msusb.c)
|
||||
|
@ -1,313 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* TCP Utils
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winsock.h>
|
||||
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifndef TCP_KEEPIDLE
|
||||
#define TCP_KEEPIDLE TCP_KEEPALIVE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else /* ifdef _WIN32 */
|
||||
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#define close(_fd) closesocket(_fd)
|
||||
#endif
|
||||
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
#endif
|
||||
|
||||
#define TAG FREERDP_TAG("utils")
|
||||
|
||||
int freerdp_tcp_connect(const char* hostname, int port)
|
||||
{
|
||||
int status;
|
||||
int sockfd;
|
||||
char servname[32];
|
||||
struct addrinfo hints;
|
||||
struct addrinfo* ai = NULL;
|
||||
struct addrinfo* res = NULL;
|
||||
|
||||
ZeroMemory(&hints, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_protocol = 0;
|
||||
hints.ai_canonname = NULL;
|
||||
hints.ai_addr = NULL;
|
||||
hints.ai_next = NULL;
|
||||
|
||||
sprintf_s(servname, 32, "%d", port);
|
||||
status = getaddrinfo(hostname, servname, &hints, &res);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
//WLog_ERR(TAG, "tcp_connect: getaddrinfo (%s)", gai_strerror(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
sockfd = -1;
|
||||
|
||||
for (ai = res; ai; ai = ai->ai_next)
|
||||
{
|
||||
sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
||||
|
||||
if (sockfd < 0)
|
||||
continue;
|
||||
|
||||
if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == 0)
|
||||
{
|
||||
WLog_ERR(TAG, "connected to %s:%s", hostname, servname);
|
||||
break;
|
||||
}
|
||||
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
|
||||
freeaddrinfo(res);
|
||||
|
||||
if (sockfd == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "unable to connect to %s:%s", hostname, servname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
int freerdp_tcp_read(int sockfd, BYTE* data, int length)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = recv(sockfd, data, length, 0);
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
return -1; /* peer disconnected */
|
||||
}
|
||||
else if (status < 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int wsa_error = WSAGetLastError();
|
||||
|
||||
/* No data available */
|
||||
if (wsa_error == WSAEWOULDBLOCK)
|
||||
return 0;
|
||||
|
||||
WLog_ERR(TAG, "recv() error: %d", wsa_error);
|
||||
#else
|
||||
/* No data available */
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return 0;
|
||||
|
||||
WLog_ERR(TAG, "recv");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int freerdp_tcp_write(int sockfd, BYTE* data, int length)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = send(sockfd, data, length, MSG_NOSIGNAL);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int wsa_error = WSAGetLastError();
|
||||
|
||||
/* No data available */
|
||||
if (wsa_error == WSAEWOULDBLOCK)
|
||||
status = 0;
|
||||
else
|
||||
WLog_ERR(TAG, "send");
|
||||
|
||||
#else
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
status = 0;
|
||||
else
|
||||
WLog_ERR(TAG, "send");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int freerdp_tcp_wait_read(int sockfd)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
struct pollfd pollfds;
|
||||
#else
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
if (sockfd < 1)
|
||||
{
|
||||
WLog_ERR(TAG, "Invalid socket to watch: %d", sockfd);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
pollfds.fd = sockfd;
|
||||
pollfds.events = POLLIN;
|
||||
pollfds.revents = 0;
|
||||
do
|
||||
{
|
||||
status = poll(&pollfds, 1, 5 * 1000);
|
||||
}
|
||||
while ((status < 0) && (errno == EINTR));
|
||||
#else
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sockfd, &fds);
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
status = _select(sockfd+1, &fds, NULL, NULL, &timeout);
|
||||
#endif
|
||||
|
||||
return status > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int freerdp_tcp_wait_write(int sockfd)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
struct pollfd pollfds;
|
||||
#else
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
if (sockfd < 1)
|
||||
{
|
||||
WLog_ERR(TAG, "Invalid socket to watch: %d", sockfd);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#ifdef HAVE_POLL_H
|
||||
pollfds.fd = sockfd;
|
||||
pollfds.events = POLLOUT;
|
||||
pollfds.revents = 0;
|
||||
do
|
||||
{
|
||||
status = poll(&pollfds, 1, 5 * 1000);
|
||||
}
|
||||
while ((status < 0) && (errno == EINTR));
|
||||
#else
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sockfd, &fds);
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
status = _select(sockfd+1, NULL, &fds, NULL, &timeout);
|
||||
#endif
|
||||
|
||||
return status > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int freerdp_tcp_disconnect(int sockfd)
|
||||
{
|
||||
if (sockfd != -1)
|
||||
{
|
||||
shutdown(sockfd, SHUT_RDWR);
|
||||
close(sockfd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_tcp_set_no_delay(int sockfd, BOOL no_delay)
|
||||
{
|
||||
UINT32 option_value;
|
||||
socklen_t option_len;
|
||||
|
||||
option_value = no_delay;
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void*) &option_value, option_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_wsa_startup()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
return WSAStartup(0x101, &wsaData);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int freerdp_wsa_cleanup()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return WSACleanup();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Unix Domain Socket Utils
|
||||
*
|
||||
* Copyright 2012 Vic Lee
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <freerdp/utils/uds.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#endif
|
||||
|
||||
#define TAG FREERDP_TAG("utils")
|
||||
|
||||
int freerdp_uds_connect(const char* path)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
|
||||
int status;
|
||||
int sockfd;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
|
||||
status = connect(sockfd, (struct sockaddr *) &addr, sizeof(addr));
|
||||
if (status < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "connect");
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sockfd;
|
||||
|
||||
#else /* ifndef _WIN32 */
|
||||
|
||||
return -1;
|
||||
|
||||
#endif
|
||||
}
|
@ -22,21 +22,17 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/winsock.h>
|
||||
|
||||
#include <freerdp/channels/wtsvc.h>
|
||||
#include <freerdp/channels/channels.h>
|
||||
|
||||
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/server/rdpsnd.h>
|
||||
|
||||
#include "sf_audin.h"
|
||||
@ -838,6 +834,7 @@ static void test_server_mainloop(freerdp_listener* instance)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
WSADATA wsaData;
|
||||
freerdp_listener* instance;
|
||||
|
||||
WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());
|
||||
@ -851,18 +848,22 @@ int main(int argc, char* argv[])
|
||||
if (argc > 2 && !strcmp(argv[2], "--fast"))
|
||||
test_dump_rfx_realtime = FALSE;
|
||||
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
|
||||
return 0;
|
||||
|
||||
/* Open the server socket and start listening. */
|
||||
freerdp_wsa_startup();
|
||||
|
||||
if (instance->Open(instance, NULL, 3389) &&
|
||||
instance->OpenLocal(instance, "/tmp/tfreerdp-server.0"))
|
||||
{
|
||||
/* Entering the server main loop. In a real server the listener can be run in its own thread. */
|
||||
test_server_mainloop(instance);
|
||||
}
|
||||
freerdp_wsa_cleanup();
|
||||
|
||||
freerdp_listener_free(instance);
|
||||
|
||||
WSACleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
||||
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <winpr/winsock.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/listener.h>
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp/channels/wtsvc.h>
|
||||
#include <freerdp/channels/channels.h>
|
||||
|
||||
@ -170,12 +170,13 @@ BOOL wfreerdp_server_stop(wfServer* server)
|
||||
|
||||
wfServer* wfreerdp_server_new()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
wfServer* server;
|
||||
|
||||
server = (wfServer*) malloc(sizeof(wfServer));
|
||||
ZeroMemory(server, sizeof(wfServer));
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
|
||||
return NULL;
|
||||
|
||||
freerdp_wsa_startup();
|
||||
server = (wfServer*) calloc(1, sizeof(wfServer));
|
||||
|
||||
if (server)
|
||||
{
|
||||
@ -196,10 +197,9 @@ void wfreerdp_server_free(wfServer* server)
|
||||
free(server);
|
||||
}
|
||||
|
||||
freerdp_wsa_cleanup();
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
|
||||
FREERDP_API BOOL wfreerdp_server_is_running(wfServer* server)
|
||||
{
|
||||
DWORD tStatus;
|
||||
|
Loading…
x
Reference in New Issue
Block a user