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