--- sourceforge.net/trunk/rdesktop/mcs.c 2000/05/10 07:36:34 4 +++ sourceforge.net/trunk/rdesktop/mcs.c 2000/07/25 12:34:29 9 @@ -33,15 +33,14 @@ mcs_send_connect_initial(conn); if (!iso_recv(conn) || !mcs_io_connect_response(&conn->in, &mcr)) { - fprintf(stderr, "MCS error, expected Connect-Response\n"); + ERROR("MCS error, expected Connect-Response\n"); iso_disconnect(conn); return NULL; } if (mcr.result != 0) { - fprintf(stderr, "MCS-Connect-Initial failed, result %d\n", - mcr.result); + ERROR("MCS-Connect-Initial failed, result %d\n", mcr.result); iso_disconnect(conn); return NULL; } @@ -51,14 +50,14 @@ mcs_send_aurq(conn); if (!iso_recv(conn) || !mcs_io_aucf(&conn->in, &aucf)) { - fprintf(stderr, "MCS error, expected AUcf\n"); + ERROR("MCS error, expected AUcf\n"); mcs_disconnect(conn); return NULL; } if (aucf.result != 0) { - fprintf(stderr, "AUrq failed, result %d\n", mcr.result); + ERROR("AUrq failed, result %d\n", mcr.result); mcs_disconnect(conn); return NULL; } @@ -82,13 +81,13 @@ mcs_send_cjrq(conn, chanid); if (!iso_recv(conn) || !mcs_io_cjcf(&conn->in, &cjcf)) { - fprintf(stderr, "MCS error, expected CJcf\n"); + ERROR("MCS error, expected CJcf\n"); return False; } if (cjcf.result != 0) { - fprintf(stderr, "CJrq failed, result %d\n", cjcf.result); + ERROR("CJrq failed, result %d\n", cjcf.result); return False; } @@ -176,7 +175,11 @@ { MCS_DATA data; - return (iso_recv(conn)) && mcs_io_data(&conn->in, &data, request); + if (!iso_recv(conn) || !mcs_io_data(&conn->in, &data, request)) + return False; + + conn->in.rdp_offset = conn->in.offset; + return True; } /* Initialise a DOMAIN_PARAMS structure */ @@ -207,16 +210,34 @@ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x01,0xca,0x00,0x00,0x02,0xc0,0x08,0x00,0x00,0x00,0x00,0x00 }; + 0x00,0x01,0xca,0x00,0x00,0x02,0xc0,0x08,0x00, + /* encryption disabled */ 0x00,0x00,0x00,0x00 }; + +char precanned_connect_userdata_e[] = { +0x00, +0x05,0x00,0x14,0x7c,0x00,0x01,0x80,0x9e,0x00,0x08,0x00,0x10,0x00,0x01,0xc0,0x00, +0x44,0x75,0x63,0x61,0x80,0x90,0x01,0xc0,0x88,0x00,0x01,0x00,0x08,0x00,0x80,0x02, +0xe0,0x01,0x01,0xca,0x03,0xaa,0x09,0x04,0x00,0x00,0xa3,0x01,0x00,0x00,0x57,0x00, +0x49,0x00,0x4e,0x00,0x39,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xca,0x00,0x00,0x02,0xc0, +0x08,0x00,0x01,0x00,0x00,0x00 +}; + +char domain_data[] = {0x01}; /* Initialise a MCS_CONNECT_INITIAL structure */ void mcs_make_connect_initial(MCS_CONNECT_INITIAL *mci) { - mci->calling_domain.length = 0; - mci->calling_domain.data = NULL; + mci->calling_domain.length = 1; + mci->calling_domain.data = domain_data; - mci->called_domain.length = 0; - mci->called_domain.data = NULL; + mci->called_domain.length = 1; + mci->called_domain.data = domain_data; mci->upward_flag = 0xff; @@ -243,18 +264,22 @@ BOOL res; /* Read/write tag */ - if (islong) { + if (islong) + { word_tag = tagval; res = msb_io_uint16(s, &word_tag); tag = word_tag; - } else { + } + else + { byte_tag = tagval; res = prs_io_uint8(s, &byte_tag); tag = byte_tag; } - if (!res || (tag != tagval)) { - fprintf(stderr, "Invalid ASN.1 tag\n"); + if (!res || (tag != tagval)) + { + ERROR("Invalid ASN.1 tag\n"); return False; } @@ -361,7 +386,7 @@ if (length != 1) { - fprintf(stderr, "Wrong length for simple type\n"); + ERROR("Wrong length for simple type\n"); return False; } @@ -428,7 +453,7 @@ res = prs_io_uint8(s, &pkt_opcode); if (pkt_opcode != opcode) { - fprintf(stderr, "Expected EDrq, received %x\n", pkt_opcode); + ERROR("Expected EDrq, received %x\n", pkt_opcode); return False; } @@ -448,7 +473,7 @@ res = prs_io_uint8(s, &pkt_opcode); if (pkt_opcode != opcode) { - fprintf(stderr, "Expected AUrq, received %x\n", pkt_opcode); + ERROR("Expected AUrq, received %x\n", pkt_opcode); return False; } @@ -465,7 +490,7 @@ res = prs_io_uint8(s, &pkt_opcode); if ((pkt_opcode & 0xfc) != opcode) { - fprintf(stderr, "Expected AUcf, received %x\n", pkt_opcode); + ERROR("Expected AUcf, received %x\n", pkt_opcode); return False; } @@ -486,7 +511,7 @@ res = prs_io_uint8(s, &pkt_opcode); if (pkt_opcode != opcode) { - fprintf(stderr, "Expected CJrq, received %x\n", pkt_opcode); + ERROR("Expected CJrq, received %x\n", pkt_opcode); return False; } @@ -506,7 +531,7 @@ res = prs_io_uint8(s, &pkt_opcode); if ((pkt_opcode & 0xfc) != opcode) { - fprintf(stderr, "Expected CJcf, received %x\n", pkt_opcode); + ERROR("Expected CJcf, received %x\n", pkt_opcode); return False; } @@ -524,21 +549,36 @@ { uint8 opcode = (request ? 25 : 26) << 2; uint8 pkt_opcode = opcode; + uint8 byte1, byte2; BOOL res; res = prs_io_uint8(s, &pkt_opcode); if (pkt_opcode != opcode) { - fprintf(stderr, "Expected MCS data, received %x\n", pkt_opcode); + ERROR("Expected MCS data, received %x\n", pkt_opcode); return False; } - dt->length |= 0x8000; - res = res ? msb_io_uint16(s, &dt->userid) : False; res = res ? msb_io_uint16(s, &dt->chanid) : False; res = res ? prs_io_uint8 (s, &dt->flags ) : False; - res = res ? msb_io_uint16(s, &dt->length) : False; + + if (s->marshall) + { + dt->length |= 0x8000; + res = res ? msb_io_uint16(s, &dt->length) : False; + } + else + { + res = res ? prs_io_uint8(s, &byte1) : False; + if (byte1 & 0x80) + { + res = res ? prs_io_uint8(s, &byte2) : False; + dt->length = ((byte1 & ~0x80) << 8) + byte2; + } + else dt->length = byte1; + } return res; } +