1 |
/* |
/* |
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-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 |
21 |
#include "rdesktop.h" |
#include "rdesktop.h" |
22 |
|
|
23 |
/* Send a self-contained ISO PDU */ |
/* Send a self-contained ISO PDU */ |
24 |
static void iso_send_msg(uint8 code) |
static void |
25 |
|
iso_send_msg(uint8 code) |
26 |
{ |
{ |
27 |
STREAM s; |
STREAM s; |
28 |
|
|
43 |
} |
} |
44 |
|
|
45 |
/* Receive a message on the ISO layer, return code */ |
/* Receive a message on the ISO layer, return code */ |
46 |
static STREAM iso_recv_msg(uint8 *code) |
static STREAM |
47 |
|
iso_recv_msg(uint8 *code) |
48 |
{ |
{ |
49 |
STREAM s; |
STREAM s; |
50 |
uint16 length; |
uint16 length; |
57 |
in_uint8(s, version); |
in_uint8(s, version); |
58 |
if (version != 3) |
if (version != 3) |
59 |
{ |
{ |
60 |
ERROR("TPKT v%d\n", version); |
error("TPKT v%d\n", version); |
61 |
return False; |
return False; |
62 |
} |
} |
63 |
|
|
82 |
} |
} |
83 |
|
|
84 |
/* Initialise ISO transport data packet */ |
/* Initialise ISO transport data packet */ |
85 |
STREAM iso_init(int length) |
STREAM |
86 |
|
iso_init(int length) |
87 |
{ |
{ |
88 |
STREAM s; |
STREAM s; |
89 |
|
|
94 |
} |
} |
95 |
|
|
96 |
/* Send an ISO data PDU */ |
/* Send an ISO data PDU */ |
97 |
void iso_send(STREAM s) |
void |
98 |
|
iso_send(STREAM s) |
99 |
{ |
{ |
100 |
uint16 length; |
uint16 length; |
101 |
|
|
114 |
} |
} |
115 |
|
|
116 |
/* Receive ISO transport data packet */ |
/* Receive ISO transport data packet */ |
117 |
STREAM iso_recv() |
STREAM |
118 |
|
iso_recv() |
119 |
{ |
{ |
120 |
STREAM s; |
STREAM s; |
121 |
uint8 code; |
uint8 code; |
123 |
s = iso_recv_msg(&code); |
s = iso_recv_msg(&code); |
124 |
if ((s == NULL) || (code != ISO_PDU_DT)) |
if ((s == NULL) || (code != ISO_PDU_DT)) |
125 |
{ |
{ |
126 |
ERROR("expected DT, got %d\n", code); |
error("expected DT, got %d\n", code); |
127 |
return False; |
return False; |
128 |
} |
} |
129 |
|
|
131 |
} |
} |
132 |
|
|
133 |
/* Establish a connection up to the ISO layer */ |
/* Establish a connection up to the ISO layer */ |
134 |
BOOL iso_connect(char *server) |
BOOL |
135 |
|
iso_connect(char *server) |
136 |
{ |
{ |
137 |
uint8 code; |
uint8 code; |
138 |
|
|
143 |
|
|
144 |
if ((iso_recv_msg(&code) == NULL) || (code != ISO_PDU_CC)) |
if ((iso_recv_msg(&code) == NULL) || (code != ISO_PDU_CC)) |
145 |
{ |
{ |
146 |
ERROR("expected CC, got %d\n", code); |
error("expected CC, got %d\n", code); |
147 |
tcp_disconnect(); |
tcp_disconnect(); |
148 |
return False; |
return False; |
149 |
} |
} |
152 |
} |
} |
153 |
|
|
154 |
/* Disconnect from the ISO layer */ |
/* Disconnect from the ISO layer */ |
155 |
void iso_disconnect() |
void |
156 |
|
iso_disconnect() |
157 |
{ |
{ |
158 |
iso_send_msg(ISO_PDU_DR); |
iso_send_msg(ISO_PDU_DR); |
159 |
tcp_disconnect(); |
tcp_disconnect(); |