2 * Copyright (c) 2005 Novell, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, contact Novell, Inc.
17 * To contact Novell about this file by physical or electronic mail,
18 * you may find current contact information at www.novell.com
20 * Author : Rohit Kumar
21 * Email ID : rokumar@novell.com
22 * Date : 25th August 2005
25 #ifndef RFBTIGHTPROTO_H
26 #define RFBTIGHTPROTO_H
31 /* PATH_MAX is not defined in limits.h on some platforms */
37 #define rfbSecTypeTight 16
39 void rfbTightUsage(void);
40 int rfbTightProcessArgs(int argc, char *argv[]);
42 /*-----------------------------------------------------------------------------
43 * Negotiation of Tunneling Capabilities (protocol version 3.7t)
45 * If the chosen security type is rfbSecTypeTight, the server sends a list of
46 * supported tunneling methods ("tunneling" refers to any additional layer of
47 * data transformation, such as encryption or external compression.)
49 * nTunnelTypes specifies the number of following rfbCapabilityInfo structures
50 * that list all supported tunneling methods in the order of preference.
52 * NOTE: If nTunnelTypes is 0, that tells the client that no tunneling can be
53 * used, and the client should not send a response requesting a tunneling
57 typedef struct _rfbTunnelingCapsMsg {
58 uint32_t nTunnelTypes;
59 /* followed by nTunnelTypes * rfbCapabilityInfo structures */
60 } rfbTunnelingCapsMsg;
62 #define sz_rfbTunnelingCapsMsg 4
64 /*-----------------------------------------------------------------------------
65 * Tunneling Method Request (protocol version 3.7t)
67 * If the list of tunneling capabilities sent by the server was not empty, the
68 * client should reply with a 32-bit code specifying a particular tunneling
69 * method. The following code should be used for no tunneling.
72 #define rfbNoTunneling 0
73 #define sig_rfbNoTunneling "NOTUNNEL"
76 /*-----------------------------------------------------------------------------
77 * Negotiation of Authentication Capabilities (protocol version 3.7t)
79 * After setting up tunneling, the server sends a list of supported
80 * authentication schemes.
82 * nAuthTypes specifies the number of following rfbCapabilityInfo structures
83 * that list all supported authentication schemes in the order of preference.
85 * NOTE: If nAuthTypes is 0, that tells the client that no authentication is
86 * necessary, and the client should not send a response requesting an
87 * authentication scheme.
90 typedef struct _rfbAuthenticationCapsMsg {
92 /* followed by nAuthTypes * rfbCapabilityInfo structures */
93 } rfbAuthenticationCapsMsg;
95 #define sz_rfbAuthenticationCapsMsg 4
97 /*-----------------------------------------------------------------------------
98 * Authentication Scheme Request (protocol version 3.7t)
100 * If the list of authentication capabilities sent by the server was not empty,
101 * the client should reply with a 32-bit code specifying a particular
102 * authentication scheme. The following codes are supported.
105 #define rfbAuthNone 1
107 #define rfbAuthUnixLogin 129
108 #define rfbAuthExternal 130
110 #define sig_rfbAuthNone "NOAUTH__"
111 #define sig_rfbAuthVNC "VNCAUTH_"
112 #define sig_rfbAuthUnixLogin "ULGNAUTH"
113 #define sig_rfbAuthExternal "XTRNAUTH"
115 /*-----------------------------------------------------------------------------
116 * Structure used to describe protocol options such as tunneling methods,
117 * authentication schemes and message types (protocol version 3.7t).
120 typedef struct _rfbCapabilityInfo {
122 uint32_t code; /* numeric identifier */
123 uint8_t vendorSignature[4]; /* vendor identification */
124 uint8_t nameSignature[8]; /* abbreviated option name */
128 #define sz_rfbCapabilityInfoVendor 4
129 #define sz_rfbCapabilityInfoName 8
130 #define sz_rfbCapabilityInfo 16
133 * Vendors known by TightVNC: standard VNC/RealVNC, TridiaVNC, and TightVNC.
136 #define rfbStandardVendor "STDV"
137 #define rfbTridiaVncVendor "TRDV"
138 #define rfbTightVncVendor "TGHT"
141 /* It's a good idea to keep these values a bit greater than required. */
142 #define MAX_TIGHT_ENCODINGS 10
143 #define MAX_TUNNELING_CAPS 16
144 #define MAX_AUTH_CAPS 16
146 typedef struct _rfbClientFileDownload {
147 char fName[PATH_MAX];
148 int downloadInProgress;
151 } rfbClientFileDownload ;
153 typedef struct _rfbClientFileUpload {
154 char fName[PATH_MAX];
155 int uploadInProgress;
159 } rfbClientFileUpload ;
161 typedef struct _rfbClientFileTransfer {
162 rfbClientFileDownload rcfd;
163 rfbClientFileUpload rcfu;
164 } rfbClientFileTransfer;
167 typedef struct _rfbTightClientRec {
169 /* Lists of capability codes sent to clients. We remember these
170 lists to restrict clients from choosing those tunneling and
171 authentication types that were not advertised. */
174 uint32_t authCaps[MAX_AUTH_CAPS];
176 /* This is not useful while we don't support tunneling:
178 uint32_t tunnelingCaps[MAX_TUNNELING_CAPS]; */
180 rfbClientFileTransfer rcft;
182 } rfbTightClientRec, *rfbTightClientPtr;
185 * Macro to fill in an rfbCapabilityInfo structure (protocol 3.7t).
186 * Normally, using macros is no good, but this macro saves us from
187 * writing constants twice -- it constructs signature names from codes.
188 * Note that "code_sym" argument should be a single symbol, not an expression.
191 #define SetCapInfo(cap_ptr, code_sym, vendor) \
193 rfbCapabilityInfo *pcap; \
195 pcap->code = Swap32IfLE(code_sym); \
196 memcpy(pcap->vendorSignature, (vendor), \
197 sz_rfbCapabilityInfoVendor); \
198 memcpy(pcap->nameSignature, sig_##code_sym, \
199 sz_rfbCapabilityInfoName); \
202 void rfbHandleSecTypeTight(rfbClientPtr cl);
205 /*-----------------------------------------------------------------------------
206 * Server Interaction Capabilities Message (protocol version 3.7t)
208 * In the protocol version 3.7t, the server informs the client what message
209 * types it supports in addition to ones defined in the protocol version 3.7.
210 * Also, the server sends the list of all supported encodings (note that it's
211 * not necessary to advertise the "raw" encoding sinse it MUST be supported in
212 * RFB 3.x protocols).
214 * This data immediately follows the server initialisation message.
217 typedef struct _rfbInteractionCapsMsg {
218 uint16_t nServerMessageTypes;
219 uint16_t nClientMessageTypes;
220 uint16_t nEncodingTypes;
221 uint16_t pad; /* reserved, must be 0 */
222 /* followed by nServerMessageTypes * rfbCapabilityInfo structures */
223 /* followed by nClientMessageTypes * rfbCapabilityInfo structures */
224 } rfbInteractionCapsMsg;
226 #define sz_rfbInteractionCapsMsg 8
228 #define rfbFileListData 130
229 #define rfbFileDownloadData 131
230 #define rfbFileUploadCancel 132
231 #define rfbFileDownloadFailed 133
233 /* signatures for non-standard messages */
234 #define sig_rfbFileListData "FTS_LSDT"
235 #define sig_rfbFileDownloadData "FTS_DNDT"
236 #define sig_rfbFileUploadCancel "FTS_UPCN"
237 #define sig_rfbFileDownloadFailed "FTS_DNFL"
241 #define rfbFileListRequest 130
242 #define rfbFileDownloadRequest 131
243 #define rfbFileUploadRequest 132
244 #define rfbFileUploadData 133
245 #define rfbFileDownloadCancel 134
246 #define rfbFileUploadFailed 135
247 #define rfbFileCreateDirRequest 136
249 /* signatures for non-standard messages */
250 #define sig_rfbFileListRequest "FTC_LSRQ"
251 #define sig_rfbFileDownloadRequest "FTC_DNRQ"
252 #define sig_rfbFileUploadRequest "FTC_UPRQ"
253 #define sig_rfbFileUploadData "FTC_UPDT"
254 #define sig_rfbFileDownloadCancel "FTC_DNCN"
255 #define sig_rfbFileUploadFailed "FTC_UPFL"
256 #define sig_rfbFileCreateDirRequest "FTC_FCDR"
259 /* signatures for basic encoding types */
260 #define sig_rfbEncodingRaw "RAW_____"
261 #define sig_rfbEncodingCopyRect "COPYRECT"
262 #define sig_rfbEncodingRRE "RRE_____"
263 #define sig_rfbEncodingCoRRE "CORRE___"
264 #define sig_rfbEncodingHextile "HEXTILE_"
265 #define sig_rfbEncodingZlib "ZLIB____"
266 #define sig_rfbEncodingTight "TIGHT___"
267 #define sig_rfbEncodingZlibHex "ZLIBHEX_"
270 /* signatures for "fake" encoding types */
271 #define sig_rfbEncodingCompressLevel0 "COMPRLVL"
272 #define sig_rfbEncodingXCursor "X11CURSR"
273 #define sig_rfbEncodingRichCursor "RCHCURSR"
274 #define sig_rfbEncodingPointerPos "POINTPOS"
275 #define sig_rfbEncodingLastRect "LASTRECT"
276 #define sig_rfbEncodingNewFBSize "NEWFBSIZ"
277 #define sig_rfbEncodingQualityLevel0 "JPEGQLVL"
280 /*-----------------------------------------------------------------------------
284 typedef struct _rfbFileListRequestMsg {
287 uint16_t dirNameSize;
288 /* Followed by char Dirname[dirNameSize] */
289 } rfbFileListRequestMsg;
291 #define sz_rfbFileListRequestMsg 4
293 /*-----------------------------------------------------------------------------
294 * FileDownloadRequest
297 typedef struct _rfbFileDownloadRequestMsg {
299 uint8_t compressedLevel;
302 /* Followed by char Filename[fNameSize] */
303 } rfbFileDownloadRequestMsg;
305 #define sz_rfbFileDownloadRequestMsg 8
307 /*-----------------------------------------------------------------------------
311 typedef struct _rfbFileUploadRequestMsg {
313 uint8_t compressedLevel;
316 /* Followed by char Filename[fNameSize] */
317 } rfbFileUploadRequestMsg;
319 #define sz_rfbFileUploadRequestMsg 8
322 /*-----------------------------------------------------------------------------
326 typedef struct _rfbFileUploadDataMsg {
328 uint8_t compressedLevel;
330 uint16_t compressedSize;
331 /* Followed by File[compressedSize],
332 but if (realSize = compressedSize = 0) followed by uint32_t modTime */
333 } rfbFileUploadDataMsg;
335 #define sz_rfbFileUploadDataMsg 6
337 /*-----------------------------------------------------------------------------
341 typedef struct _rfbFileDownloadCancelMsg {
345 /* Followed by reason[reasonLen] */
346 } rfbFileDownloadCancelMsg;
348 #define sz_rfbFileDownloadCancelMsg 4
350 /*-----------------------------------------------------------------------------
354 typedef struct _rfbFileUploadFailedMsg {
358 /* Followed by reason[reasonLen] */
359 } rfbFileUploadFailedMsg;
361 #define sz_rfbFileUploadFailedMsg 4
363 /*-----------------------------------------------------------------------------
364 * FileCreateDirRequest
367 typedef struct _rfbFileCreateDirRequestMsg {
371 /* Followed by dName[dNameLen] */
372 } rfbFileCreateDirRequestMsg;
374 #define sz_rfbFileCreateDirRequestMsg 4
377 /*-----------------------------------------------------------------------------
378 * Union of all client->server messages.
381 typedef union _rfbClientToServerTightMsg {
382 rfbFileListRequestMsg flr;
383 rfbFileDownloadRequestMsg fdr;
384 rfbFileUploadRequestMsg fupr;
385 rfbFileUploadDataMsg fud;
386 rfbFileDownloadCancelMsg fdc;
387 rfbFileUploadFailedMsg fuf;
388 rfbFileCreateDirRequestMsg fcdr;
389 } rfbClientToServerTightMsg;
393 /*-----------------------------------------------------------------------------
397 typedef struct _rfbFileListDataMsg {
402 uint16_t compressedSize;
403 /* Followed by SizeData[numFiles] */
404 /* Followed by Filenames[compressedSize] */
405 } rfbFileListDataMsg;
407 #define sz_rfbFileListDataMsg 8
409 /*-----------------------------------------------------------------------------
413 typedef struct _rfbFileDownloadDataMsg {
415 uint8_t compressLevel;
417 uint16_t compressedSize;
418 /* Followed by File[copressedSize],
419 but if (realSize = compressedSize = 0) followed by uint32_t modTime */
420 } rfbFileDownloadDataMsg;
422 #define sz_rfbFileDownloadDataMsg 6
425 /*-----------------------------------------------------------------------------
429 typedef struct _rfbFileUploadCancelMsg {
433 /* Followed by reason[reasonLen] */
434 } rfbFileUploadCancelMsg;
436 #define sz_rfbFileUploadCancelMsg 4
438 /*-----------------------------------------------------------------------------
442 typedef struct _rfbFileDownloadFailedMsg {
446 /* Followed by reason[reasonLen] */
447 } rfbFileDownloadFailedMsg;
449 #define sz_rfbFileDownloadFailedMsg 4