gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
42 #ifndef __BASE_VNC_VNC_SERVER_HH__
43 #define __BASE_VNC_VNC_SERVER_HH__
44 
45 #include <iostream>
46 
47 #include "base/vnc/vncinput.hh"
48 #include "base/circlebuf.hh"
49 #include "base/pollevent.hh"
50 #include "base/socket.hh"
51 #include "params/VncServer.hh"
52 #include "sim/sim_object.hh"
53 
58 class VncServer : public VncInput
59 {
60  public:
61 
67  const static uint32_t AuthInvalid = 0;
68  const static uint32_t AuthNone = 1;
69 
71  const static uint32_t VncOK = 0;
72 
79  };
80 
87  };
88 
90  enum MouseEvents {
94  };
95 
96  const char* vncVersion() const
97  {
98  return "RFB 003.008\n";
99  }
100 
107  };
108 
109  struct ServerInitMsg {
110  uint16_t fbWidth;
111  uint16_t fbHeight;
113  uint32_t namelen;
114  char name[2]; // just to put M5 in here
115  } M5_ATTR_PACKED;
116 
118  uint8_t type;
119  uint8_t padding;
120  uint16_t num_rects;
121  } M5_ATTR_PACKED;
122 
124  uint16_t x;
125  uint16_t y;
126  uint16_t width;
127  uint16_t height;
128  int32_t encoding;
129  } M5_ATTR_PACKED;
130 
131  struct ServerCutText {
132  uint8_t type;
133  uint8_t padding[3];
134  uint32_t length;
135  } M5_ATTR_PACKED;
136 
139  protected:
141  class ListenEvent: public PollEvent
142  {
143  protected:
145 
146  public:
147  ListenEvent(VncServer *vs, int fd, int e);
148  void process(int revent);
149  };
150 
151  friend class ListenEvent;
153 
155  class DataEvent: public PollEvent
156  {
157  protected:
159 
160  public:
161  DataEvent(VncServer *vs, int fd, int e);
162  void process(int revent);
163  };
164 
165  friend class DataEvent;
167 
168  int number;
169  int dataFd; // data stream file describer
170 
172 
173  void listen(int port);
174  void accept();
175  void data();
176  void detach();
177 
178  public:
179  typedef VncServerParams Params;
180  VncServer(const Params *p);
181  ~VncServer();
182 
183  // RFB
184  protected:
185 
188 
192 
195 
198 
201 
202  protected:
210  void sendError(const char* error_msg);
211 
217  bool read(uint8_t *buf, size_t len);
218 
227  bool read1(uint8_t *buf, size_t len);
228 
229 
234  template <typename T> bool read(T* val);
235 
236 
242  bool write(const uint8_t *buf, size_t len);
243 
248  template <typename T> bool write(T* val);
249 
253  bool write(const char* str);
254 
258  void checkProtocolVersion();
259 
262  void checkSecurity();
263 
265  void sendServerInit();
266 
270  void sendError(std::string error_msg);
271 
275  void sendFrameBufferUpdate();
276 
278  void setPixelFormat();
279 
281  void setEncodings();
282 
284  void requestFbUpdate();
285 
287  void recvKeyboardInput();
288 
290  void recvPointerInput();
291 
296  void recvCutText();
297 
301  void sendFrameBufferResized();
302 
304 
305  public:
306  void setDirty() override;
307  void frameBufferResized() override;
308 };
309 
310 #endif
int number
Definition: vncserver.hh:168
VncServerParams Params
Definition: vncserver.hh:179
static const uint32_t AuthInvalid
Authentication modes.
Definition: vncserver.hh:67
DataEvent to read data from vnc.
Definition: vncserver.hh:155
PixelFormat pixelFormat
The one and only pixel format we support.
Definition: vncserver.hh:194
void requestFbUpdate()
Receive message from client asking for updated frame buffer.
Definition: vncserver.cc:549
ListenSocket listener
Definition: vncserver.hh:171
int dataFd
Definition: vncserver.hh:169
void data()
Definition: vncserver.cc:220
void sendFrameBufferResized()
Tell the client that the frame buffer resized.
Definition: vncserver.cc:680
void listen(int port)
Definition: vncserver.cc:160
VncServer(const Params *p)
VncServer.
Definition: vncserver.cc:118
ConnectionState curState
The rfb prototol state the connection is in.
Definition: vncserver.hh:187
friend class DataEvent
Definition: vncserver.hh:165
VncServer * vncserver
Definition: vncserver.hh:144
EncodingTypes
Encoding types.
Definition: vncserver.hh:82
void setEncodings()
Receive encodings message from client and process it.
Definition: vncserver.cc:513
Bitfield< 63 > val
Definition: misc.hh:769
Bitfield< 9, 5 > vs
void sendError(const char *error_msg)
vnc client Interface
Definition: vncserver.cc:368
void checkSecurity()
Check that the security exchange was successful.
Definition: vncserver.cc:429
ServerMessages
Server -> Client message IDs.
Definition: vncserver.hh:74
void setPixelFormat()
Receive pixel foramt message from client and process it.
Definition: vncserver.cc:481
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:302
void accept()
Definition: vncserver.cc:183
DataEvent * dataEvent
Definition: vncserver.hh:166
void recvPointerInput()
Recv message from client providing new mouse movement or button click.
Definition: vncserver.cc:585
void frameBufferResized() override
Definition: vncserver.cc:722
static const PixelConverter pixelConverter
Definition: vncserver.hh:303
ListenEvent * listenEvent
Definition: vncserver.hh:152
Bitfield< 18, 16 > len
bool supportsRawEnc
If the vnc client supports receiving raw data.
Definition: vncserver.hh:197
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:713
void sendServerInit()
Send client our idea about what the frame buffer looks like.
Definition: vncserver.cc:451
struct VncServer::ServerInitMsg M5_ATTR_PACKED
friend class ListenEvent
Definition: vncserver.hh:151
bool read(uint8_t *buf, size_t len)
Read some data from the client.
Definition: vncserver.cc:281
void recvKeyboardInput()
Receive message from client providing new keyboard input.
Definition: vncserver.cc:569
void sendFrameBufferUpdate()
Send a updated frame buffer to the client.
Definition: vncserver.cc:627
static const uint32_t AuthNone
Definition: vncserver.hh:68
Bitfield< 9 > e
ListenEvent to accept a vnc client connection.
Definition: vncserver.hh:141
void checkProtocolVersion()
Check the client&#39;s protocol verion for compatibility and send the security types we support...
Definition: vncserver.cc:377
Declaration of a VNC input.
MouseEvents
keyboard/mouse support
Definition: vncserver.hh:90
bool sendUpdate
An update needs to be sent to the client.
Definition: vncserver.hh:191
void recvCutText()
Receive message from client that there is text in it&#39;s paste buffer.
Definition: vncserver.cc:603
Configurable RGB pixel converter.
Definition: pixel.hh:87
Bitfield< 14, 12 > fd
Definition: types.hh:158
Bitfield< 0 > p
const char * vncVersion() const
Definition: vncserver.hh:96
bool write(const uint8_t *buf, size_t len)
Write a buffer to the client.
Definition: vncserver.cc:317
VncServer * vncserver
Definition: vncserver.hh:158
void detach()
Definition: vncserver.cc:348
static const uint32_t VncOK
Error conditions.
Definition: vncserver.hh:71
bool supportsResizeEnc
If the vnc client supports the desktop resize command.
Definition: vncserver.hh:200

Generated on Thu May 28 2020 16:21:30 for gem5 by doxygen 1.8.13