diff options
author | Gabor X Toth <*@tg-x.net> | 2016-01-12 23:26:47 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-01-12 23:26:47 +0000 |
commit | 50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea (patch) | |
tree | a8023bdb9c9446a45792d7100303265c78713a50 /src/include | |
parent | 3cbdbe18dbd56def00c0014381ff90b4ee664904 (diff) | |
download | gnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.tar.gz gnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.zip |
psycutil reorg: message, env, slicer
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 4 | ||||
-rw-r--r-- | src/include/gnunet_psyc_env.h (renamed from src/include/gnunet_env_lib.h) | 94 | ||||
-rw-r--r-- | src/include/gnunet_psyc_message.h | 273 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 47 | ||||
-rw-r--r-- | src/include/gnunet_psyc_slicer.h | 319 | ||||
-rw-r--r-- | src/include/gnunet_psyc_util_lib.h | 227 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_plugin.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_service.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 293 |
9 files changed, 697 insertions, 566 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index af6d02ada..dd32da171 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -55,7 +55,6 @@ gnunetinclude_HEADERS = \ | |||
55 | gnunet_dnsstub_lib.h \ | 55 | gnunet_dnsstub_lib.h \ |
56 | gnunet_dns_service.h \ | 56 | gnunet_dns_service.h \ |
57 | gnunet_dv_service.h \ | 57 | gnunet_dv_service.h \ |
58 | gnunet_env_lib.h \ | ||
59 | gnunet_fragmentation_lib.h \ | 58 | gnunet_fragmentation_lib.h \ |
60 | gnunet_friends_lib.h \ | 59 | gnunet_friends_lib.h \ |
61 | gnunet_fs_service.h \ | 60 | gnunet_fs_service.h \ |
@@ -90,6 +89,9 @@ gnunetinclude_HEADERS = \ | |||
90 | gnunet_psycstore_service.h \ | 89 | gnunet_psycstore_service.h \ |
91 | gnunet_psyc_service.h \ | 90 | gnunet_psyc_service.h \ |
92 | gnunet_psyc_util_lib.h \ | 91 | gnunet_psyc_util_lib.h \ |
92 | gnunet_psyc_env.h \ | ||
93 | gnunet_psyc_message.h \ | ||
94 | gnunet_psyc_slicer.h \ | ||
93 | gnunet_program_lib.h \ | 95 | gnunet_program_lib.h \ |
94 | gnunet_protocols.h \ | 96 | gnunet_protocols.h \ |
95 | gnunet_resolver_service.h \ | 97 | gnunet_resolver_service.h \ |
diff --git a/src/include/gnunet_env_lib.h b/src/include/gnunet_psyc_env.h index dff005f17..1f7d644b6 100644 --- a/src/include/gnunet_env_lib.h +++ b/src/include/gnunet_psyc_env.h | |||
@@ -22,10 +22,10 @@ | |||
22 | * @author Gabor X Toth | 22 | * @author Gabor X Toth |
23 | * | 23 | * |
24 | * @file | 24 | * @file |
25 | * Environment library | 25 | * PSYC Environment library |
26 | * | 26 | * |
27 | * @defgroup env Environment library | 27 | * @defgroup psyc-util-env PSYC Utilities library: Environment |
28 | * Environment data structure for PSYC and Social messages. | 28 | * Environment data structure operations for PSYC and Social messages. |
29 | * | 29 | * |
30 | * Library providing operations for the @e environment of | 30 | * Library providing operations for the @e environment of |
31 | * PSYC and Social messages, and for (de)serializing variable values. | 31 | * PSYC and Social messages, and for (de)serializing variable values. |
@@ -34,8 +34,8 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | 36 | ||
37 | #ifndef GNUNET_ENV_LIB_H | 37 | #ifndef GNUNET_PSYC_ENV_H |
38 | #define GNUNET_ENV_LIB_H | 38 | #define GNUNET_PSYC_ENV_H |
39 | 39 | ||
40 | #ifdef __cplusplus | 40 | #ifdef __cplusplus |
41 | extern "C" | 41 | extern "C" |
@@ -49,64 +49,64 @@ extern "C" | |||
49 | /** | 49 | /** |
50 | * Possible operations on PSYC state (persistent) and transient variables (per message). | 50 | * Possible operations on PSYC state (persistent) and transient variables (per message). |
51 | */ | 51 | */ |
52 | enum GNUNET_ENV_Operator | 52 | enum GNUNET_PSYC_Operator |
53 | { | 53 | { |
54 | /** | 54 | /** |
55 | * Set value of a transient variable. | 55 | * Set value of a transient variable. |
56 | */ | 56 | */ |
57 | GNUNET_ENV_OP_SET = ':', | 57 | GNUNET_PSYC_OP_SET = ':', |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Assign value for a persistent state variable. | 60 | * Assign value for a persistent state variable. |
61 | * | 61 | * |
62 | * If an assigned value is NULL, the variable is deleted. | 62 | * If an assigned value is NULL, the variable is deleted. |
63 | */ | 63 | */ |
64 | GNUNET_ENV_OP_ASSIGN = '=', | 64 | GNUNET_PSYC_OP_ASSIGN = '=', |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Augment state variable. | 67 | * Augment state variable. |
68 | * | 68 | * |
69 | * Used for appending strings, adding numbers, and adding new items to a list or dictionary. | 69 | * Used for appending strings, adding numbers, and adding new items to a list or dictionary. |
70 | */ | 70 | */ |
71 | GNUNET_ENV_OP_AUGMENT = '+', | 71 | GNUNET_PSYC_OP_AUGMENT = '+', |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Diminish state variable. | 74 | * Diminish state variable. |
75 | * | 75 | * |
76 | * Used for subtracting numbers, and removing items from a list or dictionary. | 76 | * Used for subtracting numbers, and removing items from a list or dictionary. |
77 | */ | 77 | */ |
78 | GNUNET_ENV_OP_DIMINISH = '-', | 78 | GNUNET_PSYC_OP_DIMINISH = '-', |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Update state variable. | 81 | * Update state variable. |
82 | * | 82 | * |
83 | * Used for modifying a single item of a list or dictionary. | 83 | * Used for modifying a single item of a list or dictionary. |
84 | */ | 84 | */ |
85 | GNUNET_ENV_OP_UPDATE = '@', | 85 | GNUNET_PSYC_OP_UPDATE = '@', |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * PSYC variable types. | 90 | * PSYC variable types. |
91 | */ | 91 | */ |
92 | enum GNUNET_ENV_Type | 92 | enum GNUNET_PSYC_Type |
93 | { | 93 | { |
94 | GNUNET_ENV_TYPE_DATA = 0, | 94 | GNUNET_PSYC_TYPE_DATA = 0, |
95 | GNUNET_ENV_TYPE_NUMBER, | 95 | GNUNET_PSYC_TYPE_NUMBER, |
96 | GNUNET_ENV_TYPE_LIST, | 96 | GNUNET_PSYC_TYPE_LIST, |
97 | GNUNET_ENV_TYPE_DICT | 97 | GNUNET_PSYC_TYPE_DICT |
98 | }; | 98 | }; |
99 | 99 | ||
100 | 100 | ||
101 | /** | 101 | /** |
102 | * PSYC state modifier. | 102 | * PSYC state modifier. |
103 | */ | 103 | */ |
104 | struct GNUNET_ENV_Modifier | 104 | struct GNUNET_PSYC_Modifier |
105 | { | 105 | { |
106 | /** | 106 | /** |
107 | * State operation. | 107 | * State operation. |
108 | */ | 108 | */ |
109 | enum GNUNET_ENV_Operator oper; | 109 | enum GNUNET_PSYC_Operator oper; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Variable name. | 112 | * Variable name. |
@@ -126,12 +126,12 @@ struct GNUNET_ENV_Modifier | |||
126 | /** | 126 | /** |
127 | * Next modifier. | 127 | * Next modifier. |
128 | */ | 128 | */ |
129 | struct GNUNET_ENV_Modifier *next; | 129 | struct GNUNET_PSYC_Modifier *next; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | * Previous modifier. | 132 | * Previous modifier. |
133 | */ | 133 | */ |
134 | struct GNUNET_ENV_Modifier *prev; | 134 | struct GNUNET_PSYC_Modifier *prev; |
135 | }; | 135 | }; |
136 | 136 | ||
137 | 137 | ||
@@ -140,7 +140,7 @@ struct GNUNET_ENV_Modifier | |||
140 | * | 140 | * |
141 | * Contains modifiers. | 141 | * Contains modifiers. |
142 | */ | 142 | */ |
143 | struct GNUNET_ENV_Environment; | 143 | struct GNUNET_PSYC_Environment; |
144 | 144 | ||
145 | 145 | ||
146 | /** | 146 | /** |
@@ -148,8 +148,8 @@ struct GNUNET_ENV_Environment; | |||
148 | * | 148 | * |
149 | * @return A newly allocated environment. | 149 | * @return A newly allocated environment. |
150 | */ | 150 | */ |
151 | struct GNUNET_ENV_Environment * | 151 | struct GNUNET_PSYC_Environment * |
152 | GNUNET_ENV_environment_create (); | 152 | GNUNET_PSYC_env_create (); |
153 | 153 | ||
154 | 154 | ||
155 | /** | 155 | /** |
@@ -162,40 +162,40 @@ GNUNET_ENV_environment_create (); | |||
162 | * @param value_size Size of @a value. | 162 | * @param value_size Size of @a value. |
163 | */ | 163 | */ |
164 | void | 164 | void |
165 | GNUNET_ENV_environment_add (struct GNUNET_ENV_Environment *env, | 165 | GNUNET_PSYC_env_add (struct GNUNET_PSYC_Environment *env, |
166 | enum GNUNET_ENV_Operator oper, const char *name, | 166 | enum GNUNET_PSYC_Operator oper, const char *name, |
167 | const void *value, size_t value_size); | 167 | const void *value, size_t value_size); |
168 | 168 | ||
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Get the first modifier of the environment. | 171 | * Get the first modifier of the environment. |
172 | */ | 172 | */ |
173 | struct GNUNET_ENV_Modifier * | 173 | struct GNUNET_PSYC_Modifier * |
174 | GNUNET_ENV_environment_head (const struct GNUNET_ENV_Environment *env); | 174 | GNUNET_PSYC_env_head (const struct GNUNET_PSYC_Environment *env); |
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Get the last modifier of the environment. | 179 | * Get the last modifier of the environment. |
180 | */ | 180 | */ |
181 | struct GNUNET_ENV_Modifier * | 181 | struct GNUNET_PSYC_Modifier * |
182 | GNUNET_ENV_environment_tail (const struct GNUNET_ENV_Environment *env); | 182 | GNUNET_PSYC_env_tail (const struct GNUNET_PSYC_Environment *env); |
183 | 183 | ||
184 | 184 | ||
185 | /** | 185 | /** |
186 | * Remove a modifier from the environment. | 186 | * Remove a modifier from the environment. |
187 | */ | 187 | */ |
188 | void | 188 | void |
189 | GNUNET_ENV_environment_remove (struct GNUNET_ENV_Environment *env, | 189 | GNUNET_PSYC_env_remove (struct GNUNET_PSYC_Environment *env, |
190 | struct GNUNET_ENV_Modifier *mod); | 190 | struct GNUNET_PSYC_Modifier *mod); |
191 | 191 | ||
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Remove a modifier at the beginning of the environment. | 194 | * Remove a modifier at the beginning of the environment. |
195 | */ | 195 | */ |
196 | int | 196 | int |
197 | GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env, | 197 | GNUNET_PSYC_env_shift (struct GNUNET_PSYC_Environment *env, |
198 | enum GNUNET_ENV_Operator *oper, const char **name, | 198 | enum GNUNET_PSYC_Operator *oper, const char **name, |
199 | const void **value, size_t *value_size); | 199 | const void **value, size_t *value_size); |
200 | 200 | ||
201 | 201 | ||
@@ -209,7 +209,7 @@ GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env, | |||
209 | * #GNUNET_NO to stop. | 209 | * #GNUNET_NO to stop. |
210 | */ | 210 | */ |
211 | typedef int | 211 | typedef int |
212 | (*GNUNET_ENV_Iterator) (void *cls, enum GNUNET_ENV_Operator oper, | 212 | (*GNUNET_PSYC_Iterator) (void *cls, enum GNUNET_PSYC_Operator oper, |
213 | const char *name, const char *value, | 213 | const char *name, const char *value, |
214 | uint32_t value_size); | 214 | uint32_t value_size); |
215 | 215 | ||
@@ -222,8 +222,8 @@ typedef int | |||
222 | * @param it_cls Closure for iterator. | 222 | * @param it_cls Closure for iterator. |
223 | */ | 223 | */ |
224 | void | 224 | void |
225 | GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env, | 225 | GNUNET_PSYC_env_iterate (const struct GNUNET_PSYC_Environment *env, |
226 | GNUNET_ENV_Iterator it, void *it_cls); | 226 | GNUNET_PSYC_Iterator it, void *it_cls); |
227 | 227 | ||
228 | 228 | ||
229 | /** | 229 | /** |
@@ -234,7 +234,7 @@ GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env, | |||
234 | * @return Number of modifiers. | 234 | * @return Number of modifiers. |
235 | */ | 235 | */ |
236 | size_t | 236 | size_t |
237 | GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env); | 237 | GNUNET_PSYC_env_get_count (const struct GNUNET_PSYC_Environment *env); |
238 | 238 | ||
239 | 239 | ||
240 | /** | 240 | /** |
@@ -243,7 +243,7 @@ GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env); | |||
243 | * @param env The environment to destroy. | 243 | * @param env The environment to destroy. |
244 | */ | 244 | */ |
245 | void | 245 | void |
246 | GNUNET_ENV_environment_destroy (struct GNUNET_ENV_Environment *env); | 246 | GNUNET_PSYC_env_destroy (struct GNUNET_PSYC_Environment *env); |
247 | 247 | ||
248 | 248 | ||
249 | /** | 249 | /** |
@@ -253,8 +253,8 @@ GNUNET_ENV_environment_destroy (struct GNUNET_ENV_Environment *env); | |||
253 | * | 253 | * |
254 | * @return Variable type. | 254 | * @return Variable type. |
255 | */ | 255 | */ |
256 | enum GNUNET_ENV_Type | 256 | enum GNUNET_PSYC_Type |
257 | GNUNET_ENV_var_get_type (char *name); | 257 | GNUNET_PSYC_var_get_type (char *name); |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
@@ -272,8 +272,8 @@ GNUNET_ENV_var_get_type (char *name); | |||
272 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 272 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
273 | */ | 273 | */ |
274 | int | 274 | int |
275 | GNUNET_ENV_operation (char *name, void *current_value, size_t current_value_size, | 275 | GNUNET_PSYC_operation (char *name, void *current_value, size_t current_value_size, |
276 | enum GNUNET_ENV_Operator oper, void *args, size_t args_size, | 276 | enum GNUNET_PSYC_Operator oper, void *args, size_t args_size, |
277 | void **return_value, size_t *return_value_size); | 277 | void **return_value, size_t *return_value_size); |
278 | 278 | ||
279 | 279 | ||
@@ -287,7 +287,7 @@ GNUNET_ENV_operation (char *name, void *current_value, size_t current_value_size | |||
287 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). | 287 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). |
288 | */ | 288 | */ |
289 | int | 289 | int |
290 | GNUNET_ENV_value_to_number (size_t size, const void *value, int64_t *number); | 290 | GNUNET_PSYC_value_to_number (size_t size, const void *value, int64_t *number); |
291 | 291 | ||
292 | 292 | ||
293 | /** | 293 | /** |
@@ -300,7 +300,7 @@ GNUNET_ENV_value_to_number (size_t size, const void *value, int64_t *number); | |||
300 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). | 300 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). |
301 | */ | 301 | */ |
302 | int | 302 | int |
303 | GNUNET_ENV_value_to_dict (size_t size, const void *value, struct GNUNET_CONTAINER_MultiHashMap **dict); | 303 | GNUNET_PSYC_value_to_dict (size_t size, const void *value, struct GNUNET_CONTAINER_MultiHashMap **dict); |
304 | 304 | ||
305 | 305 | ||
306 | /** | 306 | /** |
@@ -312,7 +312,7 @@ GNUNET_ENV_value_to_dict (size_t size, const void *value, struct GNUNET_CONTAINE | |||
312 | * @return A newly allocated value or NULL on error. | 312 | * @return A newly allocated value or NULL on error. |
313 | */ | 313 | */ |
314 | void * | 314 | void * |
315 | GNUNET_ENV_value_from_number (int64_t number, size_t *value_size); | 315 | GNUNET_PSYC_value_from_number (int64_t number, size_t *value_size); |
316 | 316 | ||
317 | 317 | ||
318 | /** | 318 | /** |
@@ -324,7 +324,7 @@ GNUNET_ENV_value_from_number (int64_t number, size_t *value_size); | |||
324 | * @return A newly allocated value or NULL on error. | 324 | * @return A newly allocated value or NULL on error. |
325 | */ | 325 | */ |
326 | void * | 326 | void * |
327 | GNUNET_ENV_value_from_dict (struct GNUNET_CONTAINER_MultiHashMap *dict, size_t *value_size); | 327 | GNUNET_PSYC_value_from_dict (struct GNUNET_CONTAINER_MultiHashMap *dict, size_t *value_size); |
328 | 328 | ||
329 | 329 | ||
330 | #if 0 /* keep Emacsens' auto-indent happy */ | 330 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -334,7 +334,7 @@ GNUNET_ENV_value_from_dict (struct GNUNET_CONTAINER_MultiHashMap *dict, size_t * | |||
334 | } | 334 | } |
335 | #endif | 335 | #endif |
336 | 336 | ||
337 | /* ifndef GNUNET_ENV_LIB_H */ | 337 | /* ifndef GNUNET_PSYC_ENV_H */ |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | /** @} */ /* end of group */ | 340 | /** @} */ /* end of group */ |
diff --git a/src/include/gnunet_psyc_message.h b/src/include/gnunet_psyc_message.h new file mode 100644 index 000000000..d16510747 --- /dev/null +++ b/src/include/gnunet_psyc_message.h | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012, 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 | * @author Gabor X Toth | ||
23 | * | ||
24 | * @file | ||
25 | * PSYC message utilities; receiving/transmitting/logging PSYC messages | ||
26 | * | ||
27 | * @defgroup psyc-util-message PSYC Utilities library: Messages | ||
28 | * Receiving, transmitting, logging PSYC messages. | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | #ifndef GNUNET_PSYC_MESSAGE_H | ||
33 | #define GNUNET_PSYC_MESSAGE_H | ||
34 | |||
35 | #ifdef __cplusplus | ||
36 | extern "C" | ||
37 | { | ||
38 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
39 | } | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | |||
44 | #include "gnunet_util_lib.h" | ||
45 | #include "gnunet_psyc_util_lib.h" | ||
46 | #include "gnunet_psyc_service.h" | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Create a PSYC message. | ||
51 | * | ||
52 | * @param method_name | ||
53 | * PSYC method for the message. | ||
54 | * @param env | ||
55 | * Environment for the message. | ||
56 | * @param data | ||
57 | * Data payload for the message. | ||
58 | * @param data_size | ||
59 | * Size of @a data. | ||
60 | * | ||
61 | * @return Message header with size information, | ||
62 | * followed by the message parts. | ||
63 | */ | ||
64 | struct GNUNET_PSYC_Message * | ||
65 | GNUNET_PSYC_message_create (const char *method_name, | ||
66 | const struct GNUNET_PSYC_Environment *env, | ||
67 | const void *data, | ||
68 | size_t data_size); | ||
69 | |||
70 | /** | ||
71 | * Parse PSYC message. | ||
72 | * | ||
73 | * @param msg | ||
74 | * The PSYC message to parse. | ||
75 | * @param env | ||
76 | * The environment for the message with a list of modifiers. | ||
77 | * @param[out] method_name | ||
78 | * Pointer to the method name inside @a pmsg. | ||
79 | * @param[out] data | ||
80 | * Pointer to data inside @a pmsg. | ||
81 | * @param[out] data_size | ||
82 | * Size of @data is written here. | ||
83 | * | ||
84 | * @return #GNUNET_OK on success, | ||
85 | * #GNUNET_SYSERR on parse error. | ||
86 | */ | ||
87 | int | ||
88 | GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_MessageHeader *msg, | ||
89 | const char **method_name, | ||
90 | struct GNUNET_PSYC_Environment *env, | ||
91 | const void **data, | ||
92 | uint16_t *data_size); | ||
93 | |||
94 | |||
95 | void | ||
96 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | ||
97 | const struct GNUNET_MessageHeader *msg); | ||
98 | |||
99 | |||
100 | int | ||
101 | GNUNET_PSYC_check_message_parts (uint16_t data_size, const char *data, | ||
102 | uint16_t *first_ptype, uint16_t *last_ptype); | ||
103 | |||
104 | |||
105 | struct GNUNET_PSYC_TransmitHandle; | ||
106 | |||
107 | /** | ||
108 | * Create a transmission handle. | ||
109 | */ | ||
110 | struct GNUNET_PSYC_TransmitHandle * | ||
111 | GNUNET_PSYC_transmit_create (); | ||
112 | |||
113 | |||
114 | /** | ||
115 | * Destroy a transmission handle. | ||
116 | */ | ||
117 | void | ||
118 | GNUNET_PSYC_transmit_destroy (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Transmit a message. | ||
123 | * | ||
124 | * @param tmit | ||
125 | * Transmission handle. | ||
126 | * @param method_name | ||
127 | * Which method should be invoked. | ||
128 | * @param env | ||
129 | * Environment for the message. | ||
130 | * Should stay available until the first call to notify_data. | ||
131 | * Can be NULL if there are no modifiers or @a notify_mod is | ||
132 | * provided instead. | ||
133 | * @param notify_mod | ||
134 | * Function to call to obtain modifiers. | ||
135 | * Can be NULL if there are no modifiers or @a env is provided instead. | ||
136 | * @param notify_data | ||
137 | * Function to call to obtain fragments of the data. | ||
138 | * @param notify_cls | ||
139 | * Closure for @a notify_mod and @a notify_data. | ||
140 | * @param flags | ||
141 | * Flags for the message being transmitted. | ||
142 | * | ||
143 | * @return #GNUNET_OK if the transmission was started. | ||
144 | * #GNUNET_SYSERR if another transmission is already going on. | ||
145 | */ | ||
146 | int | ||
147 | GNUNET_PSYC_transmit_message (struct GNUNET_PSYC_TransmitHandle *tmit, | ||
148 | const char *method_name, | ||
149 | const struct GNUNET_PSYC_Environment *env, | ||
150 | GNUNET_PSYC_TransmitNotifyModifier notify_mod, | ||
151 | GNUNET_PSYC_TransmitNotifyData notify_data, | ||
152 | void *notify_cls, | ||
153 | uint32_t flags); | ||
154 | |||
155 | |||
156 | /** | ||
157 | * Resume transmission. | ||
158 | * | ||
159 | * @param tmit Transmission handle. | ||
160 | */ | ||
161 | void | ||
162 | GNUNET_PSYC_transmit_resume (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Abort transmission request. | ||
167 | * | ||
168 | * @param tmit Transmission handle. | ||
169 | */ | ||
170 | void | ||
171 | GNUNET_PSYC_transmit_cancel (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Got acknowledgement of a transmitted message part, continue transmission. | ||
176 | * | ||
177 | * @param tmit Transmission handle. | ||
178 | */ | ||
179 | void | ||
180 | GNUNET_PSYC_transmit_got_ack (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
181 | |||
182 | |||
183 | struct GNUNET_PSYC_ReceiveHandle; | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Create handle for receiving messages. | ||
188 | */ | ||
189 | struct GNUNET_PSYC_ReceiveHandle * | ||
190 | GNUNET_PSYC_receive_create (GNUNET_PSYC_MessageCallback message_cb, | ||
191 | GNUNET_PSYC_MessagePartCallback message_part_cb, | ||
192 | void *cb_cls); | ||
193 | |||
194 | |||
195 | /** | ||
196 | * Destroy handle for receiving messages. | ||
197 | */ | ||
198 | void | ||
199 | GNUNET_PSYC_receive_destroy (struct GNUNET_PSYC_ReceiveHandle *recv); | ||
200 | |||
201 | |||
202 | /** | ||
203 | * Reset stored data related to the last received message. | ||
204 | */ | ||
205 | void | ||
206 | GNUNET_PSYC_receive_reset (struct GNUNET_PSYC_ReceiveHandle *recv); | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Handle incoming PSYC message. | ||
211 | * | ||
212 | * @param recv Receive handle. | ||
213 | * @param msg The message. | ||
214 | * | ||
215 | * @return #GNUNET_OK on success, | ||
216 | * #GNUNET_SYSERR on receive error. | ||
217 | */ | ||
218 | int | ||
219 | GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv, | ||
220 | const struct GNUNET_PSYC_MessageHeader *msg); | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Check if @a data contains a series of valid message parts. | ||
225 | * | ||
226 | * @param data_size Size of @a data. | ||
227 | * @param data Data. | ||
228 | * @param[out] first_ptype Type of first message part. | ||
229 | * @param[out] last_ptype Type of last message part. | ||
230 | * | ||
231 | * @return Number of message parts found in @a data. | ||
232 | * or GNUNET_SYSERR if the message contains invalid parts. | ||
233 | */ | ||
234 | int | ||
235 | GNUNET_PSYC_receive_check_parts (uint16_t data_size, const char *data, | ||
236 | uint16_t *first_ptype, uint16_t *last_ptype); | ||
237 | |||
238 | |||
239 | /** | ||
240 | * Initialize PSYC message header. | ||
241 | */ | ||
242 | void | ||
243 | GNUNET_PSYC_message_header_init (struct GNUNET_PSYC_MessageHeader *pmsg, | ||
244 | const struct GNUNET_MULTICAST_MessageHeader *mmsg, | ||
245 | uint32_t flags); | ||
246 | |||
247 | |||
248 | /** | ||
249 | * Create a new PSYC message header from a multicast message for sending it to clients. | ||
250 | */ | ||
251 | struct GNUNET_PSYC_MessageHeader * | ||
252 | GNUNET_PSYC_message_header_create (const struct GNUNET_MULTICAST_MessageHeader *mmsg, | ||
253 | uint32_t flags); | ||
254 | |||
255 | |||
256 | /** | ||
257 | * Create a new PSYC message header from a PSYC message. | ||
258 | */ | ||
259 | struct GNUNET_PSYC_MessageHeader * | ||
260 | GNUNET_PSYC_message_header_create_from_psyc (const struct GNUNET_PSYC_Message *msg); | ||
261 | |||
262 | |||
263 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
264 | { | ||
265 | #endif | ||
266 | #ifdef __cplusplus | ||
267 | } | ||
268 | #endif | ||
269 | |||
270 | /* ifndef GNUNET_PSYC_MESSAGE_H */ | ||
271 | #endif | ||
272 | |||
273 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index de31fe216..526a70f01 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -92,7 +92,6 @@ extern "C" | |||
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | #include "gnunet_util_lib.h" | 94 | #include "gnunet_util_lib.h" |
95 | #include "gnunet_env_lib.h" | ||
96 | #include "gnunet_multicast_service.h" | 95 | #include "gnunet_multicast_service.h" |
97 | //Mingw work around | 96 | //Mingw work around |
98 | #ifdef MINGW | 97 | #ifdef MINGW |
@@ -917,33 +916,41 @@ enum GNUNET_PSYC_SlaveJoinFlags | |||
917 | * notification on failure (as the channel may simply take days to approve, | 916 | * notification on failure (as the channel may simply take days to approve, |
918 | * and disapproval is simply being ignored). | 917 | * and disapproval is simply being ignored). |
919 | * | 918 | * |
920 | * @param cfg Configuration to use. | 919 | * @param cfg |
921 | * @param channel_key ECC public key that identifies the channel we wish to join. | 920 | * Configuration to use. |
922 | * @param slave_key ECC private-public key pair that identifies the slave, and | 921 | * @param channel_pub_key |
922 | * ECC public key that identifies the channel we wish to join. | ||
923 | * @param slave_key | ||
924 | * ECC private-public key pair that identifies the slave, and | ||
923 | * used by multicast to sign the join request and subsequent unicast | 925 | * used by multicast to sign the join request and subsequent unicast |
924 | * requests sent to the master. | 926 | * requests sent to the master. |
925 | * @param origin Peer identity of the origin. | 927 | * @param flags |
926 | * @param relay_count Number of peers in the @a relays array. | 928 | * Join flags. |
927 | * @param relays Peer identities of members of the multicast group, which serve | 929 | * @param origin |
930 | * Peer identity of the origin. | ||
931 | * @param relay_count | ||
932 | * Number of peers in the @a relays array. | ||
933 | * @param relays | ||
934 | * Peer identities of members of the multicast group, which serve | ||
928 | * as relays and used to join the group at. | 935 | * as relays and used to join the group at. |
929 | * @param message_cb Function to invoke on message parts received from the | 936 | * @param message_cb |
930 | * channel, typically at least contains method handlers for @e join and | 937 | * Function to invoke on message fragments received from the channel. |
931 | * @e part. | 938 | * @param message_part_cb |
932 | * @param slave_connect_cb Function invoked once we have connected to the | 939 | * Function to invoke on message parts received from the channel. |
933 | * PSYC service. | 940 | * @param slave_connect_cb |
934 | * @param join_decision_cb Function invoked once we have received a join | 941 | * Function invoked once we have connected to the PSYC service. |
935 | * decision. | 942 | * @param join_decision_cb |
936 | * @param cls Closure for @a message_cb and @a slave_joined_cb. | 943 | * Function invoked once we have received a join decision. |
937 | * @param method_name Method name for the join request. | 944 | * @param cls |
938 | * @param env Environment containing transient variables for the request, or NULL. | 945 | * Closure for @a message_cb and @a slave_joined_cb. |
939 | * @param data Payload for the join message. | 946 | * @param join_msg |
940 | * @param data_size Number of bytes in @a data. | 947 | * Join message. |
941 | * | 948 | * |
942 | * @return Handle for the slave, NULL on error. | 949 | * @return Handle for the slave, NULL on error. |
943 | */ | 950 | */ |
944 | struct GNUNET_PSYC_Slave * | 951 | struct GNUNET_PSYC_Slave * |
945 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 952 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
946 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 953 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_pub_key, |
947 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, | 954 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
948 | enum GNUNET_PSYC_SlaveJoinFlags flags, | 955 | enum GNUNET_PSYC_SlaveJoinFlags flags, |
949 | const struct GNUNET_PeerIdentity *origin, | 956 | const struct GNUNET_PeerIdentity *origin, |
diff --git a/src/include/gnunet_psyc_slicer.h b/src/include/gnunet_psyc_slicer.h new file mode 100644 index 000000000..1851a6002 --- /dev/null +++ b/src/include/gnunet_psyc_slicer.h | |||
@@ -0,0 +1,319 @@ | |||
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 | * @author Gabor X Toth | ||
23 | * @author Christian Grothoff | ||
24 | * | ||
25 | * @file | ||
26 | * PSYC Slicer library | ||
27 | * | ||
28 | * @defgroup psyc-util-slicer PSYC Utilities library: Slicer | ||
29 | * Try-and-slice processing of PSYC method names and environment. | ||
30 | * @{ | ||
31 | */ | ||
32 | |||
33 | #ifndef GNUNET_PSYC_SLICER_H | ||
34 | #define GNUNET_PSYC_SLICER_H | ||
35 | |||
36 | |||
37 | #ifdef __cplusplus | ||
38 | extern "C" | ||
39 | { | ||
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | ||
42 | #endif | ||
43 | #endif | ||
44 | |||
45 | #include "gnunet_util_lib.h" | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Handle to an implementation of try-and-slice. | ||
50 | */ | ||
51 | struct GNUNET_PSYC_Slicer; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Function called upon receiving a message indicating a call to a @e method. | ||
56 | * | ||
57 | * This function is called one or more times for each message until all data | ||
58 | * fragments arrive from the network. | ||
59 | * | ||
60 | * @param cls | ||
61 | * Closure. | ||
62 | * @param msg | ||
63 | * Message part, as it arrived from the network. | ||
64 | * @param message_id | ||
65 | * Message counter, monotonically increasing from 1. | ||
66 | * @param nym | ||
67 | * The sender of the message. | ||
68 | * Can be NULL if the message is not connected to a pseudonym. | ||
69 | * @param flags | ||
70 | * OR'ed GNUNET_PSYC_MessageFlags | ||
71 | * @param method_name | ||
72 | * Original method name from PSYC. | ||
73 | * May be more specific than the registered method name due to | ||
74 | * try-and-slice matching. | ||
75 | */ | ||
76 | typedef void | ||
77 | (*GNUNET_PSYC_MethodCallback) (void *cls, | ||
78 | const struct GNUNET_PSYC_MessageMethod *msg, | ||
79 | uint64_t message_id, | ||
80 | uint32_t flags, | ||
81 | const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key, | ||
82 | const char *method_name); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Function called upon receiving a modifier of a message. | ||
87 | * | ||
88 | * @param cls | ||
89 | * Closure. | ||
90 | * @param message_id | ||
91 | * Message ID this data fragment belongs to. | ||
92 | * @param msg | ||
93 | * Message part, as it arrived from the network. | ||
94 | * @param oper | ||
95 | * Operation to perform. | ||
96 | * 0 in case of a modifier continuation. | ||
97 | * @param name | ||
98 | * Name of the modifier. | ||
99 | * NULL in case of a modifier continuation. | ||
100 | * @param value | ||
101 | * Value of the modifier. | ||
102 | * @param value_size | ||
103 | * Size of @value. | ||
104 | */ | ||
105 | typedef void | ||
106 | (*GNUNET_PSYC_ModifierCallback) (void *cls, | ||
107 | const struct GNUNET_MessageHeader *msg, | ||
108 | uint64_t message_id, | ||
109 | enum GNUNET_PSYC_Operator oper, | ||
110 | const char *name, | ||
111 | const void *value, | ||
112 | uint16_t value_size, | ||
113 | uint16_t full_value_size); | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Function called upon receiving a data fragment of a message. | ||
118 | * | ||
119 | * @param cls | ||
120 | * Closure. | ||
121 | * @param message_id | ||
122 | * Message ID this data fragment belongs to. | ||
123 | * @param msg | ||
124 | * Message part, as it arrived from the network. | ||
125 | * @param data_offset | ||
126 | * Byte offset of @a data in the overall data of the method. | ||
127 | * @param data_size | ||
128 | * Number of bytes in @a data. | ||
129 | * @param data | ||
130 | * Data stream given to the method. | ||
131 | * @param end | ||
132 | * End of message? | ||
133 | * #GNUNET_NO if there are further fragments, | ||
134 | * #GNUNET_YES if this is the last fragment, | ||
135 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. | ||
136 | */ | ||
137 | typedef void | ||
138 | (*GNUNET_PSYC_DataCallback) (void *cls, | ||
139 | const struct GNUNET_MessageHeader *msg, | ||
140 | uint64_t message_id, | ||
141 | uint64_t data_offset, | ||
142 | const void *data, | ||
143 | uint16_t data_size); | ||
144 | |||
145 | |||
146 | /** | ||
147 | * End of message. | ||
148 | * | ||
149 | * @param cls | ||
150 | * Closure. | ||
151 | * @param msg | ||
152 | * Message part, as it arrived from the network. | ||
153 | * @param message_id | ||
154 | * Message ID this data fragment belongs to. | ||
155 | * @param cancelled | ||
156 | * #GNUNET_YES if the message was cancelled, | ||
157 | * #GNUNET_NO if the message is complete. | ||
158 | */ | ||
159 | typedef void | ||
160 | (*GNUNET_PSYC_EndOfMessageCallback) (void *cls, | ||
161 | const struct GNUNET_MessageHeader *msg, | ||
162 | uint64_t message_id, | ||
163 | uint8_t cancelled); | ||
164 | |||
165 | |||
166 | /** | ||
167 | * Create a try-and-slice instance. | ||
168 | * | ||
169 | * A slicer processes incoming messages and notifies callbacks about matching | ||
170 | * methods or modifiers encountered. | ||
171 | * | ||
172 | * @return A new try-and-slice construct. | ||
173 | */ | ||
174 | struct GNUNET_PSYC_Slicer * | ||
175 | GNUNET_PSYC_slicer_create (void); | ||
176 | |||
177 | |||
178 | /** | ||
179 | * Add a method to the try-and-slice instance. | ||
180 | * | ||
181 | * The callbacks are called for messages with a matching @a method_name prefix. | ||
182 | * | ||
183 | * @param slicer | ||
184 | * The try-and-slice instance to extend. | ||
185 | * @param method_name | ||
186 | * Name of the given method, use empty string to match all. | ||
187 | * @param method_cb | ||
188 | * Method handler invoked upon a matching message. | ||
189 | * @param modifier_cb | ||
190 | * Modifier handler, invoked after @a method_cb | ||
191 | * for each modifier in the message. | ||
192 | * @param data_cb | ||
193 | * Data handler, invoked after @a modifier_cb for each data fragment. | ||
194 | * @param eom_cb | ||
195 | * Invoked upon reaching the end of a matching message. | ||
196 | * @param cls | ||
197 | * Closure for the callbacks. | ||
198 | */ | ||
199 | void | ||
200 | GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer, | ||
201 | const char *method_name, | ||
202 | GNUNET_PSYC_MethodCallback method_cb, | ||
203 | GNUNET_PSYC_ModifierCallback modifier_cb, | ||
204 | GNUNET_PSYC_DataCallback data_cb, | ||
205 | GNUNET_PSYC_EndOfMessageCallback eom_cb, | ||
206 | void *cls); | ||
207 | |||
208 | /** | ||
209 | * Remove a registered method from the try-and-slice instance. | ||
210 | * | ||
211 | * Removes one matching handler registered with the given | ||
212 | * @a method_name and callbacks. | ||
213 | * | ||
214 | * @param slicer | ||
215 | * The try-and-slice instance. | ||
216 | * @param method_name | ||
217 | * Name of the method to remove. | ||
218 | * @param method_cb | ||
219 | * Method handler. | ||
220 | * @param modifier_cb | ||
221 | * Modifier handler. | ||
222 | * @param data_cb | ||
223 | * Data handler. | ||
224 | * @param eom_cb | ||
225 | * End of message handler. | ||
226 | * | ||
227 | * @return #GNUNET_OK if a method handler was removed, | ||
228 | * #GNUNET_NO if no handler matched the given method name and callbacks. | ||
229 | */ | ||
230 | int | ||
231 | GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer, | ||
232 | const char *method_name, | ||
233 | GNUNET_PSYC_MethodCallback method_cb, | ||
234 | GNUNET_PSYC_ModifierCallback modifier_cb, | ||
235 | GNUNET_PSYC_DataCallback data_cb, | ||
236 | GNUNET_PSYC_EndOfMessageCallback eom_cb); | ||
237 | |||
238 | |||
239 | /** | ||
240 | * Watch a place for changed objects. | ||
241 | * | ||
242 | * @param slicer | ||
243 | * The try-and-slice instance. | ||
244 | * @param object_filter | ||
245 | * Object prefix to match. | ||
246 | * @param modifier_cb | ||
247 | * Function to call when encountering a state modifier. | ||
248 | * @param cls | ||
249 | * Closure for callback. | ||
250 | */ | ||
251 | void | ||
252 | GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer, | ||
253 | const char *object_filter, | ||
254 | GNUNET_PSYC_ModifierCallback modifier_cb, | ||
255 | void *cls); | ||
256 | |||
257 | |||
258 | /** | ||
259 | * Remove a registered modifier from the try-and-slice instance. | ||
260 | * | ||
261 | * Removes one matching handler registered with the given | ||
262 | * @a object_filter and callback. | ||
263 | * | ||
264 | * @param slicer | ||
265 | * The try-and-slice instance. | ||
266 | * @param object_filter | ||
267 | * Object prefix to match. | ||
268 | * @param modifier_cb | ||
269 | * Function to call when encountering a state modifier changes. | ||
270 | */ | ||
271 | int | ||
272 | GNUNET_PSYC_slicer_modifier_remove (struct GNUNET_PSYC_Slicer *slicer, | ||
273 | const char *object_filter, | ||
274 | GNUNET_PSYC_ModifierCallback modifier_cb); | ||
275 | |||
276 | |||
277 | /** | ||
278 | * Process an incoming message part and call matching handlers. | ||
279 | * | ||
280 | * @param cls | ||
281 | * Closure. | ||
282 | * @param message_id | ||
283 | * ID of the message. | ||
284 | * @param flags | ||
285 | * Flags for the message. | ||
286 | * @see enum GNUNET_PSYC_MessageFlags | ||
287 | * @param msg | ||
288 | * The message part. as it arrived from the network. | ||
289 | */ | ||
290 | void | ||
291 | GNUNET_PSYC_slicer_message (void *cls, | ||
292 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, | ||
293 | uint64_t message_id, | ||
294 | uint32_t flags, | ||
295 | uint64_t fragment_offset, | ||
296 | const struct GNUNET_MessageHeader *msg); | ||
297 | |||
298 | |||
299 | /** | ||
300 | * Destroy a given try-and-slice instance. | ||
301 | * | ||
302 | * @param slicer | ||
303 | * Slicer to destroy | ||
304 | */ | ||
305 | void | ||
306 | GNUNET_PSYC_slicer_destroy (struct GNUNET_PSYC_Slicer *slicer); | ||
307 | |||
308 | |||
309 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
310 | { | ||
311 | #endif | ||
312 | #ifdef __cplusplus | ||
313 | } | ||
314 | #endif | ||
315 | |||
316 | /* ifndef GNUNET_PSYC_SLICER_H */ | ||
317 | #endif | ||
318 | |||
319 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_psyc_util_lib.h b/src/include/gnunet_psyc_util_lib.h index 0b9ba8207..89e159e33 100644 --- a/src/include/gnunet_psyc_util_lib.h +++ b/src/include/gnunet_psyc_util_lib.h | |||
@@ -22,11 +22,7 @@ | |||
22 | * @author Gabor X Toth | 22 | * @author Gabor X Toth |
23 | * | 23 | * |
24 | * @file | 24 | * @file |
25 | * PSYC utilities; receiving/transmitting/logging PSYC messages | 25 | * PSYC utilities: messages, environment, slicer |
26 | * | ||
27 | * @defgroup psyc-util PSYC Utilities library | ||
28 | * Receiving, transmitting, logging PSYC messages. | ||
29 | * @{ | ||
30 | */ | 26 | */ |
31 | 27 | ||
32 | #ifndef GNUNET_PSYC_UTIL_LIB_H | 28 | #ifndef GNUNET_PSYC_UTIL_LIB_H |
@@ -40,223 +36,10 @@ extern "C" | |||
40 | #endif | 36 | #endif |
41 | #endif | 37 | #endif |
42 | 38 | ||
43 | #include "gnunet_util_lib.h" | ||
44 | #include "gnunet_env_lib.h" | ||
45 | #include "gnunet_psyc_service.h" | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Create a PSYC message. | ||
50 | * | ||
51 | * @param method_name | ||
52 | * PSYC method for the message. | ||
53 | * @param env | ||
54 | * Environment for the message. | ||
55 | * @param data | ||
56 | * Data payload for the message. | ||
57 | * @param data_size | ||
58 | * Size of @a data. | ||
59 | * | ||
60 | * @return Message header with size information, | ||
61 | * followed by the message parts. | ||
62 | */ | ||
63 | struct GNUNET_PSYC_Message * | ||
64 | GNUNET_PSYC_message_create (const char *method_name, | ||
65 | const struct GNUNET_ENV_Environment *env, | ||
66 | const void *data, | ||
67 | size_t data_size); | ||
68 | |||
69 | /** | ||
70 | * Parse PSYC message. | ||
71 | * | ||
72 | * @param msg | ||
73 | * The PSYC message to parse. | ||
74 | * @param env | ||
75 | * The environment for the message with a list of modifiers. | ||
76 | * @param[out] method_name | ||
77 | * Pointer to the method name inside @a pmsg. | ||
78 | * @param[out] data | ||
79 | * Pointer to data inside @a pmsg. | ||
80 | * @param[out] data_size | ||
81 | * Size of @data is written here. | ||
82 | * | ||
83 | * @return #GNUNET_OK on success, | ||
84 | * #GNUNET_SYSERR on parse error. | ||
85 | */ | ||
86 | int | ||
87 | GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_MessageHeader *msg, | ||
88 | const char **method_name, | ||
89 | struct GNUNET_ENV_Environment *env, | ||
90 | const void **data, | ||
91 | uint16_t *data_size); | ||
92 | |||
93 | |||
94 | void | ||
95 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | ||
96 | const struct GNUNET_MessageHeader *msg); | ||
97 | |||
98 | |||
99 | int | ||
100 | GNUNET_PSYC_check_message_parts (uint16_t data_size, const char *data, | ||
101 | uint16_t *first_ptype, uint16_t *last_ptype); | ||
102 | |||
103 | |||
104 | struct GNUNET_PSYC_TransmitHandle; | ||
105 | |||
106 | /** | ||
107 | * Create a transmission handle. | ||
108 | */ | ||
109 | struct GNUNET_PSYC_TransmitHandle * | ||
110 | GNUNET_PSYC_transmit_create (); | ||
111 | |||
112 | |||
113 | /** | ||
114 | * Destroy a transmission handle. | ||
115 | */ | ||
116 | void | ||
117 | GNUNET_PSYC_transmit_destroy (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Transmit a message. | ||
122 | * | ||
123 | * @param tmit | ||
124 | * Transmission handle. | ||
125 | * @param method_name | ||
126 | * Which method should be invoked. | ||
127 | * @param env | ||
128 | * Environment for the message. | ||
129 | * Should stay available until the first call to notify_data. | ||
130 | * Can be NULL if there are no modifiers or @a notify_mod is | ||
131 | * provided instead. | ||
132 | * @param notify_mod | ||
133 | * Function to call to obtain modifiers. | ||
134 | * Can be NULL if there are no modifiers or @a env is provided instead. | ||
135 | * @param notify_data | ||
136 | * Function to call to obtain fragments of the data. | ||
137 | * @param notify_cls | ||
138 | * Closure for @a notify_mod and @a notify_data. | ||
139 | * @param flags | ||
140 | * Flags for the message being transmitted. | ||
141 | * | ||
142 | * @return #GNUNET_OK if the transmission was started. | ||
143 | * #GNUNET_SYSERR if another transmission is already going on. | ||
144 | */ | ||
145 | int | ||
146 | GNUNET_PSYC_transmit_message (struct GNUNET_PSYC_TransmitHandle *tmit, | ||
147 | const char *method_name, | ||
148 | const struct GNUNET_ENV_Environment *env, | ||
149 | GNUNET_PSYC_TransmitNotifyModifier notify_mod, | ||
150 | GNUNET_PSYC_TransmitNotifyData notify_data, | ||
151 | void *notify_cls, | ||
152 | uint32_t flags); | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Resume transmission. | ||
157 | * | ||
158 | * @param tmit Transmission handle. | ||
159 | */ | ||
160 | void | ||
161 | GNUNET_PSYC_transmit_resume (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Abort transmission request. | ||
166 | * | ||
167 | * @param tmit Transmission handle. | ||
168 | */ | ||
169 | void | ||
170 | GNUNET_PSYC_transmit_cancel (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
171 | |||
172 | |||
173 | /** | ||
174 | * Got acknowledgement of a transmitted message part, continue transmission. | ||
175 | * | ||
176 | * @param tmit Transmission handle. | ||
177 | */ | ||
178 | void | ||
179 | GNUNET_PSYC_transmit_got_ack (struct GNUNET_PSYC_TransmitHandle *tmit); | ||
180 | |||
181 | |||
182 | struct GNUNET_PSYC_ReceiveHandle; | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Create handle for receiving messages. | ||
187 | */ | ||
188 | struct GNUNET_PSYC_ReceiveHandle * | ||
189 | GNUNET_PSYC_receive_create (GNUNET_PSYC_MessageCallback message_cb, | ||
190 | GNUNET_PSYC_MessagePartCallback message_part_cb, | ||
191 | void *cb_cls); | ||
192 | |||
193 | |||
194 | /** | ||
195 | * Destroy handle for receiving messages. | ||
196 | */ | ||
197 | void | ||
198 | GNUNET_PSYC_receive_destroy (struct GNUNET_PSYC_ReceiveHandle *recv); | ||
199 | |||
200 | |||
201 | /** | ||
202 | * Reset stored data related to the last received message. | ||
203 | */ | ||
204 | void | ||
205 | GNUNET_PSYC_receive_reset (struct GNUNET_PSYC_ReceiveHandle *recv); | ||
206 | |||
207 | |||
208 | /** | ||
209 | * Handle incoming PSYC message. | ||
210 | * | ||
211 | * @param recv Receive handle. | ||
212 | * @param msg The message. | ||
213 | * | ||
214 | * @return #GNUNET_OK on success, | ||
215 | * #GNUNET_SYSERR on receive error. | ||
216 | */ | ||
217 | int | ||
218 | GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv, | ||
219 | const struct GNUNET_PSYC_MessageHeader *msg); | ||
220 | 39 | ||
221 | 40 | #include "gnunet_psyc_env.h" | |
222 | /** | 41 | #include "gnunet_psyc_message.h" |
223 | * Check if @a data contains a series of valid message parts. | 42 | #include "gnunet_psyc_slicer.h" |
224 | * | ||
225 | * @param data_size Size of @a data. | ||
226 | * @param data Data. | ||
227 | * @param[out] first_ptype Type of first message part. | ||
228 | * @param[out] last_ptype Type of last message part. | ||
229 | * | ||
230 | * @return Number of message parts found in @a data. | ||
231 | * or GNUNET_SYSERR if the message contains invalid parts. | ||
232 | */ | ||
233 | int | ||
234 | GNUNET_PSYC_receive_check_parts (uint16_t data_size, const char *data, | ||
235 | uint16_t *first_ptype, uint16_t *last_ptype); | ||
236 | |||
237 | |||
238 | /** | ||
239 | * Initialize PSYC message header. | ||
240 | */ | ||
241 | void | ||
242 | GNUNET_PSYC_message_header_init (struct GNUNET_PSYC_MessageHeader *pmsg, | ||
243 | const struct GNUNET_MULTICAST_MessageHeader *mmsg, | ||
244 | uint32_t flags); | ||
245 | |||
246 | |||
247 | /** | ||
248 | * Create a new PSYC message header from a multicast message for sending it to clients. | ||
249 | */ | ||
250 | struct GNUNET_PSYC_MessageHeader * | ||
251 | GNUNET_PSYC_message_header_create (const struct GNUNET_MULTICAST_MessageHeader *mmsg, | ||
252 | uint32_t flags); | ||
253 | |||
254 | |||
255 | /** | ||
256 | * Create a new PSYC message header from a PSYC message. | ||
257 | */ | ||
258 | struct GNUNET_PSYC_MessageHeader * | ||
259 | GNUNET_PSYC_message_header_create_from_psyc (const struct GNUNET_PSYC_Message *msg); | ||
260 | 43 | ||
261 | 44 | ||
262 | #if 0 /* keep Emacsens' auto-indent happy */ | 45 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -268,5 +51,3 @@ GNUNET_PSYC_message_header_create_from_psyc (const struct GNUNET_PSYC_Message *m | |||
268 | 51 | ||
269 | /* ifndef GNUNET_PSYC_UTIL_LIB_H */ | 52 | /* ifndef GNUNET_PSYC_UTIL_LIB_H */ |
270 | #endif | 53 | #endif |
271 | |||
272 | /** @} */ /* end of group */ | ||
diff --git a/src/include/gnunet_psycstore_plugin.h b/src/include/gnunet_psycstore_plugin.h index f1512f1d9..6a0b66f28 100644 --- a/src/include/gnunet_psycstore_plugin.h +++ b/src/include/gnunet_psycstore_plugin.h | |||
@@ -248,7 +248,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions | |||
248 | int | 248 | int |
249 | (*state_modify_op) (void *cls, | 249 | (*state_modify_op) (void *cls, |
250 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 250 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
251 | enum GNUNET_ENV_Operator op, | 251 | enum GNUNET_PSYC_Operator op, |
252 | const char *name, const void *value, size_t value_size); | 252 | const char *name, const void *value, size_t value_size); |
253 | 253 | ||
254 | 254 | ||
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h index aac2955cf..a7f101a36 100644 --- a/src/include/gnunet_psycstore_service.h +++ b/src/include/gnunet_psycstore_service.h | |||
@@ -41,7 +41,7 @@ extern "C" | |||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include "gnunet_util_lib.h" | 43 | #include "gnunet_util_lib.h" |
44 | #include "gnunet_env_lib.h" | 44 | #include "gnunet_psyc_util_lib.h" |
45 | #include "gnunet_multicast_service.h" | 45 | #include "gnunet_multicast_service.h" |
46 | #include "gnunet_psyc_service.h" | 46 | #include "gnunet_psyc_service.h" |
47 | 47 | ||
@@ -546,7 +546,7 @@ GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h, | |||
546 | uint64_t max_state_message_id, | 546 | uint64_t max_state_message_id, |
547 | uint64_t state_hash_message_id, | 547 | uint64_t state_hash_message_id, |
548 | size_t modifier_count, | 548 | size_t modifier_count, |
549 | const struct GNUNET_ENV_Modifier *modifiers, | 549 | const struct GNUNET_PSYC_Modifier *modifiers, |
550 | GNUNET_PSYCSTORE_ResultCallback rcb, | 550 | GNUNET_PSYCSTORE_ResultCallback rcb, |
551 | void *rcb_cls); | 551 | void *rcb_cls); |
552 | 552 | ||
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index 344521c7a..4ad6036a9 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -216,7 +216,7 @@ extern "C" | |||
216 | 216 | ||
217 | #include <stdint.h> | 217 | #include <stdint.h> |
218 | #include "gnunet_util_lib.h" | 218 | #include "gnunet_util_lib.h" |
219 | #include "gnunet_env_lib.h" | 219 | #include "gnunet_psyc_util_lib.h" |
220 | #include "gnunet_identity_service.h" | 220 | #include "gnunet_identity_service.h" |
221 | #include "gnunet_namestore_service.h" | 221 | #include "gnunet_namestore_service.h" |
222 | #include "gnunet_psyc_service.h" | 222 | #include "gnunet_psyc_service.h" |
@@ -263,14 +263,6 @@ struct GNUNET_SOCIAL_Host; | |||
263 | struct GNUNET_SOCIAL_Guest; | 263 | struct GNUNET_SOCIAL_Guest; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * Handle to an implementation of try-and-slice. | ||
267 | */ | ||
268 | struct GNUNET_SOCIAL_Slicer; | ||
269 | |||
270 | |||
271 | |||
272 | |||
273 | /** | ||
274 | * Handle that can be used to reconnect to a place as host. | 266 | * Handle that can be used to reconnect to a place as host. |
275 | */ | 267 | */ |
276 | struct GNUNET_SOCIAL_HostConnection; | 268 | struct GNUNET_SOCIAL_HostConnection; |
@@ -450,239 +442,6 @@ GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym); | |||
450 | 442 | ||
451 | 443 | ||
452 | /** | 444 | /** |
453 | * Function called upon receiving a message indicating a call to a @e method. | ||
454 | * | ||
455 | * This function is called one or more times for each message until all data | ||
456 | * fragments arrive from the network. | ||
457 | * | ||
458 | * @param cls | ||
459 | * Closure. | ||
460 | * @param msg | ||
461 | * Message part, as it arrived from the network. | ||
462 | * @param message_id | ||
463 | * Message counter, monotonically increasing from 1. | ||
464 | * @param nym | ||
465 | * The sender of the message. | ||
466 | * Can be NULL if the message is not connected to a pseudonym. | ||
467 | * @param flags | ||
468 | * OR'ed GNUNET_PSYC_MessageFlags | ||
469 | * @param method_name | ||
470 | * Original method name from PSYC. | ||
471 | * May be more specific than the registered method name due to | ||
472 | * try-and-slice matching. | ||
473 | */ | ||
474 | typedef void | ||
475 | (*GNUNET_SOCIAL_MethodCallback) (void *cls, | ||
476 | const struct GNUNET_PSYC_MessageMethod *msg, | ||
477 | uint64_t message_id, | ||
478 | uint32_t flags, | ||
479 | const struct GNUNET_SOCIAL_Nym *nym, | ||
480 | const char *method_name); | ||
481 | |||
482 | |||
483 | /** | ||
484 | * Function called upon receiving a modifier of a message. | ||
485 | * | ||
486 | * @param cls | ||
487 | * Closure. | ||
488 | * @param message_id | ||
489 | * Message ID this data fragment belongs to. | ||
490 | * @param msg | ||
491 | * Message part, as it arrived from the network. | ||
492 | * @param oper | ||
493 | * Operation to perform. | ||
494 | * 0 in case of a modifier continuation. | ||
495 | * @param name | ||
496 | * Name of the modifier. | ||
497 | * NULL in case of a modifier continuation. | ||
498 | * @param value | ||
499 | * Value of the modifier. | ||
500 | * @param value_size | ||
501 | * Size of @value. | ||
502 | */ | ||
503 | typedef void | ||
504 | (*GNUNET_SOCIAL_ModifierCallback) (void *cls, | ||
505 | const struct GNUNET_MessageHeader *msg, | ||
506 | uint64_t message_id, | ||
507 | enum GNUNET_ENV_Operator oper, | ||
508 | const char *name, | ||
509 | const void *value, | ||
510 | uint16_t value_size, | ||
511 | uint16_t full_value_size); | ||
512 | |||
513 | |||
514 | /** | ||
515 | * Function called upon receiving a data fragment of a message. | ||
516 | * | ||
517 | * @param cls | ||
518 | * Closure. | ||
519 | * @param message_id | ||
520 | * Message ID this data fragment belongs to. | ||
521 | * @param msg | ||
522 | * Message part, as it arrived from the network. | ||
523 | * @param data_offset | ||
524 | * Byte offset of @a data in the overall data of the method. | ||
525 | * @param data_size | ||
526 | * Number of bytes in @a data. | ||
527 | * @param data | ||
528 | * Data stream given to the method. | ||
529 | * @param end | ||
530 | * End of message? | ||
531 | * #GNUNET_NO if there are further fragments, | ||
532 | * #GNUNET_YES if this is the last fragment, | ||
533 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. | ||
534 | */ | ||
535 | typedef void | ||
536 | (*GNUNET_SOCIAL_DataCallback) (void *cls, | ||
537 | const struct GNUNET_MessageHeader *msg, | ||
538 | uint64_t message_id, | ||
539 | uint64_t data_offset, | ||
540 | const void *data, | ||
541 | uint16_t data_size); | ||
542 | |||
543 | |||
544 | /** | ||
545 | * End of message. | ||
546 | * | ||
547 | * @param cls | ||
548 | * Closure. | ||
549 | * @param msg | ||
550 | * Message part, as it arrived from the network. | ||
551 | * @param message_id | ||
552 | * Message ID this data fragment belongs to. | ||
553 | * @param cancelled | ||
554 | * #GNUNET_YES if the message was cancelled, | ||
555 | * #GNUNET_NO if the message is complete. | ||
556 | */ | ||
557 | typedef void | ||
558 | (*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls, | ||
559 | const struct GNUNET_MessageHeader *msg, | ||
560 | uint64_t message_id, | ||
561 | uint8_t cancelled); | ||
562 | |||
563 | |||
564 | /** | ||
565 | * Create a try-and-slice instance. | ||
566 | * | ||
567 | * A slicer processes incoming messages and notifies callbacks about matching | ||
568 | * methods or modifiers encountered. | ||
569 | * | ||
570 | * @return A new try-and-slice construct. | ||
571 | */ | ||
572 | struct GNUNET_SOCIAL_Slicer * | ||
573 | GNUNET_SOCIAL_slicer_create (void); | ||
574 | |||
575 | |||
576 | /** | ||
577 | * Add a method to the try-and-slice instance. | ||
578 | * | ||
579 | * The callbacks are called for messages with a matching @a method_name prefix. | ||
580 | * | ||
581 | * @param slicer | ||
582 | * The try-and-slice instance to extend. | ||
583 | * @param method_name | ||
584 | * Name of the given method, use empty string to match all. | ||
585 | * @param method_cb | ||
586 | * Method handler invoked upon a matching message. | ||
587 | * @param modifier_cb | ||
588 | * Modifier handler, invoked after @a method_cb | ||
589 | * for each modifier in the message. | ||
590 | * @param data_cb | ||
591 | * Data handler, invoked after @a modifier_cb for each data fragment. | ||
592 | * @param eom_cb | ||
593 | * Invoked upon reaching the end of a matching message. | ||
594 | * @param cls | ||
595 | * Closure for the callbacks. | ||
596 | */ | ||
597 | void | ||
598 | GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer, | ||
599 | const char *method_name, | ||
600 | GNUNET_SOCIAL_MethodCallback method_cb, | ||
601 | GNUNET_SOCIAL_ModifierCallback modifier_cb, | ||
602 | GNUNET_SOCIAL_DataCallback data_cb, | ||
603 | GNUNET_SOCIAL_EndOfMessageCallback eom_cb, | ||
604 | void *cls); | ||
605 | |||
606 | /** | ||
607 | * Remove a registered method from the try-and-slice instance. | ||
608 | * | ||
609 | * Removes one matching handler registered with the given | ||
610 | * @a method_name and callbacks. | ||
611 | * | ||
612 | * @param slicer | ||
613 | * The try-and-slice instance. | ||
614 | * @param method_name | ||
615 | * Name of the method to remove. | ||
616 | * @param method_cb | ||
617 | * Method handler. | ||
618 | * @param modifier_cb | ||
619 | * Modifier handler. | ||
620 | * @param data_cb | ||
621 | * Data handler. | ||
622 | * @param eom_cb | ||
623 | * End of message handler. | ||
624 | * | ||
625 | * @return #GNUNET_OK if a method handler was removed, | ||
626 | * #GNUNET_NO if no handler matched the given method name and callbacks. | ||
627 | */ | ||
628 | int | ||
629 | GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer, | ||
630 | const char *method_name, | ||
631 | GNUNET_SOCIAL_MethodCallback method_cb, | ||
632 | GNUNET_SOCIAL_ModifierCallback modifier_cb, | ||
633 | GNUNET_SOCIAL_DataCallback data_cb, | ||
634 | GNUNET_SOCIAL_EndOfMessageCallback eom_cb); | ||
635 | |||
636 | |||
637 | /** | ||
638 | * Watch a place for changed objects. | ||
639 | * | ||
640 | * @param slicer | ||
641 | * The try-and-slice instance. | ||
642 | * @param object_filter | ||
643 | * Object prefix to match. | ||
644 | * @param modifier_cb | ||
645 | * Function to call when encountering a state modifier. | ||
646 | * @param cls | ||
647 | * Closure for callback. | ||
648 | */ | ||
649 | void | ||
650 | GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer, | ||
651 | const char *object_filter, | ||
652 | GNUNET_SOCIAL_ModifierCallback modifier_cb, | ||
653 | void *cls); | ||
654 | |||
655 | |||
656 | /** | ||
657 | * Remove a registered modifier from the try-and-slice instance. | ||
658 | * | ||
659 | * Removes one matching handler registered with the given | ||
660 | * @a object_filter and callback. | ||
661 | * | ||
662 | * @param slicer | ||
663 | * The try-and-slice instance. | ||
664 | * @param object_filter | ||
665 | * Object prefix to match. | ||
666 | * @param modifier_cb | ||
667 | * Function to call when encountering a state modifier changes. | ||
668 | */ | ||
669 | int | ||
670 | GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer, | ||
671 | const char *object_filter, | ||
672 | GNUNET_SOCIAL_ModifierCallback modifier_cb); | ||
673 | |||
674 | |||
675 | /** | ||
676 | * Destroy a given try-and-slice instance. | ||
677 | * | ||
678 | * @param slicer | ||
679 | * Slicer to destroy | ||
680 | */ | ||
681 | void | ||
682 | GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer); | ||
683 | |||
684 | |||
685 | /** | ||
686 | * Function called asking for nym to be admitted to the place. | 445 | * Function called asking for nym to be admitted to the place. |
687 | * | 446 | * |
688 | * Should call either GNUNET_SOCIAL_host_admit() or | 447 | * Should call either GNUNET_SOCIAL_host_admit() or |
@@ -704,7 +463,7 @@ typedef void | |||
704 | (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls, | 463 | (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls, |
705 | struct GNUNET_SOCIAL_Nym *nym, | 464 | struct GNUNET_SOCIAL_Nym *nym, |
706 | const char *method_name, | 465 | const char *method_name, |
707 | struct GNUNET_ENV_Environment *env, | 466 | struct GNUNET_PSYC_Environment *env, |
708 | size_t data_size, | 467 | size_t data_size, |
709 | const void *data); | 468 | const void *data); |
710 | 469 | ||
@@ -723,7 +482,7 @@ typedef void | |||
723 | typedef void | 482 | typedef void |
724 | (*GNUNET_SOCIAL_FarewellCallback) (void *cls, | 483 | (*GNUNET_SOCIAL_FarewellCallback) (void *cls, |
725 | const struct GNUNET_SOCIAL_Nym *nym, | 484 | const struct GNUNET_SOCIAL_Nym *nym, |
726 | struct GNUNET_ENV_Environment *env); | 485 | struct GNUNET_PSYC_Environment *env); |
727 | 486 | ||
728 | 487 | ||
729 | /** | 488 | /** |
@@ -778,7 +537,7 @@ struct GNUNET_SOCIAL_Host * | |||
778 | GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, | 537 | GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, |
779 | const struct GNUNET_SOCIAL_Ego *ego, | 538 | const struct GNUNET_SOCIAL_Ego *ego, |
780 | enum GNUNET_PSYC_Policy policy, | 539 | enum GNUNET_PSYC_Policy policy, |
781 | struct GNUNET_SOCIAL_Slicer *slicer, | 540 | struct GNUNET_PSYC_Slicer *slicer, |
782 | GNUNET_SOCIAL_HostEnterCallback enter_cb, | 541 | GNUNET_SOCIAL_HostEnterCallback enter_cb, |
783 | GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, | 542 | GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, |
784 | GNUNET_SOCIAL_FarewellCallback farewell_cb, | 543 | GNUNET_SOCIAL_FarewellCallback farewell_cb, |
@@ -806,7 +565,7 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, | |||
806 | */ | 565 | */ |
807 | struct GNUNET_SOCIAL_Host * | 566 | struct GNUNET_SOCIAL_Host * |
808 | GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, | 567 | GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, |
809 | struct GNUNET_SOCIAL_Slicer *slicer, | 568 | struct GNUNET_PSYC_Slicer *slicer, |
810 | GNUNET_SOCIAL_HostEnterCallback enter_cb, | 569 | GNUNET_SOCIAL_HostEnterCallback enter_cb, |
811 | GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, | 570 | GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, |
812 | GNUNET_SOCIAL_FarewellCallback farewell_cb, | 571 | GNUNET_SOCIAL_FarewellCallback farewell_cb, |
@@ -862,7 +621,7 @@ GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst, | |||
862 | void | 621 | void |
863 | GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, | 622 | GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, |
864 | const struct GNUNET_SOCIAL_Nym *nym, | 623 | const struct GNUNET_SOCIAL_Nym *nym, |
865 | struct GNUNET_ENV_Environment *env); | 624 | struct GNUNET_PSYC_Environment *env); |
866 | 625 | ||
867 | 626 | ||
868 | /** | 627 | /** |
@@ -915,7 +674,7 @@ struct GNUNET_SOCIAL_Announcement; | |||
915 | struct GNUNET_SOCIAL_Announcement * | 674 | struct GNUNET_SOCIAL_Announcement * |
916 | GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, | 675 | GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, |
917 | const char *method_name, | 676 | const char *method_name, |
918 | const struct GNUNET_ENV_Environment *env, | 677 | const struct GNUNET_PSYC_Environment *env, |
919 | GNUNET_PSYC_TransmitNotifyData notify_data, | 678 | GNUNET_PSYC_TransmitNotifyData notify_data, |
920 | void *notify_data_cls, | 679 | void *notify_data_cls, |
921 | enum GNUNET_SOCIAL_AnnounceFlags flags); | 680 | enum GNUNET_SOCIAL_AnnounceFlags flags); |
@@ -1032,7 +791,7 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, | |||
1032 | */ | 791 | */ |
1033 | void | 792 | void |
1034 | GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, | 793 | GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, |
1035 | const struct GNUNET_ENV_Environment *env, | 794 | const struct GNUNET_PSYC_Environment *env, |
1036 | GNUNET_ContinuationCallback disconnect_cb, | 795 | GNUNET_ContinuationCallback disconnect_cb, |
1037 | void *cls); | 796 | void *cls); |
1038 | 797 | ||
@@ -1062,22 +821,12 @@ typedef void | |||
1062 | * Function called upon a guest receives a decision about entry to the place. | 821 | * Function called upon a guest receives a decision about entry to the place. |
1063 | * | 822 | * |
1064 | * @param is_admitted | 823 | * @param is_admitted |
1065 | * Is the guest admitted to the place? | 824 | * Is the guest admitted to the place? |
1066 | * #GNUNET_YES if admitted, | 825 | * #GNUNET_YES if admitted, |
1067 | * #GNUNET_NO if refused entry | 826 | * #GNUNET_NO if refused entry, |
1068 | * #GNUNET_SYSERR if the request could not be answered. | 827 | * #GNUNET_SYSERR if the request could not be answered. |
1069 | * @param method_name | ||
1070 | * Method for the message sent along with the decision. | ||
1071 | * NULL if no message was sent. | ||
1072 | * @param env | ||
1073 | * Environment with variables for the message. | ||
1074 | * NULL if there are no variables. | ||
1075 | * It has to be freed using GNUNET_ENV_environment_destroy() | ||
1076 | * when it is not needed anymore. | ||
1077 | * @param data_size | ||
1078 | * Size of @data. | ||
1079 | * @param data | 828 | * @param data |
1080 | * Payload of the message. | 829 | * Entry response message. |
1081 | */ | 830 | */ |
1082 | typedef void | 831 | typedef void |
1083 | (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, | 832 | (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, |
@@ -1124,7 +873,7 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, | |||
1124 | uint32_t relay_count, | 873 | uint32_t relay_count, |
1125 | const struct GNUNET_PeerIdentity *relays, | 874 | const struct GNUNET_PeerIdentity *relays, |
1126 | const struct GNUNET_PSYC_Message *entry_msg, | 875 | const struct GNUNET_PSYC_Message *entry_msg, |
1127 | struct GNUNET_SOCIAL_Slicer *slicer, | 876 | struct GNUNET_PSYC_Slicer *slicer, |
1128 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 877 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
1129 | GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, | 878 | GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, |
1130 | void *cls); | 879 | void *cls); |
@@ -1162,7 +911,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
1162 | const char *gns_name, | 911 | const char *gns_name, |
1163 | const char *password, | 912 | const char *password, |
1164 | const struct GNUNET_PSYC_Message *join_msg, | 913 | const struct GNUNET_PSYC_Message *join_msg, |
1165 | struct GNUNET_SOCIAL_Slicer *slicer, | 914 | struct GNUNET_PSYC_Slicer *slicer, |
1166 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 915 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
1167 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, | 916 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, |
1168 | void *cls); | 917 | void *cls); |
@@ -1188,7 +937,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, | |||
1188 | struct GNUNET_SOCIAL_Guest * | 937 | struct GNUNET_SOCIAL_Guest * |
1189 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, | 938 | GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, |
1190 | enum GNUNET_PSYC_SlaveJoinFlags flags, | 939 | enum GNUNET_PSYC_SlaveJoinFlags flags, |
1191 | struct GNUNET_SOCIAL_Slicer *slicer, | 940 | struct GNUNET_PSYC_Slicer *slicer, |
1192 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | 941 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
1193 | void *cls); | 942 | void *cls); |
1194 | 943 | ||
@@ -1230,7 +979,7 @@ struct GNUNET_SOCIAL_TalkRequest; | |||
1230 | struct GNUNET_SOCIAL_TalkRequest * | 979 | struct GNUNET_SOCIAL_TalkRequest * |
1231 | GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, | 980 | GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, |
1232 | const char *method_name, | 981 | const char *method_name, |
1233 | const struct GNUNET_ENV_Environment *env, | 982 | const struct GNUNET_PSYC_Environment *env, |
1234 | GNUNET_PSYC_TransmitNotifyData notify_data, | 983 | GNUNET_PSYC_TransmitNotifyData notify_data, |
1235 | void *notify_data_cls, | 984 | void *notify_data_cls, |
1236 | enum GNUNET_SOCIAL_TalkFlags flags); | 985 | enum GNUNET_SOCIAL_TalkFlags flags); |
@@ -1289,7 +1038,7 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, | |||
1289 | */ | 1038 | */ |
1290 | void | 1039 | void |
1291 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, | 1040 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, |
1292 | struct GNUNET_ENV_Environment *env, | 1041 | struct GNUNET_PSYC_Environment *env, |
1293 | GNUNET_ContinuationCallback disconnect_cb, | 1042 | GNUNET_ContinuationCallback disconnect_cb, |
1294 | void *leave_cls); | 1043 | void *leave_cls); |
1295 | 1044 | ||
@@ -1343,7 +1092,7 @@ GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc, | |||
1343 | uint64_t end_message_id, | 1092 | uint64_t end_message_id, |
1344 | const char *method_prefix, | 1093 | const char *method_prefix, |
1345 | uint32_t flags, | 1094 | uint32_t flags, |
1346 | struct GNUNET_SOCIAL_Slicer *slicer, | 1095 | struct GNUNET_PSYC_Slicer *slicer, |
1347 | GNUNET_ResultCallback result_cb, | 1096 | GNUNET_ResultCallback result_cb, |
1348 | void *cls); | 1097 | void *cls); |
1349 | 1098 | ||
@@ -1371,7 +1120,7 @@ GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc, | |||
1371 | uint64_t message_limit, | 1120 | uint64_t message_limit, |
1372 | const char *method_prefix, | 1121 | const char *method_prefix, |
1373 | uint32_t flags, | 1122 | uint32_t flags, |
1374 | struct GNUNET_SOCIAL_Slicer *slicer, | 1123 | struct GNUNET_PSYC_Slicer *slicer, |
1375 | GNUNET_ResultCallback result_cb, | 1124 | GNUNET_ResultCallback result_cb, |
1376 | void *cls); | 1125 | void *cls); |
1377 | 1126 | ||
@@ -1524,4 +1273,4 @@ GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app, | |||
1524 | /* ifndef GNUNET_SOCIAL_SERVICE_H */ | 1273 | /* ifndef GNUNET_SOCIAL_SERVICE_H */ |
1525 | #endif | 1274 | #endif |
1526 | 1275 | ||
1527 | /** @} */ /* end of group social */ | 1276 | /** @} */ /* end of group */ |