2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * Remote Desktop Gateway (RDG)
5 * Copyright 2015 Denis Vincent <dvincent@devolutions.net>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #ifndef FREERDP_CORE_RDG_H
21 #define FREERDP_CORE_RDG_H
24 #include <winpr/wtypes.h>
25 #include <winpr/stream.h>
26 #include <winpr/collections.h>
27 #include <winpr/interlocked.h>
29 #include <freerdp/log.h>
30 #include <freerdp/utils/ringbuffer.h>
32 #include <freerdp/freerdp.h>
33 #include <freerdp/crypto/tls.h>
34 #include <freerdp/types.h>
35 #include <freerdp/settings.h>
37 typedef struct rdp_rdg rdpRdg;
41 #include "../transport.h"
43 /* HTTP channel response fields present flags. */
44 #define HTTP_CHANNEL_RESPONSE_FIELD_CHANNELID 0x1
45 #define HTTP_CHANNEL_RESPONSE_OPTIONAL 0x2
46 #define HTTP_CHANNEL_RESPONSE_FIELD_UDPPORT 0x4
48 /* HTTP extended auth. */
49 #define HTTP_EXTENDED_AUTH_NONE 0x0
50 #define HTTP_EXTENDED_AUTH_SC 0x1 /* Smart card authentication. */
51 #define HTTP_EXTENDED_AUTH_PAA 0x02 /* Pluggable authentication. */
53 /* HTTP packet types. */
54 #define PKT_TYPE_HANDSHAKE_REQUEST 0x1
55 #define PKT_TYPE_HANDSHAKE_RESPONSE 0x2
56 #define PKT_TYPE_EXTENDED_AUTH_MSG 0x3
57 #define PKT_TYPE_TUNNEL_CREATE 0x4
58 #define PKT_TYPE_TUNNEL_RESPONSE 0x5
59 #define PKT_TYPE_TUNNEL_AUTH 0x6
60 #define PKT_TYPE_TUNNEL_AUTH_RESPONSE 0x7
61 #define PKT_TYPE_CHANNEL_CREATE 0x8
62 #define PKT_TYPE_CHANNEL_RESPONSE 0x9
63 #define PKT_TYPE_DATA 0xA
64 #define PKT_TYPE_SERVICE_MESSAGE 0xB
65 #define PKT_TYPE_REAUTH_MESSAGE 0xC
66 #define PKT_TYPE_KEEPALIVE 0xD
67 #define PKT_TYPE_CLOSE_CHANNEL 0x10
68 #define PKT_TYPE_CLOSE_CHANNEL_RESPONSE 0x11
70 /* HTTP tunnel auth fields present flags. */
71 #define HTTP_TUNNEL_AUTH_FIELD_SOH 0x1
73 /* HTTP tunnel auth response fields present flags. */
74 #define HTTP_TUNNEL_AUTH_RESPONSE_FIELD_REDIR_FLAGS 0x1
75 #define HTTP_TUNNEL_AUTH_RESPONSE_FIELD_IDLE_TIMEOUT 0x2
76 #define HTTP_TUNNEL_AUTH_RESPONSE_FIELD_SOH_RESPONSE 0x4
78 /* HTTP tunnel packet fields present flags. */
79 #define HTTP_TUNNEL_PACKET_FIELD_PAA_COOKIE 0x1
80 #define HTTP_TUNNEL_PACKET_FIELD_REAUTH 0x2
82 /* HTTP tunnel redir flags. */
83 #define HTTP_TUNNEL_REDIR_ENABLE_ALL 0x80000000
84 #define HTTP_TUNNEL_REDIR_DISABLE_ALL 0x40000000
85 #define HTTP_TUNNEL_REDIR_DISABLE_DRIVE 0x1
86 #define HTTP_TUNNEL_REDIR_DISABLE_PRINTER 0x2
87 #define HTTP_TUNNEL_REDIR_DISABLE_PORT 0x4
88 #define HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD 0x8
89 #define HTTP_TUNNEL_REDIR_DISABLE_PNP 0x10
91 /* HTTP tunnel response fields present flags. */
92 #define HTTP_TUNNEL_RESPONSE_FIELD_TUNNEL_ID 0x1
93 #define HTTP_TUNNEL_RESPONSE_FIELD_CAPS 0x2
94 #define HTTP_TUNNEL_RESPONSE_FIELD_SOH_REQ 0x4
95 #define HTTP_TUNNEL_RESPONSE_FIELD_CONSENT_MSG 0x10
97 /* HTTP capability type enumeration. */
98 #define HTTP_CAPABILITY_TYPE_QUAR_SOH 0x1
99 #define HTTP_CAPABILITY_IDLE_TIMEOUT 0x2
100 #define HTTP_CAPABILITY_MESSAGING_CONSENT_SIGN 0x4
101 #define HTTP_CAPABILITY_MESSAGING_SERVICE_MSG 0x8
102 #define HTTP_CAPABILITY_REAUTH 0x10
103 #define HTTP_CAPABILITY_UDP_TRANSPORT 0x20
108 RDG_CLIENT_STATE_INITIAL,
109 RDG_CLIENT_STATE_OUT_CHANNEL_REQUEST,
110 RDG_CLIENT_STATE_OUT_CHANNEL_AUTHORIZE,
111 RDG_CLIENT_STATE_OUT_CHANNEL_AUTHORIZED,
112 RDG_CLIENT_STATE_IN_CHANNEL_REQUEST,
113 RDG_CLIENT_STATE_IN_CHANNEL_AUTHORIZE,
114 RDG_CLIENT_STATE_IN_CHANNEL_AUTHORIZED,
115 RDG_CLIENT_STATE_HANDSHAKE,
116 RDG_CLIENT_STATE_TUNNEL_CREATE,
117 RDG_CLIENT_STATE_TUNNEL_AUTHORIZE,
118 RDG_CLIENT_STATE_CHANNEL_CREATE,
119 RDG_CLIENT_STATE_OPENED,
120 RDG_CLIENT_STATE_CLOSE,
121 RDG_CLIENT_STATE_CLOSED,
122 RDG_CLIENT_STATE_NOT_FOUND,
128 rdpSettings* settings;
135 CRITICAL_SECTION writeSection;
140 UINT16 packetRemainingCount;
145 rdpRdg* rdg_new(rdpTransport* transport);
146 void rdg_free(rdpRdg* rdg);
148 BOOL rdg_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout);
149 DWORD rdg_get_event_handles(rdpRdg* rdg, HANDLE* events, DWORD count);
150 BOOL rdg_check_event_handles(rdpRdg* rdg);
153 #endif /* FREERDP_CORE_RDG_H */