/[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 207 by matthewc, Thu Sep 26 14:26:46 2002 UTC revision 409 by forsberg, Fri Jun 6 10:46:00 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-2002     Copyright (C) Matthew Chapman 1999-2002
# 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 119  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 169  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    
# Line 249  mcs_send_cjrq(uint16 chanid) Line 256  mcs_send_cjrq(uint16 chanid)
256  {  {
257          STREAM s;          STREAM s;
258    
259            DEBUG_RDP5(("Sending CJRQ for channel #%d\n", chanid));
260    
261          s = iso_init(5);          s = iso_init(5);
262    
263          out_uint8(s, (MCS_CJRQ << 2));          out_uint8(s, (MCS_CJRQ << 2));
264          out_uint16_be(s, mcs_userid);          out_uint16_be(s, g_mcs_userid);
265          out_uint16_be(s, chanid);          out_uint16_be(s, chanid);
266    
267          s_mark_end(s);          s_mark_end(s);
# Line 303  mcs_init(int length) Line 312  mcs_init(int length)
312          return s;          return s;
313  }  }
314    
315  /* Send an MCS transport data packet */  /* Send an MCS transport data packet to a specific channel */
316  void  void
317  mcs_send(STREAM s)  mcs_send_to_channel(STREAM s, uint16 channel)
318  {  {
319          uint16 length;          uint16 length;
320    
# Line 314  mcs_send(STREAM s) Line 323  mcs_send(STREAM s)
323          length |= 0x8000;          length |= 0x8000;
324    
325          out_uint8(s, (MCS_SDRQ << 2));          out_uint8(s, (MCS_SDRQ << 2));
326          out_uint16_be(s, mcs_userid);          out_uint16_be(s, g_mcs_userid);
327          out_uint16_be(s, MCS_GLOBAL_CHANNEL);          out_uint16_be(s, channel);
328          out_uint8(s, 0x70);     /* flags */          out_uint8(s, 0x70);     /* flags */
329          out_uint16_be(s, length);          out_uint16_be(s, length);
330    
331          iso_send(s);          iso_send(s);
332  }  }
333    
334    /* Send an MCS transport data packet to the global channel */
335    void
336    mcs_send(STREAM s)
337    {
338            mcs_send_to_channel(s, MCS_GLOBAL_CHANNEL);
339    }
340    
341  /* Receive an MCS transport data packet */  /* Receive an MCS transport data packet */
342  STREAM  STREAM
343  mcs_recv(void)  mcs_recv(uint16 * channel)
344  {  {
345          uint8 opcode, appid, length;          uint8 opcode, appid, length;
346          STREAM s;          STREAM s;
# Line 344  mcs_recv(void) Line 360  mcs_recv(void)
360                  return NULL;                  return NULL;
361          }          }
362    
363          in_uint8s(s, 5);        /* userid, chanid, flags */          in_uint8s(s, 2);        /* userid */
364            in_uint16_be(s, *channel);
365            in_uint8s(s, 1);        /* flags */
366          in_uint8(s, length);          in_uint8(s, length);
367          if (length & 0x80)          if (length & 0x80)
368                  in_uint8s(s, 1);        /* second byte of length */                  in_uint8s(s, 1);        /* second byte of length */
# Line 354  mcs_recv(void) Line 372  mcs_recv(void)
372    
373  /* Establish a connection up to the MCS layer */  /* Establish a connection up to the MCS layer */
374  BOOL  BOOL
375  mcs_connect(char *server, STREAM mcs_data)  mcs_connect(char *server, STREAM mcs_data, char *username)
376  {  {
377          if (!iso_connect(server))          uint16 num_channels, i;
378            rdp5_channel *channel;
379            if (!iso_connect(server, username))
380                  return False;                  return False;
381    
382          mcs_send_connect_initial(mcs_data);          mcs_send_connect_initial(mcs_data);
# Line 366  mcs_connect(char *server, STREAM mcs_dat Line 386  mcs_connect(char *server, STREAM mcs_dat
386          mcs_send_edrq();          mcs_send_edrq();
387    
388          mcs_send_aurq();          mcs_send_aurq();
389          if (!mcs_recv_aucf(&mcs_userid))          if (!mcs_recv_aucf(&g_mcs_userid))
390                  goto error;                  goto error;
391    
392          mcs_send_cjrq(mcs_userid + 1001);          mcs_send_cjrq(g_mcs_userid + MCS_USERCHANNEL_BASE);
393    
394          if (!mcs_recv_cjcf())          if (!mcs_recv_cjcf())
395                  goto error;                  goto error;
396    
# Line 377  mcs_connect(char *server, STREAM mcs_dat Line 398  mcs_connect(char *server, STREAM mcs_dat
398          if (!mcs_recv_cjcf())          if (!mcs_recv_cjcf())
399                  goto error;                  goto error;
400    
401            if (use_rdp5)
402            {
403                    num_channels = get_num_channels();
404                    for (i = 0; i < num_channels; i++)
405                    {
406                            channel = find_channel_by_num(i);
407                            mcs_send_cjrq(channel->channelno);
408                            if (!mcs_recv_cjcf())
409                                    goto error;
410                    }
411            }
412    
413          return True;          return True;
414    
415        error:        error:

Legend:
Removed from v.207  
changed lines
  Added in v.409

  ViewVC Help
Powered by ViewVC 1.1.26