diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 11c65b3f7..0e1951674 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -14,6 +14,7 @@ option(WITH_DEBUG_LICENSE "Print license debug messages." OFF) option(WITH_DEBUG_NEGO "Print negotiation related debug messages." OFF) option(WITH_DEBUG_NLA "Print authentication related debug messages." OFF) option(WITH_DEBUG_NTLM "Print NTLM debug messages" OFF) +option(WITH_DEBUG_TSG "Print Terminal Server Gateway debug messages" OFF) option(WITH_DEBUG_ORDERS "Print drawing orders debug messages" OFF) option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" OFF) option(WITH_DEBUG_RDP "Print RDP debug messages" OFF) diff --git a/config.h.in b/config.h.in index d250bedda..9b1f92599 100644 --- a/config.h.in +++ b/config.h.in @@ -37,6 +37,7 @@ #cmakedefine WITH_DEBUG_NEGO #cmakedefine WITH_DEBUG_NLA #cmakedefine WITH_DEBUG_NTLM +#cmakedefine WITH_DEBUG_TSG #cmakedefine WITH_DEBUG_ORDERS #cmakedefine WITH_DEBUG_RAIL #cmakedefine WITH_DEBUG_RDP diff --git a/include/freerdp/utils/unicode.h b/include/freerdp/utils/unicode.h index 7268a8ecb..0dabc9309 100644 --- a/include/freerdp/utils/unicode.h +++ b/include/freerdp/utils/unicode.h @@ -48,7 +48,7 @@ typedef struct _UNICONV UNICONV; FREERDP_API UNICONV* freerdp_uniconv_new(); FREERDP_API void freerdp_uniconv_free(UNICONV *uniconv); FREERDP_API char* freerdp_uniconv_in(UNICONV *uniconv, unsigned char* pin, size_t in_len); -FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, char *str, size_t *pout_len); +FREERDP_API char* freerdp_uniconv_out(UNICONV *uniconv, const char *str, size_t *pout_len); FREERDP_API void freerdp_uniconv_uppercase(UNICONV *uniconv, char *wstr, int length); #endif /* __UNICODE_UTILS_H */ diff --git a/libfreerdp-core/rpch.c b/libfreerdp-core/rpch.c index be36dfa2f..7f103240e 100644 --- a/libfreerdp-core/rpch.c +++ b/libfreerdp-core/rpch.c @@ -1,8 +1,9 @@ /** * FreeRDP: A Remote Desktop Protocol Client - * RDP Security + * RPC over HTTP * - * Copyright 2012 Fujitsu Technology Solutions GmbH - Dmitrij Jasnov + * Copyright 2012 Fujitsu Technology Solutions GmbH + * Copyright 2012 Dmitrij Jasnov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libfreerdp-core/rpch.h b/libfreerdp-core/rpch.h index 7db8ce11f..8f4b0c5de 100644 --- a/libfreerdp-core/rpch.h +++ b/libfreerdp-core/rpch.h @@ -1,8 +1,9 @@ /** * FreeRDP: A Remote Desktop Protocol Client - * RDP Security + * RPC over HTTP * - * Copyright 2012 Fujitsu Technology Solutions GmbH - Dmitrij Jasnov + * Copyright 2012 Fujitsu Technology Solutions GmbH + * Copyright 2012 Dmitrij Jasnov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +18,8 @@ * limitations under the License. */ - -#ifndef __RPCH_H_ -#define __RPCH_H_ +#ifndef FREERDP_CORE_RPCH_H +#define FREERDP_CORE_RPCH_H typedef struct rdp_rpch rdpRpch; typedef struct rdp_rpch_http rdpRpchHTTP; @@ -559,15 +559,17 @@ typedef struct { /* end common fields */ } rpcconn_shutdown_hdr_t; -/* proprietary stuff from Dmitrij Jasnov */ - -#define RPCH_HTTP_DISCONNECTED 0 -#define RPCH_HTTP_SENDING 1 -#define RPCH_HTTP_RECIEVING 2 +enum _RPCH_HTTP_STATE +{ + RPCH_HTTP_DISCONNECTED = 0, + RPCH_HTTP_SENDING = 1, + RPCH_HTTP_RECIEVING = 2 +}; +typedef enum _RPCH_HTTP_STATE RPCH_HTTP_STATE; struct rdp_rpch_http { - int state; + RPCH_HTTP_STATE state; int contentLength; int remContentLength; //struct _NTLMSSP* ntht; @@ -575,15 +577,15 @@ struct rdp_rpch_http struct rdp_rpch { - struct rdp_settings* settings; - struct rdp_tcp* tcp_in; - struct rdp_tcp* tcp_out; - struct rdp_tls* tls_in; - struct rdp_tls* tls_out; + rdpSettings* settings; + rdpTcp* tcp_in; + rdpTcp* tcp_out; + rdpTls* tls_in; + rdpTls* tls_out; //struct _NTLMSSP* ntlmssp; - struct rdp_rpch_http* http_in; - struct rdp_rpch_http* http_out; + rdpRpchHTTP* http_in; + rdpRpchHTTP* http_out; uint8* write_buffer; uint32 write_buffer_len; @@ -601,17 +603,22 @@ struct rdp_rpch uint32 pipe_call_id; }; - -rdpRpch* rpch_new(rdpSettings* settings); boolean rpch_attach(rdpRpch* rpch, rdpTcp* tcp_in, rdpTcp* tcp_out, rdpTls* tls_in, rdpTls* tls_out); boolean rpch_connect(rdpRpch* rpch); + int rpch_write(rdpRpch* rpch, uint8* data, int length, uint16 opnum); int rpch_read(rdpRpch* rpch, uint8* data, int length); +rdpRpch* rpch_new(rdpSettings* settings); + +#ifdef WITH_DEBUG_TSG +#define WITH_DEBUG_RPCH +#endif + #ifdef WITH_DEBUG_RPCH #define DEBUG_RPCH(fmt, ...) DEBUG_CLASS(RPCH, fmt, ## __VA_ARGS__) #else #define DEBUG_RPCH(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -#endif /* __RPCH_H_ */ +#endif /* FREERDP_CORE_RPCH_H */ diff --git a/libfreerdp-core/transport.c b/libfreerdp-core/transport.c index 25acef876..a275ffb42 100644 --- a/libfreerdp-core/transport.c +++ b/libfreerdp-core/transport.c @@ -59,11 +59,6 @@ STREAM* transport_send_stream_init(rdpTransport* transport, int size) return s; } -boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 port) -{ - return tcp_connect(transport->tcp, hostname, port); -} - void transport_attach(rdpTransport* transport, int sockfd) { transport->tcp->sockfd = sockfd; @@ -137,6 +132,61 @@ boolean transport_connect_nla(rdpTransport* transport) return true; } +boolean transport_tsg_connect(rdpTransport* transport, const char* hostname, uint16 port) +{ + rdpTsg* tsg = tsg_new(transport->settings); + + tsg->transport = transport; + transport->tsg = tsg; + + if (transport->tls_in == NULL) + transport->tls_in = tls_new(transport->settings); + + transport->tls_in->sockfd = transport->tcp_in->sockfd; + + if (transport->tls_out == NULL) + transport->tls_out = tls_new(transport->settings); + + transport->tls_out->sockfd = transport->tcp_out->sockfd; + + if (tls_connect(transport->tls_in) != true) + return false; + + if (tls_connect(transport->tls_out) != true) + return false; + + if (!tsg_connect(tsg, hostname, port)) + return false; + + return true; +} + +boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 port) +{ + boolean status = false; + rdpSettings* settings = transport->settings; + + if (transport->settings->ts_gateway) + { + transport->layer = TRANSPORT_LAYER_TSG; + transport->tcp_out = tcp_new(settings); + + status = tcp_connect(transport->tcp_in, settings->tsg_hostname, 443); + + if (status) + status = tcp_connect(transport->tcp_out, settings->tsg_hostname, 443); + + if (status) + status = transport_tsg_connect(transport, hostname, port); + } + else + { + status = tcp_connect(transport->tcp, hostname, port); + } + + return status; +} + boolean transport_accept_rdp(rdpTransport* transport) { /* RDP encryption */ @@ -205,6 +255,8 @@ int transport_read(rdpTransport* transport, STREAM* s) status = tls_read(transport->tls, stream_get_tail(s), stream_get_left(s)); else if (transport->layer == TRANSPORT_LAYER_TCP) status = tcp_read(transport->tcp, stream_get_tail(s), stream_get_left(s)); + else if (transport->layer == TRANSPORT_LAYER_TSG) + status = tsg_read(transport->tsg, stream_get_tail(s), stream_get_left(s)); if (status == 0 && transport->blocking) { @@ -263,6 +315,8 @@ int transport_write(rdpTransport* transport, STREAM* s) status = tls_write(transport->tls, stream_get_tail(s), length); else if (transport->layer == TRANSPORT_LAYER_TCP) status = tcp_write(transport->tcp, stream_get_tail(s), length); + else if (transport->layer == TRANSPORT_LAYER_TSG) + status = tsg_write(transport->tsg, stream_get_tail(s), length); if (status < 0) break; /* error occurred */ @@ -408,6 +462,8 @@ rdpTransport* transport_new(rdpSettings* settings) if (transport != NULL) { transport->tcp = tcp_new(settings); + transport->tcp_in = tcp_new(settings); + transport->settings = settings; /* a small 0.1ms delay when transport is blocking. */ @@ -437,9 +493,12 @@ void transport_free(rdpTransport* transport) stream_free(transport->recv_stream); stream_free(transport->send_stream); wait_obj_free(transport->recv_event); + if (transport->tls) tls_free(transport->tls); + tcp_free(transport->tcp); + xfree(transport); } } diff --git a/libfreerdp-core/transport.h b/libfreerdp-core/transport.h index d2a36680b..90693fbbe 100644 --- a/libfreerdp-core/transport.h +++ b/libfreerdp-core/transport.h @@ -24,12 +24,14 @@ typedef enum { TRANSPORT_LAYER_TCP, TRANSPORT_LAYER_TLS, + TRANSPORT_LAYER_TSG, TRANSPORT_LAYER_CLOSED } TRANSPORT_LAYER; typedef struct rdp_transport rdpTransport; #include "tcp.h" +#include "tsg.h" #include #include @@ -48,8 +50,13 @@ struct rdp_transport TRANSPORT_LAYER layer; struct rdp_tcp* tcp; struct rdp_tls* tls; - struct rdp_settings* settings; + struct rdp_tsg* tsg; + struct rdp_tcp* tcp_in; + struct rdp_tcp* tcp_out; + struct rdp_tls* tls_in; + struct rdp_tls* tls_out; struct rdp_credssp* credssp; + struct rdp_settings* settings; uint32 usleep_interval; void* recv_extra; STREAM* recv_buffer; @@ -66,6 +73,7 @@ boolean transport_disconnect(rdpTransport* transport); boolean transport_connect_rdp(rdpTransport* transport); boolean transport_connect_tls(rdpTransport* transport); boolean transport_connect_nla(rdpTransport* transport); +boolean transport_connect_tsg(rdpTransport* transport); boolean transport_accept_rdp(rdpTransport* transport); boolean transport_accept_tls(rdpTransport* transport); boolean transport_accept_nla(rdpTransport* transport); diff --git a/libfreerdp-core/tsg.c b/libfreerdp-core/tsg.c index d5de704c6..5eff258bd 100644 --- a/libfreerdp-core/tsg.c +++ b/libfreerdp-core/tsg.c @@ -1,8 +1,9 @@ /** * FreeRDP: A Remote Desktop Protocol Client - * RDP Security + * Terminal Server Gateway (TSG) * - * Copyright 2012 Fujitsu Technology Solutions GmbH - Dmitrij Jasnov + * Copyright 2012 Fujitsu Technology Solutions GmbH + * Copyright 2012 Dmitrij Jasnov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +19,7 @@ */ #include "config.h" + #include #include #include @@ -27,12 +29,50 @@ #include #include -/*#include -#include -#include */ - #include "tsg.h" +uint8 tsg_packet1[108] = +{ + 0x43, 0x56, 0x00, 0x00, 0x43, 0x56, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x54, 0x43, 0x56, + 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + 0x8A, 0xE3, 0x13, 0x71, 0x02, 0xF4, 0x36, 0x71, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x28, 0x00, 0xDD, 0x65, 0xE2, 0x44, 0xAF, 0x7D, 0xCD, 0x42, 0x85, 0x60, 0x3C, 0xDB, + 0x6E, 0x7A, 0x27, 0x29, 0x01, 0x00, 0x03, 0x00, 0x04, 0x5D, 0x88, 0x8A, 0xEB, 0x1C, 0xC9, 0x11, + 0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00 +}; + +uint8 tsg_packet2[112] = +{ + 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, + 0x53, 0x6C, 0x04, 0x33, 0x52, 0x51, 0x00, 0x00, 0x52, 0x51, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x15, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x2D, 0x00, 0x4E, 0x00, 0x48, 0x00, 0x35, 0x00, 0x37, 0x00, + 0x30, 0x00, 0x2E, 0x00, 0x43, 0x00, 0x53, 0x00, 0x4F, 0x00, 0x44, 0x00, 0x2E, 0x00, 0x6C, 0x00, + 0x6F, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8 tsg_packet3[40] = +{ + 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, + 0x53, 0x6C, 0x04, 0x33, 0x01, 0x00, 0x00, 0x00, 0x52, 0x47, 0x00, 0x00, 0x52, 0x47, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00 +}; + +uint8 tsg_packet4[48] = +{ + 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, + 0x53, 0x6C, 0x04, 0x33, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00 +}; + +uint8 tsg_packet5[20] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) { int status = -1; @@ -43,8 +83,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) uint32 length; uint8* data; - //if (!rpch_attach(rpch, transport->tcp_in, transport->tcp_out, transport->tls_in, transport->tls_out)) - if (!rpch_attach(rpch, NULL, NULL, NULL, NULL)) + if (!rpch_attach(rpch, transport->tcp_in, transport->tcp_out, transport->tls_in, transport->tls_out)) { printf("rpch_attach failed!\n"); return false; @@ -56,18 +95,7 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) return false; } - uint8 p[108] = - { - 0x43, 0x56, 0x00, 0x00, 0x43, 0x56, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x52, 0x54, 0x43, 0x56, - 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, - 0x8A, 0xE3, 0x13, 0x71, 0x02, 0xF4, 0x36, 0x71, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x40, 0x28, 0x00, 0xDD, 0x65, 0xE2, 0x44, 0xAF, 0x7D, 0xCD, 0x42, 0x85, 0x60, 0x3C, 0xDB, - 0x6E, 0x7A, 0x27, 0x29, 0x01, 0x00, 0x03, 0x00, 0x04, 0x5D, 0x88, 0x8A, 0xEB, 0x1C, 0xC9, 0x11, - 0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00 - }; - - status = rpch_write(rpch, p, 108, 1); + status = rpch_write(rpch, tsg_packet1, sizeof(tsg_packet1), 1); if (status <= 0) { @@ -94,20 +122,9 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) printf("\n"); #endif - uint8 p2[112] = - { - 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, - 0x53, 0x6C, 0x04, 0x33, 0x52, 0x51, 0x00, 0x00, 0x52, 0x51, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x15, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x2D, 0x00, 0x4E, 0x00, 0x48, 0x00, 0x35, 0x00, 0x37, 0x00, - 0x30, 0x00, 0x2E, 0x00, 0x43, 0x00, 0x53, 0x00, 0x4F, 0x00, 0x44, 0x00, 0x2E, 0x00, 0x6C, 0x00, - 0x6F, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + memcpy(tsg_packet2 + 4, tsg->tunnelContext, 16); - memcpy(p2 + 4, tsg->tunnelContext, 16); - - status = rpch_write(rpch, p2, 112, 2); + status = rpch_write(rpch, tsg_packet2, sizeof(tsg_packet2), 2); if (status <= 0) { @@ -123,15 +140,8 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) return false; } - uint8 p3[40] = - { - 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, - 0x53, 0x6C, 0x04, 0x33, 0x01, 0x00, 0x00, 0x00, 0x52, 0x47, 0x00, 0x00, 0x52, 0x47, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00 - }; - - memcpy(p3 + 4, tsg->tunnelContext, 16); - status = rpch_write(rpch, p3, 40, 3); + memcpy(tsg_packet3 + 4, tsg->tunnelContext, 16); + status = rpch_write(rpch, tsg_packet3, sizeof(tsg_packet3), 3); if (status <= 0) { @@ -145,18 +155,11 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) uint8* dest_addr_unic = (uint8*) freerdp_uniconv_out(tsg_uniconv, hostname, (size_t*) &dest_addr_unic_len); freerdp_uniconv_free(tsg_uniconv); - uint8 p4[48] = - { - 0x00, 0x00, 0x00, 0x00, 0x6A, 0x78, 0xE9, 0xAB, 0x02, 0x90, 0x1C, 0x44, 0x8D, 0x99, 0x29, 0x30, - 0x53, 0x6C, 0x04, 0x33, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00 - }; - - memcpy(p4 + 4, tsg->tunnelContext, 16); - memcpy(p4 + 38, &port, 2); + memcpy(tsg_packet4 + 4, tsg->tunnelContext, 16); + memcpy(tsg_packet4 + 38, &port, 2); STREAM* s_p4 = stream_new(60 + dest_addr_unic_len + 2); - stream_write(s_p4, p4, 48); + stream_write(s_p4, tsg_packet4, 48); stream_write_uint32(s_p4, (dest_addr_unic_len / 2) + 1); /* MaximumCount */ stream_write_uint32(s_p4, 0x00000000); /* Offset */ stream_write_uint32(s_p4, (dest_addr_unic_len / 2) + 1);/* ActualCount */ @@ -189,14 +192,8 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) printf("\n"); #endif - uint8 p5[20] = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; - - memcpy(p5 + 4, tsg->channelContext, 16); - status = rpch_write(rpch, p5, 20, 8); + memcpy(tsg_packet5 + 4, tsg->channelContext, 16); + status = rpch_write(rpch, tsg_packet5, sizeof(tsg_packet5), 8); if (status <= 0) { @@ -247,7 +244,7 @@ int tsg_write(rdpTsg* tsg, uint8* data, uint32 length) return length; } -int tsg_read(rdpTsg* tsg, uint* data, uint32 length) +int tsg_read(rdpTsg* tsg, uint8* data, uint32 length) { int status; diff --git a/libfreerdp-core/tsg.h b/libfreerdp-core/tsg.h index 36447ff6f..f8522af7d 100644 --- a/libfreerdp-core/tsg.h +++ b/libfreerdp-core/tsg.h @@ -1,8 +1,9 @@ /** * FreeRDP: A Remote Desktop Protocol Client - * RDP Security + * Terminal Server Gateway (TSG) * - * Copyright 2012 Fujitsu Technology Solutions GmbH - Dmitrij Jasnov + * Copyright 2012 Fujitsu Technology Solutions GmbH + * Copyright 2012 Dmitrij Jasnov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +18,8 @@ * limitations under the License. */ -#ifndef __TSG_H_ -#define __TSG_H_ +#ifndef FREERDP_CORE_TSG_H +#define FREERDP_CORE_TSG_H typedef struct rdp_tsg rdpTsg; @@ -34,19 +35,20 @@ typedef struct rdp_tsg rdpTsg; struct rdp_tsg { - struct rdp_settings* settings; - struct rdp_transport* transport; - struct rdp_rpch* rpch; - + rdpRpch* rpch; uint8* tunnelContext; uint8* channelContext; + rdpSettings* settings; + rdpTransport* transport; }; boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port); + +int tsg_write(rdpTsg* tsg, uint8* data, uint32 length); +int tsg_read(rdpTsg* tsg, uint8* data, uint32 length); + rdpTsg* tsg_new(rdpSettings* settings); void tsg_free(rdpTsg* tsg); -int tsg_write(rdpTsg* tsg, uint8* data, uint32 length); -int tsg_read(rdpTsg* tsg, uint* data, uint32 length); #ifdef WITH_DEBUG_TSG #define DEBUG_TSG(fmt, ...) DEBUG_CLASS(TSG, fmt, ## __VA_ARGS__) @@ -54,4 +56,4 @@ int tsg_read(rdpTsg* tsg, uint* data, uint32 length); #define DEBUG_TSG(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -#endif /* __TSG_H_ */ +#endif /* FREERDP_CORE_TSG_H */ diff --git a/libfreerdp-utils/unicode.c b/libfreerdp-utils/unicode.c index 6524a35ad..960d2360d 100644 --- a/libfreerdp-utils/unicode.c +++ b/libfreerdp-utils/unicode.c @@ -98,7 +98,7 @@ char* freerdp_uniconv_in(UNICONV* uniconv, unsigned char* pin, size_t in_len) /* Convert str from DEFAULT_CODEPAGE to WINDOWS_CODEPAGE and return buffer like xstrdup. * Buffer is 0-terminated but that is not included in the returned length. */ -char* freerdp_uniconv_out(UNICONV *uniconv, char *str, size_t *pout_len) +char* freerdp_uniconv_out(UNICONV* uniconv, const char *str, size_t* pout_len) { size_t ibl; size_t obl;