-handle new error code from enum
[oweals/gnunet.git] / src / psyc / psyc.h
1 /*
2  * This file is part of GNUnet
3  * (C) 2013 Christian Grothoff (and other contributing authors)
4  *
5  * GNUnet is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 3, or (at your
8  * option) any later version.
9  *
10  * GNUnet is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNUnet; see the file COPYING.  If not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file psyc/psyc.h
23  * @brief Common type definitions for the PSYC service and API.
24  * @author Gabor X Toth
25  */
26
27 #ifndef PSYC_H
28 #define PSYC_H
29
30 #include "gnunet_common.h"
31
32 GNUNET_NETWORK_STRUCT_BEGIN
33
34 /**** service -> library ****/
35
36 /**
37  * Answer from service to client about last operation.
38  */
39 struct OperationResult
40 {
41   /**
42    * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Operation ID.
48    */
49   uint32_t op_id GNUNET_PACKED;
50
51   /**
52    * Status code for the operation.
53    */
54   int64_t result_code GNUNET_PACKED;
55
56   /* followed by 0-terminated error message (on error) */
57
58 };
59
60
61 struct CountersResult
62 {
63   /**
64    * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS
65    */
66   struct GNUNET_MessageHeader header;
67
68   /**
69    * Status code for the operation.
70    */
71   int32_t result_code GNUNET_PACKED;
72
73   uint64_t max_message_id;
74 };
75
76
77 /**
78  * Transmit acknowledgment.
79  *
80  * Sent after the last GNUNET_PSYC_MessageModifier and after each
81  * GNUNET_PSYC_MessageData.
82  *
83  * This message acknowledges previously received messages and asks for the next
84  * fragment of data.
85  */
86 struct TransmitAck
87 {
88   /**
89    * Type: GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK
90    */
91   struct GNUNET_MessageHeader header;
92
93   /**
94    * Buffer space available for the next data fragment.
95    */
96   uint16_t buf_avail;
97 };
98
99
100 /**** library -> service ****/
101
102
103 struct MasterStartRequest
104 {
105   /**
106    * Type: GNUNET_MESSAGE_TYPE_PSYC_MASTER_START
107    */
108   struct GNUNET_MessageHeader header;
109
110   struct GNUNET_CRYPTO_EddsaPrivateKey channel_key;
111
112   uint32_t policy GNUNET_PACKED;
113 };
114
115
116 struct SlaveJoinRequest
117 {
118   /**
119    * Type: GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN
120    */
121   struct GNUNET_MessageHeader header;
122
123   uint32_t relay_count GNUNET_PACKED;
124
125   struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
126
127   struct GNUNET_CRYPTO_EddsaPrivateKey slave_key;
128
129   struct GNUNET_PeerIdentity origin;
130
131   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
132 };
133
134
135 struct ChannelSlaveAdd
136 {
137   /**
138    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD
139    */
140   struct GNUNET_MessageHeader header;
141
142   uint32_t reserved;
143
144   struct GNUNET_CRYPTO_EddsaPublicKey *slave_key;
145
146   uint64_t announced_at;
147
148   uint64_t effective_since;
149 };
150
151
152 struct ChannelSlaveRemove
153 {
154   /**
155    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM
156    */
157   struct GNUNET_MessageHeader header;
158
159   uint32_t reserved;
160
161   struct GNUNET_CRYPTO_EddsaPublicKey *slave_key;
162
163   uint64_t announced_at;
164 };
165
166
167 struct StoryRequest
168 {
169   /**
170    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STORY_REQUEST
171    */
172   struct GNUNET_MessageHeader header;
173
174   uint64_t op_id;
175
176   uint64_t start_message_id;
177
178   uint64_t end_message_id;
179 };
180
181
182 struct StateQuery
183 {
184   /**
185    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_QUERY
186    */
187   struct GNUNET_MessageHeader header;
188
189   uint64_t op_id;
190
191   /* Followed by NUL-terminated name. */
192 };
193
194
195 struct StateResult
196 {
197   /**
198    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_RESULT
199    */
200   struct GNUNET_MessageHeader header;
201
202   /**
203    * Size of name, including NUL terminator.
204    */
205   uint16_t name_size GNUNET_PACKED;
206
207   /**
208    * OR'd StateOpFlags
209    */
210   uint8_t flags;
211
212   /* Followed by NUL-terminated name, then the value. */
213 };
214
215
216 GNUNET_NETWORK_STRUCT_END
217
218 #endif