1 |
matty |
3 |
/* |
2 |
|
|
rdesktop: A Remote Desktop Protocol client. |
3 |
|
|
Protocol services - parsing layer |
4 |
|
|
Copyright (C) Matthew Chapman 1999-2000 |
5 |
|
|
|
6 |
|
|
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 |
8 |
|
|
the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
(at your option) any later version. |
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful, |
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
GNU General Public License for more details. |
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License |
17 |
|
|
along with this program; if not, write to the Free Software |
18 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
/* Parser state */ |
22 |
|
|
typedef struct stream |
23 |
|
|
{ |
24 |
|
|
/* Parsing layer */ |
25 |
|
|
unsigned char *data; |
26 |
|
|
unsigned int size; |
27 |
|
|
unsigned int offset; |
28 |
|
|
unsigned int end; |
29 |
|
|
BOOL marshall; |
30 |
|
|
BOOL error; |
31 |
|
|
|
32 |
|
|
/* Other layers */ |
33 |
|
|
int iso_offset; |
34 |
|
|
int mcs_offset; |
35 |
|
|
int rdp_offset; |
36 |
|
|
|
37 |
|
|
} *STREAM; |
38 |
|
|
|
39 |
|
|
/* Connection state */ |
40 |
|
|
typedef struct connection |
41 |
|
|
{ |
42 |
matty |
6 |
/* User interface */ |
43 |
|
|
HWINDOW wnd; |
44 |
|
|
|
45 |
matty |
3 |
/* Parsing layer */ |
46 |
|
|
struct stream in; |
47 |
|
|
struct stream out; |
48 |
|
|
|
49 |
|
|
/* TCP layer */ |
50 |
|
|
int tcp_socket; |
51 |
|
|
|
52 |
|
|
/* MCS layer */ |
53 |
|
|
uint16 mcs_userid; |
54 |
|
|
|
55 |
|
|
} *HCONN; |
56 |
|
|
|
57 |
|
|
#define STREAM_INIT(s,m) { s.data = xmalloc(2048); s.end = s.size = 2048; s.offset = 0; s.marshall = m; s.error = False; } |
58 |
|
|
#define STREAM_SIZE(s,l) { if (l > s.size) { s.data = xrealloc(s.data,l); s.end = s.size = l; } } |
59 |
|
|
#define REMAINING(s) ( s->end - s->offset ) |
60 |
|
|
#define PUSH_LAYER(s,v,l) { s.v = s.offset; s.offset += l; } |
61 |
|
|
#define POP_LAYER(s,v) { s.offset = s.v; } |
62 |
|
|
#define MARK_END(s) { s.end = s.offset; } |