aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
committerGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
commit50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea (patch)
treea8023bdb9c9446a45792d7100303265c78713a50 /src
parent3cbdbe18dbd56def00c0014381ff90b4ee664904 (diff)
downloadgnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.tar.gz
gnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.zip
psycutil reorg: message, env, slicer
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/include/Makefile.am4
-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.h273
-rw-r--r--src/include/gnunet_psyc_service.h47
-rw-r--r--src/include/gnunet_psyc_slicer.h319
-rw-r--r--src/include/gnunet_psyc_util_lib.h227
-rw-r--r--src/include/gnunet_psycstore_plugin.h2
-rw-r--r--src/include/gnunet_psycstore_service.h4
-rw-r--r--src/include/gnunet_social_service.h293
-rw-r--r--src/psyc/Makefile.am8
-rw-r--r--src/psyc/gnunet-service-psyc.c2
-rw-r--r--src/psyc/psyc_api.c1
-rw-r--r--src/psyc/test_psyc.c37
-rw-r--r--src/psycstore/Makefile.am14
-rw-r--r--src/psycstore/gnunet-service-psycstore.c4
-rw-r--r--src/psycstore/plugin_psycstore_sqlite.c6
-rw-r--r--src/psycstore/psycstore_api.c2
-rw-r--r--src/psycstore/test_plugin_psycstore.c13
-rw-r--r--src/psycstore/test_psycstore.c6
-rw-r--r--src/psycutil/Makefile.am (renamed from src/env/Makefile.am)22
-rw-r--r--src/psycutil/psyc_env.c (renamed from src/env/env.c)57
-rw-r--r--src/psycutil/psyc_message.c (renamed from src/psycstore/psyc_util_lib.c)31
-rw-r--r--src/psycutil/psyc_slicer.c610
-rw-r--r--src/psycutil/test_psyc_env.c (renamed from src/env/test_env.c)35
-rw-r--r--src/social/Makefile.am8
-rw-r--r--src/social/gnunet-service-social.c6
-rw-r--r--src/social/social.h32
-rw-r--r--src/social/social_api.c690
-rw-r--r--src/social/test_social.c127
30 files changed, 1563 insertions, 1413 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6e0fa5c4b..925d395aa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@ if HAVE_EXPERIMENTAL
16 EXP_DIR = \ 16 EXP_DIR = \
17 dv \ 17 dv \
18 multicast \ 18 multicast \
19 env \ 19 psycutil \
20 psycstore \ 20 psycstore \
21 psyc \ 21 psyc \
22 rps \ 22 rps \
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
41extern "C" 41extern "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 */
52enum GNUNET_ENV_Operator 52enum 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 */
92enum GNUNET_ENV_Type 92enum 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 */
104struct GNUNET_ENV_Modifier 104struct 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 */
143struct GNUNET_ENV_Environment; 143struct 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 */
151struct GNUNET_ENV_Environment * 151struct GNUNET_PSYC_Environment *
152GNUNET_ENV_environment_create (); 152GNUNET_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 */
164void 164void
165GNUNET_ENV_environment_add (struct GNUNET_ENV_Environment *env, 165GNUNET_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 */
173struct GNUNET_ENV_Modifier * 173struct GNUNET_PSYC_Modifier *
174GNUNET_ENV_environment_head (const struct GNUNET_ENV_Environment *env); 174GNUNET_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 */
181struct GNUNET_ENV_Modifier * 181struct GNUNET_PSYC_Modifier *
182GNUNET_ENV_environment_tail (const struct GNUNET_ENV_Environment *env); 182GNUNET_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 */
188void 188void
189GNUNET_ENV_environment_remove (struct GNUNET_ENV_Environment *env, 189GNUNET_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 */
196int 196int
197GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env, 197GNUNET_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 */
211typedef int 211typedef 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 */
224void 224void
225GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env, 225GNUNET_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 */
236size_t 236size_t
237GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env); 237GNUNET_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 */
245void 245void
246GNUNET_ENV_environment_destroy (struct GNUNET_ENV_Environment *env); 246GNUNET_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 */
256enum GNUNET_ENV_Type 256enum GNUNET_PSYC_Type
257GNUNET_ENV_var_get_type (char *name); 257GNUNET_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 */
274int 274int
275GNUNET_ENV_operation (char *name, void *current_value, size_t current_value_size, 275GNUNET_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 */
289int 289int
290GNUNET_ENV_value_to_number (size_t size, const void *value, int64_t *number); 290GNUNET_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 */
302int 302int
303GNUNET_ENV_value_to_dict (size_t size, const void *value, struct GNUNET_CONTAINER_MultiHashMap **dict); 303GNUNET_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 */
314void * 314void *
315GNUNET_ENV_value_from_number (int64_t number, size_t *value_size); 315GNUNET_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 */
326void * 326void *
327GNUNET_ENV_value_from_dict (struct GNUNET_CONTAINER_MultiHashMap *dict, size_t *value_size); 327GNUNET_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
36extern "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 */
64struct GNUNET_PSYC_Message *
65GNUNET_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 */
87int
88GNUNET_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
95void
96GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind,
97 const struct GNUNET_MessageHeader *msg);
98
99
100int
101GNUNET_PSYC_check_message_parts (uint16_t data_size, const char *data,
102 uint16_t *first_ptype, uint16_t *last_ptype);
103
104
105struct GNUNET_PSYC_TransmitHandle;
106
107/**
108 * Create a transmission handle.
109 */
110struct GNUNET_PSYC_TransmitHandle *
111GNUNET_PSYC_transmit_create ();
112
113
114/**
115 * Destroy a transmission handle.
116 */
117void
118GNUNET_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 */
146int
147GNUNET_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 */
161void
162GNUNET_PSYC_transmit_resume (struct GNUNET_PSYC_TransmitHandle *tmit);
163
164
165/**
166 * Abort transmission request.
167 *
168 * @param tmit Transmission handle.
169 */
170void
171GNUNET_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 */
179void
180GNUNET_PSYC_transmit_got_ack (struct GNUNET_PSYC_TransmitHandle *tmit);
181
182
183struct GNUNET_PSYC_ReceiveHandle;
184
185
186/**
187 * Create handle for receiving messages.
188 */
189struct GNUNET_PSYC_ReceiveHandle *
190GNUNET_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 */
198void
199GNUNET_PSYC_receive_destroy (struct GNUNET_PSYC_ReceiveHandle *recv);
200
201
202/**
203 * Reset stored data related to the last received message.
204 */
205void
206GNUNET_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 */
218int
219GNUNET_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 */
234int
235GNUNET_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 */
242void
243GNUNET_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 */
251struct GNUNET_PSYC_MessageHeader *
252GNUNET_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 */
259struct GNUNET_PSYC_MessageHeader *
260GNUNET_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 */
944struct GNUNET_PSYC_Slave * 951struct GNUNET_PSYC_Slave *
945GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 952GNUNET_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
38extern "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 */
51struct 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 */
76typedef 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 */
105typedef 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 */
137typedef 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 */
159typedef 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 */
174struct GNUNET_PSYC_Slicer *
175GNUNET_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 */
199void
200GNUNET_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 */
230int
231GNUNET_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 */
251void
252GNUNET_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 */
271int
272GNUNET_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 */
290void
291GNUNET_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 */
305void
306GNUNET_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 */
63struct GNUNET_PSYC_Message *
64GNUNET_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 */
86int
87GNUNET_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
94void
95GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind,
96 const struct GNUNET_MessageHeader *msg);
97
98
99int
100GNUNET_PSYC_check_message_parts (uint16_t data_size, const char *data,
101 uint16_t *first_ptype, uint16_t *last_ptype);
102
103
104struct GNUNET_PSYC_TransmitHandle;
105
106/**
107 * Create a transmission handle.
108 */
109struct GNUNET_PSYC_TransmitHandle *
110GNUNET_PSYC_transmit_create ();
111
112
113/**
114 * Destroy a transmission handle.
115 */
116void
117GNUNET_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 */
145int
146GNUNET_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 */
160void
161GNUNET_PSYC_transmit_resume (struct GNUNET_PSYC_TransmitHandle *tmit);
162
163
164/**
165 * Abort transmission request.
166 *
167 * @param tmit Transmission handle.
168 */
169void
170GNUNET_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 */
178void
179GNUNET_PSYC_transmit_got_ack (struct GNUNET_PSYC_TransmitHandle *tmit);
180
181
182struct GNUNET_PSYC_ReceiveHandle;
183
184
185/**
186 * Create handle for receiving messages.
187 */
188struct GNUNET_PSYC_ReceiveHandle *
189GNUNET_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 */
197void
198GNUNET_PSYC_receive_destroy (struct GNUNET_PSYC_ReceiveHandle *recv);
199
200
201/**
202 * Reset stored data related to the last received message.
203 */
204void
205GNUNET_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 */
217int
218GNUNET_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 */
233int
234GNUNET_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 */
241void
242GNUNET_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 */
250struct GNUNET_PSYC_MessageHeader *
251GNUNET_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 */
258struct GNUNET_PSYC_MessageHeader *
259GNUNET_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;
263struct GNUNET_SOCIAL_Guest; 263struct GNUNET_SOCIAL_Guest;
264 264
265/** 265/**
266 * Handle to an implementation of try-and-slice.
267 */
268struct 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 */
276struct GNUNET_SOCIAL_HostConnection; 268struct 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 */
474typedef 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 */
503typedef 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 */
535typedef 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 */
557typedef 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 */
572struct GNUNET_SOCIAL_Slicer *
573GNUNET_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 */
597void
598GNUNET_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 */
628int
629GNUNET_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 */
649void
650GNUNET_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 */
669int
670GNUNET_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 */
681void
682GNUNET_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
723typedef void 482typedef 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 *
778GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, 537GNUNET_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 */
807struct GNUNET_SOCIAL_Host * 566struct GNUNET_SOCIAL_Host *
808GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, 567GNUNET_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,
862void 621void
863GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, 622GNUNET_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;
915struct GNUNET_SOCIAL_Announcement * 674struct GNUNET_SOCIAL_Announcement *
916GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, 675GNUNET_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 */
1033void 792void
1034GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, 793GNUNET_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 */
1082typedef void 831typedef 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,
1188struct GNUNET_SOCIAL_Guest * 937struct GNUNET_SOCIAL_Guest *
1189GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, 938GNUNET_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;
1230struct GNUNET_SOCIAL_TalkRequest * 979struct GNUNET_SOCIAL_TalkRequest *
1231GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, 980GNUNET_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 */
1290void 1039void
1291GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, 1040GNUNET_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 */
diff --git a/src/psyc/Makefile.am b/src/psyc/Makefile.am
index 4bb28ce0a..e00537e73 100644
--- a/src/psyc/Makefile.am
+++ b/src/psyc/Makefile.am
@@ -24,8 +24,7 @@ libgnunetpsyc_la_SOURCES = \
24 psyc_api.c psyc.h 24 psyc_api.c psyc.h
25libgnunetpsyc_la_LIBADD = \ 25libgnunetpsyc_la_LIBADD = \
26 $(top_builddir)/src/util/libgnunetutil.la \ 26 $(top_builddir)/src/util/libgnunetutil.la \
27 $(top_builddir)/src/env/libgnunetenv.la \ 27 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
28 $(top_builddir)/src/psycstore/libgnunetpsycutil.la \
29 $(GN_LIBINTL) $(XLIB) 28 $(GN_LIBINTL) $(XLIB)
30libgnunetpsyc_la_LDFLAGS = \ 29libgnunetpsyc_la_LDFLAGS = \
31 $(GN_LIB_LDFLAGS) $(WINFLAGS) \ 30 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
@@ -43,7 +42,7 @@ gnunet_service_psyc_LDADD = \
43 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 42 $(top_builddir)/src/statistics/libgnunetstatistics.la \
44 $(top_builddir)/src/multicast/libgnunetmulticast.la \ 43 $(top_builddir)/src/multicast/libgnunetmulticast.la \
45 $(top_builddir)/src/psycstore/libgnunetpsycstore.la \ 44 $(top_builddir)/src/psycstore/libgnunetpsycstore.la \
46 $(top_builddir)/src/psycstore/libgnunetpsycutil.la \ 45 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
47 $(GN_LIBINTL) 46 $(GN_LIBINTL)
48gnunet_service_psyc_CFLAGS = $(AM_CFLAGS) 47gnunet_service_psyc_CFLAGS = $(AM_CFLAGS)
49 48
@@ -62,10 +61,9 @@ test_psyc_SOURCES = \
62 test_psyc.c 61 test_psyc.c
63test_psyc_LDADD = \ 62test_psyc_LDADD = \
64 libgnunetpsyc.la \ 63 libgnunetpsyc.la \
65 $(top_builddir)/src/psycstore/libgnunetpsycutil.la \ 64 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
66 $(top_builddir)/src/testing/libgnunettesting.la \ 65 $(top_builddir)/src/testing/libgnunettesting.la \
67 $(top_builddir)/src/core/libgnunetcore.la \ 66 $(top_builddir)/src/core/libgnunetcore.la \
68 $(top_builddir)/src/env/libgnunetenv.la \
69 $(top_builddir)/src/util/libgnunetutil.la 67 $(top_builddir)/src/util/libgnunetutil.la
70 68
71EXTRA_DIST = \ 69EXTRA_DIST = \
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c
index e9727c485..827f3d79b 100644
--- a/src/psyc/gnunet-service-psyc.c
+++ b/src/psyc/gnunet-service-psyc.c
@@ -2477,7 +2477,7 @@ store_recv_state_var (void *cls, const char *name,
2477 mod->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER); 2477 mod->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER);
2478 mod->name_size = htons (name_size); 2478 mod->name_size = htons (name_size);
2479 mod->value_size = htonl (value_size); 2479 mod->value_size = htonl (value_size);
2480 mod->oper = htons (GNUNET_ENV_OP_ASSIGN); 2480 mod->oper = htons (GNUNET_PSYC_OP_ASSIGN);
2481 memcpy (&mod[1], name, name_size); 2481 memcpy (&mod[1], name, name_size);
2482 memcpy (((char *) &mod[1]) + name_size, value, value_size); 2482 memcpy (((char *) &mod[1]) + name_size, value, value_size);
2483 } 2483 }
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c
index 8152fc47f..c9d74f3c8 100644
--- a/src/psyc/psyc_api.c
+++ b/src/psyc/psyc_api.c
@@ -34,7 +34,6 @@
34 34
35#include "platform.h" 35#include "platform.h"
36#include "gnunet_util_lib.h" 36#include "gnunet_util_lib.h"
37#include "gnunet_env_lib.h"
38#include "gnunet_multicast_service.h" 37#include "gnunet_multicast_service.h"
39#include "gnunet_psyc_service.h" 38#include "gnunet_psyc_service.h"
40#include "gnunet_psyc_util_lib.h" 39#include "gnunet_psyc_util_lib.h"
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c
index f167e2697..74e27a48f 100644
--- a/src/psyc/test_psyc.c
+++ b/src/psyc/test_psyc.c
@@ -32,7 +32,6 @@
32#include "gnunet_common.h" 32#include "gnunet_common.h"
33#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
34#include "gnunet_testing_lib.h" 34#include "gnunet_testing_lib.h"
35#include "gnunet_env_lib.h"
36#include "gnunet_psyc_util_lib.h" 35#include "gnunet_psyc_util_lib.h"
37#include "gnunet_psyc_service.h" 36#include "gnunet_psyc_service.h"
38#include "gnunet_core_service.h" 37#include "gnunet_core_service.h"
@@ -69,8 +68,8 @@ struct TransmitClosure
69{ 68{
70 struct GNUNET_PSYC_MasterTransmitHandle *mst_tmit; 69 struct GNUNET_PSYC_MasterTransmitHandle *mst_tmit;
71 struct GNUNET_PSYC_SlaveTransmitHandle *slv_tmit; 70 struct GNUNET_PSYC_SlaveTransmitHandle *slv_tmit;
72 struct GNUNET_ENV_Environment *env; 71 struct GNUNET_PSYC_Environment *env;
73 struct GNUNET_ENV_Modifier *mod; 72 struct GNUNET_PSYC_Modifier *mod;
74 char *data[16]; 73 char *data[16];
75 const char *mod_value; 74 const char *mod_value;
76 size_t mod_value_size; 75 size_t mod_value_size;
@@ -116,7 +115,7 @@ void master_stopped (void *cls)
116{ 115{
117 if (NULL != tmit) 116 if (NULL != tmit)
118 { 117 {
119 GNUNET_ENV_environment_destroy (tmit->env); 118 GNUNET_PSYC_env_destroy (tmit->env);
120 GNUNET_free (tmit); 119 GNUNET_free (tmit);
121 tmit = NULL; 120 tmit = NULL;
122 } 121 }
@@ -617,7 +616,7 @@ tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper,
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
618 "Test #%d: Transmit notify modifier: %lu bytes available, " 617 "Test #%d: Transmit notify modifier: %lu bytes available, "
619 "%u modifiers left to process.\n", 618 "%u modifiers left to process.\n",
620 test, *data_size, GNUNET_ENV_environment_get_count (tmit->env)); 619 test, *data_size, GNUNET_PSYC_env_get_count (tmit->env));
621 620
622 uint16_t name_size = 0; 621 uint16_t name_size = 0;
623 size_t value_size = 0; 622 size_t value_size = 0;
@@ -697,12 +696,12 @@ slave_transmit ()
697 "Test #%d: Slave sending request to master.\n", test); 696 "Test #%d: Slave sending request to master.\n", test);
698 697
699 tmit = GNUNET_new (struct TransmitClosure); 698 tmit = GNUNET_new (struct TransmitClosure);
700 tmit->env = GNUNET_ENV_environment_create (); 699 tmit->env = GNUNET_PSYC_env_create ();
701 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 700 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
702 "_abc", "abc def", 7); 701 "_abc", "abc def", 7);
703 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 702 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
704 "_abc_def", "abc def ghi", 11); 703 "_abc_def", "abc def ghi", 11);
705 tmit->mod = GNUNET_ENV_environment_head (tmit->env); 704 tmit->mod = GNUNET_PSYC_env_head (tmit->env);
706 tmit->n = 0; 705 tmit->n = 0;
707 tmit->data[0] = "slave test"; 706 tmit->data[0] = "slave test";
708 tmit->data_count = 1; 707 tmit->data_count = 1;
@@ -835,10 +834,10 @@ slave_join (int t)
835 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%d: Joining slave.\n"); 834 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%d: Joining slave.\n");
836 835
837 struct GNUNET_PeerIdentity origin = this_peer; 836 struct GNUNET_PeerIdentity origin = this_peer;
838 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 837 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
839 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, 838 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN,
840 "_foo", "bar baz", 7); 839 "_foo", "bar baz", 7);
841 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, 840 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN,
842 "_foo_bar", "foo bar baz", 11); 841 "_foo_bar", "foo bar baz", 11);
843 struct GNUNET_PSYC_Message * 842 struct GNUNET_PSYC_Message *
844 join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); 843 join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9);
@@ -851,7 +850,7 @@ slave_join (int t)
851 join_msg); 850 join_msg);
852 GNUNET_free (join_msg); 851 GNUNET_free (join_msg);
853 slv_chn = GNUNET_PSYC_slave_get_channel (slv); 852 slv_chn = GNUNET_PSYC_slave_get_channel (slv);
854 GNUNET_ENV_environment_destroy (env); 853 GNUNET_PSYC_env_destroy (env);
855} 854}
856 855
857 856
@@ -881,20 +880,20 @@ master_transmit ()
881 val_cont[i] = (0 == j % 10000) ? '0' + j / 10000 : '!'; 880 val_cont[i] = (0 == j % 10000) ? '0' + j / 10000 : '!';
882 881
883 tmit = GNUNET_new (struct TransmitClosure); 882 tmit = GNUNET_new (struct TransmitClosure);
884 tmit->env = GNUNET_ENV_environment_create (); 883 tmit->env = GNUNET_PSYC_env_create ();
885 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 884 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
886 "_foo", "bar baz", 7); 885 "_foo", "bar baz", 7);
887 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 886 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
888 name_max, val_max, 887 name_max, val_max,
889 GNUNET_PSYC_MODIFIER_MAX_PAYLOAD 888 GNUNET_PSYC_MODIFIER_MAX_PAYLOAD
890 - name_max_size); 889 - name_max_size);
891 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 890 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
892 "_foo_bar", "foo bar baz", 11); 891 "_foo_bar", "foo bar baz", 11);
893 GNUNET_ENV_environment_add (tmit->env, GNUNET_ENV_OP_ASSIGN, 892 GNUNET_PSYC_env_add (tmit->env, GNUNET_PSYC_OP_ASSIGN,
894 name_cont, val_cont, 893 name_cont, val_cont,
895 GNUNET_PSYC_MODIFIER_MAX_PAYLOAD - name_cont_size 894 GNUNET_PSYC_MODIFIER_MAX_PAYLOAD - name_cont_size
896 + GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD); 895 + GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD);
897 tmit->mod = GNUNET_ENV_environment_head (tmit->env); 896 tmit->mod = GNUNET_PSYC_env_head (tmit->env);
898 tmit->data[0] = "foo"; 897 tmit->data[0] = "foo";
899 tmit->data[1] = GNUNET_malloc (GNUNET_PSYC_DATA_MAX_PAYLOAD + 1); 898 tmit->data[1] = GNUNET_malloc (GNUNET_PSYC_DATA_MAX_PAYLOAD + 1);
900 for (i = 0; i < GNUNET_PSYC_DATA_MAX_PAYLOAD; i++) 899 for (i = 0; i < GNUNET_PSYC_DATA_MAX_PAYLOAD; i++)
diff --git a/src/psycstore/Makefile.am b/src/psycstore/Makefile.am
index 639c53262..a527837de 100644
--- a/src/psycstore/Makefile.am
+++ b/src/psycstore/Makefile.am
@@ -27,17 +27,7 @@ SQLITE_TESTS = test_plugin_psycstore_sqlite
27endif 27endif
28endif 28endif
29 29
30lib_LTLIBRARIES = libgnunetpsycutil.la libgnunetpsycstore.la 30lib_LTLIBRARIES = libgnunetpsycstore.la
31
32libgnunetpsycutil_la_SOURCES = \
33 psyc_util_lib.c
34libgnunetpsycutil_la_LIBADD = \
35 $(top_builddir)/src/util/libgnunetutil.la \
36 $(top_builddir)/src/env/libgnunetenv.la \
37 $(GN_LIBINTL) $(XLIB)
38libgnunetpsycutil_la_LDFLAGS = \
39 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
40 -version-info 0:0:0
41 31
42libgnunetpsycstore_la_SOURCES = \ 32libgnunetpsycstore_la_SOURCES = \
43 psycstore_api.c \ 33 psycstore_api.c \
@@ -59,7 +49,7 @@ gnunet_service_psycstore_SOURCES = \
59gnunet_service_psycstore_LDADD = \ 49gnunet_service_psycstore_LDADD = \
60 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 50 $(top_builddir)/src/statistics/libgnunetstatistics.la \
61 $(top_builddir)/src/util/libgnunetutil.la \ 51 $(top_builddir)/src/util/libgnunetutil.la \
62 libgnunetpsycutil.la \ 52 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
63 $(GN_LIBINTL) 53 $(GN_LIBINTL)
64 54
65plugin_LTLIBRARIES = \ 55plugin_LTLIBRARIES = \
diff --git a/src/psycstore/gnunet-service-psycstore.c b/src/psycstore/gnunet-service-psycstore.c
index 53e593455..2bcc87b24 100644
--- a/src/psycstore/gnunet-service-psycstore.c
+++ b/src/psycstore/gnunet-service-psycstore.c
@@ -551,7 +551,7 @@ recv_state_message_part (void *cls,
551 const char *name = (const char *) &pmod[1]; 551 const char *name = (const char *) &pmod[1];
552 const void *value = name + name_size; 552 const void *value = name + name_size;
553 553
554 if (GNUNET_ENV_OP_SET != pmod->oper) 554 if (GNUNET_PSYC_OP_SET != pmod->oper)
555 { // Apply non-transient operation. 555 { // Apply non-transient operation.
556 if (psize == sizeof (*pmod) + name_size + value_size) 556 if (psize == sizeof (*pmod) + name_size + value_size)
557 { 557 {
@@ -576,7 +576,7 @@ recv_state_message_part (void *cls,
576 } 576 }
577 577
578 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: 578 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
579 if (GNUNET_ENV_OP_SET != scls->mod_oper) 579 if (GNUNET_PSYC_OP_SET != scls->mod_oper)
580 { 580 {
581 if (scls->mod_value_remaining == 0) 581 if (scls->mod_value_remaining == 0)
582 { 582 {
diff --git a/src/psycstore/plugin_psycstore_sqlite.c b/src/psycstore/plugin_psycstore_sqlite.c
index 4ad3b1517..cc460d27f 100644
--- a/src/psycstore/plugin_psycstore_sqlite.c
+++ b/src/psycstore/plugin_psycstore_sqlite.c
@@ -35,7 +35,7 @@
35#include "gnunet_psycstore_service.h" 35#include "gnunet_psycstore_service.h"
36#include "gnunet_multicast_service.h" 36#include "gnunet_multicast_service.h"
37#include "gnunet_crypto_lib.h" 37#include "gnunet_crypto_lib.h"
38#include "gnunet_env_lib.h" 38#include "gnunet_psyc_util_lib.h"
39#include "psycstore.h" 39#include "psycstore.h"
40#include <sqlite3.h> 40#include <sqlite3.h>
41 41
@@ -1564,7 +1564,7 @@ state_modify_begin (void *cls,
1564static int 1564static int
1565state_modify_op (void *cls, 1565state_modify_op (void *cls,
1566 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, 1566 const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
1567 enum GNUNET_ENV_Operator op, 1567 enum GNUNET_PSYC_Operator op,
1568 const char *name, const void *value, size_t value_size) 1568 const char *name, const void *value, size_t value_size)
1569{ 1569{
1570 struct Plugin *plugin = cls; 1570 struct Plugin *plugin = cls;
@@ -1572,7 +1572,7 @@ state_modify_op (void *cls,
1572 1572
1573 switch (op) 1573 switch (op)
1574 { 1574 {
1575 case GNUNET_ENV_OP_ASSIGN: 1575 case GNUNET_PSYC_OP_ASSIGN:
1576 return state_assign (plugin, plugin->insert_state_current, channel_key, 1576 return state_assign (plugin, plugin->insert_state_current, channel_key,
1577 name, value, value_size); 1577 name, value, value_size);
1578 1578
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c
index 8f067b452..bfef07d3d 100644
--- a/src/psycstore/psycstore_api.c
+++ b/src/psycstore/psycstore_api.c
@@ -1303,7 +1303,7 @@ GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h,
1303 uint64_t max_state_message_id, 1303 uint64_t max_state_message_id,
1304 uint64_t state_hash_message_id, 1304 uint64_t state_hash_message_id,
1305 size_t modifier_count, 1305 size_t modifier_count,
1306 const struct GNUNET_ENV_Modifier *modifiers, 1306 const struct GNUNET_PSYC_Modifier *modifiers,
1307 GNUNET_PSYCSTORE_ResultCallback rcb, 1307 GNUNET_PSYCSTORE_ResultCallback rcb,
1308 void *rcb_cls) 1308 void *rcb_cls)
1309{ 1309{
diff --git a/src/psycstore/test_plugin_psycstore.c b/src/psycstore/test_plugin_psycstore.c
index 3a022ec52..c15765a88 100644
--- a/src/psycstore/test_plugin_psycstore.c
+++ b/src/psycstore/test_plugin_psycstore.c
@@ -18,11 +18,12 @@
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21/* 21/**
22 * @file psycstore/test_plugin_psycstore.c
23 * @brief Test for the PSYCstore plugins.
24 * @author Gabor X Toth 22 * @author Gabor X Toth
25 * @author Christian Grothoff 23 * @author Christian Grothoff
24 *
25 * @file
26 * Test for the PSYCstore plugins.
26 */ 27 */
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
@@ -309,12 +310,12 @@ run (void *cls, char *const *args, const char *cfgfile,
309 message_id, 0)); 310 message_id, 0));
310 311
311 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key, 312 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key,
312 GNUNET_ENV_OP_ASSIGN, 313 GNUNET_PSYC_OP_ASSIGN,
313 "_foo", 314 "_foo",
314 C2ARG("one two three"))); 315 C2ARG("one two three")));
315 316
316 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key, 317 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key,
317 GNUNET_ENV_OP_ASSIGN, 318 GNUNET_PSYC_OP_ASSIGN,
318 "_foo_bar", slave_key, 319 "_foo_bar", slave_key,
319 sizeof (*slave_key))); 320 sizeof (*slave_key)));
320 321
@@ -401,7 +402,7 @@ run (void *cls, char *const *args, const char *cfgfile,
401 message_id - max_state_msg_id)); 402 message_id - max_state_msg_id));
402 403
403 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key, 404 GNUNET_assert (GNUNET_OK == db->state_modify_op (db->cls, &channel_pub_key,
404 GNUNET_ENV_OP_ASSIGN, 405 GNUNET_PSYC_OP_ASSIGN,
405 "_sync_foo", 406 "_sync_foo",
406 C2ARG("five six seven"))); 407 C2ARG("five six seven")));
407 408
diff --git a/src/psycstore/test_psycstore.c b/src/psycstore/test_psycstore.c
index 1e7004021..e57545198 100644
--- a/src/psycstore/test_psycstore.c
+++ b/src/psycstore/test_psycstore.c
@@ -77,7 +77,7 @@ struct StateClosure {
77 size_t value_size[16]; 77 size_t value_size[16];
78} scls; 78} scls;
79 79
80static struct GNUNET_ENV_Modifier modifiers[16]; 80static struct GNUNET_PSYC_Modifier modifiers[16];
81 81
82/** 82/**
83 * Clean up all resources used. 83 * Clean up all resources used.
@@ -328,13 +328,13 @@ message_get_latest_result (void *cls, int64_t result,
328 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_latest:\t%d\n", result); 328 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_latest:\t%d\n", result);
329 GNUNET_assert (0 < result && fcls->n == fcls->n_expected); 329 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
330 330
331 modifiers[0] = (struct GNUNET_ENV_Modifier) { 331 modifiers[0] = (struct GNUNET_PSYC_Modifier) {
332 .oper = '=', 332 .oper = '=',
333 .name = "_sync_foo", 333 .name = "_sync_foo",
334 .value = "three two one", 334 .value = "three two one",
335 .value_size = sizeof ("three two one") - 1 335 .value_size = sizeof ("three two one") - 1
336 }; 336 };
337 modifiers[1] = (struct GNUNET_ENV_Modifier) { 337 modifiers[1] = (struct GNUNET_PSYC_Modifier) {
338 .oper = '=', 338 .oper = '=',
339 .name = "_sync_bar", 339 .name = "_sync_bar",
340 .value = "ten eleven twelve", 340 .value = "ten eleven twelve",
diff --git a/src/env/Makefile.am b/src/psycutil/Makefile.am
index eda55a8a7..2a916fe30 100644
--- a/src/env/Makefile.am
+++ b/src/psycutil/Makefile.am
@@ -14,20 +14,22 @@ if USE_COVERAGE
14 XLIB = -lgcov 14 XLIB = -lgcov
15endif 15endif
16 16
17lib_LTLIBRARIES = libgnunetenv.la 17lib_LTLIBRARIES = libgnunetpsycutil.la
18 18
19libgnunetenv_la_SOURCES = \ 19libgnunetpsycutil_la_SOURCES = \
20 env.c 20 psyc_env.c \
21libgnunetenv_la_LIBADD = \ 21 psyc_message.c \
22 psyc_slicer.c
23libgnunetpsycutil_la_LIBADD = \
22 $(top_builddir)/src/util/libgnunetutil.la \ 24 $(top_builddir)/src/util/libgnunetutil.la \
23 $(GN_LIBINTL) $(XLIB) 25 $(GN_LIBINTL) $(XLIB)
24libgnunetenv_la_LDFLAGS = \ 26libgnunetpsycutil_la_LDFLAGS = \
25 $(GN_LIB_LDFLAGS) $(WINFLAGS) \ 27 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
26 -version-info 0:0:0 28 -version-info 0:0:0
27 29
28if HAVE_TESTING 30if HAVE_TESTING
29check_PROGRAMS = \ 31check_PROGRAMS = \
30 test_env 32 test_psyc_env
31endif 33endif
32 34
33if ENABLE_TEST_RUN 35if ENABLE_TEST_RUN
@@ -35,9 +37,9 @@ AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PAT
35TESTS = $(check_PROGRAMS) 37TESTS = $(check_PROGRAMS)
36endif 38endif
37 39
38test_env_SOURCES = \ 40test_psyc_env_SOURCES = \
39 test_env.c 41 test_psyc_env.c
40test_env_LDADD = \ 42test_psyc_env_LDADD = \
41 libgnunetenv.la \ 43 libgnunetpsycutil.la \
42 $(top_builddir)/src/testing/libgnunettesting.la \ 44 $(top_builddir)/src/testing/libgnunettesting.la \
43 $(top_builddir)/src/util/libgnunetutil.la 45 $(top_builddir)/src/util/libgnunetutil.la
diff --git a/src/env/env.c b/src/psycutil/psyc_env.c
index febc3d33a..9c9c1a96d 100644
--- a/src/env/env.c
+++ b/src/psycutil/psyc_env.c
@@ -19,25 +19,26 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file env/env.c
23 * @brief Library providing operations for the @e environment of
24 * PSYC and Social messages, and for (de)serializing variable values.
25 * @author Gabor X Toth 22 * @author Gabor X Toth
23 *
24 * @file
25 * Library providing operations for the @e environment of
26 * PSYC and Social messages.
26 */ 27 */
27 28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include "gnunet_env_lib.h" 31#include "gnunet_psyc_env.h"
31 32
32/** 33/**
33 * Environment for a message. 34 * Environment for a message.
34 * 35 *
35 * Contains modifiers. 36 * Contains modifiers.
36 */ 37 */
37struct GNUNET_ENV_Environment 38struct GNUNET_PSYC_Environment
38{ 39{
39 struct GNUNET_ENV_Modifier *mod_head; 40 struct GNUNET_PSYC_Modifier *mod_head;
40 struct GNUNET_ENV_Modifier *mod_tail; 41 struct GNUNET_PSYC_Modifier *mod_tail;
41 size_t mod_count; 42 size_t mod_count;
42}; 43};
43 44
@@ -47,10 +48,10 @@ struct GNUNET_ENV_Environment
47 * 48 *
48 * @return A newly allocated environment. 49 * @return A newly allocated environment.
49 */ 50 */
50struct GNUNET_ENV_Environment * 51struct GNUNET_PSYC_Environment *
51GNUNET_ENV_environment_create () 52GNUNET_PSYC_env_create ()
52{ 53{
53 return GNUNET_new (struct GNUNET_ENV_Environment); 54 return GNUNET_new (struct GNUNET_PSYC_Environment);
54} 55}
55 56
56 57
@@ -64,11 +65,11 @@ GNUNET_ENV_environment_create ()
64 * @param value_size Size of @a value. 65 * @param value_size Size of @a value.
65 */ 66 */
66void 67void
67GNUNET_ENV_environment_add (struct GNUNET_ENV_Environment *env, 68GNUNET_PSYC_env_add (struct GNUNET_PSYC_Environment *env,
68 enum GNUNET_ENV_Operator oper, const char *name, 69 enum GNUNET_PSYC_Operator oper, const char *name,
69 const void *value, size_t value_size) 70 const void *value, size_t value_size)
70{ 71{
71 struct GNUNET_ENV_Modifier *mod = GNUNET_new (struct GNUNET_ENV_Modifier); 72 struct GNUNET_PSYC_Modifier *mod = GNUNET_new (struct GNUNET_PSYC_Modifier);
72 mod->oper = oper; 73 mod->oper = oper;
73 mod->name = name; 74 mod->name = name;
74 mod->value = value; 75 mod->value = value;
@@ -81,8 +82,8 @@ GNUNET_ENV_environment_add (struct GNUNET_ENV_Environment *env,
81/** 82/**
82 * Get the first modifier of the environment. 83 * Get the first modifier of the environment.
83 */ 84 */
84struct GNUNET_ENV_Modifier * 85struct GNUNET_PSYC_Modifier *
85GNUNET_ENV_environment_head (const struct GNUNET_ENV_Environment *env) 86GNUNET_PSYC_env_head (const struct GNUNET_PSYC_Environment *env)
86{ 87{
87 return env->mod_head; 88 return env->mod_head;
88} 89}
@@ -91,8 +92,8 @@ GNUNET_ENV_environment_head (const struct GNUNET_ENV_Environment *env)
91/** 92/**
92 * Get the last modifier of the environment. 93 * Get the last modifier of the environment.
93 */ 94 */
94struct GNUNET_ENV_Modifier * 95struct GNUNET_PSYC_Modifier *
95GNUNET_ENV_environment_tail (const struct GNUNET_ENV_Environment *env) 96GNUNET_PSYC_env_tail (const struct GNUNET_PSYC_Environment *env)
96{ 97{
97 return env->mod_tail; 98 return env->mod_tail;
98} 99}
@@ -102,8 +103,8 @@ GNUNET_ENV_environment_tail (const struct GNUNET_ENV_Environment *env)
102 * Remove a modifier from the environment. 103 * Remove a modifier from the environment.
103 */ 104 */
104void 105void
105GNUNET_ENV_environment_remove (struct GNUNET_ENV_Environment *env, 106GNUNET_PSYC_env_remove (struct GNUNET_PSYC_Environment *env,
106 struct GNUNET_ENV_Modifier *mod) 107 struct GNUNET_PSYC_Modifier *mod)
107{ 108{
108 GNUNET_CONTAINER_DLL_remove (env->mod_head, env->mod_tail, mod); 109 GNUNET_CONTAINER_DLL_remove (env->mod_head, env->mod_tail, mod);
109} 110}
@@ -121,14 +122,14 @@ GNUNET_ENV_environment_remove (struct GNUNET_ENV_Environment *env,
121 * @return 122 * @return
122 */ 123 */
123int 124int
124GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env, 125GNUNET_PSYC_env_shift (struct GNUNET_PSYC_Environment *env,
125 enum GNUNET_ENV_Operator *oper, const char **name, 126 enum GNUNET_PSYC_Operator *oper, const char **name,
126 const void **value, size_t *value_size) 127 const void **value, size_t *value_size)
127{ 128{
128 if (NULL == env->mod_head) 129 if (NULL == env->mod_head)
129 return GNUNET_NO; 130 return GNUNET_NO;
130 131
131 struct GNUNET_ENV_Modifier *mod = env->mod_head; 132 struct GNUNET_PSYC_Modifier *mod = env->mod_head;
132 *oper = mod->oper; 133 *oper = mod->oper;
133 *name = mod->name; 134 *name = mod->name;
134 *value = mod->value; 135 *value = mod->value;
@@ -150,10 +151,10 @@ GNUNET_ENV_environment_shift (struct GNUNET_ENV_Environment *env,
150 * @param it_cls Closure for iterator. 151 * @param it_cls Closure for iterator.
151 */ 152 */
152void 153void
153GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env, 154GNUNET_PSYC_env_iterate (const struct GNUNET_PSYC_Environment *env,
154 GNUNET_ENV_Iterator it, void *it_cls) 155 GNUNET_PSYC_Iterator it, void *it_cls)
155{ 156{
156 struct GNUNET_ENV_Modifier *mod; 157 struct GNUNET_PSYC_Modifier *mod;
157 for (mod = env->mod_head; NULL != mod; mod = mod->next) 158 for (mod = env->mod_head; NULL != mod; mod = mod->next)
158 it (it_cls, mod->oper, mod->name, mod->value, mod->value_size); 159 it (it_cls, mod->oper, mod->name, mod->value, mod->value_size);
159} 160}
@@ -167,7 +168,7 @@ GNUNET_ENV_environment_iterate (const struct GNUNET_ENV_Environment *env,
167 * @return Number of modifiers. 168 * @return Number of modifiers.
168 */ 169 */
169size_t 170size_t
170GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env) 171GNUNET_PSYC_env_get_count (const struct GNUNET_PSYC_Environment *env)
171{ 172{
172 return env->mod_count; 173 return env->mod_count;
173} 174}
@@ -179,9 +180,9 @@ GNUNET_ENV_environment_get_count (const struct GNUNET_ENV_Environment *env)
179 * @param env The environment to destroy. 180 * @param env The environment to destroy.
180 */ 181 */
181void 182void
182GNUNET_ENV_environment_destroy (struct GNUNET_ENV_Environment *env) 183GNUNET_PSYC_env_destroy (struct GNUNET_PSYC_Environment *env)
183{ 184{
184 struct GNUNET_ENV_Modifier *mod, *prev = NULL; 185 struct GNUNET_PSYC_Modifier *mod, *prev = NULL;
185 for (mod = env->mod_head; NULL != mod; mod = mod->next) 186 for (mod = env->mod_head; NULL != mod; mod = mod->next)
186 { 187 {
187 if (NULL != prev) 188 if (NULL != prev)
diff --git a/src/psycstore/psyc_util_lib.c b/src/psycutil/psyc_message.c
index e87d6106d..8c214d2b6 100644
--- a/src/psycstore/psyc_util_lib.c
+++ b/src/psycutil/psyc_message.c
@@ -28,9 +28,8 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_env_lib.h"
32#include "gnunet_psyc_service.h"
33#include "gnunet_psyc_util_lib.h" 31#include "gnunet_psyc_util_lib.h"
32#include "gnunet_psyc_service.h"
34 33
35#define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__) 34#define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__)
36 35
@@ -70,7 +69,7 @@ struct GNUNET_PSYC_TransmitHandle
70 /** 69 /**
71 * Modifier of the environment that is currently being transmitted. 70 * Modifier of the environment that is currently being transmitted.
72 */ 71 */
73 struct GNUNET_ENV_Modifier *mod; 72 struct GNUNET_PSYC_Modifier *mod;
74 73
75 /** 74 /**
76 * 75 *
@@ -180,18 +179,18 @@ struct GNUNET_PSYC_ReceiveHandle
180 */ 179 */
181struct GNUNET_PSYC_Message * 180struct GNUNET_PSYC_Message *
182GNUNET_PSYC_message_create (const char *method_name, 181GNUNET_PSYC_message_create (const char *method_name,
183 const struct GNUNET_ENV_Environment *env, 182 const struct GNUNET_PSYC_Environment *env,
184 const void *data, 183 const void *data,
185 size_t data_size) 184 size_t data_size)
186{ 185{
187 struct GNUNET_ENV_Modifier *mod = NULL; 186 struct GNUNET_PSYC_Modifier *mod = NULL;
188 struct GNUNET_PSYC_MessageMethod *pmeth = NULL; 187 struct GNUNET_PSYC_MessageMethod *pmeth = NULL;
189 struct GNUNET_PSYC_MessageModifier *pmod = NULL; 188 struct GNUNET_PSYC_MessageModifier *pmod = NULL;
190 struct GNUNET_MessageHeader *pmsg = NULL; 189 struct GNUNET_MessageHeader *pmsg = NULL;
191 uint16_t env_size = 0; 190 uint16_t env_size = 0;
192 if (NULL != env) 191 if (NULL != env)
193 { 192 {
194 mod = GNUNET_ENV_environment_head (env); 193 mod = GNUNET_PSYC_env_head (env);
195 while (NULL != mod) 194 while (NULL != mod)
196 { 195 {
197 env_size += sizeof (*pmod) + strlen (mod->name) + 1 + mod->value_size; 196 env_size += sizeof (*pmod) + strlen (mod->name) + 1 + mod->value_size;
@@ -221,7 +220,7 @@ GNUNET_PSYC_message_create (const char *method_name,
221 uint16_t p = sizeof (*msg) + sizeof (*pmeth) + method_name_size; 220 uint16_t p = sizeof (*msg) + sizeof (*pmeth) + method_name_size;
222 if (NULL != env) 221 if (NULL != env)
223 { 222 {
224 mod = GNUNET_ENV_environment_head (env); 223 mod = GNUNET_PSYC_env_head (env);
225 while (NULL != mod) 224 while (NULL != mod)
226 { 225 {
227 uint16_t mod_name_size = strlen (mod->name) + 1; 226 uint16_t mod_name_size = strlen (mod->name) + 1;
@@ -694,7 +693,7 @@ transmit_notify_env (void *cls, uint16_t *data_size, void *data, uint8_t *oper,
694int 693int
695GNUNET_PSYC_transmit_message (struct GNUNET_PSYC_TransmitHandle *tmit, 694GNUNET_PSYC_transmit_message (struct GNUNET_PSYC_TransmitHandle *tmit,
696 const char *method_name, 695 const char *method_name,
697 const struct GNUNET_ENV_Environment *env, 696 const struct GNUNET_PSYC_Environment *env,
698 GNUNET_PSYC_TransmitNotifyModifier notify_mod, 697 GNUNET_PSYC_TransmitNotifyModifier notify_mod,
699 GNUNET_PSYC_TransmitNotifyData notify_data, 698 GNUNET_PSYC_TransmitNotifyData notify_data,
700 void *notify_cls, 699 void *notify_cls,
@@ -720,14 +719,14 @@ GNUNET_PSYC_transmit_message (struct GNUNET_PSYC_TransmitHandle *tmit,
720 tmit->notify_mod_cls = tmit; 719 tmit->notify_mod_cls = tmit;
721 if (NULL != env) 720 if (NULL != env)
722 { 721 {
723 struct GNUNET_ENV_Modifier mod = {}; 722 struct GNUNET_PSYC_Modifier mod = {};
724 mod.next = GNUNET_ENV_environment_head (env); 723 mod.next = GNUNET_PSYC_env_head (env);
725 tmit->mod = &mod; 724 tmit->mod = &mod;
726 725
727 struct GNUNET_ENV_Modifier *m = tmit->mod; 726 struct GNUNET_PSYC_Modifier *m = tmit->mod;
728 while (NULL != (m = m->next)) 727 while (NULL != (m = m->next))
729 { 728 {
730 if (m->oper != GNUNET_ENV_OP_SET) 729 if (m->oper != GNUNET_PSYC_OP_SET)
731 flags |= GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY; 730 flags |= GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY;
732 } 731 }
733 } 732 }
@@ -1171,7 +1170,7 @@ GNUNET_PSYC_receive_check_parts (uint16_t data_size, const char *data,
1171 1170
1172struct ParseMessageClosure 1171struct ParseMessageClosure
1173{ 1172{
1174 struct GNUNET_ENV_Environment *env; 1173 struct GNUNET_PSYC_Environment *env;
1175 const char **method_name; 1174 const char **method_name;
1176 const void **data; 1175 const void **data;
1177 uint16_t *data_size; 1176 uint16_t *data_size;
@@ -1210,8 +1209,8 @@ parse_message_part_cb (void *cls,
1210 1209
1211 const char *name = (const char *) &pmod[1]; 1210 const char *name = (const char *) &pmod[1];
1212 const void *value = name + ntohs (pmod->name_size); 1211 const void *value = name + ntohs (pmod->name_size);
1213 GNUNET_ENV_environment_add (pmc->env, pmod->oper, name, value, 1212 GNUNET_PSYC_env_add (pmc->env, pmod->oper, name, value,
1214 ntohl (pmod->value_size)); 1213 ntohl (pmod->value_size));
1215 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_MODIFIER; 1214 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_MODIFIER;
1216 break; 1215 break;
1217 } 1216 }
@@ -1252,7 +1251,7 @@ parse_message_part_cb (void *cls,
1252int 1251int
1253GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_MessageHeader *msg, 1252GNUNET_PSYC_message_parse (const struct GNUNET_PSYC_MessageHeader *msg,
1254 const char **method_name, 1253 const char **method_name,
1255 struct GNUNET_ENV_Environment *env, 1254 struct GNUNET_PSYC_Environment *env,
1256 const void **data, 1255 const void **data,
1257 uint16_t *data_size) 1256 uint16_t *data_size)
1258{ 1257{
diff --git a/src/psycutil/psyc_slicer.c b/src/psycutil/psyc_slicer.c
new file mode 100644
index 000000000..fe9912416
--- /dev/null
+++ b/src/psycutil/psyc_slicer.c
@@ -0,0 +1,610 @@
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 *
24 * @file
25 * PSYC Slicer API
26 */
27
28#include <inttypes.h>
29
30#include "platform.h"
31#include "gnunet_util_lib.h"
32#include "gnunet_psyc_util_lib.h"
33
34#define LOG(kind,...) GNUNET_log_from (kind, "psyc-util-slicer",__VA_ARGS__)
35
36
37/**
38 * Handle for a try-and-slice instance.
39 */
40struct GNUNET_PSYC_Slicer
41{
42 /**
43 * Method handlers: H(method_name) -> SlicerMethodCallbacks
44 */
45 struct GNUNET_CONTAINER_MultiHashMap *method_handlers;
46
47 /**
48 * Modifier handlers: H(modifier_name) -> SlicerModifierCallbacks
49 */
50 struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers;
51
52 /**
53 * Currently being processed message part.
54 */
55 const struct GNUNET_MessageHeader *msg;
56
57 /**
58 * ID of currently being received message.
59 */
60 uint64_t message_id;
61
62 /**
63 * Method name of currently being received message.
64 */
65 char *method_name;
66
67 /**
68 * Name of currently processed modifier.
69 */
70 char *mod_name;
71
72 /**
73 * Value of currently processed modifier.
74 */
75 char *mod_value;
76
77 /**
78 * Public key of the nym the current message originates from.
79 */
80 struct GNUNET_CRYPTO_EcdsaPublicKey nym_pub_key;
81
82 /**
83 * Size of @a method_name (including terminating \0).
84 */
85 uint16_t method_name_size;
86
87 /**
88 * Size of @a modifier_name (including terminating \0).
89 */
90 uint16_t mod_name_size;
91
92 /**
93 * Size of modifier value fragment.
94 */
95 uint16_t mod_value_size;
96
97 /**
98 * Full size of modifier value.
99 */
100 uint16_t mod_full_value_size;
101
102 /**
103 * Remaining bytes from the value of the current modifier.
104 */
105 uint16_t mod_value_remaining;
106
107 /**
108 * Operator of currently processed modifier.
109 */
110 uint8_t mod_oper;
111};
112
113
114/**
115 * Callbacks for a slicer method handler.
116 */
117struct SlicerMethodCallbacks
118{
119 GNUNET_PSYC_MethodCallback method_cb;
120 GNUNET_PSYC_ModifierCallback modifier_cb;
121 GNUNET_PSYC_DataCallback data_cb;
122 GNUNET_PSYC_EndOfMessageCallback eom_cb;
123 void *cls;
124};
125
126
127struct SlicerMethodRemoveClosure
128{
129 struct GNUNET_PSYC_Slicer *slicer;
130 struct SlicerMethodCallbacks rm_cbs;
131};
132
133
134/**
135 * Callbacks for a slicer method handler.
136 */
137struct SlicerModifierCallbacks
138{
139 GNUNET_PSYC_ModifierCallback modifier_cb;
140 void *cls;
141};
142
143
144struct SlicerModifierRemoveClosure
145{
146 struct GNUNET_PSYC_Slicer *slicer;
147 struct SlicerModifierCallbacks rm_cbs;
148};
149
150
151/**
152 * Call a method handler for an incoming message part.
153 */
154int
155slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
156 void *value)
157{
158 struct GNUNET_PSYC_Slicer *slicer = cls;
159 const struct GNUNET_MessageHeader *msg = slicer->msg;
160 struct SlicerMethodCallbacks *cbs = value;
161 uint16_t ptype = ntohs (msg->type);
162
163 switch (ptype)
164 {
165 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
166 {
167 if (NULL == cbs->method_cb)
168 break;
169 struct GNUNET_PSYC_MessageMethod *
170 meth = (struct GNUNET_PSYC_MessageMethod *) msg;
171 cbs->method_cb (cbs->cls, meth, slicer->message_id,
172 ntohl (meth->flags),
173 &slicer->nym_pub_key,
174 slicer->method_name);
175 break;
176 }
177
178 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
179 {
180 if (NULL == cbs->modifier_cb)
181 break;
182 struct GNUNET_PSYC_MessageModifier *
183 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
184 cbs->modifier_cb (cbs->cls, &mod->header, slicer->message_id,
185 mod->oper, (const char *) &mod[1],
186 (const void *) &mod[1] + ntohs (mod->name_size),
187 ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size),
188 ntohs (mod->value_size));
189 break;
190 }
191
192 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
193 {
194 if (NULL == cbs->modifier_cb)
195 break;
196 cbs->modifier_cb (cbs->cls, msg, slicer->message_id,
197 slicer->mod_oper, slicer->mod_name, &msg[1],
198 ntohs (msg->size) - sizeof (*msg),
199 slicer->mod_full_value_size);
200 break;
201 }
202
203 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
204 {
205 if (NULL == cbs->data_cb)
206 break;
207 uint64_t data_offset = 0; // FIXME
208 cbs->data_cb (cbs->cls, msg, slicer->message_id,
209 data_offset, &msg[1], ntohs (msg->size) - sizeof (*msg));
210 break;
211 }
212
213 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
214 if (NULL == cbs->eom_cb)
215 break;
216 cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_NO);
217 break;
218
219 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
220 if (NULL == cbs->eom_cb)
221 break;
222 cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_YES);
223 break;
224 }
225 return GNUNET_YES;
226}
227
228
229/**
230 * Call a method handler for an incoming message part.
231 */
232int
233slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
234 void *value)
235{
236 struct GNUNET_PSYC_Slicer *slicer = cls;
237 struct SlicerModifierCallbacks *cbs = value;
238
239 cbs->modifier_cb (cbs->cls, slicer->msg, slicer->message_id, slicer->mod_oper,
240 slicer->mod_name, slicer->mod_value,
241 slicer->mod_value_size, slicer->mod_full_value_size);
242 return GNUNET_YES;
243}
244
245
246/**
247 * Process an incoming message part and call matching handlers.
248 *
249 * @param cls
250 * Closure.
251 * @param message_id
252 * ID of the message.
253 * @param flags
254 * Flags for the message.
255 * @see enum GNUNET_PSYC_MessageFlags
256 * @param msg
257 * The message part. as it arrived from the network.
258 */
259void
260GNUNET_PSYC_slicer_message (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
261 uint64_t message_id, uint32_t flags, uint64_t fragment_offset,
262 const struct GNUNET_MessageHeader *msg)
263{
264 struct GNUNET_PSYC_Slicer *slicer = cls;
265 slicer->nym_pub_key = *slave_pub_key;
266
267 uint16_t ptype = ntohs (msg->type);
268 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype)
269 {
270 struct GNUNET_PSYC_MessageMethod *
271 meth = (struct GNUNET_PSYC_MessageMethod *) msg;
272 slicer->method_name_size = ntohs (meth->header.size) - sizeof (*meth);
273 slicer->method_name = GNUNET_malloc (slicer->method_name_size);
274 memcpy (slicer->method_name, &meth[1], slicer->method_name_size);
275 slicer->message_id = message_id;
276 }
277 else
278 {
279 GNUNET_assert (message_id == slicer->message_id);
280 }
281
282 char *nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (slave_pub_key);
283 LOG (GNUNET_ERROR_TYPE_DEBUG,
284 "Slicer received message of type %u and size %u, "
285 "with ID %" PRIu64 " and method %s from %s\n",
286 ptype, ntohs (msg->size), message_id, slicer->method_name, nym_str);
287 GNUNET_free (nym_str);
288
289 slicer->msg = msg;
290
291 /* try-and-slice modifier */
292
293 switch (ptype)
294 {
295 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
296 {
297 struct GNUNET_PSYC_MessageModifier *
298 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
299 slicer->mod_oper = mod->oper;
300 slicer->mod_name_size = ntohs (mod->name_size);
301 slicer->mod_name = GNUNET_malloc (slicer->mod_name_size);
302 memcpy (slicer->mod_name, &mod[1], slicer->mod_name_size);
303 slicer->mod_value = (char *) &mod[1] + slicer->mod_name_size;
304 slicer->mod_full_value_size = ntohs (mod->value_size);
305 slicer->mod_value_remaining = slicer->mod_full_value_size;
306 slicer->mod_value_size
307 = ntohs (mod->header.size) - sizeof (*mod) - slicer->mod_name_size;
308 }
309 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
310 if (ptype == GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT)
311 {
312 slicer->mod_value = (char *) &msg[1];
313 slicer->mod_value_size = ntohs (msg->size) - sizeof (*msg);
314 }
315 slicer->mod_value_remaining -= slicer->mod_value_size;
316 char *name = GNUNET_malloc (slicer->mod_name_size);
317 memcpy (name, slicer->mod_name, slicer->mod_name_size);
318 do
319 {
320 struct GNUNET_HashCode key;
321 uint16_t name_len = strlen (name);
322 GNUNET_CRYPTO_hash (name, name_len, &key);
323 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
324 slicer_modifier_handler_notify,
325 slicer);
326 char *p = strrchr (name, '_');
327 if (NULL == p)
328 break;
329 *p = '\0';
330 } while (1);
331 GNUNET_free (name);
332 }
333
334 /* try-and-slice method */
335
336 char *name = GNUNET_malloc (slicer->method_name_size);
337 memcpy (name, slicer->method_name, slicer->method_name_size);
338 do
339 {
340 struct GNUNET_HashCode key;
341 uint16_t name_len = strlen (name);
342 GNUNET_CRYPTO_hash (name, name_len, &key);
343 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
344 slicer_method_handler_notify,
345 slicer);
346 char *p = strrchr (name, '_');
347 if (NULL == p)
348 break;
349 *p = '\0';
350 } while (1);
351 GNUNET_free (name);
352
353 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
354 GNUNET_free (slicer->method_name);
355
356 if (0 == slicer->mod_value_remaining && NULL != slicer->mod_name)
357 {
358 GNUNET_free (slicer->mod_name);
359 slicer->mod_name = NULL;
360 slicer->mod_name_size = 0;
361 slicer->mod_value_size = 0;
362 slicer->mod_full_value_size = 0;
363 slicer->mod_oper = 0;
364 }
365
366 slicer->msg = NULL;
367}
368
369
370/**
371 * Create a try-and-slice instance.
372 *
373 * A slicer processes incoming messages and notifies callbacks about matching
374 * methods or modifiers encountered.
375 *
376 * @return A new try-and-slice construct.
377 */
378struct GNUNET_PSYC_Slicer *
379GNUNET_PSYC_slicer_create (void)
380{
381 struct GNUNET_PSYC_Slicer *slicer = GNUNET_malloc (sizeof (*slicer));
382 slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
383 slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
384 return slicer;
385}
386
387
388/**
389 * Add a method to the try-and-slice instance.
390 *
391 * The callbacks are called for messages with a matching @a method_name prefix.
392 *
393 * @param slicer
394 * The try-and-slice instance to extend.
395 * @param method_name
396 * Name of the given method, use empty string to match all.
397 * @param method_cb
398 * Method handler invoked upon a matching message.
399 * @param modifier_cb
400 * Modifier handler, invoked after @a method_cb
401 * for each modifier in the message.
402 * @param data_cb
403 * Data handler, invoked after @a modifier_cb for each data fragment.
404 * @param eom_cb
405 * Invoked upon reaching the end of a matching message.
406 * @param cls
407 * Closure for the callbacks.
408 */
409void
410GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
411 const char *method_name,
412 GNUNET_PSYC_MethodCallback method_cb,
413 GNUNET_PSYC_ModifierCallback modifier_cb,
414 GNUNET_PSYC_DataCallback data_cb,
415 GNUNET_PSYC_EndOfMessageCallback eom_cb,
416 void *cls)
417{
418 struct GNUNET_HashCode key;
419 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
420
421 struct SlicerMethodCallbacks *cbs = GNUNET_malloc (sizeof (*cbs));
422 cbs->method_cb = method_cb;
423 cbs->modifier_cb = modifier_cb;
424 cbs->data_cb = data_cb;
425 cbs->eom_cb = eom_cb;
426 cbs->cls = cls;
427
428 GNUNET_CONTAINER_multihashmap_put (slicer->method_handlers, &key, cbs,
429 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
430}
431
432
433int
434slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
435{
436 struct SlicerMethodRemoveClosure *rm_cls = cls;
437 struct GNUNET_PSYC_Slicer *slicer = rm_cls->slicer;
438 struct SlicerMethodCallbacks *rm_cbs = &rm_cls->rm_cbs;
439 struct SlicerMethodCallbacks *cbs = value;
440
441 if (cbs->method_cb == rm_cbs->method_cb
442 && cbs->modifier_cb == rm_cbs->modifier_cb
443 && cbs->data_cb == rm_cbs->data_cb
444 && cbs->eom_cb == rm_cbs->eom_cb)
445 {
446 GNUNET_CONTAINER_multihashmap_remove (slicer->method_handlers, key, cbs);
447 GNUNET_free (cbs);
448 return GNUNET_NO;
449 }
450 return GNUNET_YES;
451}
452
453
454/**
455 * Remove a registered method from the try-and-slice instance.
456 *
457 * Removes one matching handler registered with the given
458 * @a method_name and callbacks.
459 *
460 * @param slicer
461 * The try-and-slice instance.
462 * @param method_name
463 * Name of the method to remove.
464 * @param method_cb
465 * Method handler.
466 * @param modifier_cb
467 * Modifier handler.
468 * @param data_cb
469 * Data handler.
470 * @param eom_cb
471 * End of message handler.
472 *
473 * @return #GNUNET_OK if a method handler was removed,
474 * #GNUNET_NO if no handler matched the given method name and callbacks.
475 */
476int
477GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer,
478 const char *method_name,
479 GNUNET_PSYC_MethodCallback method_cb,
480 GNUNET_PSYC_ModifierCallback modifier_cb,
481 GNUNET_PSYC_DataCallback data_cb,
482 GNUNET_PSYC_EndOfMessageCallback eom_cb)
483{
484 struct GNUNET_HashCode key;
485 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
486
487 struct SlicerMethodRemoveClosure rm_cls;
488 rm_cls.slicer = slicer;
489 struct SlicerMethodCallbacks *rm_cbs = &rm_cls.rm_cbs;
490 rm_cbs->method_cb = method_cb;
491 rm_cbs->modifier_cb = modifier_cb;
492 rm_cbs->data_cb = data_cb;
493 rm_cbs->eom_cb = eom_cb;
494
495 return
496 (GNUNET_SYSERR
497 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
498 slicer_method_remove,
499 &rm_cls))
500 ? GNUNET_NO
501 : GNUNET_OK;
502}
503
504
505/**
506 * Watch a place for changed objects.
507 *
508 * @param slicer
509 * The try-and-slice instance.
510 * @param object_filter
511 * Object prefix to match.
512 * @param modifier_cb
513 * Function to call when encountering a state modifier.
514 * @param cls
515 * Closure for callback.
516 */
517void
518GNUNET_PSYC_slicer_modifier_add (struct GNUNET_PSYC_Slicer *slicer,
519 const char *object_filter,
520 GNUNET_PSYC_ModifierCallback modifier_cb,
521 void *cls)
522{
523 struct SlicerModifierCallbacks *cbs = GNUNET_malloc (sizeof *cbs);
524 cbs->modifier_cb = modifier_cb;
525 cbs->cls = cls;
526
527 struct GNUNET_HashCode key;
528 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
529 GNUNET_CONTAINER_multihashmap_put (slicer->modifier_handlers, &key, cbs,
530 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
531}
532
533
534int
535slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
536{
537 struct SlicerModifierRemoveClosure *rm_cls = cls;
538 struct GNUNET_PSYC_Slicer *slicer = rm_cls->slicer;
539 struct SlicerModifierCallbacks *rm_cbs = &rm_cls->rm_cbs;
540 struct SlicerModifierCallbacks *cbs = value;
541
542 if (cbs->modifier_cb == rm_cbs->modifier_cb)
543 {
544 GNUNET_CONTAINER_multihashmap_remove (slicer->modifier_handlers, key, cbs);
545 GNUNET_free (cbs);
546 return GNUNET_NO;
547 }
548 return GNUNET_YES;
549}
550
551
552/**
553 * Remove a registered modifier from the try-and-slice instance.
554 *
555 * Removes one matching handler registered with the given
556 * @a object_filter and @a modifier_cb.
557 *
558 * @param slicer
559 * The try-and-slice instance.
560 * @param object_filter
561 * Object prefix to match.
562 * @param modifier_cb
563 * Function to call when encountering a state modifier changes.
564 */
565int
566GNUNET_PSYC_slicer_modifier_remove (struct GNUNET_PSYC_Slicer *slicer,
567 const char *object_filter,
568 GNUNET_PSYC_ModifierCallback modifier_cb)
569{
570 struct GNUNET_HashCode key;
571 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
572
573 struct SlicerModifierRemoveClosure rm_cls;
574 rm_cls.slicer = slicer;
575 struct SlicerModifierCallbacks *rm_cbs = &rm_cls.rm_cbs;
576 rm_cbs->modifier_cb = modifier_cb;
577
578 return
579 (GNUNET_SYSERR
580 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
581 slicer_modifier_remove,
582 &rm_cls))
583 ? GNUNET_NO
584 : GNUNET_OK;
585 }
586
587
588int
589slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value)
590{
591 struct SlicerMethodCallbacks *cbs = value;
592 GNUNET_free (cbs);
593 return GNUNET_YES;
594}
595
596
597/**
598 * Destroy a given try-and-slice instance.
599 *
600 * @param slicer
601 * Slicer to destroy
602 */
603void
604GNUNET_PSYC_slicer_destroy (struct GNUNET_PSYC_Slicer *slicer)
605{
606 GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
607 slicer_method_free, NULL);
608 GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers);
609 GNUNET_free (slicer);
610}
diff --git a/src/env/test_env.c b/src/psycutil/test_psyc_env.c
index 3af9e26f0..021e7fe10 100644
--- a/src/env/test_env.c
+++ b/src/psycutil/test_psyc_env.c
@@ -19,24 +19,25 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file env/test_env.c
23 * @brief Tests for the environment library.
24 * @author Gabor X Toth 22 * @author Gabor X Toth
23 *
24 * @file
25 * Tests for the environment library.
25 */ 26 */
26 27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_testing_lib.h" 30#include "gnunet_testing_lib.h"
30#include "gnunet_env_lib.h" 31#include "gnunet_psyc_util_lib.h"
31 32
32struct GNUNET_ENV_Modifier mods[] = { 33struct GNUNET_PSYC_Modifier mods[] = {
33 { .oper = GNUNET_ENV_OP_SET, 34 { .oper = GNUNET_PSYC_OP_SET,
34 .name = "_foo", .value = "foo", .value_size = 3 }, 35 .name = "_foo", .value = "foo", .value_size = 3 },
35 36
36 { .oper = GNUNET_ENV_OP_ASSIGN, 37 { .oper = GNUNET_PSYC_OP_ASSIGN,
37 .name = "_foo_bar", .value = "foo bar", .value_size = 7 }, 38 .name = "_foo_bar", .value = "foo bar", .value_size = 7 },
38 39
39 { .oper = GNUNET_ENV_OP_AUGMENT, 40 { .oper = GNUNET_PSYC_OP_AUGMENT,
40 .name = "_foo_bar_baz", .value = "foo bar baz", .value_size = 11 } 41 .name = "_foo_bar_baz", .value = "foo bar baz", .value_size = 11 }
41}; 42};
42 43
@@ -46,11 +47,11 @@ struct ItCls
46}; 47};
47 48
48int 49int
49iterator (void *cls, enum GNUNET_ENV_Operator oper, 50iterator (void *cls, enum GNUNET_PSYC_Operator oper,
50 const char *name, const char *value, uint32_t value_size) 51 const char *name, const char *value, uint32_t value_size)
51{ 52{
52 struct ItCls *it_cls = cls; 53 struct ItCls *it_cls = cls;
53 struct GNUNET_ENV_Modifier *m = &mods[it_cls->n++]; 54 struct GNUNET_PSYC_Modifier *m = &mods[it_cls->n++];
54 55
55 GNUNET_assert (oper == m->oper); 56 GNUNET_assert (oper == m->oper);
56 GNUNET_assert (value_size == m->value_size); 57 GNUNET_assert (value_size == m->value_size);
@@ -65,31 +66,31 @@ main (int argc, char *argv[])
65{ 66{
66 GNUNET_log_setup ("test-env", "WARNING", NULL); 67 GNUNET_log_setup ("test-env", "WARNING", NULL);
67 68
68 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 69 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
69 GNUNET_assert (NULL != env); 70 GNUNET_assert (NULL != env);
70 int i, len = 3; 71 int i, len = 3;
71 72
72 for (i = 0; i < len; i++) 73 for (i = 0; i < len; i++)
73 { 74 {
74 GNUNET_ENV_environment_add (env, mods[i].oper, mods[i].name, 75 GNUNET_PSYC_env_add (env, mods[i].oper, mods[i].name,
75 mods[i].value, mods[i].value_size); 76 mods[i].value, mods[i].value_size);
76 } 77 }
77 78
78 struct ItCls it_cls = { .n = 0 }; 79 struct ItCls it_cls = { .n = 0 };
79 GNUNET_ENV_environment_iterate (env, iterator, &it_cls); 80 GNUNET_PSYC_env_iterate (env, iterator, &it_cls);
80 GNUNET_assert (len == it_cls.n); 81 GNUNET_assert (len == it_cls.n);
81 82
82 for (i = 0; i < len; i++) 83 for (i = 0; i < len; i++)
83 { 84 {
84 enum GNUNET_ENV_Operator oper; 85 enum GNUNET_PSYC_Operator oper;
85 const char *name; 86 const char *name;
86 const void *value; 87 const void *value;
87 size_t value_size; 88 size_t value_size;
88 GNUNET_ENV_environment_shift (env, &oper, &name, &value, &value_size); 89 GNUNET_PSYC_env_shift (env, &oper, &name, &value, &value_size);
89 GNUNET_assert (len - i - 1 == GNUNET_ENV_environment_get_count (env)); 90 GNUNET_assert (len - i - 1 == GNUNET_PSYC_env_get_count (env));
90 } 91 }
91 92
92 GNUNET_ENV_environment_destroy (env); 93 GNUNET_PSYC_env_destroy (env);
93 94
94 return 0; 95 return 0;
95} 96}
diff --git a/src/social/Makefile.am b/src/social/Makefile.am
index 739385e19..bf1532411 100644
--- a/src/social/Makefile.am
+++ b/src/social/Makefile.am
@@ -24,7 +24,7 @@ libgnunetsocial_la_SOURCES = \
24 social_api.c social.h 24 social_api.c social.h
25libgnunetsocial_la_LIBADD = \ 25libgnunetsocial_la_LIBADD = \
26 $(top_builddir)/src/util/libgnunetutil.la \ 26 $(top_builddir)/src/util/libgnunetutil.la \
27 $(top_builddir)/src/env/libgnunetenv.la \ 27 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
28 $(GN_LIBINTL) $(XLIB) 28 $(GN_LIBINTL) $(XLIB)
29libgnunetsocial_la_LDFLAGS = \ 29libgnunetsocial_la_LDFLAGS = \
30 $(GN_LIB_LDFLAGS) $(WINFLAGS) \ 30 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
@@ -40,9 +40,8 @@ gnunet_service_social_SOURCES = \
40gnunet_service_social_LDADD = \ 40gnunet_service_social_LDADD = \
41 $(top_builddir)/src/util/libgnunetutil.la \ 41 $(top_builddir)/src/util/libgnunetutil.la \
42 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 42 $(top_builddir)/src/statistics/libgnunetstatistics.la \
43 $(top_builddir)/src/env/libgnunetenv.la \ 43 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
44 $(top_builddir)/src/psyc/libgnunetpsyc.la \ 44 $(top_builddir)/src/psyc/libgnunetpsyc.la \
45 $(top_builddir)/src/psycstore/libgnunetpsycutil.la \
46 $(top_builddir)/src/core/libgnunetcore.la \ 45 $(top_builddir)/src/core/libgnunetcore.la \
47 $(top_builddir)/src/identity/libgnunetidentity.la \ 46 $(top_builddir)/src/identity/libgnunetidentity.la \
48 $(top_builddir)/src/gns/libgnunetgns.la \ 47 $(top_builddir)/src/gns/libgnunetgns.la \
@@ -66,8 +65,7 @@ test_social_LDADD = \
66 libgnunetsocial.la \ 65 libgnunetsocial.la \
67 $(top_builddir)/src/testing/libgnunettesting.la \ 66 $(top_builddir)/src/testing/libgnunettesting.la \
68 $(top_builddir)/src/util/libgnunetutil.la \ 67 $(top_builddir)/src/util/libgnunetutil.la \
69 $(top_builddir)/src/env/libgnunetenv.la \ 68 $(top_builddir)/src/psycutil/libgnunetpsycutil.la \
70 $(top_builddir)/src/psycstore/libgnunetpsycutil.la \
71 $(top_builddir)/src/core/libgnunetcore.la \ 69 $(top_builddir)/src/core/libgnunetcore.la \
72 $(top_builddir)/src/identity/libgnunetidentity.la 70 $(top_builddir)/src/identity/libgnunetidentity.la
73 71
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index ec4b18d0b..d4dfe9b0f 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -734,7 +734,7 @@ psyc_recv_join_dcsn (void *cls,
734void 734void
735psyc_recv_file (struct Place *plc, const struct GNUNET_PSYC_MessageHeader *msg, 735psyc_recv_file (struct Place *plc, const struct GNUNET_PSYC_MessageHeader *msg,
736 uint32_t flags, uint64_t message_id, uint64_t fragment_offset, 736 uint32_t flags, uint64_t message_id, uint64_t fragment_offset,
737 const char *method_name, struct GNUNET_ENV_Environment *env, 737 const char *method_name, struct GNUNET_PSYC_Environment *env,
738 const void *data, uint16_t data_size) 738 const void *data, uint16_t data_size)
739{ 739{
740 if (plc->file_message_id != message_id) 740 if (plc->file_message_id != message_id)
@@ -794,7 +794,7 @@ psyc_recv_message (void *cls,
794 /* process message */ 794 /* process message */
795 /* FIXME: use slicer */ 795 /* FIXME: use slicer */
796 const char *method_name = NULL; 796 const char *method_name = NULL;
797 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 797 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
798 const void *data = NULL; 798 const void *data = NULL;
799 uint16_t data_size = 0; 799 uint16_t data_size = 0;
800 800
@@ -815,7 +815,7 @@ psyc_recv_message (void *cls,
815 } 815 }
816 } 816 }
817 } 817 }
818 GNUNET_ENV_environment_destroy (env); 818 GNUNET_PSYC_env_destroy (env);
819 819
820 place_send_msg (plc, &msg->header); 820 place_send_msg (plc, &msg->header);
821} 821}
diff --git a/src/social/social.h b/src/social/social.h
index b797a89ac..0980cbf5c 100644
--- a/src/social/social.h
+++ b/src/social/social.h
@@ -80,6 +80,19 @@ struct AppDetachRequest
80}; 80};
81 81
82 82
83struct 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
83struct HostEnterRequest 96struct HostEnterRequest
84{ 97{
85 /** 98 /**
@@ -207,6 +220,7 @@ struct ZoneAddNymRequest
207 /* Followed by const char *name */ 220 /* Followed by const char *name */
208}; 221};
209 222
223
210/**** service -> library ****/ 224/**** service -> library ****/
211 225
212 226
@@ -266,24 +280,6 @@ struct HostEnterAck {
266}; 280};
267 281
268 282
269#if REMOVE
270struct NymEnterRequest
271{
272 /**
273 * Type: GNUNET_MESSAGE_TYPE_SOCIAL_NYM_ENTER
274 */
275 struct GNUNET_MessageHeader header;
276
277 /**
278 * Public key of the joining slave.
279 */
280 struct GNUNET_CRYPTO_EcdsaPublicKey nym_key;
281
282 /* Followed by struct GNUNET_MessageHeader join_request */
283};
284#endif
285
286
287GNUNET_NETWORK_STRUCT_END 283GNUNET_NETWORK_STRUCT_END
288 284
289#endif 285#endif
diff --git a/src/social/social_api.c b/src/social/social_api.c
index 3d5e9853f..3404160a9 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -19,9 +19,10 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file social/social_api.c
23 * @brief Social service; implements social interactions using the PSYC service.
24 * @author Gabor X Toth 22 * @author Gabor X Toth
23 *
24 * @file
25 * Social service; implements social interactions using the PSYC service.
25 */ 26 */
26 27
27#include <inttypes.h> 28#include <inttypes.h>
@@ -29,7 +30,6 @@
29 30
30#include "platform.h" 31#include "platform.h"
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
32#include "gnunet_env_lib.h"
33#include "gnunet_psyc_service.h" 33#include "gnunet_psyc_service.h"
34#include "gnunet_psyc_util_lib.h" 34#include "gnunet_psyc_util_lib.h"
35#include "gnunet_social_service.h" 35#include "gnunet_social_service.h"
@@ -156,7 +156,7 @@ struct GNUNET_SOCIAL_Place
156 /** 156 /**
157 * Slicer for processing incoming methods. 157 * Slicer for processing incoming methods.
158 */ 158 */
159 struct GNUNET_SOCIAL_Slicer *slicer; 159 struct GNUNET_PSYC_Slicer *slicer;
160 160
161 /** 161 /**
162 * Message to send on reconnect. 162 * Message to send on reconnect.
@@ -211,7 +211,7 @@ struct GNUNET_SOCIAL_Host
211 /** 211 /**
212 * Slicer for processing incoming methods. 212 * Slicer for processing incoming methods.
213 */ 213 */
214 struct GNUNET_SOCIAL_Slicer *slicer; 214 struct GNUNET_PSYC_Slicer *slicer;
215 215
216 GNUNET_SOCIAL_HostEnterCallback enter_cb; 216 GNUNET_SOCIAL_HostEnterCallback enter_cb;
217 217
@@ -225,7 +225,7 @@ struct GNUNET_SOCIAL_Host
225 void *cb_cls; 225 void *cb_cls;
226 226
227 struct GNUNET_SOCIAL_Nym *notice_place_leave_nym; 227 struct GNUNET_SOCIAL_Nym *notice_place_leave_nym;
228 struct GNUNET_ENV_Environment *notice_place_leave_env; 228 struct GNUNET_PSYC_Environment *notice_place_leave_env;
229}; 229};
230 230
231 231
@@ -244,7 +244,7 @@ struct GNUNET_SOCIAL_Guest
244 /** 244 /**
245 * Slicer for processing incoming methods. 245 * Slicer for processing incoming methods.
246 */ 246 */
247 struct GNUNET_SOCIAL_Slicer *slicer; 247 struct GNUNET_PSYC_Slicer *slicer;
248 248
249 GNUNET_SOCIAL_GuestEnterCallback enter_cb; 249 GNUNET_SOCIAL_GuestEnterCallback enter_cb;
250 250
@@ -265,120 +265,6 @@ struct GNUNET_CONTAINER_MultiHashMap *nyms;
265 265
266 266
267/** 267/**
268 * Handle for a try-and-slice instance.
269 */
270struct GNUNET_SOCIAL_Slicer
271{
272 /**
273 * Method handlers: method_name -> SlicerMethodCallbacks
274 */
275 struct GNUNET_CONTAINER_MultiHashMap *method_handlers;
276
277 /**
278 * Modifier handlers: modifier name -> SlicerModifierCallbacks
279 */
280 struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers;
281
282 /**
283 * Currently being processed message part.
284 */
285 const struct GNUNET_MessageHeader *msg;
286
287 /**
288 * ID of currently being received message.
289 */
290 uint64_t message_id;
291
292 /**
293 * Method name of currently being received message.
294 */
295 char *method_name;
296
297 /**
298 * Name of currently processed modifier.
299 */
300 char *mod_name;
301
302 /**
303 * Value of currently processed modifier.
304 */
305 char *mod_value;
306
307 /**
308 * Public key of the nym the current message originates from.
309 */
310 struct GNUNET_CRYPTO_EcdsaPublicKey nym_key;
311
312 /**
313 * Size of @a method_name (including terminating \0).
314 */
315 uint16_t method_name_size;
316
317 /**
318 * Size of @a modifier_name (including terminating \0).
319 */
320 uint16_t mod_name_size;
321
322 /**
323 * Size of modifier value fragment.
324 */
325 uint16_t mod_value_size;
326
327 /**
328 * Full size of modifier value.
329 */
330 uint16_t mod_full_value_size;
331
332 /**
333 * Remaining bytes from the value of the current modifier.
334 */
335 uint16_t mod_value_remaining;
336
337 /**
338 * Operator of currently processed modifier.
339 */
340 uint8_t mod_oper;
341};
342
343
344/**
345 * Callbacks for a slicer method handler.
346 */
347struct SlicerMethodCallbacks
348{
349 GNUNET_SOCIAL_MethodCallback method_cb;
350 GNUNET_SOCIAL_ModifierCallback modifier_cb;
351 GNUNET_SOCIAL_DataCallback data_cb;
352 GNUNET_SOCIAL_EndOfMessageCallback eom_cb;
353 void *cls;
354};
355
356
357struct SlicerMethodRemoveClosure
358{
359 struct GNUNET_SOCIAL_Slicer *slicer;
360 struct SlicerMethodCallbacks rm_cbs;
361};
362
363
364/**
365 * Callbacks for a slicer method handler.
366 */
367struct SlicerModifierCallbacks
368{
369 GNUNET_SOCIAL_ModifierCallback modifier_cb;
370 void *cls;
371};
372
373
374struct SlicerModifierRemoveClosure
375{
376 struct GNUNET_SOCIAL_Slicer *slicer;
377 struct SlicerModifierCallbacks rm_cbs;
378};
379
380
381/**
382 * Handle for an announcement request. 268 * Handle for an announcement request.
383 */ 269 */
384struct GNUNET_SOCIAL_Announcement 270struct GNUNET_SOCIAL_Announcement
@@ -535,20 +421,23 @@ host_recv_notice_place_leave_method (void *cls,
535 const struct GNUNET_PSYC_MessageMethod *meth, 421 const struct GNUNET_PSYC_MessageMethod *meth,
536 uint64_t message_id, 422 uint64_t message_id,
537 uint32_t flags, 423 uint32_t flags,
538 const struct GNUNET_SOCIAL_Nym *nym, 424 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
539 const char *method_name) 425 const char *method_name)
540{ 426{
541 struct GNUNET_SOCIAL_Host *hst = cls; 427 struct GNUNET_SOCIAL_Host *hst = cls;
428
542 if (0 == memcmp (&(struct GNUNET_CRYPTO_EcdsaPublicKey) {}, 429 if (0 == memcmp (&(struct GNUNET_CRYPTO_EcdsaPublicKey) {},
543 &nym->pub_key, sizeof (nym->pub_key))) 430 nym_pub_key, sizeof (*nym_pub_key)))
544 return; 431 return;
545 432
433 struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (nym_pub_key);
434
546 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 435 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
547 "Host received method for message ID %" PRIu64 " from nym %s: %s\n", 436 "Host received method for message ID %" PRIu64 " from nym %s: %s\n",
548 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name); 437 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name);
549 438
550 hst->notice_place_leave_nym = (struct GNUNET_SOCIAL_Nym *) nym; 439 hst->notice_place_leave_nym = (struct GNUNET_SOCIAL_Nym *) nym;
551 hst->notice_place_leave_env = GNUNET_ENV_environment_create (); 440 hst->notice_place_leave_env = GNUNET_PSYC_env_create ();
552 441
553 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); 442 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key);
554 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -561,7 +450,7 @@ static void
561host_recv_notice_place_leave_modifier (void *cls, 450host_recv_notice_place_leave_modifier (void *cls,
562 const struct GNUNET_MessageHeader *msg, 451 const struct GNUNET_MessageHeader *msg,
563 uint64_t message_id, 452 uint64_t message_id,
564 enum GNUNET_ENV_Operator oper, 453 enum GNUNET_PSYC_Operator oper,
565 const char *name, 454 const char *name,
566 const void *value, 455 const void *value,
567 uint16_t value_size, 456 uint16_t value_size,
@@ -581,8 +470,8 @@ host_recv_notice_place_leave_modifier (void *cls,
581 || 0 == memcmp (name, "_nym_", sizeof ("_nym_") - 1)) 470 || 0 == memcmp (name, "_nym_", sizeof ("_nym_") - 1))
582 return; 471 return;
583 472
584 GNUNET_ENV_environment_add (hst->notice_place_leave_env, 473 GNUNET_PSYC_env_add (hst->notice_place_leave_env,
585 GNUNET_ENV_OP_SET, name, value, value_size); 474 GNUNET_PSYC_OP_SET, name, value, value_size);
586} 475}
587 476
588 477
@@ -607,482 +496,19 @@ host_recv_notice_place_leave_eom (void *cls,
607 hst->farewell_cb (hst->cb_cls, hst->notice_place_leave_nym, 496 hst->farewell_cb (hst->cb_cls, hst->notice_place_leave_nym,
608 hst->notice_place_leave_env); 497 hst->notice_place_leave_env);
609 /* announce leaving guest to place */ 498 /* announce leaving guest to place */
610 GNUNET_ENV_environment_add (hst->notice_place_leave_env, GNUNET_ENV_OP_SET, 499 GNUNET_PSYC_env_add (hst->notice_place_leave_env, GNUNET_PSYC_OP_SET,
611 "_nym", hst->notice_place_leave_nym, 500 "_nym", hst->notice_place_leave_nym,
612 sizeof (*hst->notice_place_leave_nym)); 501 sizeof (*hst->notice_place_leave_nym));
613 GNUNET_SOCIAL_host_announce (hst, "_notice_place_leave", 502 GNUNET_SOCIAL_host_announce (hst, "_notice_place_leave",
614 hst->notice_place_leave_env, 503 hst->notice_place_leave_env,
615 NULL, NULL, GNUNET_SOCIAL_ANNOUNCE_NONE); 504 NULL, NULL, GNUNET_SOCIAL_ANNOUNCE_NONE);
616 nym_destroy (hst->notice_place_leave_nym); 505 nym_destroy (hst->notice_place_leave_nym);
617 } 506 }
618 GNUNET_ENV_environment_destroy (hst->notice_place_leave_env); 507 GNUNET_PSYC_env_destroy (hst->notice_place_leave_env);
619 hst->notice_place_leave_env = NULL; 508 hst->notice_place_leave_env = NULL;
620} 509}
621 510
622 511
623/*** SLICER ***/
624
625/**
626 * Call a method handler for an incoming message part.
627 */
628int
629slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
630 void *value)
631{
632 struct GNUNET_SOCIAL_Slicer *slicer = cls;
633 const struct GNUNET_MessageHeader *msg = slicer->msg;
634 struct SlicerMethodCallbacks *cbs = value;
635 uint16_t ptype = ntohs (msg->type);
636
637 switch (ptype)
638 {
639 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
640 {
641 if (NULL == cbs->method_cb)
642 break;
643 struct GNUNET_PSYC_MessageMethod *
644 meth = (struct GNUNET_PSYC_MessageMethod *) msg;
645 cbs->method_cb (cbs->cls, meth, slicer->message_id,
646 ntohl (meth->flags),
647 nym_get_or_create (&slicer->nym_key),
648 slicer->method_name);
649 break;
650 }
651
652 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
653 {
654 if (NULL == cbs->modifier_cb)
655 break;
656 struct GNUNET_PSYC_MessageModifier *
657 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
658 cbs->modifier_cb (cbs->cls, &mod->header, slicer->message_id,
659 mod->oper, (const char *) &mod[1],
660 (const void *) &mod[1] + ntohs (mod->name_size),
661 ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size),
662 ntohs (mod->value_size));
663 break;
664 }
665
666 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
667 {
668 if (NULL == cbs->modifier_cb)
669 break;
670 cbs->modifier_cb (cbs->cls, msg, slicer->message_id,
671 slicer->mod_oper, slicer->mod_name, &msg[1],
672 ntohs (msg->size) - sizeof (*msg),
673 slicer->mod_full_value_size);
674 break;
675 }
676
677 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
678 {
679 if (NULL == cbs->data_cb)
680 break;
681 uint64_t data_offset = 0; // FIXME
682 cbs->data_cb (cbs->cls, msg, slicer->message_id,
683 data_offset, &msg[1], ntohs (msg->size) - sizeof (*msg));
684 break;
685 }
686
687 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
688 if (NULL == cbs->eom_cb)
689 break;
690 cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_NO);
691 break;
692
693 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
694 if (NULL == cbs->eom_cb)
695 break;
696 cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_YES);
697 break;
698 }
699 return GNUNET_YES;
700}
701
702
703/**
704 * Call a method handler for an incoming message part.
705 */
706int
707slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
708 void *value)
709{
710 struct GNUNET_SOCIAL_Slicer *slicer = cls;
711 struct SlicerModifierCallbacks *cbs = value;
712
713 cbs->modifier_cb (cbs->cls, slicer->msg, slicer->message_id, slicer->mod_oper,
714 slicer->mod_name, slicer->mod_value,
715 slicer->mod_value_size, slicer->mod_full_value_size);
716 return GNUNET_YES;
717}
718
719
720/**
721 * Process an incoming message part and call matching handlers.
722 *
723 * @param cls
724 * Closure.
725 * @param message_id
726 * ID of the message.
727 * @param flags
728 * Flags for the message.
729 * @see enum GNUNET_PSYC_MessageFlags
730 * @param msg
731 * The message part. as it arrived from the network.
732 */
733static void
734slicer_message (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
735 uint64_t message_id, uint32_t flags, uint64_t fragment_offset,
736 const struct GNUNET_MessageHeader *msg)
737{
738 struct GNUNET_SOCIAL_Slicer *slicer = cls;
739 slicer->nym_key = *slave_key;
740
741 uint16_t ptype = ntohs (msg->type);
742 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype)
743 {
744 struct GNUNET_PSYC_MessageMethod *
745 meth = (struct GNUNET_PSYC_MessageMethod *) msg;
746 slicer->method_name_size = ntohs (meth->header.size) - sizeof (*meth);
747 slicer->method_name = GNUNET_malloc (slicer->method_name_size);
748 memcpy (slicer->method_name, &meth[1], slicer->method_name_size);
749 slicer->message_id = message_id;
750 }
751 else
752 {
753 GNUNET_assert (message_id == slicer->message_id);
754 }
755
756 char *nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (slave_key);
757 LOG (GNUNET_ERROR_TYPE_DEBUG,
758 "Slicer received message of type %u and size %u, "
759 "with ID %" PRIu64 " and method %s from %s\n",
760 ptype, ntohs (msg->size), message_id, slicer->method_name, nym_str);
761 GNUNET_free (nym_str);
762
763 slicer->msg = msg;
764
765 /* try-and-slice modifier */
766
767 switch (ptype)
768 {
769 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
770 {
771 struct GNUNET_PSYC_MessageModifier *
772 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
773 slicer->mod_oper = mod->oper;
774 slicer->mod_name_size = ntohs (mod->name_size);
775 slicer->mod_name = GNUNET_malloc (slicer->mod_name_size);
776 memcpy (slicer->mod_name, &mod[1], slicer->mod_name_size);
777 slicer->mod_value = (char *) &mod[1] + slicer->mod_name_size;
778 slicer->mod_full_value_size = ntohs (mod->value_size);
779 slicer->mod_value_remaining = slicer->mod_full_value_size;
780 slicer->mod_value_size
781 = ntohs (mod->header.size) - sizeof (*mod) - slicer->mod_name_size;
782 }
783 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
784 if (ptype == GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT)
785 {
786 slicer->mod_value = (char *) &msg[1];
787 slicer->mod_value_size = ntohs (msg->size) - sizeof (*msg);
788 }
789 slicer->mod_value_remaining -= slicer->mod_value_size;
790 char *name = GNUNET_malloc (slicer->mod_name_size);
791 memcpy (name, slicer->mod_name, slicer->mod_name_size);
792 do
793 {
794 struct GNUNET_HashCode key;
795 uint16_t name_len = strlen (name);
796 GNUNET_CRYPTO_hash (name, name_len, &key);
797 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
798 slicer_modifier_handler_notify,
799 slicer);
800 char *p = strrchr (name, '_');
801 if (NULL == p)
802 break;
803 *p = '\0';
804 } while (1);
805 GNUNET_free (name);
806 }
807
808 /* try-and-slice method */
809
810 char *name = GNUNET_malloc (slicer->method_name_size);
811 memcpy (name, slicer->method_name, slicer->method_name_size);
812 do
813 {
814 struct GNUNET_HashCode key;
815 uint16_t name_len = strlen (name);
816 GNUNET_CRYPTO_hash (name, name_len, &key);
817 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
818 slicer_method_handler_notify,
819 slicer);
820 char *p = strrchr (name, '_');
821 if (NULL == p)
822 break;
823 *p = '\0';
824 } while (1);
825 GNUNET_free (name);
826
827 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
828 GNUNET_free (slicer->method_name);
829
830 if (0 == slicer->mod_value_remaining && NULL != slicer->mod_name)
831 {
832 GNUNET_free (slicer->mod_name);
833 slicer->mod_name = NULL;
834 slicer->mod_name_size = 0;
835 slicer->mod_value_size = 0;
836 slicer->mod_full_value_size = 0;
837 slicer->mod_oper = 0;
838 }
839
840 slicer->msg = NULL;
841}
842
843
844/**
845 * Create a try-and-slice instance.
846 *
847 * A slicer processes incoming messages and notifies callbacks about matching
848 * methods or modifiers encountered.
849 *
850 * @return A new try-and-slice construct.
851 */
852struct GNUNET_SOCIAL_Slicer *
853GNUNET_SOCIAL_slicer_create (void)
854{
855 struct GNUNET_SOCIAL_Slicer *slicer = GNUNET_malloc (sizeof (*slicer));
856 slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
857 slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
858 return slicer;
859}
860
861
862/**
863 * Add a method to the try-and-slice instance.
864 *
865 * The callbacks are called for messages with a matching @a method_name prefix.
866 *
867 * @param slicer
868 * The try-and-slice instance to extend.
869 * @param method_name
870 * Name of the given method, use empty string to match all.
871 * @param method_cb
872 * Method handler invoked upon a matching message.
873 * @param modifier_cb
874 * Modifier handler, invoked after @a method_cb
875 * for each modifier in the message.
876 * @param data_cb
877 * Data handler, invoked after @a modifier_cb for each data fragment.
878 * @param eom_cb
879 * Invoked upon reaching the end of a matching message.
880 * @param cls
881 * Closure for the callbacks.
882 */
883void
884GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
885 const char *method_name,
886 GNUNET_SOCIAL_MethodCallback method_cb,
887 GNUNET_SOCIAL_ModifierCallback modifier_cb,
888 GNUNET_SOCIAL_DataCallback data_cb,
889 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
890 void *cls)
891{
892 struct GNUNET_HashCode key;
893 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
894
895 struct SlicerMethodCallbacks *cbs = GNUNET_malloc (sizeof (*cbs));
896 cbs->method_cb = method_cb;
897 cbs->modifier_cb = modifier_cb;
898 cbs->data_cb = data_cb;
899 cbs->eom_cb = eom_cb;
900 cbs->cls = cls;
901
902 GNUNET_CONTAINER_multihashmap_put (slicer->method_handlers, &key, cbs,
903 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
904}
905
906
907int
908slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
909{
910 struct SlicerMethodRemoveClosure *rm_cls = cls;
911 struct GNUNET_SOCIAL_Slicer *slicer = rm_cls->slicer;
912 struct SlicerMethodCallbacks *rm_cbs = &rm_cls->rm_cbs;
913 struct SlicerMethodCallbacks *cbs = value;
914
915 if (cbs->method_cb == rm_cbs->method_cb
916 && cbs->modifier_cb == rm_cbs->modifier_cb
917 && cbs->data_cb == rm_cbs->data_cb
918 && cbs->eom_cb == rm_cbs->eom_cb)
919 {
920 GNUNET_CONTAINER_multihashmap_remove (slicer->method_handlers, key, cbs);
921 GNUNET_free (cbs);
922 return GNUNET_NO;
923 }
924 return GNUNET_YES;
925}
926
927
928/**
929 * Remove a registered method from the try-and-slice instance.
930 *
931 * Removes one matching handler registered with the given
932 * @a method_name and callbacks.
933 *
934 * @param slicer
935 * The try-and-slice instance.
936 * @param method_name
937 * Name of the method to remove.
938 * @param method_cb
939 * Method handler.
940 * @param modifier_cb
941 * Modifier handler.
942 * @param data_cb
943 * Data handler.
944 * @param eom_cb
945 * End of message handler.
946 *
947 * @return #GNUNET_OK if a method handler was removed,
948 * #GNUNET_NO if no handler matched the given method name and callbacks.
949 */
950int
951GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
952 const char *method_name,
953 GNUNET_SOCIAL_MethodCallback method_cb,
954 GNUNET_SOCIAL_ModifierCallback modifier_cb,
955 GNUNET_SOCIAL_DataCallback data_cb,
956 GNUNET_SOCIAL_EndOfMessageCallback eom_cb)
957{
958 struct GNUNET_HashCode key;
959 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
960
961 struct SlicerMethodRemoveClosure rm_cls;
962 rm_cls.slicer = slicer;
963 struct SlicerMethodCallbacks *rm_cbs = &rm_cls.rm_cbs;
964 rm_cbs->method_cb = method_cb;
965 rm_cbs->modifier_cb = modifier_cb;
966 rm_cbs->data_cb = data_cb;
967 rm_cbs->eom_cb = eom_cb;
968
969 return
970 (GNUNET_SYSERR
971 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
972 slicer_method_remove,
973 &rm_cls))
974 ? GNUNET_NO
975 : GNUNET_OK;
976}
977
978
979/**
980 * Watch a place for changed objects.
981 *
982 * @param slicer
983 * The try-and-slice instance.
984 * @param object_filter
985 * Object prefix to match.
986 * @param modifier_cb
987 * Function to call when encountering a state modifier.
988 * @param cls
989 * Closure for callback.
990 */
991void
992GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
993 const char *object_filter,
994 GNUNET_SOCIAL_ModifierCallback modifier_cb,
995 void *cls)
996{
997 struct SlicerModifierCallbacks *cbs = GNUNET_malloc (sizeof *cbs);
998 cbs->modifier_cb = modifier_cb;
999 cbs->cls = cls;
1000
1001 struct GNUNET_HashCode key;
1002 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
1003 GNUNET_CONTAINER_multihashmap_put (slicer->modifier_handlers, &key, cbs,
1004 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1005}
1006
1007
1008int
1009slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
1010{
1011 struct SlicerModifierRemoveClosure *rm_cls = cls;
1012 struct GNUNET_SOCIAL_Slicer *slicer = rm_cls->slicer;
1013 struct SlicerModifierCallbacks *rm_cbs = &rm_cls->rm_cbs;
1014 struct SlicerModifierCallbacks *cbs = value;
1015
1016 if (cbs->modifier_cb == rm_cbs->modifier_cb)
1017 {
1018 GNUNET_CONTAINER_multihashmap_remove (slicer->modifier_handlers, key, cbs);
1019 GNUNET_free (cbs);
1020 return GNUNET_NO;
1021 }
1022 return GNUNET_YES;
1023}
1024
1025
1026/**
1027 * Remove a registered modifier from the try-and-slice instance.
1028 *
1029 * Removes one matching handler registered with the given
1030 * @a object_filter and @a modifier_cb.
1031 *
1032 * @param slicer
1033 * The try-and-slice instance.
1034 * @param object_filter
1035 * Object prefix to match.
1036 * @param modifier_cb
1037 * Function to call when encountering a state modifier changes.
1038 */
1039int
1040GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
1041 const char *object_filter,
1042 GNUNET_SOCIAL_ModifierCallback modifier_cb)
1043{
1044 struct GNUNET_HashCode key;
1045 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
1046
1047 struct SlicerModifierRemoveClosure rm_cls;
1048 rm_cls.slicer = slicer;
1049 struct SlicerModifierCallbacks *rm_cbs = &rm_cls.rm_cbs;
1050 rm_cbs->modifier_cb = modifier_cb;
1051
1052 return
1053 (GNUNET_SYSERR
1054 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
1055 slicer_modifier_remove,
1056 &rm_cls))
1057 ? GNUNET_NO
1058 : GNUNET_OK;
1059 }
1060
1061
1062int
1063slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value)
1064{
1065 struct SlicerMethodCallbacks *cbs = value;
1066 GNUNET_free (cbs);
1067 return GNUNET_YES;
1068}
1069
1070
1071/**
1072 * Destroy a given try-and-slice instance.
1073 *
1074 * @param slicer
1075 * Slicer to destroy
1076 */
1077void
1078GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer)
1079{
1080 GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
1081 slicer_method_free, NULL);
1082 GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers);
1083 GNUNET_free (slicer);
1084}
1085
1086/*** CLIENT ***/ 512/*** CLIENT ***/
1087 513
1088 514
@@ -1405,7 +831,7 @@ host_recv_enter_request (void *cls,
1405 return; 831 return;
1406 832
1407 const char *method_name = NULL; 833 const char *method_name = NULL;
1408 struct GNUNET_ENV_Environment *env = NULL; 834 struct GNUNET_PSYC_Environment *env = NULL;
1409 struct GNUNET_PSYC_MessageHeader *entry_pmsg = NULL; 835 struct GNUNET_PSYC_MessageHeader *entry_pmsg = NULL;
1410 const void *data = NULL; 836 const void *data = NULL;
1411 uint16_t data_size = 0; 837 uint16_t data_size = 0;
@@ -1423,7 +849,7 @@ host_recv_enter_request (void *cls,
1423 "Received join_msg of type %u and size %u.\n", 849 "Received join_msg of type %u and size %u.\n",
1424 ntohs (join_msg->header.type), ntohs (join_msg->header.size)); 850 ntohs (join_msg->header.type), ntohs (join_msg->header.size));
1425 851
1426 env = GNUNET_ENV_environment_create (); 852 env = GNUNET_PSYC_env_create ();
1427 entry_pmsg = GNUNET_PSYC_message_header_create_from_psyc (join_msg); 853 entry_pmsg = GNUNET_PSYC_message_header_create_from_psyc (join_msg);
1428 if (GNUNET_OK != GNUNET_PSYC_message_parse (entry_pmsg, &method_name, env, 854 if (GNUNET_OK != GNUNET_PSYC_message_parse (entry_pmsg, &method_name, env,
1429 &data, &data_size)) 855 &data, &data_size))
@@ -1444,7 +870,7 @@ host_recv_enter_request (void *cls,
1444 } while (0); 870 } while (0);
1445 871
1446 if (NULL != env) 872 if (NULL != env)
1447 GNUNET_ENV_environment_destroy (env); 873 GNUNET_PSYC_env_destroy (env);
1448 if (NULL != entry_pmsg) 874 if (NULL != entry_pmsg)
1449 GNUNET_free (entry_pmsg); 875 GNUNET_free (entry_pmsg);
1450} 876}
@@ -1693,7 +1119,7 @@ host_cleanup (void *cls)
1693 } 1119 }
1694 if (NULL != hst->slicer) 1120 if (NULL != hst->slicer)
1695 { 1121 {
1696 GNUNET_SOCIAL_slicer_destroy (hst->slicer); 1122 GNUNET_PSYC_slicer_destroy (hst->slicer);
1697 hst->slicer = NULL; 1123 hst->slicer = NULL;
1698 } 1124 }
1699 GNUNET_free (hst); 1125 GNUNET_free (hst);
@@ -1743,7 +1169,7 @@ struct GNUNET_SOCIAL_Host *
1743GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, 1169GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
1744 const struct GNUNET_SOCIAL_Ego *ego, 1170 const struct GNUNET_SOCIAL_Ego *ego,
1745 enum GNUNET_PSYC_Policy policy, 1171 enum GNUNET_PSYC_Policy policy,
1746 struct GNUNET_SOCIAL_Slicer *slicer, 1172 struct GNUNET_PSYC_Slicer *slicer,
1747 GNUNET_SOCIAL_HostEnterCallback enter_cb, 1173 GNUNET_SOCIAL_HostEnterCallback enter_cb,
1748 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, 1174 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
1749 GNUNET_SOCIAL_FarewellCallback farewell_cb, 1175 GNUNET_SOCIAL_FarewellCallback farewell_cb,
@@ -1765,14 +1191,14 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
1765 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); 1191 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc));
1766 1192
1767 plc->tmit = GNUNET_PSYC_transmit_create (plc->client); 1193 plc->tmit = GNUNET_PSYC_transmit_create (plc->client);
1768 plc->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, plc->slicer); 1194 plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer);
1769 1195
1770 hst->slicer = GNUNET_SOCIAL_slicer_create (); 1196 hst->slicer = GNUNET_PSYC_slicer_create ();
1771 GNUNET_SOCIAL_slicer_method_add (hst->slicer, "_notice_place_leave", 1197 GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave",
1772 host_recv_notice_place_leave_method, 1198 host_recv_notice_place_leave_method,
1773 host_recv_notice_place_leave_modifier, 1199 host_recv_notice_place_leave_modifier,
1774 NULL, host_recv_notice_place_leave_eom, hst); 1200 NULL, host_recv_notice_place_leave_eom, hst);
1775 hst->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, hst->slicer); 1201 hst->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, hst->slicer);
1776 1202
1777 uint16_t app_id_size = strlen (app->id) + 1; 1203 uint16_t app_id_size = strlen (app->id) + 1;
1778 struct HostEnterRequest *hreq = GNUNET_malloc (sizeof (*hreq) + app_id_size); 1204 struct HostEnterRequest *hreq = GNUNET_malloc (sizeof (*hreq) + app_id_size);
@@ -1810,7 +1236,7 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
1810 */ 1236 */
1811 struct GNUNET_SOCIAL_Host * 1237 struct GNUNET_SOCIAL_Host *
1812GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, 1238GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
1813 struct GNUNET_SOCIAL_Slicer *slicer, 1239 struct GNUNET_PSYC_Slicer *slicer,
1814 GNUNET_SOCIAL_HostEnterCallback enter_cb, 1240 GNUNET_SOCIAL_HostEnterCallback enter_cb,
1815 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, 1241 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
1816 GNUNET_SOCIAL_FarewellCallback farewell_cb, 1242 GNUNET_SOCIAL_FarewellCallback farewell_cb,
@@ -1837,14 +1263,14 @@ GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
1837 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc)); 1263 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, hst, sizeof (*plc));
1838 1264
1839 plc->tmit = GNUNET_PSYC_transmit_create (plc->client); 1265 plc->tmit = GNUNET_PSYC_transmit_create (plc->client);
1840 plc->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, plc->slicer); 1266 plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer);
1841 1267
1842 hst->slicer = GNUNET_SOCIAL_slicer_create (); 1268 hst->slicer = GNUNET_PSYC_slicer_create ();
1843 GNUNET_SOCIAL_slicer_method_add (hst->slicer, "_notice_place_leave", 1269 GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave",
1844 host_recv_notice_place_leave_method, 1270 host_recv_notice_place_leave_method,
1845 host_recv_notice_place_leave_modifier, 1271 host_recv_notice_place_leave_modifier,
1846 NULL, host_recv_notice_place_leave_eom, hst); 1272 NULL, host_recv_notice_place_leave_eom, hst);
1847 hst->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, hst->slicer); 1273 hst->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, hst->slicer);
1848 1274
1849 hreq->header.size = htons (sizeof (*hreq) + app_id_size); 1275 hreq->header.size = htons (sizeof (*hreq) + app_id_size);
1850 hreq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER); 1276 hreq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER);
@@ -1926,12 +1352,12 @@ GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
1926void 1352void
1927GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *hst, 1353GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *hst,
1928 const struct GNUNET_SOCIAL_Nym *nym, 1354 const struct GNUNET_SOCIAL_Nym *nym,
1929 struct GNUNET_ENV_Environment *env) 1355 struct GNUNET_PSYC_Environment *env)
1930{ 1356{
1931 if (NULL == env) 1357 if (NULL == env)
1932 env = GNUNET_ENV_environment_create (); 1358 env = GNUNET_PSYC_env_create ();
1933 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET, 1359 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
1934 "_nym", &nym->pub_key, sizeof (nym->pub_key)); 1360 "_nym", &nym->pub_key, sizeof (nym->pub_key));
1935 GNUNET_SOCIAL_host_announce (hst, "_notice_place_leave", env, NULL, NULL, 1361 GNUNET_SOCIAL_host_announce (hst, "_notice_place_leave", env, NULL, NULL,
1936 GNUNET_SOCIAL_ANNOUNCE_NONE); 1362 GNUNET_SOCIAL_ANNOUNCE_NONE);
1937} 1363}
@@ -2033,7 +1459,7 @@ GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym)
2033struct GNUNET_SOCIAL_Announcement * 1459struct GNUNET_SOCIAL_Announcement *
2034GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst, 1460GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst,
2035 const char *method_name, 1461 const char *method_name,
2036 const struct GNUNET_ENV_Environment *env, 1462 const struct GNUNET_PSYC_Environment *env,
2037 GNUNET_PSYC_TransmitNotifyData notify_data, 1463 GNUNET_PSYC_TransmitNotifyData notify_data,
2038 void *notify_data_cls, 1464 void *notify_data_cls,
2039 enum GNUNET_SOCIAL_AnnounceFlags flags) 1465 enum GNUNET_SOCIAL_AnnounceFlags flags)
@@ -2152,7 +1578,7 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
2152 */ 1578 */
2153void 1579void
2154GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, 1580GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
2155 const struct GNUNET_ENV_Environment *env, 1581 const struct GNUNET_PSYC_Environment *env,
2156 GNUNET_ContinuationCallback disconnect_cb, 1582 GNUNET_ContinuationCallback disconnect_cb,
2157 void *cls) 1583 void *cls)
2158{ 1584{
@@ -2242,7 +1668,7 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
2242 uint32_t relay_count, 1668 uint32_t relay_count,
2243 const struct GNUNET_PeerIdentity *relays, 1669 const struct GNUNET_PeerIdentity *relays,
2244 const struct GNUNET_PSYC_Message *entry_msg, 1670 const struct GNUNET_PSYC_Message *entry_msg,
2245 struct GNUNET_SOCIAL_Slicer *slicer, 1671 struct GNUNET_PSYC_Slicer *slicer,
2246 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 1672 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
2247 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, 1673 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
2248 void *cls) 1674 void *cls)
@@ -2264,7 +1690,7 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
2264 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); 1690 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc));
2265 1691
2266 plc->tmit = GNUNET_PSYC_transmit_create (plc->client); 1692 plc->tmit = GNUNET_PSYC_transmit_create (plc->client);
2267 plc->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, plc->slicer); 1693 plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer);
2268 1694
2269 struct GuestEnterRequest * 1695 struct GuestEnterRequest *
2270 greq = guest_enter_request_create (app->id, &ego->pub_key, &plc->pub_key, 1696 greq = guest_enter_request_create (app->id, &ego->pub_key, &plc->pub_key,
@@ -2307,7 +1733,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
2307 const char *gns_name, 1733 const char *gns_name,
2308 const char *password, 1734 const char *password,
2309 const struct GNUNET_PSYC_Message *join_msg, 1735 const struct GNUNET_PSYC_Message *join_msg,
2310 struct GNUNET_SOCIAL_Slicer *slicer, 1736 struct GNUNET_PSYC_Slicer *slicer,
2311 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 1737 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
2312 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, 1738 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
2313 void *cls) 1739 void *cls)
@@ -2356,7 +1782,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
2356 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); 1782 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc));
2357 1783
2358 plc->tmit = GNUNET_PSYC_transmit_create (plc->client); 1784 plc->tmit = GNUNET_PSYC_transmit_create (plc->client);
2359 plc->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, plc->slicer); 1785 plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer);
2360 1786
2361 plc->connect_msg = &greq->header; 1787 plc->connect_msg = &greq->header;
2362 place_send_connect_msg (plc); 1788 place_send_connect_msg (plc);
@@ -2385,7 +1811,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
2385struct GNUNET_SOCIAL_Guest * 1811struct GNUNET_SOCIAL_Guest *
2386GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, 1812GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
2387 enum GNUNET_PSYC_SlaveJoinFlags flags, 1813 enum GNUNET_PSYC_SlaveJoinFlags flags,
2388 struct GNUNET_SOCIAL_Slicer *slicer, 1814 struct GNUNET_PSYC_Slicer *slicer,
2389 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 1815 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
2390 void *cls) 1816 void *cls)
2391{ 1817{
@@ -2416,7 +1842,7 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn
2416 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc)); 1842 GNUNET_CLIENT_MANAGER_set_user_context_ (plc->client, gst, sizeof (*plc));
2417 1843
2418 plc->tmit = GNUNET_PSYC_transmit_create (plc->client); 1844 plc->tmit = GNUNET_PSYC_transmit_create (plc->client);
2419 plc->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, plc->slicer); 1845 plc->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, plc->slicer);
2420 1846
2421 plc->connect_msg = &greq->header; 1847 plc->connect_msg = &greq->header;
2422 place_send_connect_msg (plc); 1848 place_send_connect_msg (plc);
@@ -2448,7 +1874,7 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn
2448struct GNUNET_SOCIAL_TalkRequest * 1874struct GNUNET_SOCIAL_TalkRequest *
2449GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst, 1875GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst,
2450 const char *method_name, 1876 const char *method_name,
2451 const struct GNUNET_ENV_Environment *env, 1877 const struct GNUNET_PSYC_Environment *env,
2452 GNUNET_PSYC_TransmitNotifyData notify_data, 1878 GNUNET_PSYC_TransmitNotifyData notify_data,
2453 void *notify_data_cls, 1879 void *notify_data_cls,
2454 enum GNUNET_SOCIAL_TalkFlags flags) 1880 enum GNUNET_SOCIAL_TalkFlags flags)
@@ -2526,7 +1952,7 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
2526 */ 1952 */
2527void 1953void
2528GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, 1954GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
2529 struct GNUNET_ENV_Environment *env, 1955 struct GNUNET_PSYC_Environment *env,
2530 GNUNET_ContinuationCallback disconnect_cb, 1956 GNUNET_ContinuationCallback disconnect_cb,
2531 void *cls) 1957 void *cls)
2532{ 1958{
@@ -2575,14 +2001,14 @@ place_history_replay (struct GNUNET_SOCIAL_Place *plc,
2575 uint64_t message_limit, 2001 uint64_t message_limit,
2576 const char *method_prefix, 2002 const char *method_prefix,
2577 uint32_t flags, 2003 uint32_t flags,
2578 struct GNUNET_SOCIAL_Slicer *slicer, 2004 struct GNUNET_PSYC_Slicer *slicer,
2579 GNUNET_ResultCallback result_cb, 2005 GNUNET_ResultCallback result_cb,
2580 void *cls) 2006 void *cls)
2581{ 2007{
2582 struct GNUNET_PSYC_HistoryRequestMessage *req; 2008 struct GNUNET_PSYC_HistoryRequestMessage *req;
2583 struct GNUNET_SOCIAL_HistoryRequest *hist = GNUNET_malloc (sizeof (*hist)); 2009 struct GNUNET_SOCIAL_HistoryRequest *hist = GNUNET_malloc (sizeof (*hist));
2584 hist->plc = plc; 2010 hist->plc = plc;
2585 hist->recv = GNUNET_PSYC_receive_create (NULL, slicer_message, slicer); 2011 hist->recv = GNUNET_PSYC_receive_create (NULL, GNUNET_PSYC_slicer_message, slicer);
2586 hist->result_cb = result_cb; 2012 hist->result_cb = result_cb;
2587 hist->cls = cls; 2013 hist->cls = cls;
2588 hist->op_id = GNUNET_CLIENT_MANAGER_op_add (plc->client, 2014 hist->op_id = GNUNET_CLIENT_MANAGER_op_add (plc->client,
@@ -2638,7 +2064,7 @@ GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
2638 uint64_t end_message_id, 2064 uint64_t end_message_id,
2639 const char *method_prefix, 2065 const char *method_prefix,
2640 uint32_t flags, 2066 uint32_t flags,
2641 struct GNUNET_SOCIAL_Slicer *slicer, 2067 struct GNUNET_PSYC_Slicer *slicer,
2642 GNUNET_ResultCallback result_cb, 2068 GNUNET_ResultCallback result_cb,
2643 void *cls) 2069 void *cls)
2644{ 2070{
@@ -2674,7 +2100,7 @@ GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
2674 uint64_t message_limit, 2100 uint64_t message_limit,
2675 const char *method_prefix, 2101 const char *method_prefix,
2676 uint32_t flags, 2102 uint32_t flags,
2677 struct GNUNET_SOCIAL_Slicer *slicer, 2103 struct GNUNET_PSYC_Slicer *slicer,
2678 GNUNET_ResultCallback result_cb, 2104 GNUNET_ResultCallback result_cb,
2679 void *cls) 2105 void *cls)
2680{ 2106{
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 1fb9cc568..925fff03e 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -30,7 +30,6 @@
30#include "gnunet_common.h" 30#include "gnunet_common.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_testing_lib.h" 32#include "gnunet_testing_lib.h"
33#include "gnunet_env_lib.h"
34#include "gnunet_psyc_util_lib.h" 33#include "gnunet_psyc_util_lib.h"
35#include "gnunet_social_service.h" 34#include "gnunet_social_service.h"
36#include "gnunet_core_service.h" 35#include "gnunet_core_service.h"
@@ -75,8 +74,8 @@ struct GNUNET_HashCode place_pub_hash;
75struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key; 74struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key;
76struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key; 75struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key;
77 76
78struct GNUNET_SOCIAL_Slicer *host_slicer; 77struct GNUNET_PSYC_Slicer *host_slicer;
79struct GNUNET_SOCIAL_Slicer *guest_slicer; 78struct GNUNET_PSYC_Slicer *guest_slicer;
80 79
81struct GNUNET_SOCIAL_Host *hst; 80struct GNUNET_SOCIAL_Host *hst;
82struct GNUNET_SOCIAL_Guest *gst; 81struct GNUNET_SOCIAL_Guest *gst;
@@ -90,7 +89,7 @@ struct GuestEnterMessage
90{ 89{
91 struct GNUNET_PSYC_Message *msg; 90 struct GNUNET_PSYC_Message *msg;
92 const char *method_name; 91 const char *method_name;
93 struct GNUNET_ENV_Environment *env; 92 struct GNUNET_PSYC_Environment *env;
94 void *data; 93 void *data;
95 uint16_t data_size; 94 uint16_t data_size;
96} guest_enter_msg; 95} guest_enter_msg;
@@ -99,7 +98,7 @@ struct TransmitClosure
99{ 98{
100 struct GNUNET_SOCIAL_Announcement *host_ann; 99 struct GNUNET_SOCIAL_Announcement *host_ann;
101 struct GNUNET_SOCIAL_TalkRequest *guest_talk; 100 struct GNUNET_SOCIAL_TalkRequest *guest_talk;
102 struct GNUNET_ENV_Environment *env; 101 struct GNUNET_PSYC_Environment *env;
103 char *data[16]; 102 char *data[16];
104 uint8_t data_delay[16]; 103 uint8_t data_delay[16];
105 uint8_t data_count; 104 uint8_t data_count;
@@ -156,7 +155,7 @@ static void
156host_answer_door (void *cls, 155host_answer_door (void *cls,
157 struct GNUNET_SOCIAL_Nym *nym, 156 struct GNUNET_SOCIAL_Nym *nym,
158 const char *method_name, 157 const char *method_name,
159 struct GNUNET_ENV_Environment *env, 158 struct GNUNET_PSYC_Environment *env,
160 size_t data_size, 159 size_t data_size,
161 const void *data); 160 const void *data);
162 161
@@ -199,13 +198,13 @@ cleanup ()
199 198
200 if (NULL != guest_slicer) 199 if (NULL != guest_slicer)
201 { 200 {
202 GNUNET_SOCIAL_slicer_destroy (guest_slicer); 201 GNUNET_PSYC_slicer_destroy (guest_slicer);
203 guest_slicer = NULL; 202 guest_slicer = NULL;
204 } 203 }
205 204
206 if (NULL != host_slicer) 205 if (NULL != host_slicer)
207 { 206 {
208 GNUNET_SOCIAL_slicer_destroy (host_slicer); 207 GNUNET_PSYC_slicer_destroy (host_slicer);
209 host_slicer = NULL; 208 host_slicer = NULL;
210 } 209 }
211 210
@@ -292,7 +291,7 @@ notify_data (void *cls, uint16_t *data_size, void *data)
292 struct TransmitClosure *tmit = cls; 291 struct TransmitClosure *tmit = cls;
293 if (NULL != tmit->env) 292 if (NULL != tmit->env)
294 { 293 {
295 GNUNET_ENV_environment_destroy (tmit->env); 294 GNUNET_PSYC_env_destroy (tmit->env);
296 tmit->env = NULL; 295 tmit->env = NULL;
297 } 296 }
298 if (0 == tmit->data_count) 297 if (0 == tmit->data_count)
@@ -355,7 +354,7 @@ schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
355static void 354static void
356host_farewell2 (void *cls, 355host_farewell2 (void *cls,
357 const struct GNUNET_SOCIAL_Nym *nym, 356 const struct GNUNET_SOCIAL_Nym *nym,
358 struct GNUNET_ENV_Environment *env) 357 struct GNUNET_PSYC_Environment *env)
359{ 358{
360 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 359 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
361 "Nym left the place again.\n"); 360 "Nym left the place again.\n");
@@ -526,7 +525,7 @@ zone_add_place ()
526static void 525static void
527host_farewell (void *cls, 526host_farewell (void *cls,
528 const struct GNUNET_SOCIAL_Nym *nym, 527 const struct GNUNET_SOCIAL_Nym *nym,
529 struct GNUNET_ENV_Environment *env) 528 struct GNUNET_PSYC_Environment *env)
530{ 529{
531 const struct GNUNET_CRYPTO_EcdsaPublicKey * 530 const struct GNUNET_CRYPTO_EcdsaPublicKey *
532 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym); 531 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
@@ -536,7 +535,7 @@ host_farewell (void *cls,
536 "Farewell: nym %s (%s) has left the place.\n", 535 "Farewell: nym %s (%s) has left the place.\n",
537 GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str); 536 GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str);
538 GNUNET_free (str); 537 GNUNET_free (str);
539 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env)); 538 GNUNET_assert (1 == GNUNET_PSYC_env_get_count (env));
540 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))) 539 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)))
541 { 540 {
542 str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&guest_pub_key); 541 str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&guest_pub_key);
@@ -565,11 +564,11 @@ guest_leave()
565 else 564 else
566 test = TEST_GUEST_LEAVE2; 565 test = TEST_GUEST_LEAVE2;
567 566
568 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 567 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
569 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET, 568 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
570 "_message", DATA2ARG ("Leaving.")); 569 "_message", DATA2ARG ("Leaving."));
571 GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL); 570 GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL);
572 GNUNET_ENV_environment_destroy (env); 571 GNUNET_PSYC_env_destroy (env);
573 gst = NULL; 572 gst = NULL;
574 gst_plc = NULL; 573 gst_plc = NULL;
575} 574}
@@ -723,7 +722,7 @@ guest_recv_method (void *cls,
723 const struct GNUNET_PSYC_MessageMethod *meth, 722 const struct GNUNET_PSYC_MessageMethod *meth,
724 uint64_t message_id, 723 uint64_t message_id,
725 uint32_t flags, 724 uint32_t flags,
726 const struct GNUNET_SOCIAL_Nym *nym, 725 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
727 const char *method_name) 726 const char *method_name)
728{ 727{
729 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 728 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -738,7 +737,7 @@ static void
738guest_recv_modifier (void *cls, 737guest_recv_modifier (void *cls,
739 const struct GNUNET_MessageHeader *msg, 738 const struct GNUNET_MessageHeader *msg,
740 uint64_t message_id, 739 uint64_t message_id,
741 enum GNUNET_ENV_Operator oper, 740 enum GNUNET_PSYC_Operator oper,
742 const char *name, 741 const char *name,
743 const void *value, 742 const void *value,
744 uint16_t value_size, 743 uint16_t value_size,
@@ -755,7 +754,7 @@ static void
755guest_recv_mod_foo_bar (void *cls, 754guest_recv_mod_foo_bar (void *cls,
756 const struct GNUNET_MessageHeader *msg, 755 const struct GNUNET_MessageHeader *msg,
757 uint64_t message_id, 756 uint64_t message_id,
758 enum GNUNET_ENV_Operator oper, 757 enum GNUNET_PSYC_Operator oper,
759 const char *name, 758 const char *name,
760 const void *value, 759 const void *value,
761 uint16_t value_size, 760 uint16_t value_size,
@@ -833,7 +832,7 @@ host_recv_method (void *cls,
833 const struct GNUNET_PSYC_MessageMethod *meth, 832 const struct GNUNET_PSYC_MessageMethod *meth,
834 uint64_t message_id, 833 uint64_t message_id,
835 uint32_t flags, 834 uint32_t flags,
836 const struct GNUNET_SOCIAL_Nym *nym, 835 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
837 const char *method_name) 836 const char *method_name)
838{ 837{
839 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 838 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -848,7 +847,7 @@ static void
848host_recv_modifier (void *cls, 847host_recv_modifier (void *cls,
849 const struct GNUNET_MessageHeader *msg, 848 const struct GNUNET_MessageHeader *msg,
850 uint64_t message_id, 849 uint64_t message_id,
851 enum GNUNET_ENV_Operator oper, 850 enum GNUNET_PSYC_Operator oper,
852 const char *name, 851 const char *name,
853 const void *value, 852 const void *value,
854 uint16_t value_size, 853 uint16_t value_size,
@@ -924,11 +923,11 @@ guest_talk ()
924 test = TEST_GUEST_TALK; 923 test = TEST_GUEST_TALK;
925 924
926 tmit = (struct TransmitClosure) {}; 925 tmit = (struct TransmitClosure) {};
927 tmit.env = GNUNET_ENV_environment_create (); 926 tmit.env = GNUNET_PSYC_env_create ();
928 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 927 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
929 "_bar_foo", DATA2ARG ("one two three")); 928 "_bar_foo", DATA2ARG ("one two three"));
930 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 929 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
931 "_bar_baz", DATA2ARG ("four five")); 930 "_bar_baz", DATA2ARG ("four five"));
932 tmit.data[0] = "zzz xxx yyy"; 931 tmit.data[0] = "zzz xxx yyy";
933 tmit.data[1] = "zyx wvu tsr qpo"; 932 tmit.data[1] = "zyx wvu tsr qpo";
934 tmit.data_delay[1] = 1; 933 tmit.data_delay[1] = 1;
@@ -951,13 +950,13 @@ host_announce ()
951 "Test #%u: Host announcement.\n", test); 950 "Test #%u: Host announcement.\n", test);
952 951
953 tmit = (struct TransmitClosure) {}; 952 tmit = (struct TransmitClosure) {};
954 tmit.env = GNUNET_ENV_environment_create (); 953 tmit.env = GNUNET_PSYC_env_create ();
955 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 954 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
956 "_foo", DATA2ARG ("bar baz")); 955 "_foo", DATA2ARG ("bar baz"));
957 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 956 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
958 "_foo_bar", DATA2ARG ("foo bar")); 957 "_foo_bar", DATA2ARG ("foo bar"));
959 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 958 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
960 "_foo_bar_baz", DATA2ARG ("foo bar baz")); 959 "_foo_bar_baz", DATA2ARG ("foo bar baz"));
961 tmit.data[0] = "aaa bbb ccc"; 960 tmit.data[0] = "aaa bbb ccc";
962 tmit.data[1] = "abc def ghi jkl"; 961 tmit.data[1] = "abc def ghi jkl";
963 tmit.data_delay[1] = 1; 962 tmit.data_delay[1] = 1;
@@ -976,8 +975,8 @@ static void
976host_announce2 () 975host_announce2 ()
977{ 976{
978 GNUNET_assert (2 == mod_foo_bar_rcls.n); 977 GNUNET_assert (2 == mod_foo_bar_rcls.n);
979 GNUNET_SOCIAL_slicer_modifier_remove (guest_slicer, "_foo_bar", 978 GNUNET_PSYC_slicer_modifier_remove (guest_slicer, "_foo_bar",
980 guest_recv_mod_foo_bar); 979 guest_recv_mod_foo_bar);
981 980
982 test = TEST_HOST_ANNOUNCE2; 981 test = TEST_HOST_ANNOUNCE2;
983 982
@@ -985,13 +984,13 @@ host_announce2 ()
985 "Test #%u: Host announcement 2.\n", test); 984 "Test #%u: Host announcement 2.\n", test);
986 985
987 tmit = (struct TransmitClosure) {}; 986 tmit = (struct TransmitClosure) {};
988 tmit.env = GNUNET_ENV_environment_create (); 987 tmit.env = GNUNET_PSYC_env_create ();
989 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 988 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
990 "_foo2", DATA2ARG ("BAR BAZ")); 989 "_foo2", DATA2ARG ("BAR BAZ"));
991 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 990 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
992 "_foo2_bar", DATA2ARG ("FOO BAR")); 991 "_foo2_bar", DATA2ARG ("FOO BAR"));
993 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 992 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
994 "_foo2_bar", DATA2ARG ("FOO BAR BAZ")); 993 "_foo2_bar", DATA2ARG ("FOO BAR BAZ"));
995 tmit.data[0] = "AAA BBB CCC"; 994 tmit.data[0] = "AAA BBB CCC";
996 tmit.data[1] = "ABC DEF GHI JKL"; 995 tmit.data[1] = "ABC DEF GHI JKL";
997 tmit.data[2] = "TESTING ONE TWO THREE"; 996 tmit.data[2] = "TESTING ONE TWO THREE";
@@ -1015,7 +1014,7 @@ guest_recv_entry_decision (void *cls,
1015 1014
1016 if (NULL != entry_msg) 1015 if (NULL != entry_msg)
1017 { 1016 {
1018 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 1017 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
1019 const char *method_name = NULL; 1018 const char *method_name = NULL;
1020 const void *data = NULL; 1019 const void *data = NULL;
1021 uint16_t data_size = 0; 1020 uint16_t data_size = 0;
@@ -1057,7 +1056,7 @@ static void
1057host_answer_door (void *cls, 1056host_answer_door (void *cls,
1058 struct GNUNET_SOCIAL_Nym *nym, 1057 struct GNUNET_SOCIAL_Nym *nym,
1059 const char *method_name, 1058 const char *method_name,
1060 struct GNUNET_ENV_Environment *env, 1059 struct GNUNET_PSYC_Environment *env,
1061 size_t data_size, 1060 size_t data_size,
1062 const void *data) 1061 const void *data)
1063{ 1062{
@@ -1113,11 +1112,11 @@ guest_enter ()
1113 struct GuestEnterMessage *emsg = &guest_enter_msg; 1112 struct GuestEnterMessage *emsg = &guest_enter_msg;
1114 1113
1115 emsg->method_name = "_request_enter"; 1114 emsg->method_name = "_request_enter";
1116 emsg->env = GNUNET_ENV_environment_create (); 1115 emsg->env = GNUNET_PSYC_env_create ();
1117 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1116 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1118 "_abc", "abc def", 7); 1117 "_abc", "abc def", 7);
1119 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1118 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1120 "_abc_def", "abc def ghi", 11); 1119 "_abc_def", "abc def ghi", 11);
1121 emsg->data = "let me in"; 1120 emsg->data = "let me in";
1122 emsg->data_size = strlen (emsg->data) + 1; 1121 emsg->data_size = strlen (emsg->data) + 1;
1123 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1122 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
@@ -1142,11 +1141,11 @@ guest_enter_by_name ()
1142 struct GuestEnterMessage *emsg = &guest_enter_msg; 1141 struct GuestEnterMessage *emsg = &guest_enter_msg;
1143 1142
1144 emsg->method_name = "_request_enter"; 1143 emsg->method_name = "_request_enter";
1145 emsg->env = GNUNET_ENV_environment_create (); 1144 emsg->env = GNUNET_PSYC_env_create ();
1146 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1145 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1147 "_abc", "abc def", 7); 1146 "_abc", "abc def", 7);
1148 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1147 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1149 "_abc_def", "abc def ghi", 11); 1148 "_abc_def", "abc def ghi", 11);
1150 emsg->data = "let me in"; 1149 emsg->data = "let me in";
1151 emsg->data_size = strlen (emsg->data) + 1; 1150 emsg->data_size = strlen (emsg->data) + 1;
1152 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1151 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
@@ -1175,12 +1174,12 @@ guest_init ()
1175{ 1174{
1176 guest_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (guest_ego)); 1175 guest_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (guest_ego));
1177 1176
1178 guest_slicer = GNUNET_SOCIAL_slicer_create (); 1177 guest_slicer = GNUNET_PSYC_slicer_create ();
1179 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "", 1178 GNUNET_PSYC_slicer_method_add (guest_slicer, "",
1180 guest_recv_method, guest_recv_modifier, 1179 guest_recv_method, guest_recv_modifier,
1181 guest_recv_data, guest_recv_eom, NULL); 1180 guest_recv_data, guest_recv_eom, NULL);
1182 GNUNET_SOCIAL_slicer_modifier_add (guest_slicer, "_foo_bar", 1181 GNUNET_PSYC_slicer_modifier_add (guest_slicer, "_foo_bar",
1183 guest_recv_mod_foo_bar, &mod_foo_bar_rcls); 1182 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
1184 test = TEST_HOST_ANSWER_DOOR_ADMIT; 1183 test = TEST_HOST_ANSWER_DOOR_ADMIT;
1185 1184
1186 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", &host_pub_key, 1185 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", &host_pub_key,
@@ -1224,10 +1223,10 @@ host_entered (void *cls, int result,
1224static void 1223static void
1225host_enter () 1224host_enter ()
1226{ 1225{
1227 host_slicer = GNUNET_SOCIAL_slicer_create (); 1226 host_slicer = GNUNET_PSYC_slicer_create ();
1228 GNUNET_SOCIAL_slicer_method_add (host_slicer, "", 1227 GNUNET_PSYC_slicer_method_add (host_slicer, "",
1229 &host_recv_method, &host_recv_modifier, 1228 &host_recv_method, &host_recv_modifier,
1230 &host_recv_data, &host_recv_eom, NULL); 1229 &host_recv_data, &host_recv_eom, NULL);
1231 1230
1232 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); 1231 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n");
1233 test = TEST_HOST_ENTER; 1232 test = TEST_HOST_ENTER;