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