/[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

revision 64 by astrand, Thu Jul 18 16:38:31 2002 UTC revision 381 by jsorg71, Fri May 30 21:59:56 2003 UTC
# Line 1  Line 1 
1  /*  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Protocol services - Multipoint Communications Service     Protocol services - Multipoint Communications Service
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2002
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 20  Line 20 
20    
21  #include "rdesktop.h"  #include "rdesktop.h"
22    
23  uint16 mcs_userid;  uint16 g_mcs_userid;
24    extern BOOL use_rdp5;
25    
26  /* Parse an ASN.1 BER header */  /* Parse an ASN.1 BER header */
27  static BOOL  static BOOL
# Line 89  ber_out_integer(STREAM s, int value) Line 90  ber_out_integer(STREAM s, int value)
90    
91  /* Output a DOMAIN_PARAMS structure (ASN.1 BER) */  /* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
92  static void  static void
93  mcs_out_domain_params(STREAM s, int max_channels, int max_users,  mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
                       int max_tokens, int max_pdusize)  
94  {  {
95          ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);          ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
96          ber_out_integer(s, max_channels);          ber_out_integer(s, max_channels);
# Line 120  static void Line 120  static void
120  mcs_send_connect_initial(STREAM mcs_data)  mcs_send_connect_initial(STREAM mcs_data)
121  {  {
122          int datalen = mcs_data->end - mcs_data->data;          int datalen = mcs_data->end - mcs_data->data;
123          int length = 7 + 3 * 34 + 4 + datalen;          int length = 9 + 3 * 34 + 4 + datalen;
124          STREAM s;          STREAM s;
125    
126          s = iso_init(length + 5);          s = iso_init(length + 5);
127    
128          ber_out_header(s, MCS_CONNECT_INITIAL, length);          ber_out_header(s, MCS_CONNECT_INITIAL, length);
129          ber_out_header(s, BER_TAG_OCTET_STRING, 0);     /* calling domain */          ber_out_header(s, BER_TAG_OCTET_STRING, 1);     /* calling domain */
130          ber_out_header(s, BER_TAG_OCTET_STRING, 0);     /* called domain */          out_uint8(s, 1);
131            ber_out_header(s, BER_TAG_OCTET_STRING, 1);     /* called domain */
132            out_uint8(s, 1);
133    
134          ber_out_header(s, BER_TAG_BOOLEAN, 1);          ber_out_header(s, BER_TAG_BOOLEAN, 1);
135          out_uint8(s, 0xff);     /* upward flag */          out_uint8(s, 0xff);     /* upward flag */
136    
137          mcs_out_domain_params(s, 2, 2, 0, 0xffff);      /* target params */          mcs_out_domain_params(s, 34, 2, 0, 0xffff);     /* target params */
138          mcs_out_domain_params(s, 1, 1, 1, 0x420);       /* min params */          mcs_out_domain_params(s, 1, 1, 1, 0x420);       /* min params */
139          mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff);       /* max params */          mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff);       /* max params */
140    
# Line 170  mcs_recv_connect_response(STREAM mcs_dat Line 172  mcs_recv_connect_response(STREAM mcs_dat
172          mcs_parse_domain_params(s);          mcs_parse_domain_params(s);
173    
174          ber_parse_header(s, BER_TAG_OCTET_STRING, &length);          ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
         if (length > mcs_data->size)  
         {  
                 error("MCS data length %d\n", length);  
                 length = mcs_data->size;  
         }  
   
         in_uint8a(s, mcs_data->data, length);  
         mcs_data->p = mcs_data->data;  
         mcs_data->end = mcs_data->data + length;  
