/[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 24 by matty, Sat Jan 6 03:12:10 2001 UTC revision 192 by matthewc, Tue Sep 24 07:59:14 2002 UTC
# Line 1  Line 1 
1  /*  /*
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-2000     Copyright (C) Matthew Chapman 1999-2001
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 23  Line 23 
23  uint16 mcs_userid;  uint16 mcs_userid;
24    
25  /* Parse an ASN.1 BER header */  /* Parse an ASN.1 BER header */
26  static BOOL ber_parse_header(STREAM s, int tagval, int *length)  static BOOL
27    ber_parse_header(STREAM s, int tagval, int *length)
28  {  {
29          int tag, len;          int tag, len;
30    
# Line 37  static BOOL ber_parse_header(STREAM s, i Line 38  static BOOL ber_parse_header(STREAM s, i
38    
39          if (tag != tagval)          if (tag != tagval)
40          {          {
41                  ERROR("expected tag %d, got %d\n", tagval, tag);                  error("expected tag %d, got %d\n", tagval, tag);
42                  return False;                  return False;
43          }          }
44    
# Line 57  static BOOL ber_parse_header(STREAM s, i Line 58  static BOOL ber_parse_header(STREAM s, i
58  }  }
59    
60  /* Output an ASN.1 BER header */  /* Output an ASN.1 BER header */
61  static void ber_out_header(STREAM s, int tagval, int length)  static void
62    ber_out_header(STREAM s, int tagval, int length)
63  {  {
64          if (tagval > 0xff)          if (tagval > 0xff)
65          {          {
# Line 78  static void ber_out_header(STREAM s, int Line 80  static void ber_out_header(STREAM s, int
80  }  }
81    
82  /* Output an ASN.1 BER integer */  /* Output an ASN.1 BER integer */
83  static void ber_out_integer(STREAM s, int value)  static void
84    ber_out_integer(STREAM s, int value)
85  {  {
86          ber_out_header(s, BER_TAG_INTEGER, 2);          ber_out_header(s, BER_TAG_INTEGER, 2);
87          out_uint16_be(s, value);          out_uint16_be(s, value);
88  }  }
89    
90  /* Output a DOMAIN_PARAMS structure (ASN.1 BER) */  /* Output a DOMAIN_PARAMS structure (ASN.1 BER) */
91  static void mcs_out_domain_params(STREAM s, int max_channels, int max_users,  static void
92                                    int max_tokens, int max_pdusize)  mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
93  {  {
94          ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);          ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32);
95          ber_out_integer(s, max_channels);          ber_out_integer(s, max_channels);
# Line 100  static void mcs_out_domain_params(STREAM Line 103  static void mcs_out_domain_params(STREAM
103  }  }
104    
105  /* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */  /* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */
106  static BOOL mcs_parse_domain_params(STREAM s)  static BOOL
107    mcs_parse_domain_params(STREAM s)
108  {  {
109          int length;          int length;
110    
# Line 111  static BOOL mcs_parse_domain_params(STRE Line 115  static BOOL mcs_parse_domain_params(STRE
115  }  }
116    
117  /* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */  /* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */
118  static void mcs_send_connect_initial(STREAM mcs_data)  static void
119    mcs_send_connect_initial(STREAM mcs_data)
120  {  {
121          int datalen = mcs_data->end - mcs_data->data;          int datalen = mcs_data->end - mcs_data->data;
122          int length = 7 + 3 * 34 + 4 + datalen;          int length = 7 + 3 * 34 + 4 + datalen;
# Line 138  static void mcs_send_connect_initial(STR Line 143  static void mcs_send_connect_initial(STR
143  }  }
144    
145  /* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */  /* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */
146  static BOOL mcs_recv_connect_response(STREAM mcs_data)  static BOOL
147    mcs_recv_connect_response(STREAM mcs_data)
148  {  {
149          uint8 result;          uint8 result;
150          int length;          int length;
# Line 154  static BOOL mcs_recv_connect_response(ST Line 160  static BOOL mcs_recv_connect_response(ST
160          in_uint8(s, result);          in_uint8(s, result);
161          if (result != 0)          if (result != 0)
162          {          {
163                  ERROR("MCS connect: %d\n", result);                  error("MCS connect: %d\n", result);
164                  return False;                  return False;
165          }          }
166    
# Line 165  static BOOL mcs_recv_connect_response(ST Line 171  static BOOL mcs_recv_connect_response(ST
171          ber_parse_header(s, BER_TAG_OCTET_STRING, &length);          ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
172          if (length > mcs_data->size)          if (length > mcs_data->size)
173          {          {
174                  WARN("MCS data length %d\n", length);                  error("MCS data length %d\n", length);
175                  length = mcs_data->size;                  length = mcs_data->size;
176          }          }
177    
# Line 177  static BOOL mcs_recv_connect_response(ST Line 183  static BOOL mcs_recv_connect_response(ST
183  }  }
184    
185  /* Send an EDrq message (ASN.1 PER) */  /* Send an EDrq message (ASN.1 PER) */
186  static void mcs_send_edrq()  static void
187    mcs_send_edrq(void)
188  {  {
189          STREAM s;          STREAM s;
190    
# Line 192  static void mcs_send_edrq() Line 199  static void mcs_send_edrq()
199  }  }
200    
201  /* Send an AUrq message (ASN.1 PER) */  /* Send an AUrq message (ASN.1 PER) */
202  static void mcs_send_aurq()  static void
203    mcs_send_aurq(void)
204  {  {
205          STREAM s;          STREAM s;
206    
# Line 205  static void mcs_send_aurq() Line 213  static void mcs_send_aurq()
213  }  }
214    
215  /* Expect a AUcf message (ASN.1 PER) */  /* Expect a AUcf message (ASN.1 PER) */
216  static BOOL mcs_recv_aucf(uint16 *mcs_userid)  static BOOL
217    mcs_recv_aucf(uint16 * mcs_userid)
218  {  {
219          uint8 opcode, result;          uint8 opcode, result;
220          STREAM s;          STREAM s;
# Line 217  static BOOL mcs_recv_aucf(uint16 *mcs_us Line 226  static BOOL mcs_recv_aucf(uint16 *mcs_us
226          in_uint8(s, opcode);          in_uint8(s, opcode);
227          if ((opcode >> 2) != MCS_AUCF)          if ((opcode >> 2) != MCS_AUCF)
228          {          {
229                  ERROR("expected AUcf, got %d\n", opcode);                  error("expected AUcf, got %d\n", opcode);
230                  return False;                  return False;
231          }          }
232    
233          in_uint8(s, result);          in_uint8(s, result);
234          if (result != 0)          if (result != 0)
235          {          {
236                  ERROR("AUrq: %d\n", result);                  error("AUrq: %d\n", result);
237                  return False;                  return False;
238          }          }
239    
# Line 235  static BOOL mcs_recv_aucf(uint16 *mcs_us Line 244  static BOOL mcs_recv_aucf(uint16 *mcs_us
244  }  }
245    
246  /* Send a CJrq message (ASN.1 PER) */  /* Send a CJrq message (ASN.1 PER) */
247  static void mcs_send_cjrq(uint16 chanid)  static void
248    mcs_send_cjrq(uint16 chanid)
249  {  {
250          STREAM s;          STREAM s;
251    
# Line 250  static void mcs_send_cjrq(uint16 chanid) Line 260  static void mcs_send_cjrq(uint16 chanid)
260  }  }
261    
262  /* Expect a CJcf message (ASN.1 PER) */  /* Expect a CJcf message (ASN.1 PER) */
263  static BOOL mcs_recv_cjcf()  static BOOL
264    mcs_recv_cjcf(void)
265  {  {
266          uint8 opcode, result;          uint8 opcode, result;
267          STREAM s;          STREAM s;
# Line 262  static BOOL mcs_recv_cjcf() Line 273  static BOOL mcs_recv_cjcf()
273          in_uint8(s, opcode);          in_uint8(s, opcode);
274          if ((opcode >> 2) != MCS_CJCF)          if ((opcode >> 2) != MCS_CJCF)
275          {          {
276                  ERROR("expected CJcf, got %d\n", opcode);                  error("expected CJcf, got %d\n", opcode);
277                  return False;                  return False;
278          }          }
279    
280          in_uint8(s, result);          in_uint8(s, result);
281          if (result != 0)          if (result != 0)
282          {          {
283                  ERROR("CJrq: %d\n", result);                  error("CJrq: %d\n", result);
284                  return False;                  return False;
285          }          }
286    
# Line 281  static BOOL mcs_recv_cjcf() Line 292  static BOOL mcs_recv_cjcf()
292  }  }
293    
294  /* Initialise an MCS transport data packet */  /* Initialise an MCS transport data packet */
295  STREAM mcs_init(int length)  STREAM
296    mcs_init(int length)
297  {  {
298          STREAM s;          STREAM s;
299    
# Line 292  STREAM mcs_init(int length) Line 304  STREAM mcs_init(int length)
304  }  }
305    
306  /* Send an MCS transport data packet */  /* Send an MCS transport data packet */
307  void mcs_send(STREAM s)  void
308    mcs_send(STREAM s)
309  {  {
310          uint16 length;          uint16 length;
311    
# Line 310  void mcs_send(STREAM s) Line 323  void mcs_send(STREAM s)
323  }  }
324    
325  /* Receive an MCS transport data packet */  /* Receive an MCS transport data packet */
326  STREAM mcs_recv()  STREAM
327    mcs_recv(void)
328  {  {
329          uint8 opcode, appid, length;          uint8 opcode, appid, length;
330          STREAM s;          STREAM s;
# Line 325  STREAM mcs_recv() Line 339  STREAM mcs_recv()
339          {          {
340                  if (appid != MCS_DPUM)                  if (appid != MCS_DPUM)
341                  {                  {
342                          ERROR("expected data, got %d\n", opcode);                          error("expected data, got %d\n", opcode);
343                  }                  }
344                  return NULL;                  return NULL;
345          }          }
# Line 339  STREAM mcs_recv() Line 353  STREAM mcs_recv()
353  }  }
354    
355  /* Establish a connection up to the MCS layer */  /* Establish a connection up to the MCS layer */
356  BOOL mcs_connect(char *server, STREAM mcs_data)  BOOL
357    mcs_connect(char *server, STREAM mcs_data)
358  {  {
359          if (!iso_connect(server))          if (!iso_connect(server))
360                  return False;                  return False;
# Line 370  BOOL mcs_connect(char *server, STREAM mc Line 385  BOOL mcs_connect(char *server, STREAM mc
385  }  }
386    
387  /* Disconnect from the MCS layer */  /* Disconnect from the MCS layer */
388  void mcs_disconnect()  void
389    mcs_disconnect(void)
390  {  {
391          iso_disconnect();          iso_disconnect();
392  }  }

Legend:
Removed from v.24  
changed lines
  Added in v.192

  ViewVC Help
Powered by ViewVC 1.1.26