/[rdesktop]/sourceforge.net/trunk/rdesktop/mcs.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/mcs.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

sourceforge.net/branches/RDESKTOP/rdesktop/mcs.c revision 3 by matty, Wed May 10 07:36:34 2000 UTC sourceforge.net/trunk/rdesktop/mcs.c revision 9 by matty, Tue Jul 25 12:34:29 2000 UTC
# Line 33  HCONN mcs_connect(char *server) Line 33  HCONN mcs_connect(char *server)
33          mcs_send_connect_initial(conn);          mcs_send_connect_initial(conn);
34          if (!iso_recv(conn) || !mcs_io_connect_response(&conn->in, &mcr))          if (!iso_recv(conn) || !mcs_io_connect_response(&conn->in, &mcr))
35          {          {
36                  fprintf(stderr, "MCS error, expected Connect-Response\n");                  ERROR("MCS error, expected Connect-Response\n");
37                  iso_disconnect(conn);                  iso_disconnect(conn);
38                  return NULL;                  return NULL;
39          }          }
40    
41          if (mcr.result != 0)          if (mcr.result != 0)
42          {          {
43                  fprintf(stderr, "MCS-Connect-Initial failed, result %d\n",                  ERROR("MCS-Connect-Initial failed, result %d\n", mcr.result);
                         mcr.result);  
44                  iso_disconnect(conn);                  iso_disconnect(conn);
45                  return NULL;                  return NULL;
46          }          }
# Line 51  HCONN mcs_connect(char *server) Line 50  HCONN mcs_connect(char *server)
50          mcs_send_aurq(conn);          mcs_send_aurq(conn);
51          if (!iso_recv(conn) || !mcs_io_aucf(&conn->in, &aucf))          if (!iso_recv(conn) || !mcs_io_aucf(&conn->in, &aucf))
52          {          {
53                  fprintf(stderr, "MCS error, expected AUcf\n");                  ERROR("MCS error, expected AUcf\n");
54                  mcs_disconnect(conn);                  mcs_disconnect(conn);
55                  return NULL;                  return NULL;
56          }          }
57    
58          if (aucf.result != 0)          if (aucf.result != 0)
59          {          {
60                  fprintf(stderr, "AUrq failed, result %d\n", mcr.result);                  ERROR("AUrq failed, result %d\n", mcr.result);
61                  mcs_disconnect(conn);                  mcs_disconnect(conn);
62                  return NULL;                  return NULL;
63          }          }
# Line 82  BOOL mcs_join_channel(HCONN conn, uint16 Line 81  BOOL mcs_join_channel(HCONN conn, uint16
81          mcs_send_cjrq(conn, chanid);          mcs_send_cjrq(conn, chanid);
82          if (!iso_recv(conn) || !mcs_io_cjcf(&conn->in, &cjcf))          if (!iso_recv(conn) || !mcs_io_cjcf(&conn->in, &cjcf))
83          {          {
84                  fprintf(stderr, "MCS error, expected CJcf\n");                  ERROR("MCS error, expected CJcf\n");
85                  return False;                  return False;
86          }          }
87    
88          if (cjcf.result != 0)          if (cjcf.result != 0)
89          {          {
90                  fprintf(stderr, "CJrq failed, result %d\n", cjcf.result);                  ERROR("CJrq failed, result %d\n", cjcf.result);
91                  return False;                  return False;
92          }          }
93    
# Line 176  BOOL mcs_recv(HCONN conn, BOOL request) Line 175  BOOL mcs_recv(HCONN conn, BOOL request)
175  {  {
176          MCS_DATA data;          MCS_DATA data;
177    
178          return (iso_recv(conn)) && mcs_io_data(&conn->in, &data, request);          if (!iso_recv(conn) || !mcs_io_data(&conn->in, &data, request))
179                    return False;
180    
181            conn->in.rdp_offset = conn->in.offset;
182            return True;
183  }  }
184    
185  /* Initialise a DOMAIN_PARAMS structure */  /* Initialise a DOMAIN_PARAMS structure */
# Line 207  char precanned_connect_userdata[] = { Line 210  char precanned_connect_userdata[] = {
210     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,
211     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,
212     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,
213     0x00,0x01,0xca,0x00,0x00,0x02,0xc0,0x08,0x00,0x00,0x00,0x00,0x00 };     0x00,0x01,0xca,0x00,0x00,0x02,0xc0,0x08,0x00,
214       /* encryption disabled */ 0x00,0x00,0x00,0x00 };
215    
216    char precanned_connect_userdata_e[] = {
217    0x00,
218    0x05,0x00,0x14,0x7c,0x00,0x01,0x80,0x9e,0x00,0x08,0x00,0x10,0x00,0x01,0xc0,0x00,
219    0x44,0x75,0x63,0x61,0x80,0x90,0x01,0xc0,0x88,0x00,0x01,0x00,0x08,0x00,0x80,0x02,
220    0xe0,0x01,0x01,0xca,0x03,0xaa,0x09,0x04,0x00,0x00,0xa3,0x01,0x00,0x00,0x57,0x00,
221    0x49,0x00,0x4e,0x00,0x39,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
222    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
223    0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
224    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
225    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
226    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
227    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xca,0x00,0x00,0x02,0xc0,
228    0x08,0x00,0x01,0x00,0x00,0x00
229    };
230    
231    char domain_data[] = {0x01};
232    
233  /* Initialise a MCS_CONNECT_INITIAL structure */  /* Initialise a MCS_CONNECT_INITIAL structure */
234  void mcs_make_connect_initial(MCS_CONNECT_INITIAL *mci)  void mcs_make_connect_initial(MCS_CONNECT_INITIAL *mci)
235  {  {
236          mci->calling_domain.length = 0;          mci->calling_domain.length = 1;
237          mci->calling_domain.data = NULL;          mci->calling_domain.data = domain_data;
238    
239          mci->called_domain.length = 0;          mci->called_domain.length = 1;
240          mci->called_domain.data = NULL;          mci->called_domain.data = domain_data;
241    
242          mci->upward_flag = 0xff;          mci->upward_flag = 0xff;
243    
# Line 243  BOOL ber_io_header(STREAM s, BOOL islong Line 264  BOOL ber_io_header(STREAM s, BOOL islong
264          BOOL res;          BOOL res;
265    
266          /* Read/write tag */          /* Read/write tag */
267          if (islong) {          if (islong)
268            {
269                  word_tag = tagval;                  word_tag = tagval;
270                  res = msb_io_uint16(s, &word_tag);                  res = msb_io_uint16(s, &word_tag);
271                  tag = word_tag;                  tag = word_tag;
272          } else {          }
273            else
274            {
275                  byte_tag = tagval;                  byte_tag = tagval;
276                  res = prs_io_uint8(s, &byte_tag);                  res = prs_io_uint8(s, &byte_tag);
277                  tag = byte_tag;                  tag = byte_tag;
278          }          }
279    
280          if (!res || (tag != tagval)) {          if (!res || (tag != tagval))
281                  fprintf(stderr, "Invalid ASN.1 tag\n");          {
282                    ERROR("Invalid ASN.1 tag\n");
283                  return False;                  return False;
284          }          }
285    
# Line 361  BOOL ber_io_uint8(STREAM s, uint8 *i, in Line 386  BOOL ber_io_uint8(STREAM s, uint8 *i, in
386    
387          if (length != 1)          if (length != 1)
388          {          {
389                  fprintf(stderr, "Wrong length for simple type\n");                  ERROR("Wrong length for simple type\n");
390                  return False;                  return False;
391          }          }
392    
# Line 428  BOOL mcs_io_edrq(STREAM s, MCS_EDRQ *edr Line 453  BOOL mcs_io_edrq(STREAM s, MCS_EDRQ *edr
453          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
454          if (pkt_opcode != opcode)          if (pkt_opcode != opcode)
455          {          {
456                  fprintf(stderr, "Expected EDrq, received %x\n", pkt_opcode);                  ERROR("Expected EDrq, received %x\n", pkt_opcode);
457                  return False;                  return False;
458          }          }
459    
# Line 448  BOOL mcs_io_aurq(STREAM s, MCS_AURQ *aur Line 473  BOOL mcs_io_aurq(STREAM s, MCS_AURQ *aur
473          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
474          if (pkt_opcode != opcode)          if (pkt_opcode != opcode)
475          {          {
476                  fprintf(stderr, "Expected AUrq, received %x\n", pkt_opcode);                  ERROR("Expected AUrq, received %x\n", pkt_opcode);
477                  return False;                  return False;
478          }          }
479    
# Line 465  BOOL mcs_io_aucf(STREAM s, MCS_AUCF *auc Line 490  BOOL mcs_io_aucf(STREAM s, MCS_AUCF *auc
490          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
491          if ((pkt_opcode & 0xfc) != opcode)          if ((pkt_opcode & 0xfc) != opcode)
492          {          {
493                  fprintf(stderr, "Expected AUcf, received %x\n", pkt_opcode);                  ERROR("Expected AUcf, received %x\n", pkt_opcode);
494                  return False;                  return False;
495          }          }
496    
# Line 486  BOOL mcs_io_cjrq(STREAM s, MCS_CJRQ *cjr Line 511  BOOL mcs_io_cjrq(STREAM s, MCS_CJRQ *cjr
511          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
512          if (pkt_opcode != opcode)          if (pkt_opcode != opcode)
513          {          {
514                  fprintf(stderr, "Expected CJrq, received %x\n", pkt_opcode);                  ERROR("Expected CJrq, received %x\n", pkt_opcode);
515                  return False;                  return False;
516          }          }
517    
# Line 506  BOOL mcs_io_cjcf(STREAM s, MCS_CJCF *cjc Line 531  BOOL mcs_io_cjcf(STREAM s, MCS_CJCF *cjc
531          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
532          if ((pkt_opcode & 0xfc) != opcode)          if ((pkt_opcode & 0xfc) != opcode)
533          {          {
534                  fprintf(stderr, "Expected CJcf, received %x\n", pkt_opcode);                  ERROR("Expected CJcf, received %x\n", pkt_opcode);
535                  return False;                  return False;
536          }          }
537    
# Line 524  BOOL mcs_io_data(STREAM s, MCS_DATA *dt, Line 549  BOOL mcs_io_data(STREAM s, MCS_DATA *dt,
549  {  {
550          uint8 opcode = (request ? 25 : 26) << 2;          uint8 opcode = (request ? 25 : 26) << 2;
551          uint8 pkt_opcode = opcode;          uint8 pkt_opcode = opcode;
552            uint8 byte1, byte2;
553          BOOL res;          BOOL res;
554    
555          res = prs_io_uint8(s, &pkt_opcode);          res = prs_io_uint8(s, &pkt_opcode);
556          if (pkt_opcode != opcode)          if (pkt_opcode != opcode)
557          {          {
558                  fprintf(stderr, "Expected MCS data, received %x\n", pkt_opcode);                  ERROR("Expected MCS data, received %x\n", pkt_opcode);
559                  return False;                  return False;
560          }          }
561    
         dt->length |= 0x8000;  
   
562          res = res ? msb_io_uint16(s, &dt->userid) : False;          res = res ? msb_io_uint16(s, &dt->userid) : False;
563          res = res ? msb_io_uint16(s, &dt->chanid) : False;          res = res ? msb_io_uint16(s, &dt->chanid) : False;
564          res = res ? prs_io_uint8 (s, &dt->flags ) : False;          res = res ? prs_io_uint8 (s, &dt->flags ) : False;
565          res = res ? msb_io_uint16(s, &dt->length) : False;  
566            if (s->marshall)
567            {
568                    dt->length |= 0x8000;
569                    res = res ? msb_io_uint16(s, &dt->length) : False;
570            }
571            else
572            {
573                    res = res ? prs_io_uint8(s, &byte1) : False;
574                    if (byte1 & 0x80)
575                    {
576                            res = res ? prs_io_uint8(s, &byte2) : False;
577                            dt->length = ((byte1 & ~0x80) << 8) + byte2;
578                    }
579                    else dt->length = byte1;
580            }
581    
582          return res;          return res;
583  }  }
584    

Legend:
Removed from v.3  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26