typedef struct Rdp Rdp; typedef struct Vchan Vchan; #define GSHORT(p) ((p)[0]|((p)[1]<<8)) #define GSHORTB(p) ((p)[0]<<8|((p)[1])) #define GLONG(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) #define GLONGB(p) (((p)[0]<<24)|((p)[1]<<16)|((p)[2]<<8)|(p)[3]) #define PSHORT(p,v) (p)[0]=(v);(p)[1]=(v)>>8 #define PSHORTB(p,v) (p)[0]=(v)>>8;(p)[1]=(v) #define PLONG(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24 #define PLONGB(p,v) (p)[0]=(v)>>24;(p)[1]=(v)>>16;(p)[2]=(v)>>8;(p)[3]=(v) #define MIN(x,y) (((x) < (y)) ? (x) : (y)) enum { MAXTPDU= 16386, /* max TPDU size */ GLOBALCHAN= 1003, /* MCS global channel's id */ NumOrders= 32, }; struct Rdp { int fd; /* connection I/O descriptor */ int opt; /* client options */ int autologon; /* enable auto logon */ char *label; /* window label */ char *local; /* local system name */ char *user; /* user name */ char *windom; /* domain for auto logon */ char *passwd; /* password for auto logon (sic) */ char *shell; /* remote shell override */ char *rwd; /* remote working directory */ ulong chan; /* remote graphics channel descriptor */ int depth; /* color depth as exposed by the protocol */ int hupreason; /* hangup reason as server explains */ int mcsuid; /* MCS [T.122] userId */ int userchan; /* MCS user channelId */ int shareid; /* share ID - [T128] section 8.4.2 */ int licensed; /* licensing sub-protocol completion */ int active; /* T.128 action state */ Point dim; /* rfb size */ }; enum /* Rdp.opt */ { OVersion5 = 1<<0, /* RDP5 if set, RDP4 if not */ OEncrypt = 1<<1, /* enable encryption */ OConsole = 1<<2, /* attach to the console sesstion */ OSnarf = 1<<3, /* proxy clipboard */ }; struct Vchan { int mcsid; /* MCS channelId */ int flags; char name[8]; uchar* buf; /* defragmentation buffer */ int nb; /* sizeof buf */ int pos; /* next fragment offset */ void (*fn)(uchar*,uchar*); }; Vchan* lookupvc(int); Vchan* namevc(char*); int sendvc(char*,uchar*,int); void scanvcpdu(uchar*,uchar*,int); enum /* 2.2.7 Capability Sets; T.128 */ { CAPSTYPE_GENERAL= 1, CAPSTYPE_BITMAP= 2, CAPSTYPE_ORDER= 3, CAPSTYPE_BITMAPCACHE= 4, CAPSTYPE_BITMAPCACHE2= 19, CAPSTYPE_POINTER= 8, CAPSTYPE_INPUT= 13, CAPSTYPE_SOUND= 12, CAPSTYPE_GLYPHCACHE= 16, GENCAPSIZE= 24, BITCAPSIZE= 30, ORDCAPSIZE= 88, BCACAPSIZE= 40, PTRCAPSIZE= 8, INPCAPSIZE= 88, SNDCAPSIZE= 8, GLYCAPSIZE= 52, }; enum /* 2.2.7.1.1 General Capability Set (TS_GENERAL_CAPABILITYSET) */ { FASTPATH_OUTPUT_SUPPORTED = 0x0001, NO_BITMAP_COMPRESSION_HDR = 0x0400, LONG_CREDENTIALS_SUPPORTED = 0x0004, AUTORECONNECT_SUPPORTED = 0x0008, ENC_SALTED_CHECKSUM = 0x0010, }; enum /* 2.2.8.1.1.2.1 Basic (TS_SECURITY_HEADER) */ { SEC_EXCHANGE_PKT = 0x0001, SEC_ENCRYPT = 0x0008, SEC_RESET_SEQNO = 0x0010, SEC_IGNORE_SEQNO = 0x0020, SEC_INFO_PKT = 0x0040, SEC_LICENSE_PKT = 0x0080, SEC_SECURE_CHECKSUM = 0x0800, }; enum /* 2.2.8.1.1.3.1.1 Slow-Path Input Event (TS_INPUT_EVENT) */ { INPUT_EVENT_SYNC= 0, INPUT_EVENT_SCANCODE= 4, INPUT_EVENT_UNICODE= 5, INPUT_EVENT_MOUSE= 0x8001, }; enum /* orderFlags */ { NEGOTIATEORDERSUPPORT= 0x02, ZEROBOUNDSDELTASSUPPORT= 0x08, COLORINDEXSUPPORT= 0x20, SOLIDPATTERNBRUSHONLY= 0x40, ORDERFLAGS_EXTRA_FLAGS= 0x80, }; enum { TPKTFIXLEN= 4, TPDATAFIXLEN= (TPKTFIXLEN+3), MCSCIFIXLEN= (18+3*2+24*4), }; extern Rdp rd; extern uchar orderSupport[NumOrders]; extern uchar cmap[256]; /* 8bpp translation table */ extern Vchan vctab[]; /* static virtual channels table */ extern uint nvc; /* number of vctab entries */ extern char Eshort[]; extern char Ebignum[]; extern char Esmall[];