Contiki 2.6
|
00001 /* 00002 * Copyright (c) 2001, Adam Dunkels. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote 00014 * products derived from this software without specific prior 00015 * written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00018 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00019 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00021 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00023 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00025 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00026 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 * 00029 * This file is part of the uIP TCP/IP stack. 00030 * 00031 * $Id: vnc-server.h,v 1.1 2006/06/17 22:41:16 adamdunkels Exp $ 00032 * 00033 */ 00034 00035 #ifndef __VNC_SERVER_H__ 00036 #define __VNC_SERVER_H__ 00037 00038 00039 /*struct vnc_server_updatearea { 00040 uint8_t active; 00041 uint8_t x, y; 00042 uint8_t w, h; 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 uint8_t type; 00053 00054 uint8_t x, y; 00055 uint8_t w, h; 00056 }; 00057 00058 struct vnc_server_state { 00059 uint16_t counter; 00060 uint8_t type; 00061 uint8_t state; 00062 uint16_t height, width; 00063 00064 uint8_t update_requested; 00065 00066 /* Variables used when sending screen updates. */ 00067 uint8_t x, y, x1, y1, x2, y2; 00068 uint8_t w, h; 00069 00070 00071 00072 uint16_t readlen; 00073 uint8_t sendmsg; 00074 uint8_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 /* Sendmsg */ 00119 enum { 00120 SEND_NONE, 00121 SEND_BLANK, 00122 SENT_BLANK, 00123 SEND_SCREEN, 00124 SEND_UPDATE 00125 }; 00126 00127 00128 /* Definitions of the RFB (Remote Frame Buffer) protocol 00129 structures and constants. */ 00130 00131 #include "contiki-net.h" 00132 00133 void vnc_server_send_data(struct vnc_server_state *vs); 00134 uint8_t vnc_server_draw_rect(uint8_t *ptr, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t c); 00135 00136 00137 /* Generic rectangle - x, y coordinates, width and height. */ 00138 struct rfb_rect { 00139 uint16_t x; 00140 uint16_t y; 00141 uint16_t w; 00142 uint16_t h; 00143 }; 00144 00145 /* Pixel format definition. */ 00146 struct rfb_pixel_format { 00147 uint8_t bps; /* Bits per pixel: 8, 16 or 32. */ 00148 uint8_t depth; /* Color depth: 8-32 */ 00149 uint8_t endian; /* 1 - big endian (motorola), 0 - little endian 00150 (x86) */ 00151 uint8_t truecolor; /* 1 - true color is used, 0 - true color is not used. */ 00152 00153 /* The following fields are only used if true color is used. */ 00154 uint16_t red_max, green_max, blue_max; 00155 uint8_t red_shift, green_shift, blue_shift; 00156 uint8_t pad1; 00157 uint16_t pad2; 00158 }; 00159 00160 00161 /* RFB authentication constants. */ 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 /* RFB message types. */ 00172 00173 /* From server to client: */ 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 /* From client to server. */ 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 /* Encoding types. */ 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 /* Message definitions. */ 00196 00197 /* Server to client messages. */ 00198 00199 struct rfb_server_init { 00200 uint16_t width; 00201 uint16_t height; 00202 struct rfb_pixel_format format; 00203 uint8_t namelength[4]; 00204 /* Followed by name. */ 00205 }; 00206 00207 struct rfb_fb_update { 00208 uint8_t type; 00209 uint8_t pad; 00210 uint16_t rects; /* Number of rectanges (struct rfb_fb_update_rect_hdr + 00211 data) that follows. */ 00212 }; 00213 00214 struct rfb_fb_update_rect_hdr { 00215 struct rfb_rect rect; 00216 uint8_t encoding[4]; 00217 }; 00218 00219 struct rfb_copy_rect { 00220 uint16_t srcx; 00221 uint16_t srcy; 00222 }; 00223 00224 struct rfb_rre_hdr { 00225 uint16_t subrects[2]; /* Number of subrectangles (struct 00226 rfb_rre_subrect) to follow. */ 00227 uint8_t bgpixel; 00228 }; 00229 00230 struct rfb_rre_subrect { 00231 uint8_t pixel; 00232 struct rfb_rect rect; 00233 }; 00234 00235 struct rfb_corre_rect { 00236 uint8_t x; 00237 uint8_t y; 00238 uint8_t w; 00239 uint8_t h; 00240 }; 00241 00242 /* Client to server messages. */ 00243 00244 struct rfb_set_pixel_format { 00245 uint8_t type; 00246 uint8_t pad; 00247 uint16_t pad2; 00248 struct rfb_pixel_format format; 00249 }; 00250 00251 struct rfb_fix_colormap_entries { 00252 uint8_t type; 00253 uint8_t pad; 00254 uint16_t firstcolor; 00255 uint16_t colors; 00256 }; 00257 00258 struct rfb_set_encoding { 00259 uint8_t type; 00260 uint8_t pad; 00261 uint16_t encodings; 00262 }; 00263 00264 struct rfb_fb_update_request { 00265 uint8_t type; 00266 uint8_t incremental; 00267 uint16_t x; 00268 uint16_t y; 00269 uint16_t w; 00270 uint16_t h; 00271 }; 00272 00273 struct rfb_key_event { 00274 uint8_t type; 00275 uint8_t down; 00276 uint16_t pad; 00277 uint8_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 uint8_t type; 00285 uint8_t buttonmask; 00286 uint16_t x; 00287 uint16_t y; 00288 }; 00289 00290 struct rfb_client_cut_text { 00291 uint8_t type; 00292 uint8_t pad[3]; 00293 uint8_t len[4]; 00294 }; 00295 00296 #endif /* __VNC_SERVER_H__ */