2000-05-10 09:36:34 +02:00
|
|
|
/*
|
|
|
|
rdesktop: A Remote Desktop Protocol client.
|
|
|
|
Protocol services - Multipoint Communications Service
|
2002-09-26 16:26:46 +02:00
|
|
|
Copyright (C) Matthew Chapman 1999-2002
|
2000-05-10 09:36:34 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
#include "rdesktop.h"
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
uint16 mcs_userid;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Parse an ASN.1 BER header */
|
2001-01-06 04:47:04 +01:00
|
|
|
static BOOL
|
|
|
|
ber_parse_header(STREAM s, int tagval, int *length)
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
|
|
|
int tag, len;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
if (tagval > 0xff)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint16_be(s, tag);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
else
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8(s, tag)}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
if (tag != tagval)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("expected tag %d, got %d\n", tagval, tag);
|
2000-08-15 12:23:24 +02:00
|
|
|
return False;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, len);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
if (len & 0x80)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
len &= ~0x80;
|
|
|
|
*length = 0;
|
|
|
|
while (len--)
|
|
|
|
next_be(s, *length);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2001-01-06 04:12:10 +01:00
|
|
|
else
|
|
|
|
*length = len;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s_check(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output an ASN.1 BER header */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
ber_out_header(STREAM s, int tagval, int length)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
if (tagval > 0xff)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_be(s, tagval);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
else
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, tagval);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
if (length >= 0x80)
|
|
|
|
{
|
|
|
|
out_uint8(s, 0x82);
|
|
|
|
out_uint16_be(s, length);
|
|
|
|
}
|
2001-01-06 04:12:10 +01:00
|
|
|
else
|
|
|
|
out_uint8(s, length);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output an ASN.1 BER integer */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
ber_out_integer(STREAM s, int value)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_header(s, BER_TAG_INTEGER, 2);
|
|
|
|
out_uint16_be(s, value);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2002-07-30 09:18:48 +02:00
|
|
|
mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
|
|
|
|
ber_out_integer(s, max_channels);
|
|
|
|
ber_out_integer(s, max_users);
|
|
|
|
ber_out_integer(s, max_tokens);
|
2001-01-06 04:12:10 +01:00
|
|
|
ber_out_integer(s, 1); /* num_priorities */
|
|
|
|
ber_out_integer(s, 0); /* min_throughput */
|
|
|
|
ber_out_integer(s, 1); /* max_height */
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_integer(s, max_pdusize);
|
2001-01-06 04:12:10 +01:00
|
|
|
ber_out_integer(s, 2); /* ver_protocol */
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static BOOL
|
|
|
|
mcs_parse_domain_params(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
int length;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);
|
|
|
|
in_uint8s(s, length);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s_check(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
mcs_send_connect_initial(STREAM mcs_data)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
int datalen = mcs_data->end - mcs_data->data;
|
2001-01-06 04:12:10 +01:00
|
|
|
int length = 7 + 3 * 34 + 4 + datalen;
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_init(length + 5);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_header(s, MCS_CONNECT_INITIAL, length);
|
2001-01-06 04:12:10 +01:00
|
|
|
ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* calling domain */
|
|
|
|
ber_out_header(s, BER_TAG_OCTET_STRING, 0); /* called domain */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_header(s, BER_TAG_BOOLEAN, 1);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint8(s, 0xff); /* upward flag */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
mcs_out_domain_params(s, 2, 2, 0, 0xffff); /* target params */
|
|
|
|
mcs_out_domain_params(s, 1, 1, 1, 0x420); /* min params */
|
|
|
|
mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff); /* max params */
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_out_header(s, BER_TAG_OCTET_STRING, datalen);
|
|
|
|
out_uint8p(s, mcs_data->data, datalen);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
iso_send(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static BOOL
|
|
|
|
mcs_recv_connect_response(STREAM mcs_data)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 result;
|
|
|
|
int length;
|
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_recv();
|
|
|
|
if (s == NULL)
|
|
|
|
return False;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_parse_header(s, MCS_CONNECT_RESPONSE, &length);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_parse_header(s, BER_TAG_RESULT, &length);
|
|
|
|
in_uint8(s, result);
|
|
|
|
if (result != 0)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("MCS connect: %d\n", result);
|
2000-05-10 09:36:34 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
ber_parse_header(s, BER_TAG_INTEGER, &length);
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, length); /* connect id */
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_parse_domain_params(s);
|
|
|
|
|
|
|
|
ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
|
|
|
|
if (length > mcs_data->size)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("MCS data length %d\n", length);
|
2000-08-15 12:23:24 +02:00
|
|
|
length = mcs_data->size;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8a(s, mcs_data->data, length);
|
|
|
|
mcs_data->p = mcs_data->data;
|
|
|
|
mcs_data->end = mcs_data->data + length;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s_check_end(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an EDrq message (ASN.1 PER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2002-09-24 09:59:14 +02:00
|
|
|
mcs_send_edrq(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_init(5);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, (MCS_EDRQ << 2));
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint16_be(s, 1); /* height */
|
|
|
|
out_uint16_be(s, 1); /* interval */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
iso_send(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an AUrq message (ASN.1 PER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
2002-09-24 09:59:14 +02:00
|
|
|
mcs_send_aurq(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_init(1);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, (MCS_AURQ << 2));
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
iso_send(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Expect a AUcf message (ASN.1 PER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static BOOL
|
2002-07-18 18:38:31 +02:00
|
|
|
mcs_recv_aucf(uint16 * mcs_userid)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 opcode, result;
|
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_recv();
|
|
|
|
if (s == NULL)
|
2000-05-10 09:36:34 +02:00
|
|
|
return False;
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, opcode);
|
|
|
|
if ((opcode >> 2) != MCS_AUCF)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("expected AUcf, got %d\n", opcode);
|
2000-05-10 09:36:34 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, result);
|
|
|
|
if (result != 0)
|
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("AUrq: %d\n", result);
|
2000-08-15 12:23:24 +02:00
|
|
|
return False;
|
|
|
|
}
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
if (opcode & 2)
|
|
|
|
in_uint16_be(s, *mcs_userid);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s_check_end(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send a CJrq message (ASN.1 PER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static void
|
|
|
|
mcs_send_cjrq(uint16 chanid)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
|
|
|
|
|
|
|
s = iso_init(5);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, (MCS_CJRQ << 2));
|
|
|
|
out_uint16_be(s, mcs_userid);
|
|
|
|
out_uint16_be(s, chanid);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_mark_end(s);
|
|
|
|
iso_send(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Expect a CJcf message (ASN.1 PER) */
|
2001-01-06 04:47:04 +01:00
|
|
|
static BOOL
|
2002-09-24 09:59:14 +02:00
|
|
|
mcs_recv_cjcf(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 opcode, result;
|
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_recv();
|
|
|
|
if (s == NULL)
|
|
|
|
return False;
|
|
|
|
|
|
|
|
in_uint8(s, opcode);
|
|
|
|
if ((opcode >> 2) != MCS_CJCF)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("expected CJcf, got %d\n", opcode);
|
2000-05-10 09:36:34 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, result);
|
|
|
|
if (result != 0)
|
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("CJrq: %d\n", result);
|
2000-08-15 12:23:24 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 4); /* mcs_userid, req_chanid */
|
2000-08-15 12:23:24 +02:00
|
|
|
if (opcode & 2)
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 2); /* join_chanid */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s_check_end(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Initialise an MCS transport data packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
STREAM
|
|
|
|
mcs_init(int length)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
STREAM s;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s = iso_init(length + 8);
|
|
|
|
s_push_layer(s, mcs_hdr, 8);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Send an MCS transport data packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
mcs_send(STREAM s)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint16 length;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
s_pop_layer(s, mcs_hdr);
|
|
|
|
length = s->end - s->p - 8;
|
|
|
|
length |= 0x8000;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint8(s, (MCS_SDRQ << 2));
|
|
|
|
out_uint16_be(s, mcs_userid);
|
|
|
|
out_uint16_be(s, MCS_GLOBAL_CHANNEL);
|
2001-01-06 04:12:10 +01:00
|
|
|
out_uint8(s, 0x70); /* flags */
|
2000-08-15 12:23:24 +02:00
|
|
|
out_uint16_be(s, length);
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
iso_send(s);
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Receive an MCS transport data packet */
|
2001-01-06 04:47:04 +01:00
|
|
|
STREAM
|
2002-09-24 09:59:14 +02:00
|
|
|
mcs_recv(void)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 opcode, appid, length;
|
|
|
|
STREAM s;
|
|
|
|
|
|
|
|
s = iso_recv();
|
|
|
|
if (s == NULL)
|
|
|
|
return NULL;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, opcode);
|
|
|
|
appid = opcode >> 2;
|
|
|
|
if (appid != MCS_SDIN)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
if (appid != MCS_DPUM)
|
|
|
|
{
|
2001-09-14 15:51:38 +02:00
|
|
|
error("expected data, got %d\n", opcode);
|
2000-08-15 12:23:24 +02:00
|
|
|
}
|
|
|
|
return NULL;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 5); /* userid, chanid, flags */
|
2000-08-15 12:23:24 +02:00
|
|
|
in_uint8(s, length);
|
|
|
|
if (length & 0x80)
|
2001-01-06 04:12:10 +01:00
|
|
|
in_uint8s(s, 1); /* second byte of length */
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return s;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Establish a connection up to the MCS layer */
|
2001-01-06 04:47:04 +01:00
|
|
|
BOOL
|
|
|
|
mcs_connect(char *server, STREAM mcs_data)
|
2000-05-10 09:36:34 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
if (!iso_connect(server))
|
2000-05-10 09:36:34 +02:00
|
|
|
return False;
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_send_connect_initial(mcs_data);
|
|
|
|
if (!mcs_recv_connect_response(mcs_data))
|
|
|
|
goto error;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_send_edrq();
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_send_aurq();
|
|
|
|
if (!mcs_recv_aucf(&mcs_userid))
|
|
|
|
goto error;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_send_cjrq(mcs_userid + 1001);
|
|
|
|
if (!mcs_recv_cjcf())
|
|
|
|
goto error;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
mcs_send_cjrq(MCS_GLOBAL_CHANNEL);
|
|
|
|
if (!mcs_recv_cjcf())
|
|
|
|
goto error;
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return True;
|
2000-05-10 09:36:34 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
error:
|
2000-08-15 12:23:24 +02:00
|
|
|
iso_disconnect();
|
|
|
|
return False;
|
2000-05-10 09:36:34 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
/* Disconnect from the MCS layer */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
mcs_disconnect(void)
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
|
|
|
iso_disconnect();
|
|
|
|
}
|