gem5  v22.0.0.1
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/circlebuf.hh"
48 #include "base/compiler.hh"
49 #include "base/pollevent.hh"
50 #include "base/socket.hh"
51 #include "base/vnc/vncinput.hh"
52 #include "params/VncServer.hh"
53 #include "sim/sim_object.hh"
54 
59 namespace gem5
60 {
61 
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 
79  {
84  };
85 
88  {
93  };
94 
97  {
101  };
102 
103  const char* vncVersion() const
104  {
105  return "RFB 003.008\n";
106  }
107 
109  {
115  };
116 
118  {
119  uint16_t fbWidth;
120  uint16_t fbHeight;
122  uint32_t namelen;
123  char name[2]; // just to put M5 in here
124  };
125 
127  {
128  uint8_t type;
129  uint8_t padding;
130  uint16_t num_rects;
131  };
132 
134  {
135  uint16_t x;
136  uint16_t y;
137  uint16_t width;
138  uint16_t height;
139  int32_t encoding;
140  };
141 
143  {
144  uint8_t type;
145  uint8_t padding[3];
146  uint32_t length;
147  };
148 
151  protected:
153  class ListenEvent: public PollEvent
154  {
155  protected:
157 
158  public:
159  ListenEvent(VncServer *vs, int fd, int e);
160  void process(int revent);
161  };
162 
163  friend class ListenEvent;
165 
167  class DataEvent: public PollEvent
168  {
169  protected:
171 
172  public:
173  DataEvent(VncServer *vs, int fd, int e);
174  void process(int revent);
175  };
176 
177  friend class DataEvent;
179 
180  int number;
181  int dataFd; // data stream file describer
182 
184 
185  void listen(int port);
186  void accept();
187  void data();
188  void detach();
189 
190  public:
191  typedef VncServerParams Params;
192  VncServer(const Params &p);
193  ~VncServer();
194 
195  // RFB
196  protected:
197 
200 
204 
207 
210 
213 
214  protected:
222  void sendError(const char* error_msg);
223 
229  bool read(uint8_t *buf, size_t len);
230 
239  bool read1(uint8_t *buf, size_t len);
240 
241 
246  template <typename T> bool read(T* val);
247 
248 
254  bool write(const uint8_t *buf, size_t len);
255 
260  template <typename T> bool write(T* val);
261 
265  bool write(const char* str);
266 
270  void checkProtocolVersion();
271 
274  void checkSecurity();
275 
277  void sendServerInit();
278 
282  void sendError(std::string error_msg);
283 
287  void sendFrameBufferUpdate();
288 
290  void setPixelFormat();
291 
293  void setEncodings();
294 
296  void requestFbUpdate();
297 
299  void recvKeyboardInput();
300 
302  void recvPointerInput();
303 
308  void recvCutText();
309 
313  void sendFrameBufferResized();
314 
316 
317  public:
318  void setDirty() override;
319  void frameBufferResized() override;
320 };
321 
322 } // namespace gem5
323 
324 #endif
gem5::VncServer::ListenEvent::ListenEvent
ListenEvent(VncServer *vs, int fd, int e)
Poll event for the listen socket.
Definition: vncserver.cc:87
gem5::VncServer::ServerInitMsg
Definition: vncserver.hh:117
gem5::VncServer::dataEvent
DataEvent * dataEvent
Definition: vncserver.hh:178
gem5::VncServer::curState
ConnectionState curState
The rfb prototol state the connection is in.
Definition: vncserver.hh:199
gem5::VncServer::ServerInitMsg::fbWidth
uint16_t fbWidth
Definition: vncserver.hh:119
socket.hh
gem5::VncServer::EncodingHextile
@ EncodingHextile
Definition: vncserver.hh:91
gem5::VncServer::AuthNone
const static uint32_t AuthNone
Definition: vncserver.hh:72
gem5::GEM5_PACKED
PM4 packets.
Definition: pm4_defines.hh:77
gem5::VncServer::FrameBufferRect::y
uint16_t y
Definition: vncserver.hh:136
gem5::VncServer::WaitForSecurityResponse
@ WaitForSecurityResponse
Definition: vncserver.hh:111
gem5::VncServer::sendFrameBufferUpdate
void sendFrameBufferUpdate()
Send a updated frame buffer to the client.
Definition: vncserver.cc:629
gem5::VncServer::accept
void accept()
Definition: vncserver.cc:183
gem5::VncServer::WaitForProtocolVersion
@ WaitForProtocolVersion
Definition: vncserver.hh:110
gem5::VncServer::EncodingCopyRect
@ EncodingCopyRect
Definition: vncserver.hh:90
gem5::ArmISA::fd
Bitfield< 14, 12 > fd
Definition: types.hh:150
gem5::VncServer::setPixelFormat
void setPixelFormat()
Receive pixel foramt message from client and process it.
Definition: vncserver.cc:483
gem5::VncServer::ServerInitMsg::fbHeight
uint16_t fbHeight
Definition: vncserver.hh:120
gem5::VncServer::ServerCutText::length
uint32_t length
Definition: vncserver.hh:146
circlebuf.hh
gem5::VncServer::ServerInitMsg::namelen
uint32_t namelen
Definition: vncserver.hh:122
gem5::VncServer::ServerCutText::type
uint8_t type
Definition: vncserver.hh:144
gem5::VncServer::sendFrameBufferResized
void sendFrameBufferResized()
Tell the client that the frame buffer resized.
Definition: vncserver.cc:682
gem5::VncServer::FrameBufferRect::width
uint16_t width
Definition: vncserver.hh:137
vncinput.hh
gem5::ListenSocket
Definition: socket.hh:38
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:65
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
gem5::VncServer::setEncodings
void setEncodings()
Receive encodings message from client and process it.
Definition: vncserver.cc:515
gem5::VncServer::NormalPhase
@ NormalPhase
Definition: vncserver.hh:114
gem5::VncServer::FrameBufferUpdate
Definition: vncserver.hh:126
gem5::PollEvent
Definition: pollevent.hh:43
gem5::VncServer
Definition: vncserver.hh:62
gem5::VncServer::listenEvent
ListenEvent * listenEvent
Definition: vncserver.hh:164
gem5::VncServer::vncVersion
const char * vncVersion() const
Definition: vncserver.hh:103
gem5::VncServer::number
int number
Definition: vncserver.hh:180
gem5::VncServer::FrameBufferUpdate::padding
uint8_t padding
Definition: vncserver.hh:129
gem5::VncServer::recvCutText
void recvCutText()
Receive message from client that there is text in it's paste buffer.
Definition: vncserver.cc:605
gem5::VncServer::data
void data()
Definition: vncserver.cc:220
gem5::VncServer::FrameBufferRect::encoding
int32_t encoding
Definition: vncserver.hh:139
gem5::VncServer::ListenEvent::vncserver
VncServer * vncserver
Definition: vncserver.hh:156
gem5::VncServer::FrameBufferRect::height
uint16_t height
Definition: vncserver.hh:138
gem5::VncServer::supportsRawEnc
bool supportsRawEnc
If the vnc client supports receiving raw data.
Definition: vncserver.hh:209
gem5::VncServer::VncOK
const static uint32_t VncOK
Error conditions.
Definition: vncserver.hh:75
gem5::VncServer::recvKeyboardInput
void recvKeyboardInput()
Receive message from client providing new keyboard input.
Definition: vncserver.cc:571
gem5::VncServer::ServerFrameBufferUpdate
@ ServerFrameBufferUpdate
Definition: vncserver.hh:80
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
sim_object.hh
gem5::VncServer::ServerBell
@ ServerBell
Definition: vncserver.hh:82
gem5::VncServer::recvPointerInput
void recvPointerInput()
Recv message from client providing new mouse movement or button click.
Definition: vncserver.cc:587
gem5::VncServer::FrameBufferUpdate::type
uint8_t type
Definition: vncserver.hh:128
gem5::VncServer::DataEvent::DataEvent
DataEvent(VncServer *vs, int fd, int e)
Poll event for the data socket.
Definition: vncserver.cc:101
pollevent.hh
gem5::VncServer::FrameBufferUpdate::num_rects
uint16_t num_rects
Definition: vncserver.hh:130
gem5::VncServer::ListenEvent::process
void process(int revent)
Definition: vncserver.cc:93
len
uint16_t len
Definition: helpers.cc:62
gem5::VncServer::sendUpdate
bool sendUpdate
An update needs to be sent to the client.
Definition: vncserver.hh:203
gem5::VncServer::EncodingDesktopSize
@ EncodingDesktopSize
Definition: vncserver.hh:92
gem5::VncServer::listener
ListenSocket listener
Definition: vncserver.hh:183
gem5::VncServer::FrameBufferRect::x
uint16_t x
Definition: vncserver.hh:135
compiler.hh
gem5::VncServer::InitializationPhase
@ InitializationPhase
Definition: vncserver.hh:113
gem5::VncServer::listen
void listen(int port)
Definition: vncserver.cc:160
gem5::VncServer::MouseRightButton
@ MouseRightButton
Definition: vncserver.hh:99
gem5::VncServer::dataFd
int dataFd
Definition: vncserver.hh:181
gem5::PixelConverter
Configurable RGB pixel converter.
Definition: pixel.hh:91
gem5::VncServer::EncodingRaw
@ EncodingRaw
Definition: vncserver.hh:89
gem5::VncServer::AuthInvalid
const static uint32_t AuthInvalid
Authentication modes.
Definition: vncserver.hh:71
gem5::VncServer::checkProtocolVersion
void checkProtocolVersion()
Check the client's protocol verion for compatibility and send the security types we support.
Definition: vncserver.cc:377
gem5::VncServer::DataEvent
DataEvent to read data from vnc.
Definition: vncserver.hh:167
gem5::VncServer::requestFbUpdate
void requestFbUpdate()
Receive message from client asking for updated frame buffer.
Definition: vncserver.cc:551
gem5::VncServer::setDirty
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:715
gem5::VncServer::ServerSetColorMapEntries
@ ServerSetColorMapEntries
Definition: vncserver.hh:81
gem5::VncServer::write
bool write(const uint8_t *buf, size_t len)
Write a buffer to the client.
Definition: vncserver.cc:317
gem5::VncServer::FrameBufferRect
Definition: vncserver.hh:133
gem5::VncServer::DataEvent::vncserver
VncServer * vncserver
Definition: vncserver.hh:170
gem5::VncServer::ServerCutText
Definition: vncserver.hh:142
gem5::VncServer::read
bool read(uint8_t *buf, size_t len)
Read some data from the client.
Definition: vncserver.cc:281
gem5::VncInput::Params
VncInputParams Params
Definition: vncinput.hh:166
gem5::VncServer::ServerInitMsg::px
PixelFormat px
Definition: vncserver.hh:121
gem5::VncInput::PixelFormat
Definition: vncinput.hh:104
gem5::VncServer::MouseEvents
MouseEvents
keyboard/mouse support
Definition: vncserver.hh:96
gem5::VncServer::WaitForClientInit
@ WaitForClientInit
Definition: vncserver.hh:112
gem5::VncServer::sendServerInit
void sendServerInit()
Send client our idea about what the frame buffer looks like.
Definition: vncserver.cc:453
gem5::VncServer::detach
void detach()
Definition: vncserver.cc:348
gem5::VncInput
Definition: vncinput.hh:89
gem5::VncServer::read1
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
gem5::VncServer::MouseMiddleButton
@ MouseMiddleButton
Definition: vncserver.hh:100
gem5::VncServer::sendError
void sendError(const char *error_msg)
vnc client Interface
Definition: vncserver.cc:368
gem5::ArmISA::vs
Bitfield< 19 > vs
Definition: misc_types.hh:570
gem5::VncServer::ListenEvent
ListenEvent to accept a vnc client connection.
Definition: vncserver.hh:153
gem5::VncServer::ServerMessages
ServerMessages
Server -> Client message IDs.
Definition: vncserver.hh:78
gem5::VncServer::frameBufferResized
void frameBufferResized() override
Definition: vncserver.cc:724
gem5::VncServer::supportsResizeEnc
bool supportsResizeEnc
If the vnc client supports the desktop resize command.
Definition: vncserver.hh:212
gem5::VncServer::VncServer
VncServer(const Params &p)
VncServer.
Definition: vncserver.cc:118
gem5::VncServer::MouseLeftButton
@ MouseLeftButton
Definition: vncserver.hh:98
gem5::VncServer::EncodingTypes
EncodingTypes
Encoding types.
Definition: vncserver.hh:87
gem5::VncServer::~VncServer
~VncServer()
Definition: vncserver.cc:145
gem5::VncServer::Params
VncServerParams Params
Definition: vncserver.hh:191
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::VncServer::pixelConverter
static const PixelConverter pixelConverter
Definition: vncserver.hh:315
gem5::VncServer::ConnectionState
ConnectionState
Definition: vncserver.hh:108
gem5::VncServer::DataEvent::process
void process(int revent)
Definition: vncserver.cc:107
gem5::VncServer::pixelFormat
PixelFormat pixelFormat
The one and only pixel format we support.
Definition: vncserver.hh:206
gem5::VncServer::checkSecurity
void checkSecurity()
Check that the security exchange was successful.
Definition: vncserver.cc:431

Generated on Sat Jun 18 2022 08:12:19 for gem5 by doxygen 1.8.17