1 Barrier client protocol
2 =======================
4 QEMU's ``input-barrier`` device implements the client end of
5 the KVM (Keyboard-Video-Mouse) software
6 `Barrier <https://github.com/debauchee/barrier>`__.
8 This document briefly describes the protocol as we implement it.
13 Message format between the server and client is in two parts:
15 #. the payload length, a 32bit integer in network endianness
18 The payload starts with a 4byte string (without NUL) which is the
19 command. The first command between the server and the client
20 is the only command not encoded on 4 bytes ("Barrier").
21 The remaining part of the payload is decoded according to the command.
26 This comes from ``barrier/src/lib/barrier/protocol_types.h``.
28 barrierCmdHello "Barrier"
29 ^^^^^^^^^^^^^^^^^^^^^^^^^^
34 ``{ int16_t minor, int16_t major }``
38 ``minor`` = protocol major version number supported by server
40 ``major`` = protocol minor version number supported by server
42 barrierCmdHelloBack "Barrier"
43 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48 ``{ int16_t minor, int16_t major, char *name}``
50 Respond to hello from server
52 ``minor`` = protocol major version number supported by client
54 ``major`` = protocol minor version number supported by client
56 ``name`` = client name
58 barrierCmdDInfo "DINF"
59 ^^^^^^^^^^^^^^^^^^^^^^^
64 ``{ int16_t x_origin, int16_t y_origin, int16_t width, int16_t height, int16_t x, int16_t y}``
66 The client screen must send this message in response to the
67 barrierCmdQInfo message. It must also send this message when the
68 screen's resolution changes. In this case, the client screen should
69 ignore any barrierCmdDMouseMove messages until it receives a
70 barrierCmdCInfoAck in order to prevent attempts to move the mouse off
73 barrierCmdCNoop "CNOP"
74 ^^^^^^^^^^^^^^^^^^^^^^^
83 barrierCmdCClose "CBYE"
84 ^^^^^^^^^^^^^^^^^^^^^^^
93 barrierCmdCEnter "CINN"
94 ^^^^^^^^^^^^^^^^^^^^^^^
99 ``{ int16_t x, int16_t y, int32_t seq, int16_t modifier }``
103 ``x``, ``y`` = entering screen absolute coordinates
105 ``seq`` = sequence number, which is used to order messages between
106 screens. the secondary screen must return this number
109 ``modifier`` = modifier key mask. this will have bits set for each
110 toggle modifier key that is activated on entry to the
111 screen. the secondary screen should adjust its toggle
112 modifiers to reflect that state.
114 barrierCmdCLeave "COUT"
115 ^^^^^^^^^^^^^^^^^^^^^^^
122 Leaving screen. the secondary screen should send clipboard data in
123 response to this message for those clipboards that it has grabbed
124 (i.e. has sent a barrierCmdCClipboard for and has not received a
125 barrierCmdCClipboard for with a greater sequence number) and that
126 were grabbed or have changed since the last leave.
128 barrierCmdCClipboard "CCLP"
129 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
134 ``{ int8_t id, int32_t seq }``
136 Grab clipboard. Sent by screen when some other app on that screen
139 ``id`` = the clipboard identifier
141 ``seq`` = sequence number. Client must use the sequence number passed in
142 the most recent barrierCmdCEnter. the server always sends 0.
144 barrierCmdCScreenSaver "CSEC"
145 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150 ``{ int8_t started }``
154 ``started`` = Screensaver on primary has started (1) or closed (0)
156 barrierCmdCResetOptions "CROP"
157 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164 Reset options. Client should reset all of its options to their
167 barrierCmdCInfoAck "CIAK"
168 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
175 Resolution change acknowledgment. Sent by server in response to a
176 client screen's barrierCmdDInfo. This is sent for every
177 barrierCmdDInfo, whether or not the server had sent a barrierCmdQInfo.
179 barrierCmdCKeepAlive "CALV"
180 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
187 Keep connection alive. Sent by the server periodically to verify
188 that connections are still up and running. clients must reply in
189 kind on receipt. if the server gets an error sending the message or
190 does not receive a reply within a reasonable time then the server
191 disconnects the client. if the client doesn't receive these (or any
192 message) periodically then it should disconnect from the server. the
193 appropriate interval is defined by an option.
195 barrierCmdDKeyDown "DKDN"
196 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
201 ``{ int16_t keyid, int16_t modifier [,int16_t button] }``
205 ``keyid`` = X11 key id
207 ``modified`` = modified mask
209 ``button`` = X11 Xkb keycode (optional)
211 barrierCmdDKeyRepeat "DKRP"
212 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
217 ``{ int16_t keyid, int16_t modifier, int16_t repeat [,int16_t button] }``
221 ``keyid`` = X11 key id
223 ``modified`` = modified mask
225 ``repeat`` = number of repeats
227 ``button`` = X11 Xkb keycode (optional)
229 barrierCmdDKeyUp "DKUP"
230 ^^^^^^^^^^^^^^^^^^^^^^^
235 ``{ int16_t keyid, int16_t modifier [,int16_t button] }``
239 ``keyid`` = X11 key id
241 ``modified`` = modified mask
243 ``button`` = X11 Xkb keycode (optional)
245 barrierCmdDMouseDown "DMDN"
246 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
251 ``{ int8_t button }``
253 Mouse button pressed.
255 ``button`` = button id
257 barrierCmdDMouseUp "DMUP"
258 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
263 ``{ int8_t button }``
265 Mouse button release.
267 ``button`` = button id
269 barrierCmdDMouseMove "DMMV"
270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
275 ``{ int16_t x, int16_t y }``
277 Absolute mouse moved.
279 ``x``, ``y`` = absolute screen coordinates
281 barrierCmdDMouseRelMove "DMRM"
282 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287 ``{ int16_t x, int16_t y }``
289 Relative mouse moved.
291 ``x``, ``y`` = r relative screen coordinates
293 barrierCmdDMouseWheel "DMWM"
294 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
299 ``{ int16_t x , int16_t y }`` or ``{ int16_t y }``
301 Mouse scroll. The delta should be +120 for one tick forward (away
302 from the user) or right and -120 for one tick backward (toward the
309 barrierCmdDClipboard "DCLP"
310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
315 ``{ int8_t id, int32_t seq, int8_t mark, char *data }``
319 ``id`` = clipboard id
321 ``seq`` = sequence number. The sequence number is 0 when sent by the
322 server. Client screens should use the/ sequence number from
323 the most recent barrierCmdCEnter.
325 barrierCmdDSetOptions "DSOP"
326 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
331 ``{ int32 t nb, { int32_t id, int32_t val }[] }``
333 Set options. Client should set the given option/value pairs.
335 ``nb`` = numbers of ``{ id, val }`` entries
339 ``val`` = option new value
341 barrierCmdDFileTransfer "DFTR"
342 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
347 ``{ int8_t mark, char *content }``
351 * ``mark`` = 0 means the content followed is the file size
352 * 1 means the content followed is the chunk data
353 * 2 means the file transfer is finished
355 barrierCmdDDragInfo "DDRG"
356 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
361 ``{ int16_t nb, char *content }``
365 ``nb`` = number of dragging objects
367 ``content`` = object's directory
369 barrierCmdQInfo "QINF"
370 ^^^^^^^^^^^^^^^^^^^^^^^
379 Client should reply with a barrierCmdDInfo
381 barrierCmdEIncompatible "EICV"
382 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
387 ``{ int16_t nb, major *minor }``
389 Incompatible version.
391 ``major`` = major version
393 ``minor`` = minor version
395 barrierCmdEBusy "EBSY"
396 ^^^^^^^^^^^^^^^^^^^^^^^
403 Name provided when connecting is already in use.
405 barrierCmdEUnknown "EUNK"
406 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
413 Unknown client. Name provided when connecting is not in primary's
414 screen configuration map.
416 barrierCmdEBad "EBAD"
417 ^^^^^^^^^^^^^^^^^^^^^^^
424 Protocol violation. Server should disconnect after sending this