175    
176            sec_process_mcs_data(s);
177            /*
178               if (length > mcs_data->size)
179               {
180               error("MCS data length %d, expected %d\n", length,
181               mcs_data->size);
182               length = mcs_data->size;
183               }
184    
185               in_uint8a(s, mcs_data->data, length);
186               mcs_data->p = mcs_data->data;
187               mcs_data->end = mcs_data->data + length;
188             */
189          return s_check_end(s);          return s_check_end(s);
190  }  }
191    
192  /* Send an EDrq message (ASN.1 PER) */  /* Send an EDrq message (ASN.1 PER) */
193  static void  static void
194  mcs_send_edrq()  mcs_send_edrq(void)
195  {  {
196          STREAM s;          STREAM s;
197    
# Line 201  mcs_send_edrq() Line 207  mcs_send_edrq()
207    
208  /* Send an AUrq message (ASN.1 PER) */  /* Send an AUrq message (ASN.1 PER) */
209  static void  static void
210  mcs_send_aurq()  mcs_send_aurq(void)
211  {  {
212          STREAM s;          STREAM s;
213    
# Line 253  mcs_send_cjrq(uint16 chanid) Line 259  mcs_send_cjrq(uint16 chanid)
259          s = iso_init(5);          s = iso_init(5);
260    
261          out_uint8(s, (MCS_CJRQ << 2));          out_uint8(s, (MCS_CJRQ << 2));
262          out_uint16_be(s, mcs_userid);          out_uint16_be(s, g_mcs_userid);
263          out_uint16_be(s, chanid);          out_uint16_be(s, chanid);
264    
265          s_mark_end(s);          s_mark_end(s);
# Line 262  mcs_send_cjrq(uint16 chanid) Line 268  mcs_send_cjrq(uint16 chanid)
268    
269  /* Expect a CJcf message (ASN.1 PER) */  /* Expect a CJcf message (ASN.1 PER) */
270  static BOOL  static BOOL
271  mcs_recv_cjcf()  mcs_recv_cjcf(void)
272  {  {
273          uint8 opcode, result;          uint8 opcode, result;
274          STREAM s;          STREAM s;
# Line 315  mcs_send(STREAM s) Line 321  mcs_send(STREAM s)
321          length |= 0x8000;          length |= 0x8000;
322    
323          out_uint8(s, (MCS_SDRQ << 2));          out_uint8(s, (MCS_SDRQ << 2));
324          out_uint16_be(s, mcs_userid);          out_uint16_be(s, g_mcs_userid);
325          out_uint16_be(s, MCS_GLOBAL_CHANNEL);          out_uint16_be(s, MCS_GLOBAL_CHANNEL);
326          out_uint8(s, 0x70);     /* flags */          out_uint8(s, 0x70);     /* flags */
327          out_uint16_be(s, length);          out_uint16_be(s, length);
# Line 325  mcs_send(STREAM s) Line 331  mcs_send(STREAM s)
331    
332  /* Receive an MCS transport data packet */  /* Receive an MCS transport data packet */
333  STREAM  STREAM
334  mcs_recv()  mcs_recv(uint16 * channel)
335  {  {
336          uint8 opcode, appid, length;          uint8 opcode, appid, length;
337          STREAM s;          STREAM s;
# Line 345  mcs_recv() Line 351  mcs_recv()
351                  return NULL;                  return NULL;
352          }          }
353    
354          in_uint8s(s, 5);        /* userid, chanid, flags */          in_uint8s(s, 2);        /* userid */
355            in_uint16_be(s, *channel);
356            in_uint8s(s, 1);        /* flags */
357          in_uint8(s, length);          in_uint8(s, length);
358          if (length & 0x80)          if (length & 0x80)
359                  in_uint8s(s, 1);        /* second byte of length */                  in_uint8s(s, 1);        /* second byte of length */
# Line 355  mcs_recv() Line 363  mcs_recv()
363    
364  /* Establish a connection up to the MCS layer */  /* Establish a connection up to the MCS layer */
365  BOOL  BOOL
366  mcs_connect(char *server, STREAM mcs_data)  mcs_connect(char *server, STREAM mcs_data, char *username)
367  {  {
368          if (!iso_connect(server))          if (!iso_connect(server, username))
369                  return False;                  return False;
370    
371          mcs_send_connect_initial(mcs_data);          mcs_send_connect_initial(mcs_data);
# Line 367  mcs_connect(char *server, STREAM mcs_dat Line 375  mcs_connect(char *server, STREAM mcs_dat
375          mcs_send_edrq();          mcs_send_edrq();
376    
377          mcs_send_aurq();          mcs_send_aurq();
378          if (!mcs_recv_aucf(&mcs_userid))          if (!mcs_recv_aucf(&g_mcs_userid))
379                  goto error;                  goto error;
380    
381          mcs_send_cjrq(mcs_userid + 1001);          mcs_send_cjrq(g_mcs_userid + 1001);
382          if (!mcs_recv_cjcf())          if (!mcs_recv_cjcf())
383                  goto error;                  goto error;
384    
# Line 378  mcs_connect(char *server, STREAM mcs_dat Line 386  mcs_connect(char *server, STREAM mcs_dat
386          if (!mcs_recv_cjcf())          if (!mcs_recv_cjcf())
387                  goto error;                  goto error;
388    
389            if (use_rdp5)
390            {
391                    /* Note: If we send this cjrq after telling the server we support RDP4 only,
392                       the server won't respond with a cjcf and we will hang. */
393                    mcs_send_cjrq(MCS_GLOBAL_CHANNEL + 1);  /* hack - clipboard */
394                    if (!mcs_recv_cjcf())
395                            goto error;
396            }
397    
398          return True;          return True;
399    
400        error:        error:
# Line 387  mcs_connect(char *server, STREAM mcs_dat Line 404  mcs_connect(char *server, STREAM mcs_dat
404    
405  /* Disconnect from the MCS layer */  /* Disconnect from the MCS layer */
406  void  void
407  mcs_disconnect()  mcs_disconnect(void)
408  {  {
409          iso_disconnect();          iso_disconnect();
410  }  }

Legend:
Removed from v.64  
changed lines
  Added in v.381

  ViewVC Help
Powered by ViewVC 1.1.26