gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vncserver.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Ali Saidi
38  * William Wang
39  */
40 
45 #ifndef __BASE_VNC_VNC_SERVER_HH__
46 #define __BASE_VNC_VNC_SERVER_HH__
47 
48 #include <iostream>
49 
50 #include "base/vnc/vncinput.hh"
51 #include "base/bitmap.hh"
52 #include "base/circlebuf.hh"
53 #include "base/pollevent.hh"
54 #include "base/socket.hh"
55 #include "params/VncServer.hh"
56 #include "sim/sim_object.hh"
57 
62 class VncServer : public VncInput
63 {
64  public:
65 
71  const static uint32_t AuthInvalid = 0;
72  const static uint32_t AuthNone = 1;
73 
75  const static uint32_t VncOK = 0;
76 
83  };
84 
91  };
92 
94  enum MouseEvents {
98  };
99 
100  const char* vncVersion() const
101  {
102  return "RFB 003.008\n";
103  }
104 
111  };
112 
113  struct ServerInitMsg {
114  uint16_t fbWidth;
115  uint16_t fbHeight;
117  uint32_t namelen;
118  char name[2]; // just to put M5 in here
119  } M5_ATTR_PACKED;
120 
122  uint8_t type;
123  uint8_t padding;
124  uint16_t num_rects;
125  } M5_ATTR_PACKED;
126 
128  uint16_t x;
129  uint16_t y;
130  uint16_t width;
131  uint16_t height;
132  int32_t encoding;
133  } M5_ATTR_PACKED;
134 
135  struct ServerCutText {
136  uint8_t type;
137  uint8_t padding[3];
138  uint32_t length;
139  } M5_ATTR_PACKED;
140 
143  protected:
145  class ListenEvent: public PollEvent
146  {
147  protected:
149 
150  public:
151  ListenEvent(VncServer *vs, int fd, int e);
152  void process(int revent);
153  };
154 
155  friend class ListenEvent;
157 
159  class DataEvent: public PollEvent
160  {
161  protected:
163 
164  public:
165  DataEvent(VncServer *vs, int fd, int e);
166  void process(int revent);
167  };
168 
169  friend class DataEvent;
171 
172  int number;
173  int dataFd; // data stream file describer
174 
176 
177  void listen(int port);
178  void accept();
179  void data();
180  void detach();
181 
182  public:
183  typedef VncServerParams Params;
184  VncServer(const Params *p);
185  ~VncServer();
186 
187  // RFB
188  protected:
189 
192 
196 
199 
202 
205 
206  protected:
214  void sendError(const char* error_msg);
215 
221  bool read(uint8_t *buf, size_t len);
222 
231  bool read1(uint8_t *buf, size_t len);
232 
233 
238  template <typename T> bool read(T* val);
239 
240 
246  bool write(const uint8_t *buf, size_t len);
247 
252  template <typename T> bool write(T* val);
253 
257  bool write(const char* str);
258 
262  void checkProtocolVersion();
263 
266  void checkSecurity();
267 
269  void sendServerInit();
270 
274  void sendError(std::string error_msg);
275 
279  void sendFrameBufferUpdate();
280 
282  void setPixelFormat();
283 
285  void setEncodings();
286 
288  void requestFbUpdate();
289 
291  void recvKeyboardInput();
292 
294  void recvPointerInput();
295 
300  void recvCutText();
301 
305  void sendFrameBufferResized();
306 
308 
309  public:
310  void setDirty() override;
311  void frameBufferResized() override;
312 };
313 
314 #endif
int number
Definition: vncserver.hh:172
VncServerParams Params
Definition: vncserver.hh:183
static const uint32_t AuthInvalid
Authentication modes.
Definition: vncserver.hh:71
DataEvent to read data from vnc.
Definition: vncserver.hh:159
PixelFormat pixelFormat
The one and only pixel format we support.
Definition: vncserver.hh:198
void process(int revent)
Definition: vncserver.cc:111
void requestFbUpdate()
Receive message from client asking for updated frame buffer.
Definition: vncserver.cc:556
ListenSocket listener
Definition: vncserver.hh:175
int dataFd
Definition: vncserver.hh:173
void data()
Definition: vncserver.cc:227
void sendFrameBufferResized()
Tell the client that the frame buffer resized.
Definition: vncserver.cc:687
void listen(int port)
Definition: vncserver.cc:164
VncServer(const Params *p)
VncServer.
Definition: vncserver.cc:122
ConnectionState curState
The rfb prototol state the connection is in.
Definition: vncserver.hh:191
VncServer * vncserver
Definition: vncserver.hh:148
EncodingTypes
Encoding types.
Definition: vncserver.hh:86
void setEncodings()
Receive encodings message from client and process it.
Definition: vncserver.cc:520
Bitfield< 63 > val
Definition: misc.hh:770
Bitfield< 9, 5 > vs
void sendError(const char *error_msg)
vnc client Interface
Definition: vncserver.cc:375
void checkSecurity()
Check that the security exchange was successful.
Definition: vncserver.cc:436
ListenEvent(VncServer *vs, int fd, int e)
Poll event for the listen socket.
Definition: vncserver.cc:91
ServerMessages
Server -> Client message IDs.
Definition: vncserver.hh:78
void setPixelFormat()
Receive pixel foramt message from client and process it.
Definition: vncserver.cc:488
bool read1(uint8_t *buf, size_t len)
Read len -1 bytes from the client into the buffer provided + 1 assert that we read enough bytes...
Definition: vncserver.cc:309
VncInputParams Params
Definition: vncinput.hh:157
void accept()
Definition: vncserver.cc:190
DataEvent * dataEvent
Definition: vncserver.hh:170
void recvPointerInput()
Recv message from client providing new mouse movement or button click.
Definition: vncserver.cc:592
void frameBufferResized() override
Definition: vncserver.cc:729
static const PixelConverter pixelConverter
Definition: vncserver.hh:307
ListenEvent * listenEvent
Definition: vncserver.hh:156
bool supportsRawEnc
If the vnc client supports receiving raw data.
Definition: vncserver.hh:201
void setDirty() override
The frame buffer uses this call to notify the vnc server that the frame buffer has been updated and a...
Definition: vncserver.cc:720
void sendServerInit()
Send client our idea about what the frame buffer looks like.
Definition: vncserver.cc:458
struct VncServer::ServerInitMsg M5_ATTR_PACKED
const char * vncVersion() const
Definition: vncserver.hh:100
bool read(uint8_t *buf, size_t len)
Read some data from the client.
Definition: vncserver.cc:288
void recvKeyboardInput()
Receive message from client providing new keyboard input.
Definition: vncserver.cc:576
void sendFrameBufferUpdate()
Send a updated frame buffer to the client.
Definition: vncserver.cc:634
static const uint32_t AuthNone
Definition: vncserver.hh:72
Bitfield< 9 > e
Definition: miscregs.hh:1376
ListenEvent to accept a vnc client connection.
Definition: vncserver.hh:145
void checkProtocolVersion()
Check the client's protocol verion for compatibility and send the security types we support...
Definition: vncserver.cc:384
Declaration of a VNC input.
MouseEvents
keyboard/mouse support
Definition: vncserver.hh:94
void process(int revent)
Definition: vncserver.cc:97
bool sendUpdate
An update needs to be sent to the client.
Definition: vncserver.hh:195
Bitfield< 18, 16 > len
Definition: miscregs.hh:1626
DataEvent(VncServer *vs, int fd, int e)
Poll event for the data socket.
Definition: vncserver.cc:105
void recvCutText()
Receive message from client that there is text in it's paste buffer.
Definition: vncserver.cc:610
Configurable RGB pixel converter.
Definition: framebuffer.hh:91
Bitfield< 14, 12 > fd
Definition: types.hh:155
Bitfield< 0 > p
bool write(const uint8_t *buf, size_t len)
Write a buffer to the client.
Definition: vncserver.cc:324
VncServer * vncserver
Definition: vncserver.hh:162
void detach()
Definition: vncserver.cc:355
static const uint32_t VncOK
Error conditions.
Definition: vncserver.hh:75
bool supportsResizeEnc
If the vnc client supports the desktop resize command.
Definition: vncserver.hh:204

Generated on Fri Jun 9 2017 13:03:41 for gem5 by doxygen 1.8.6