/[rdesktop]/jpeg/rdesktop/trunk/iso.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 /jpeg/rdesktop/trunk/iso.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 347 by forsberg, Thu Mar 27 13:11:58 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 - ISO layer     Protocol services - ISO layer
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 42  iso_send_msg(uint8 code) Line 42  iso_send_msg(uint8 code)
42          tcp_send(s);          tcp_send(s);
43  }  }
44    
45    static void
46    iso_send_connection_request(char *username)
47    {
48            STREAM s;
49            int length = 30 + strlen(username);
50    
51            s = tcp_init(length);
52    
53            out_uint8(s, 3);        /* version */
54            out_uint8(s, 0);        /* reserved */
55            out_uint16_be(s, length);       /* length */
56    
57            out_uint8(s, length - 5);       /* hdrlen */
58            out_uint8(s, ISO_PDU_CR);
59            out_uint16(s, 0);       /* dst_ref */
60            out_uint16(s, 0);       /* src_ref */
61            out_uint8(s, 0);        /* class */
62    
63            out_uint8p(s, "Cookie: mstshash=", strlen("Cookie: mstshash="));
64            out_uint8p(s, username, strlen(username));
65    
66            out_uint8(s, 0x0d);     /* Unknown */
67            out_uint8(s, 0x0a);     /* Unknown */
68    
69            s_mark_end(s);
70            tcp_send(s);
71    }
72    
73  /* Receive a message on the ISO layer, return code */  /* Receive a message on the ISO layer, return code */
74  static STREAM  static STREAM
75  iso_recv_msg(uint8 * code)  iso_recv_msg(uint8 * code)
# Line 49  iso_recv_msg(uint8 * code) Line 77  iso_recv_msg(uint8 * code)
77          STREAM s;          STREAM s;
78          uint16 length;          uint16 length;
79          uint8 version;          uint8 version;
80            BOOL shortform = False; // Shut the compiler up.
81    
82          next_packet:
83          s = tcp_recv(4);          s = tcp_recv(4);
84          if (s == NULL)          if (s == NULL)
85                  return NULL;                  return NULL;
86    
87          in_uint8(s, version);          in_uint8(s, version);
88          if (version != 3)          switch (version & 3)
89          {          {
90                  error("TPKT v%d\n", version);                  case 0:
91                  return NULL;                          in_uint8(s, length);
92                            if (length & 0x80)
93                            {
94                                    length &= ~0x80;
95                                    next_be(s, length);
96                                    shortform = False;
97                            }
98                            else
99                            {
100                                    shortform = True;
101                            }
102                            break;
103    
104                    case 3:
105                            in_uint8s(s, 1);        /* pad */
106                            in_uint16_be(s, length);
107                            break;
108    
109                    default:
110                            error("TPKT v%d\n", version);
111                            return NULL;
112          }          }
113    
         in_uint8s(s, 1);        /* pad */  
         in_uint16_be(s, length);  
   
114          s = tcp_recv(length - 4);          s = tcp_recv(length - 4);
115          if (s == NULL)          if (s == NULL)
116                  return NULL;                  return NULL;
117    
118            if ((version & 3) == 0)
119            {
120                    rdp5_process(s, version & 0x80, shortform);
121                    goto next_packet;
122            }
123    
124          in_uint8s(s, 1);        /* hdrlen */          in_uint8s(s, 1);        /* hdrlen */
125          in_uint8(s, *code);          in_uint8(s, *code);
126    
# Line 115  iso_send(STREAM s) Line 168  iso_send(STREAM s)
168    
169  /* Receive ISO transport data packet */  /* Receive ISO transport data packet */
170  STREAM  STREAM
171  iso_recv()  iso_recv(void)
172  {  {
173          STREAM s;          STREAM s;
174          uint8 code;          uint8 code;
# Line 135  iso_recv() Line 188  iso_recv()
188    
189  /* Establish a connection up to the ISO layer */  /* Establish a connection up to the ISO layer */
190  BOOL  BOOL
191  iso_connect(char *server)  iso_connect(char *server, char *username)
192  {  {
193          uint8 code;          uint8 code;
194    
195          if (!tcp_connect(server))          if (!tcp_connect(server))
196                  return False;                  return False;
197    
198          iso_send_msg(ISO_PDU_CR);          iso_send_connection_request(username);
199    
200          if (iso_recv_msg(&code) == NULL)          if (iso_recv_msg(&code) == NULL)
201                  return False;                  return False;
# Line 159  iso_connect(char *server) Line 212  iso_connect(char *server)
212    
213  /* Disconnect from the ISO layer */  /* Disconnect from the ISO layer */
214  void  void
215  iso_disconnect()  iso_disconnect(void)
216  {  {
217          iso_send_msg(ISO_PDU_DR);          iso_send_msg(ISO_PDU_DR);
218          tcp_disconnect();          tcp_disconnect();

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

  ViewVC Help
Powered by ViewVC 1.1.26