libxrdp: work on RDP negotiation

ulab-next
speidy 11 years ago
parent 8914b523ee
commit 2b0524ad7e

@ -31,6 +31,29 @@
#define ISO_PDU_DT 0xF0 /* Data */
#define ISO_PDU_ER 0x70 /* Error */
/* RDP Security Negotiation codes */
#define RDP_NEG_REQ 0x01
#define RDP_NEG_RSP 0x02
#define RDP_NEG_FAILURE 0x03
/* Protocol types codes */
#define PROTOCOL_RDP 0x0
#define PROTOCOL_SSL 0x1
#define PROTOCOL_HYBRID 0x2
#define PROTOCOL_HYBRID_EX 0x8
/* Negotiation packet flags */
#define EXTENDED_CLIENT_DATA_SUPPORTED 0x1
#define DYNVC_GFX_PROTOCOL_SUPPORTED 0x2
#define RDP_NEGRSP_RESERVED 0x4
/* Failure Codes */
#define SSL_REQUIRED_BY_SERVER 0x1
#define SSL_NOT_ALLOWED_BY_SERVER 0x2
#define SSL_CERT_NOT_ON_SERVER 0x3
#define INCONSISTENT_FLAGS 0x4
#define HYBRID_REQUIRED_BY_SERVER 0x5
#define SSL_WITH_USER_AUTH_REQUIRED_BY_SERVER 0x6
/* MCS PDU codes */
#define MCS_EDRQ 1 /* Erect Domain Request */
#define MCS_DPUM 8 /* Disconnect Provider Ultimatum */

@ -62,6 +62,9 @@ xrdp_iso_recv_msg(struct xrdp_iso *self, struct stream *s, int *code)
return 1;
}
// print CR packet hex dump
g_hexdump(s->p, 19);
in_uint8(s, ver);
if (ver != 3)
@ -86,7 +89,7 @@ xrdp_iso_recv_msg(struct xrdp_iso *self, struct stream *s, int *code)
}
else
{
in_uint8s(s, 13);
in_uint8s(s, 5+8);
}
return 0;
@ -119,7 +122,7 @@ xrdp_iso_recv(struct xrdp_iso *self, struct stream *s)
/*****************************************************************************/
static int APP_CC
xrdp_iso_send_msg(struct xrdp_iso *self, struct stream *s, int code)
xrdp_iso_send_msg(struct xrdp_iso *self, struct stream *s, int code, int negostate)
{
if (xrdp_tcp_init(self->tcp_layer, s) != 0)
{
@ -137,11 +140,23 @@ xrdp_iso_send_msg(struct xrdp_iso *self, struct stream *s, int code)
out_uint16_be(s, 0x1234);
out_uint8(s, 0);
/* RDP_NEG_RSP - 8 bytes*/
out_uint8(s, 2); /* TYPE_RDP_NEG_RSP */
out_uint8(s, 1); /* flags */
out_uint16_le(s, 8); /* length */
out_uint32_le(s, 0); /* selectedProtocol: 0 = RDP , 1 = TLS , 2 = CREDSSP */
s_mark_end(s);
switch (negostate)
{
case RDP_NEG_FAILURE:
out_uint8(s, RDP_NEG_FAILURE); /* RDP_NEG_FAILURE */
out_uint8(s, 0); /* no flags available */
out_uint16_le(s, 8); /* fixed length */
out_uint32_le(s, SSL_NOT_ALLOWED_BY_SERVER); /* failure code */
break;
case RDP_NEG_RSP:
out_uint8(s, RDP_NEG_RSP); /* TYPE_RDP_NEG_RSP */
out_uint8(s, EXTENDED_CLIENT_DATA_SUPPORTED); /* flags */
out_uint16_le(s, 8); /* fixed length */
out_uint32_le(s, PROTOCOL_RDP); /* selected protocol */
break;
}
s_mark_end(s);
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
{
@ -157,8 +172,9 @@ int APP_CC
xrdp_iso_incoming(struct xrdp_iso *self)
{
int code;
int negostate;
struct stream *s;
//todo: negostate init and change
make_stream(s);
init_stream(s, 8192);
DEBUG((" in xrdp_iso_incoming"));
@ -175,7 +191,15 @@ xrdp_iso_incoming(struct xrdp_iso *self)
return 1;
}
if (xrdp_iso_send_msg(self, s, ISO_PDU_CC) != 0)
//RDP Negotiate Security Layer
/* if (xrdp_nego_init(self, s, ISO_PDU_CC,init) != 0)
{
free_stream(s);
return 1;
}*/
if (xrdp_iso_send_msg(self, s, ISO_PDU_CC, negostate) != 0)
{
free_stream(s);
return 1;

Loading…
Cancel
Save