|
|
@ -27,7 +27,7 @@ struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner)
|
|
|
|
struct xrdp_mcs* self;
|
|
|
|
struct xrdp_mcs* self;
|
|
|
|
|
|
|
|
|
|
|
|
self = (struct xrdp_mcs*)g_malloc(sizeof(struct xrdp_mcs), 1);
|
|
|
|
self = (struct xrdp_mcs*)g_malloc(sizeof(struct xrdp_mcs), 1);
|
|
|
|
self->owner = owner;
|
|
|
|
self->sec_layer = owner;
|
|
|
|
self->in_s = owner->in_s;
|
|
|
|
self->in_s = owner->in_s;
|
|
|
|
self->out_s = owner->out_s;
|
|
|
|
self->out_s = owner->out_s;
|
|
|
|
self->userid = 1;
|
|
|
|
self->userid = 1;
|
|
|
@ -45,6 +45,23 @@ void xrdp_mcs_delete(struct xrdp_mcs* self)
|
|
|
|
g_free(self);
|
|
|
|
g_free(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* returns error */
|
|
|
|
|
|
|
|
int xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int chanid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (xrdp_iso_init(self->iso_layer, 8) != 0)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
out_uint8(self->out_s, (MCS_CJCF << 2) | 2);
|
|
|
|
|
|
|
|
out_uint8(self->out_s, 0);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, self->userid);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, chanid);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, chanid);
|
|
|
|
|
|
|
|
s_mark_end(self->out_s);
|
|
|
|
|
|
|
|
if (xrdp_iso_send(self->iso_layer) != 0)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* returns error */
|
|
|
|
/* returns error */
|
|
|
|
int xrdp_mcs_recv(struct xrdp_mcs* self)
|
|
|
|
int xrdp_mcs_recv(struct xrdp_mcs* self)
|
|
|
@ -53,16 +70,32 @@ int xrdp_mcs_recv(struct xrdp_mcs* self)
|
|
|
|
int opcode;
|
|
|
|
int opcode;
|
|
|
|
int len;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG((" in xrdp_mcs_recv\n\r"));
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (xrdp_iso_recv(self->iso_layer) != 0)
|
|
|
|
if (xrdp_iso_recv(self->iso_layer) != 0)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
in_uint8(self->in_s, opcode);
|
|
|
|
in_uint8(self->in_s, opcode);
|
|
|
|
appid = opcode >> 2;
|
|
|
|
appid = opcode >> 2;
|
|
|
|
|
|
|
|
if (appid == MCS_DPUM)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (appid == MCS_CJRQ)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
xrdp_mcs_send_cjcf(self, self->userid + MCS_USERCHANNEL_BASE);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (appid != MCS_SDRQ)
|
|
|
|
if (appid != MCS_SDRQ)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DEBUG((" out xrdp_mcs_recv err got 0x%x need MCS_SDRQ\n\r", appid));
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
in_uint8s(self->in_s, 5);
|
|
|
|
in_uint8s(self->in_s, 5);
|
|
|
|
in_uint8(self->in_s, len);
|
|
|
|
in_uint8(self->in_s, len);
|
|
|
|
if (len & 0x80)
|
|
|
|
if (len & 0x80)
|
|
|
|
in_uint8s(self->in_s, 1);
|
|
|
|
in_uint8s(self->in_s, 1);
|
|
|
|
|
|
|
|
DEBUG((" out xrdp_mcs_recv\n\r"));
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -72,6 +105,7 @@ int xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, int tag_val, int* len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int tag;
|
|
|
|
int tag;
|
|
|
|
int l;
|
|
|
|
int l;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
if (tag_val > 0xff)
|
|
|
|
if (tag_val > 0xff)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -90,7 +124,8 @@ int xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, int tag_val, int* len)
|
|
|
|
*len = 0;
|
|
|
|
*len = 0;
|
|
|
|
while (l > 0)
|
|
|
|
while (l > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
next_be(self->in_s, *len);
|
|
|
|
in_uint8(self->in_s, i);
|
|
|
|
|
|
|
|
*len = (*len << 8) | i;
|
|
|
|
l--;
|
|
|
|
l--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -203,7 +238,7 @@ int xrdp_mcs_send_aucf(struct xrdp_mcs* self)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (xrdp_iso_init(self->iso_layer, 4) != 0)
|
|
|
|
if (xrdp_iso_init(self->iso_layer, 4) != 0)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
out_uint8(self->out_s, (MCS_AUCF << 2) | 2);
|
|
|
|
out_uint8(self->out_s, ((MCS_AUCF << 2) | 2));
|
|
|
|
out_uint8s(self->out_s, 1);
|
|
|
|
out_uint8s(self->out_s, 1);
|
|
|
|
out_uint16_be(self->out_s, self->userid);
|
|
|
|
out_uint16_be(self->out_s, self->userid);
|
|
|
|
s_mark_end(self->out_s);
|
|
|
|
s_mark_end(self->out_s);
|
|
|
@ -233,23 +268,6 @@ int xrdp_mcs_recv_cjrq(struct xrdp_mcs* self)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* returns error */
|
|
|
|
|
|
|
|
int xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int chanid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (xrdp_iso_init(self->iso_layer, 8) != 0)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
out_uint8(self->out_s, (MCS_CJCF << 2) | 2);
|
|
|
|
|
|
|
|
out_uint8(self->out_s, 0);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, self->userid);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, chanid);
|
|
|
|
|
|
|
|
out_uint16_be(self->out_s, chanid);
|
|
|
|
|
|
|
|
s_mark_end(self->out_s);
|
|
|
|
|
|
|
|
if (xrdp_iso_send(self->iso_layer) != 0)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* returns error */
|
|
|
|
/* returns error */
|
|
|
|
int xrdp_mcs_ber_out_header(struct xrdp_mcs* self, int tag_val, int len)
|
|
|
|
int xrdp_mcs_ber_out_header(struct xrdp_mcs* self, int tag_val, int len)
|
|
|
@ -349,6 +367,7 @@ int xrdp_mcs_send_connect_response(struct xrdp_mcs* self)
|
|
|
|
/* returns error */
|
|
|
|
/* returns error */
|
|
|
|
int xrdp_mcs_incoming(struct xrdp_mcs* self)
|
|
|
|
int xrdp_mcs_incoming(struct xrdp_mcs* self)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
DEBUG((" in xrdp_mcs_incoming\n\r"));
|
|
|
|
if (xrdp_iso_incoming(self->iso_layer) != 0)
|
|
|
|
if (xrdp_iso_incoming(self->iso_layer) != 0)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
if (xrdp_mcs_recv_connect_initial(self) != 0)
|
|
|
|
if (xrdp_mcs_recv_connect_initial(self) != 0)
|
|
|
@ -369,6 +388,7 @@ int xrdp_mcs_incoming(struct xrdp_mcs* self)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
if (xrdp_mcs_send_cjcf(self, MCS_GLOBAL_CHANNEL) != 0)
|
|
|
|
if (xrdp_mcs_send_cjcf(self, MCS_GLOBAL_CHANNEL) != 0)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
DEBUG((" out xrdp_mcs_incoming\n\r"));
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|