vnc-server.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __VNC_SERVER_H__
00036 #define __VNC_SERVER_H__
00037
00038
00039
00040
00041
00042
00043
00044
00045 struct vnc_server_update {
00046 struct vnc_server_update *next;
00047
00048 #define VNC_SERVER_UPDATE_NONE 0
00049 #define VNC_SERVER_UPDATE_PARTS 1
00050 #define VNC_SERVER_UPDATE_FULL 2
00051
00052 u8_t type;
00053
00054 u8_t x, y;
00055 u8_t w, h;
00056 };
00057
00058 struct vnc_server_state {
00059 u16_t counter;
00060 u8_t type;
00061 u8_t state;
00062 u16_t height, width;
00063
00064 u8_t update_requested;
00065
00066
00067 u8_t x, y, x1, y1, x2, y2;
00068 u8_t w, h;
00069
00070
00071
00072 u16_t readlen;
00073 u8_t sendmsg;
00074 u8_t button;
00075
00076
00077 struct vnc_server_update *updates_current;
00078 struct vnc_server_update *updates_pending;
00079 struct vnc_server_update *updates_free;
00080
00081 #define VNC_SERVER_MAX_UPDATES 8
00082 struct vnc_server_update updates_pool[VNC_SERVER_MAX_UPDATES];
00083
00084 };
00085
00086 struct vnc_server_update *
00087 vnc_server_update_alloc(struct vnc_server_state *vs);
00088 void vnc_server_update_free(struct vnc_server_state *vs,
00089 struct vnc_server_update *a);
00090 void vnc_server_update_remove(struct vnc_server_state *vs,
00091 struct vnc_server_update *a);
00092
00093 void vnc_server_update_add(struct vnc_server_state *vs,
00094 struct vnc_server_update *a);
00095 struct vnc_server_update *
00096 vnc_server_update_dequeue(struct vnc_server_state *vs);
00097
00098
00099
00100
00101 void vnc_server_init(void);
00102 void vnc_server_appcall(struct vnc_server_state *state);
00103
00104
00105 extern struct vnc_server_state *vs;
00106
00107 enum {
00108 VNC_DEALLOCATED,
00109 VNC_VERSION,
00110 VNC_VERSION2,
00111 VNC_AUTH,
00112 VNC_AUTH2,
00113 VNC_INIT,
00114 VNC_INIT2,
00115 VNC_RUNNING
00116 };
00117
00118
00119 enum {
00120 SEND_NONE,
00121 SEND_BLANK,
00122 SENT_BLANK,
00123 SEND_SCREEN,
00124 SEND_UPDATE
00125 };
00126
00127
00128
00129
00130
00131 #include "contiki-net.h"
00132
00133 void vnc_server_send_data(struct vnc_server_state *vs);
00134 u8_t vnc_server_draw_rect(u8_t *ptr, u16_t x, u16_t y, u16_t w, u16_t h, u8_t c);
00135
00136
00137
00138 struct rfb_rect {
00139 u16_t x;
00140 u16_t y;
00141 u16_t w;
00142 u16_t h;
00143 };
00144
00145
00146 struct rfb_pixel_format {
00147 u8_t bps;
00148 u8_t depth;
00149 u8_t endian;
00150
00151 u8_t truecolor;
00152
00153
00154 u16_t red_max, green_max, blue_max;
00155 u8_t red_shift, green_shift, blue_shift;
00156 u8_t pad1;
00157 u16_t pad2;
00158 };
00159
00160
00161
00162
00163 #define RFB_AUTH_FAILED 0
00164 #define RFB_AUTH_NONE 1
00165 #define RFB_AUTH_VNC 2
00166
00167 #define RFB_VNC_AUTH_OK 0
00168 #define RFB_VNC_AUTH_FAILED 1
00169 #define RFB_VNC_AUTH_TOOMANY 2
00170
00171
00172
00173
00174 #define RFB_FB_UPDATE 0
00175 #define RFB_SET_COLORMAP_ENTRIES 1
00176 #define RFB_BELL 2
00177 #define RFB_SERVER_CUT_TEXT 3
00178
00179
00180 #define RFB_SET_PIXEL_FORMAT 0
00181 #define RFB_FIX_COLORMAP_ENTRIES 1
00182 #define RFB_SET_ENCODINGS 2
00183 #define RFB_FB_UPDATE_REQ 3
00184 #define RFB_KEY_EVENT 4
00185 #define RFB_POINTER_EVENT 5
00186 #define RFB_CLIENT_CUT_TEXT 6
00187
00188
00189 #define RFB_ENC_RAW 0
00190 #define RFB_ENC_COPYRECT 1
00191 #define RFB_ENC_RRE 2
00192 #define RFB_ENC_CORRE 3
00193 #define RFB_ENC_HEXTILE 4
00194
00195
00196
00197
00198
00199 struct rfb_server_init {
00200 u16_t width;
00201 u16_t height;
00202 struct rfb_pixel_format format;
00203 u8_t namelength[4];
00204
00205 };
00206
00207 struct rfb_fb_update {
00208 u8_t type;
00209 u8_t pad;
00210 u16_t rects;
00211
00212 };
00213
00214 struct rfb_fb_update_rect_hdr {
00215 struct rfb_rect rect;
00216 u8_t encoding[4];
00217 };
00218
00219 struct rfb_copy_rect {
00220 u16_t srcx;
00221 u16_t srcy;
00222 };
00223
00224 struct rfb_rre_hdr {
00225 u16_t subrects[2];
00226
00227 u8_t bgpixel;
00228 };
00229
00230 struct rfb_rre_subrect {
00231 u8_t pixel;
00232 struct rfb_rect rect;
00233 };
00234
00235 struct rfb_corre_rect {
00236 u8_t x;
00237 u8_t y;
00238 u8_t w;
00239 u8_t h;
00240 };
00241
00242
00243
00244 struct rfb_set_pixel_format {
00245 u8_t type;
00246 u8_t pad;
00247 u16_t pad2;
00248 struct rfb_pixel_format format;
00249 };
00250
00251 struct rfb_fix_colormap_entries {
00252 u8_t type;
00253 u8_t pad;
00254 u16_t firstcolor;
00255 u16_t colors;
00256 };
00257
00258 struct rfb_set_encoding {
00259 u8_t type;
00260 u8_t pad;
00261 u16_t encodings;
00262 };
00263
00264 struct rfb_fb_update_request {
00265 u8_t type;
00266 u8_t incremental;
00267 u16_t x;
00268 u16_t y;
00269 u16_t w;
00270 u16_t h;
00271 };
00272
00273 struct rfb_key_event {
00274 u8_t type;
00275 u8_t down;
00276 u16_t pad;
00277 u8_t key[4];
00278 };
00279
00280 #define RFB_BUTTON_MASK1 1
00281 #define RFB_BUTTON_MASK2 2
00282 #define RFB_BUTTON_MASK3 4
00283 struct rfb_pointer_event {
00284 u8_t type;
00285 u8_t buttonmask;
00286 u16_t x;
00287 u16_t y;
00288 };
00289
00290 struct rfb_client_cut_text {
00291 u8_t type;
00292 u8_t pad[3];
00293 u8_t len[4];
00294 };
00295
00296 #endif