social: api, doc
[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    * Operation ID.
77    */
78   uint64_t op_id GNUNET_PACKED;
79
80 };
81
82
83 struct MsgProcRequest
84 {
85   /**
86    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET
87    */
88   struct GNUNET_MessageHeader header;
89
90   /**
91    * @see enum GNUNET_SOCIAL_MsgProcFlags
92    */
93   uint32_t flags;
94
95   /* Followed by char *method_prefix */
96 };
97
98
99 struct HostEnterRequest
100 {
101   /**
102    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER
103    */
104   struct GNUNET_MessageHeader header;
105
106   uint32_t policy GNUNET_PACKED;
107
108   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
109
110   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
111
112   struct GNUNET_CRYPTO_EddsaPrivateKey place_key;
113
114   /* Followed by char *app_id */
115 };
116
117
118 struct GuestEnterRequest
119 {
120   /**
121    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER
122    */
123   struct GNUNET_MessageHeader header;
124
125   uint32_t relay_count GNUNET_PACKED;
126
127   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
128
129   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
130
131   struct GNUNET_PeerIdentity origin;
132
133   uint32_t flags GNUNET_PACKED;
134
135   /* Followed by char *app_id */
136   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
137   /* Followed by struct GNUNET_MessageHeader *join_msg */
138 };
139
140
141 /** Compatible parts of HostEnterRequest and GuestEnterRequest */
142 struct PlaceEnterRequest
143 {
144   struct GNUNET_MessageHeader header;
145
146   uint32_t reserved GNUNET_PACKED;
147
148   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
149
150   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
151 };
152
153
154 struct EgoPlacePublicKey
155 {
156   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
157   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
158 };
159
160
161 struct GuestEnterByNameRequest
162 {
163   /**
164    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME
165    */
166   struct GNUNET_MessageHeader header;
167
168   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
169
170   /* Followed by char *app_id */
171   /* Followed by char *gns_name */
172   /* Followed by char *password */
173   /* Followed by struct GNUNET_MessageHeader *join_msg */
174 };
175
176
177 struct ZoneAddPlaceRequest
178 {
179   struct GNUNET_MessageHeader header;
180
181   uint32_t relay_count GNUNET_PACKED;
182
183   /**
184    * Operation ID.
185    */
186   uint64_t op_id;
187
188   /**
189    * Expiration time: absolute value in us.
190    */
191   uint64_t expiration_time;
192
193   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
194
195   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
196
197   struct GNUNET_PeerIdentity origin;
198
199   /* Followed by const char *name */
200   /* Followed by const char *password */
201   /* Followed by  struct GNUNET_PeerIdentity *relays[relay_count] */
202 };
203
204
205 struct ZoneAddNymRequest
206 {
207   struct GNUNET_MessageHeader header;
208
209   /**
210    * Operation ID.
211    */
212   uint64_t op_id;
213
214   /**
215    * Expiration time: absolute value in us.
216    */
217   uint64_t expiration_time;
218
219   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
220
221   struct GNUNET_CRYPTO_EcdsaPublicKey nym_pub_key;
222
223   /* Followed by const char *name */
224 };
225
226
227 /**** service -> library ****/
228
229
230 struct AppEgoMessage
231 {
232   /**
233    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO
234    */
235   struct GNUNET_MessageHeader header;
236
237   /**
238    * Public key of ego.
239    */
240   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
241
242   /* Followed by char *name */
243 };
244
245
246 struct AppPlaceMessage
247 {
248   /**
249    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE
250    */
251   struct GNUNET_MessageHeader header;
252
253   struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
254
255   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
256
257   uint8_t is_host;
258
259   uint8_t place_state;
260 };
261
262
263 struct HostEnterAck {
264   /**
265    * Type: GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK
266    */
267   struct GNUNET_MessageHeader header;
268
269   /**
270    * Status code for the operation.
271    */
272   uint32_t result_code GNUNET_PACKED;
273
274   /**
275    * Last message ID sent to the channel.
276    */
277   uint64_t max_message_id GNUNET_PACKED;
278
279   /**
280    * Public key of the place.
281    */
282   struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
283 };
284
285
286 GNUNET_NETWORK_STRUCT_END
287
288 #endif