Blame libfreerdp/core/nego.h

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * RDP Protocol Security Negotiation
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifndef FREERDP_LIB_CORE_NEGO_H
Packit 1fb8d4
#define FREERDP_LIB_CORE_NEGO_H
Packit 1fb8d4
Packit 1fb8d4
#include "transport.h"
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/types.h>
Packit 1fb8d4
#include <freerdp/settings.h>
Packit 1fb8d4
#include <freerdp/log.h>
Packit 1fb8d4
#include <freerdp/api.h>
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/stream.h>
Packit 1fb8d4
Packit Service 5a9772
/* Protocol Security Negotiation Protocols
Packit Service 5a9772
 * [MS-RDPBCGR] 2.2.1.1.1 RDP Negotiation Request (RDP_NEG_REQ)
Packit Service 5a9772
 */
Packit Service 5a9772
#define PROTOCOL_RDP 0x00000000
Packit Service 5a9772
#define PROTOCOL_SSL 0x00000001
Packit Service 5a9772
#define PROTOCOL_HYBRID 0x00000002
Packit Service 5a9772
#define PROTOCOL_RDSTLS 0x00000004
Packit Service 5a9772
#define PROTOCOL_HYBRID_EX 0x00000008
Packit 1fb8d4
Packit Service 5a9772
#define PROTOCOL_FAILED_NEGO 0x80000000 /* only used internally, not on the wire */
Packit 1fb8d4
Packit 1fb8d4
/* Protocol Security Negotiation Failure Codes */
Packit 1fb8d4
enum RDP_NEG_FAILURE_FAILURECODES
Packit 1fb8d4
{
Packit 1fb8d4
	SSL_REQUIRED_BY_SERVER = 0x00000001,
Packit 1fb8d4
	SSL_NOT_ALLOWED_BY_SERVER = 0x00000002,
Packit 1fb8d4
	SSL_CERT_NOT_ON_SERVER = 0x00000003,
Packit 1fb8d4
	INCONSISTENT_FLAGS = 0x00000004,
Packit 1fb8d4
	HYBRID_REQUIRED_BY_SERVER = 0x00000005,
Packit 1fb8d4
	SSL_WITH_USER_AUTH_REQUIRED_BY_SERVER = 0x00000006
Packit 1fb8d4
};
Packit 1fb8d4
Packit 1fb8d4
/* Authorization Result */
Packit Service 5a9772
#define AUTHZ_SUCCESS 0x00000000
Packit Service 5a9772
#define AUTHZ_ACCESS_DENIED 0x0000052E
Packit 1fb8d4
Packit 1fb8d4
enum _NEGO_STATE
Packit 1fb8d4
{
Packit 1fb8d4
	NEGO_STATE_INITIAL,
Packit Service 5a9772
	NEGO_STATE_EXT,  /* Extended NLA (NLA + TLS implicit) */
Packit Service 5a9772
	NEGO_STATE_NLA,  /* Network Level Authentication (TLS implicit) */
Packit Service 5a9772
	NEGO_STATE_TLS,  /* TLS Encryption without NLA */
Packit Service 5a9772
	NEGO_STATE_RDP,  /* Standard Legacy RDP Encryption */
Packit 1fb8d4
	NEGO_STATE_FAIL, /* Negotiation failure */
Packit 1fb8d4
	NEGO_STATE_FINAL
Packit 1fb8d4
};
Packit 1fb8d4
typedef enum _NEGO_STATE NEGO_STATE;
Packit 1fb8d4
Packit 1fb8d4
/* RDP Negotiation Messages */
Packit 1fb8d4
enum RDP_NEG_MSG
Packit 1fb8d4
{
Packit 1fb8d4
	/* X224_TPDU_CONNECTION_REQUEST */
Packit 1fb8d4
	TYPE_RDP_NEG_REQ = 0x1,
Packit 1fb8d4
	/* X224_TPDU_CONNECTION_CONFIRM */
Packit 1fb8d4
	TYPE_RDP_NEG_RSP = 0x2,
Packit 1fb8d4
	TYPE_RDP_NEG_FAILURE = 0x3
Packit 1fb8d4
};
Packit 1fb8d4
Packit Service 5a9772
#define EXTENDED_CLIENT_DATA_SUPPORTED 0x01
Packit Service 5a9772
#define DYNVC_GFX_PROTOCOL_SUPPORTED 0x02
Packit Service 5a9772
#define RDP_NEGRSP_RESERVED 0x04
Packit Service 5a9772
#define RESTRICTED_ADMIN_MODE_SUPPORTED 0x08
Packit 1fb8d4
Packit Service 5a9772
#define PRECONNECTION_PDU_V1_SIZE 16
Packit Service 5a9772
#define PRECONNECTION_PDU_V2_MIN_SIZE (PRECONNECTION_PDU_V1_SIZE + 2)
Packit 1fb8d4
Packit Service 5a9772
#define PRECONNECTION_PDU_V1 1
Packit Service 5a9772
#define PRECONNECTION_PDU_V2 2
Packit 1fb8d4
Packit Service 5a9772
#define RESTRICTED_ADMIN_MODE_REQUIRED 0x01
Packit Service 5a9772
#define REDIRECTED_AUTHENTICATION_MODE_REQUIRED 0x02
Packit Service 5a9772
#define CORRELATION_INFO_PRESENT 0x08
Packit 1fb8d4
Packit 1fb8d4
typedef struct rdp_nego rdpNego;
Packit 1fb8d4
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_connect(rdpNego* nego);
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_disconnect(rdpNego* nego);
Packit 1fb8d4
Packit 1fb8d4
FREERDP_LOCAL int nego_recv(rdpTransport* transport, wStream* s, void* extra);
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_read_request(rdpNego* nego, wStream* s);
Packit 1fb8d4
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_send_negotiation_request(rdpNego* nego);
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_send_negotiation_response(rdpNego* nego);
Packit 1fb8d4
Packit 1fb8d4
FREERDP_LOCAL rdpNego* nego_new(rdpTransport* transport);
Packit 1fb8d4
FREERDP_LOCAL void nego_free(rdpNego* nego);
Packit 1fb8d4
Packit 1fb8d4
FREERDP_LOCAL void nego_init(rdpNego* nego);
Packit Service 5a9772
FREERDP_LOCAL BOOL nego_set_target(rdpNego* nego, const char* hostname, UINT16 port);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_negotiation_enabled(rdpNego* nego, BOOL NegotiateSecurityLayer);
Packit 1fb8d4
FREERDP_LOCAL void nego_set_restricted_admin_mode_required(rdpNego* nego,
Packit Service 5a9772
                                                           BOOL RestrictedAdminModeRequired);
