Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / social / social.h
1 /*
2  * This file is part of GNUnet
3  * Copyright (C) 2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 /**
22  * @file social/social.h
23  * @brief Common type definitions for the Social service and API.
24  * @author Gabor X Toth
25  */
26
27 #ifndef SOCIAL_H
28 #define SOCIAL_H
29
30 #include "platform.h"
31 #include "gnunet_social_service.h"
32
33 enum MessageState
34 {
35   MSG_STATE_START    = 0,
36   MSG_STATE_HEADER   = 1,
37   MSG_STATE_METHOD   = 2,
38   MSG_STATE_MODIFIER = 3,
39   MSG_STATE_MOD_CONT = 4,
40   MSG_STATE_DATA     = 5,
41   MSG_STATE_END      = 6,
42   MSG_STATE_CANCEL   = 7,
43   MSG_STATE_ERROR    = 8,
44 };
45
46
47 GNUNET_NETWORK_STRUCT_BEGIN
48
49 /**** library -> service ****/
50
51
52 struct AppConnectRequest
53 {
54   /**
55    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT
56    */
57   struct GNUNET_MessageHeader header;
58
59   /* Followed by char *app_id */
60 };
61
62
63 struct AppDetachRequest
64 {
65   /**
66    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH
67    */
68   struct GNUNET_MessageHeader header;
69
70   /**
71    * Public key of place.
72    */
73   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
74
75   /**
76    * Public key of ego.
77    */
78   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
79
80   /**
81    * Operation ID.
82    */
83   uint64_t op_id GNUNET_PACKED;
84 };
85
86
87 struct MsgProcRequest
88 {
89   /**
90    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET
91    */
92   struct GNUNET_MessageHeader header;
93
94   /**
95    * @see enum GNUNET_SOCIAL_MsgProcFlags
96    */
97   uint32_t flags;
98
99   /* Followed by char *method_prefix */
100 };
101
102
103 struct HostEnterRequest
104 {
105   /**
106    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER
107    */
108   struct GNUNET_MessageHeader header;
109
110   uint32_t policy GNUNET_PACKED;
111
112   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
113
114   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
115
116   struct GNUNET_CRYPTO_EddsaPrivateKey place_key;
117
118   /* Followed by char *app_id */
119 };
120
121
122 struct GuestEnterRequest
123 {
124   /**
125    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER
126    */
127   struct GNUNET_MessageHeader header;
128
129   uint32_t relay_count GNUNET_PACKED;
130
131   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
132
133   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
134
135   struct GNUNET_PeerIdentity origin;
136
137   uint32_t flags GNUNET_PACKED;
138
139   /* Followed by char *app_id */
140   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
141   /* Followed by struct GNUNET_MessageHeader *join_msg */
142 };
143
144
145 /** Compatible parts of HostEnterRequest and GuestEnterRequest */
146 struct PlaceEnterRequest
147 {
148   struct GNUNET_MessageHeader header;
149
150   uint32_t reserved GNUNET_PACKED;
151
152   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
153
154   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
155 };
156
157
158 struct EgoPlacePublicKey
159 {
160   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
161   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
162 };
163
164
165 struct GuestEnterByNameRequest
166 {
167   /**
168    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME
169    */
170   struct GNUNET_MessageHeader header;
171
172   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
173
174   /* Followed by char *app_id */
175   /* Followed by char *gns_name */
176   /* Followed by char *password */
177   /* Followed by struct GNUNET_MessageHeader *join_msg */
178 };
179
180
181 struct ZoneAddPlaceRequest
182 {
183   struct GNUNET_MessageHeader header;
184
185   uint32_t relay_count GNUNET_PACKED;
186
187   /**
188    * Operation ID.
189    */
190   uint64_t op_id;
191
192   /**
193    * Expiration time: absolute value in us.
194    */
195   uint64_t expiration_time;
196
197   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
198
199   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
200
201   struct GNUNET_PeerIdentity origin;
202
203   /* Followed by const char *name */
204   /* Followed by const char *password */
205   /* Followed by  struct GNUNET_PeerIdentity *relays[relay_count] */
206 };
207
208
209 struct ZoneAddNymRequest
210 {
211   struct GNUNET_MessageHeader header;
212
213   /**
214    * Operation ID.
215    */
216   uint64_t op_id;
217
218   /**
219    * Expiration time: absolute value in us.
220    */
221   uint64_t expiration_time;
222
223   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
224
225   struct GNUNET_CRYPTO_EcdsaPublicKey nym_pub_key;
226
227   /* Followed by const char *name */
228 };
229
230
231 /**** service -> library ****/
232
233
234 struct AppEgoMessage
235 {
236   /**
237    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO
238    */
239   struct GNUNET_MessageHeader header;
240
241   /**
242    * Public key of ego.
243    */
244   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
245
246   /* Followed by char *name */
247 };
248
249
250 struct AppPlaceMessage
251 {
252   /**
253    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE
254    */
255   struct GNUNET_MessageHeader header;
256
257   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
258
259   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
260
261   uint8_t is_host;
262
263   uint8_t place_state;
264 };
265
266
267 struct HostEnterAck {
268   /**
269    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK
270    */
271   struct GNUNET_MessageHeader header;
272
273   /**
274    * Status code for the operation.
275    */
276   uint32_t result_code GNUNET_PACKED;
277
278   /**
279    * Last message ID sent to the channel.
280    */
281   uint64_t max_message_id GNUNET_PACKED;
282
283   /**
284    * Public key of the place.
285    */
286   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
287 };
288
289
290 GNUNET_NETWORK_STRUCT_END
291
292 #endif