20 #ifndef FREERDP_LIB_CORE_NEGO_H
21 #define FREERDP_LIB_CORE_NEGO_H
23 #include "transport.h"
25 #include <freerdp/types.h>
26 #include <freerdp/settings.h>
27 #include <freerdp/log.h>
28 #include <freerdp/api.h>
30 #include <winpr/stream.h>
35 #define PROTOCOL_RDP 0x00000000
36 #define PROTOCOL_SSL 0x00000001
37 #define PROTOCOL_HYBRID 0x00000002
38 #define PROTOCOL_RDSTLS 0x00000004
39 #define PROTOCOL_HYBRID_EX 0x00000008
40 #define PROTOCOL_RDSAAD 0x00000010
42 #define PROTOCOL_FAILED_NEGO 0x80000000
45 enum RDP_NEG_FAILURE_FAILURECODES
47 SSL_REQUIRED_BY_SERVER = 0x00000001,
48 SSL_NOT_ALLOWED_BY_SERVER = 0x00000002,
49 SSL_CERT_NOT_ON_SERVER = 0x00000003,
50 INCONSISTENT_FLAGS = 0x00000004,
51 HYBRID_REQUIRED_BY_SERVER = 0x00000005,
52 SSL_WITH_USER_AUTH_REQUIRED_BY_SERVER = 0x00000006
72 TYPE_RDP_NEG_REQ = 0x1,
74 TYPE_RDP_NEG_RSP = 0x2,
75 TYPE_RDP_NEG_FAILURE = 0x3,
76 TYPE_RDP_CORRELATION_INFO = 0x6
81 EXTENDED_CLIENT_DATA_SUPPORTED = 0x01,
82 DYNVC_GFX_PROTOCOL_SUPPORTED = 0x02,
83 RDP_NEGRSP_RESERVED = 0x04,
84 RESTRICTED_ADMIN_MODE_SUPPORTED = 0x08,
85 REDIRECTED_AUTHENTICATION_MODE_SUPPORTED = 0x10
88 #define PRECONNECTION_PDU_V1_SIZE 16
89 #define PRECONNECTION_PDU_V2_MIN_SIZE (PRECONNECTION_PDU_V1_SIZE + 2)
91 #define PRECONNECTION_PDU_V1 1
92 #define PRECONNECTION_PDU_V2 2
94 #define RESTRICTED_ADMIN_MODE_REQUIRED 0x01
95 #define REDIRECTED_AUTHENTICATION_MODE_REQUIRED 0x02
96 #define CORRELATION_INFO_PRESENT 0x08
98 typedef struct rdp_nego rdpNego;
100 FREERDP_LOCAL BOOL nego_connect(rdpNego* nego);
101 FREERDP_LOCAL BOOL nego_disconnect(rdpNego* nego);
103 FREERDP_LOCAL
int nego_recv(rdpTransport* transport,
wStream* s,
void* extra);
104 FREERDP_LOCAL BOOL nego_read_request(rdpNego* nego,
wStream* s);
106 FREERDP_LOCAL BOOL nego_send_negotiation_request(rdpNego* nego);
107 FREERDP_LOCAL BOOL nego_send_negotiation_response(rdpNego* nego);
109 FREERDP_LOCAL
void nego_free(rdpNego* nego);
111 WINPR_ATTR_MALLOC(nego_free, 1)
112 FREERDP_LOCAL rdpNego* nego_new(rdpTransport* transport);
114 FREERDP_LOCAL
void nego_init(rdpNego* nego);
115 FREERDP_LOCAL BOOL nego_set_target(rdpNego* nego, const
char* hostname, UINT16 port);
116 FREERDP_LOCAL
void nego_set_negotiation_enabled(rdpNego* nego, BOOL NegotiateSecurityLayer);
117 FREERDP_LOCAL
void nego_set_restricted_admin_mode_required(rdpNego* nego,
118 BOOL RestrictedAdminModeRequired);
119 FREERDP_LOCAL
void nego_set_RCG_required(rdpNego* nego, BOOL enabled);
120 FREERDP_LOCAL
void nego_set_RCG_supported(rdpNego* nego, BOOL enabled);
121 FREERDP_LOCAL BOOL nego_get_remoteCredentialGuard(rdpNego* nego);
122 FREERDP_LOCAL
void nego_set_childsession_enabled(rdpNego* nego, BOOL ChildSessionEnabled);
123 FREERDP_LOCAL
void nego_set_gateway_enabled(rdpNego* nego, BOOL GatewayEnabled);
124 FREERDP_LOCAL
void nego_set_gateway_bypass_local(rdpNego* nego, BOOL GatewayBypassLocal);
125 FREERDP_LOCAL
void nego_enable_rdp(rdpNego* nego, BOOL enable_rdp);
126 FREERDP_LOCAL
void nego_enable_tls(rdpNego* nego, BOOL enable_tls);
127 FREERDP_LOCAL
void nego_enable_nla(rdpNego* nego, BOOL enable_nla);
128 FREERDP_LOCAL
void nego_enable_rdstls(rdpNego* nego, BOOL enable_rdstls);
129 FREERDP_LOCAL
void nego_enable_aad(rdpNego* nego, BOOL enable_aad);
130 FREERDP_LOCAL
void nego_enable_ext(rdpNego* nego, BOOL enable_ext);
131 FREERDP_LOCAL const BYTE* nego_get_routing_token(rdpNego* nego, DWORD* RoutingTokenLength);
132 FREERDP_LOCAL BOOL nego_set_routing_token(rdpNego* nego, const
void* RoutingToken,
133 DWORD RoutingTokenLength);
134 FREERDP_LOCAL BOOL nego_set_cookie(rdpNego* nego, const
char* cookie);
135 FREERDP_LOCAL
void nego_set_cookie_max_length(rdpNego* nego, UINT32 CookieMaxLength);
136 FREERDP_LOCAL
void nego_set_send_preconnection_pdu(rdpNego* nego, BOOL SendPreconnectionPdu);
137 FREERDP_LOCAL
void nego_set_preconnection_id(rdpNego* nego, UINT32 PreconnectionId);
138 FREERDP_LOCAL
void nego_set_preconnection_blob(rdpNego* nego, const
char* PreconnectionBlob);
140 FREERDP_LOCAL UINT32 nego_get_selected_protocol(rdpNego* nego);
141 FREERDP_LOCAL BOOL nego_set_selected_protocol(rdpNego* nego, UINT32 SelectedProtocol);
143 FREERDP_LOCAL UINT32 nego_get_requested_protocols(rdpNego* nego);
144 FREERDP_LOCAL BOOL nego_set_requested_protocols(rdpNego* nego, UINT32 RequestedProtocols);
146 FREERDP_LOCAL BOOL nego_update_settings_from_state(rdpNego* nego, rdpSettings* settings);
148 FREERDP_LOCAL BOOL nego_set_state(rdpNego* nego, NEGO_STATE state);
149 FREERDP_LOCAL NEGO_STATE nego_get_state(rdpNego* nego);
151 FREERDP_LOCAL SEC_WINNT_AUTH_IDENTITY* nego_get_identity(rdpNego* nego);
153 FREERDP_LOCAL
void nego_free_nla(rdpNego* nego);
155 FREERDP_LOCAL const
char* nego_protocol_to_str(UINT32 protocol,
char* buffer,
size_t size);