Packit 1fb8d4
FREERDP_LOCAL void nego_set_gateway_enabled(rdpNego* nego, BOOL GatewayEnabled);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_gateway_bypass_local(rdpNego* nego, BOOL GatewayBypassLocal);
Packit 1fb8d4
FREERDP_LOCAL void nego_enable_rdp(rdpNego* nego, BOOL enable_rdp);
Packit 1fb8d4
FREERDP_LOCAL void nego_enable_tls(rdpNego* nego, BOOL enable_tls);
Packit 1fb8d4
FREERDP_LOCAL void nego_enable_nla(rdpNego* nego, BOOL enable_nla);
Packit 1fb8d4
FREERDP_LOCAL void nego_enable_ext(rdpNego* nego, BOOL enable_ext);
Packit Service 5a9772
FREERDP_LOCAL const BYTE* nego_get_routing_token(rdpNego* nego, DWORD* RoutingTokenLength);
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken,
Packit Service 5a9772
                                          DWORD RoutingTokenLength);
Packit 1fb8d4
FREERDP_LOCAL BOOL nego_set_cookie(rdpNego* nego, char* cookie);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_cookie_max_length(rdpNego* nego, UINT32 CookieMaxLength);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_send_preconnection_pdu(rdpNego* nego, BOOL SendPreconnectionPdu);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_preconnection_id(rdpNego* nego, UINT32 PreconnectionId);
Packit Service 5a9772
FREERDP_LOCAL void nego_set_preconnection_blob(rdpNego* nego, char* PreconnectionBlob);
Packit Service 5a9772
Packit Service 5a9772
FREERDP_LOCAL UINT32 nego_get_selected_protocol(rdpNego* nego);
Packit Service 5a9772
FREERDP_LOCAL BOOL nego_set_selected_protocol(rdpNego* nego, UINT32 SelectedProtocol);
Packit Service 5a9772
Packit Service 5a9772
FREERDP_LOCAL UINT32 nego_get_requested_protocols(rdpNego* nego);
Packit Service 5a9772
FREERDP_LOCAL BOOL nego_set_requested_protocols(rdpNego* nego, UINT32 RequestedProtocols);
Packit Service 5a9772
Packit Service 5a9772
FREERDP_LOCAL BOOL nego_set_state(rdpNego* nego, NEGO_STATE state);
Packit Service 5a9772
FREERDP_LOCAL NEGO_STATE nego_get_state(rdpNego* nego);
Packit Service 5a9772
Packit Service 5a9772
FREERDP_LOCAL SEC_WINNT_AUTH_IDENTITY* nego_get_identity(rdpNego* nego);
Packit Service 5a9772
Packit Service 5a9772
FREERDP_LOCAL void nego_free_nla(rdpNego* nego);
Packit 1fb8d4
Packit 1fb8d4
#endif /* FREERDP_LIB_CORE_NEGO_H */