uploaded original spice-server-0.12.4 and celt-0.5.1.3
[sdk/emulator/libs/spice-server.git] / spice-common / spice-protocol / spice / protocol.h
1 /*
2    Copyright (C) 2009 Red Hat, Inc.
3
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions are
6    met:
7
8        * Redistributions of source code must retain the above copyright
9          notice, this list of conditions and the following disclaimer.
10        * Redistributions in binary form must reproduce the above copyright
11          notice, this list of conditions and the following disclaimer in
12          the documentation and/or other materials provided with the
13          distribution.
14        * Neither the name of the copyright holder nor the names of its
15          contributors may be used to endorse or promote products derived
16          from this software without specific prior written permission.
17
18    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
19    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef _H_SPICE_PROTOCOL
32 #define _H_SPICE_PROTOCOL
33
34 #include <spice/types.h>
35 #include <spice/enums.h>
36 #include <spice/start-packed.h>
37
38 #define SPICE_MAGIC (*(uint32_t*)"REDQ")
39 #define SPICE_VERSION_MAJOR 2
40 #define SPICE_VERSION_MINOR 2
41
42 // Encryption & Ticketing Parameters
43 #define SPICE_MAX_PASSWORD_LENGTH 60
44 #define SPICE_TICKET_KEY_PAIR_LENGTH 1024
45 #define SPICE_TICKET_PUBKEY_BYTES (SPICE_TICKET_KEY_PAIR_LENGTH / 8 + 34)
46
47 typedef struct SPICE_ATTR_PACKED SpiceLinkHeader {
48     uint32_t magic;
49     uint32_t major_version;
50     uint32_t minor_version;
51     uint32_t size;
52 } SpiceLinkHeader;
53
54 enum {
55     SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION,
56     SPICE_COMMON_CAP_AUTH_SPICE,
57     SPICE_COMMON_CAP_AUTH_SASL,
58     SPICE_COMMON_CAP_MINI_HEADER,
59 };
60
61 typedef struct SPICE_ATTR_PACKED SpiceLinkMess {
62     uint32_t connection_id;
63     uint8_t channel_type;
64     uint8_t channel_id;
65     uint32_t num_common_caps;
66     uint32_t num_channel_caps;
67     uint32_t caps_offset;
68 } SpiceLinkMess;
69
70 typedef struct SPICE_ATTR_PACKED SpiceLinkReply {
71     uint32_t error;
72     uint8_t pub_key[SPICE_TICKET_PUBKEY_BYTES];
73     uint32_t num_common_caps;
74     uint32_t num_channel_caps;
75     uint32_t caps_offset;
76 } SpiceLinkReply;
77
78 typedef struct SPICE_ATTR_PACKED SpiceLinkEncryptedTicket {
79     uint8_t encrypted_data[SPICE_TICKET_KEY_PAIR_LENGTH / 8];
80 } SpiceLinkEncryptedTicket;
81
82 typedef struct SPICE_ATTR_PACKED SpiceLinkAuthMechanism {
83     uint32_t auth_mechanism;
84 } SpiceLinkAuthMechanism;
85
86 typedef struct SPICE_ATTR_PACKED SpiceDataHeader {
87     uint64_t serial;
88     uint16_t type;
89     uint32_t size;
90     uint32_t sub_list; //offset to SpiceSubMessageList[]
91 } SpiceDataHeader;
92
93 typedef struct SPICE_ATTR_PACKED SpiceMiniDataHeader {
94     uint16_t type;
95     uint32_t size;
96 } SpiceMiniDataHeader;
97
98 typedef struct SPICE_ATTR_PACKED SpiceSubMessage {
99     uint16_t type;
100     uint32_t size;
101 } SpiceSubMessage;
102
103 typedef struct SPICE_ATTR_PACKED SpiceSubMessageList {
104     uint16_t size;
105     uint32_t sub_messages[0]; //offsets to SpicedSubMessage
106 } SpiceSubMessageList;
107
108 #define SPICE_INPUT_MOTION_ACK_BUNCH 4
109
110 enum {
111     SPICE_PLAYBACK_CAP_CELT_0_5_1,
112     SPICE_PLAYBACK_CAP_VOLUME,
113     SPICE_PLAYBACK_CAP_LATENCY,
114 };
115
116 enum {
117     SPICE_RECORD_CAP_CELT_0_5_1,
118     SPICE_RECORD_CAP_VOLUME,
119 };
120
121 enum {
122     SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE,
123     SPICE_MAIN_CAP_NAME_AND_UUID,
124     SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS,
125     SPICE_MAIN_CAP_SEAMLESS_MIGRATE,
126 };
127
128 enum {
129     SPICE_DISPLAY_CAP_SIZED_STREAM,
130     SPICE_DISPLAY_CAP_MONITORS_CONFIG,
131     SPICE_DISPLAY_CAP_COMPOSITE,
132     SPICE_DISPLAY_CAP_A8_SURFACE,
133     SPICE_DISPLAY_CAP_STREAM_REPORT,
134 };
135
136 enum {
137     SPICE_INPUTS_CAP_KEY_SCANCODE,
138 };
139
140 enum {
141     SPICE_PORT_EVENT_OPENED,
142     SPICE_PORT_EVENT_CLOSED,
143     SPICE_PORT_EVENT_BREAK,
144 };
145
146 #include <spice/end-packed.h>
147
148 #endif /* _H_SPICE_PROTOCOL */