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