summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vnc/vnc.h
blob: a52ef4b652a8cf0b5de7897710eaecbc516752cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <draw.h>
#include <memdraw.h>

typedef struct Pixfmt	Pixfmt;
typedef struct Colorfmt	Colorfmt;
typedef struct Vnc	Vnc;

struct Colorfmt {
	int		max;
	int		shift;
};

struct Pixfmt {
	int		bpp;
	int		depth;
	int		bigendian;
	int		truecolor;
	Colorfmt	red;
	Colorfmt	green;
	Colorfmt	blue;
};

struct Vnc {
	QLock;
	int		datafd;			/* for network connection */
	int		ctlfd;			/* control for network connection */

	Biobuf		in;
	Biobuf		out;

	Rectangle	dim;
	Pixfmt;

	/* client only */
	char		*name;
	char		*srvaddr;
	int		vers;

	int		canresize;
	struct {
		ulong		id;
		Rectangle	rect;
		ulong		flags;
	}		screen[1];
};

enum {
	VerLen		= 12,
	/* authentication negotiation */
	AFailed		= 0,
	ANoAuth,
	AVncAuth,

	/* vnc auth negotiation */
	VncAuthOK	= 0,
	VncAuthFailed,
	VncAuthTooMany,
	VncChalLen	= 16,

	/* server to client */
	MFrameUpdate	= 0,
	MSetCmap,
	MBell,
	MSCut,
	MSAck,

	/* client to server */
	MPixFmt		= 0,
	MFixCmap,
	MSetEnc,
	MFrameReq,
	MKey,
	MMouse,
	MCCut,
	MSetDesktopSize = 251,

	/* image encoding methods */
	EncRaw		= 0,
	EncCopyRect	= 1,
	EncRre		= 2,
	EncCorre	= 4,
	EncHextile	= 5,
	EncZlib		= 6,  /* 6,7,8 have been used by others */
	EncTight	= 7,
	EncZHextile	= 8,
	EncMouseWarp	= 9,

	EncDesktopSize	= -223,
	EncXDesktopSize	= -308,

	/* paramaters for hextile encoding */
	HextileDim	= 16,
	HextileRaw	= 1,
	HextileBack	= 2,
	HextileFore	= 4,
	HextileRects	= 8,
	HextileCols	= 16
};

/*
 * we're only using the ulong as a place to store bytes,
 * and as something to compare against.
 * the bytes are stored in little-endian format.
 */
typedef ulong Color;

/* auth.c */
extern	int		vncauth(Vnc*, char*);
extern	int		vnchandshake(Vnc*);
extern	int		vncsrvauth(Vnc*);
extern	int		vncsrvhandshake(Vnc*);

/* proto.c */
extern	Vnc*		vncinit(int, int, Vnc*);
extern	uchar		vncrdchar(Vnc*);
extern	ushort		vncrdshort(Vnc*);
extern	ulong		vncrdlong(Vnc*);
extern	Point		vncrdpoint(Vnc*);
extern	Rectangle	vncrdrect(Vnc*);
extern	Rectangle	vncrdcorect(Vnc*);
extern	Pixfmt		vncrdpixfmt(Vnc*);
extern	void		vncrdbytes(Vnc*, void*, int);
extern	char*		vncrdstring(Vnc*);
extern	char*	vncrdstringx(Vnc*);
extern	void		vncwrstring(Vnc*, char*);
extern  void    	vncgobble(Vnc*, long);

extern	void		vncflush(Vnc*);
extern	void		vncterm(Vnc*);
extern	void		vncwrbytes(Vnc*, void*, int);
extern	void		vncwrlong(Vnc*, ulong);
extern	void		vncwrshort(Vnc*, ushort);
extern	void		vncwrchar(Vnc*, uchar);
extern	void		vncwrpixfmt(Vnc*, Pixfmt*);
extern	void		vncwrrect(Vnc*, Rectangle);
extern	void		vncwrpoint(Vnc*, Point);

extern	void		vnclock(Vnc*);		/* for writing */
extern	void		vncunlock(Vnc*);

extern	void		hexdump(void*, int);

/* implemented by clients of the io library */
extern	void		vnchungup(Vnc*);

extern	int		verbose;