aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_social_service.h156
-rw-r--r--src/psycstore/psyc_util_lib.c5
-rw-r--r--src/social/social_api.c443
-rw-r--r--src/social/test_social.c95
4 files changed, 486 insertions, 213 deletions
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index 4864543fd..24aa871ed 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -105,7 +105,7 @@ typedef void
105 105
106 106
107/** 107/**
108 * Function called upon receiving a data fragment of a message. 108 * Function called upon receiving a modifier of a message.
109 * 109 *
110 * @param cls 110 * @param cls
111 * Closure. 111 * Closure.
@@ -115,8 +115,10 @@ typedef void
115 * Message part, as it arrived from the network. 115 * Message part, as it arrived from the network.
116 * @param oper 116 * @param oper
117 * Operation to perform. 117 * Operation to perform.
118 * 0 in case of a modifier continuation.
118 * @param name 119 * @param name
119 * Name of the modifier. 120 * Name of the modifier.
121 * NULL in case of a modifier continuation.
120 * @param value 122 * @param value
121 * Value of the modifier. 123 * Value of the modifier.
122 * @param value_size 124 * @param value_size
@@ -124,12 +126,13 @@ typedef void
124 */ 126 */
125typedef void 127typedef void
126(*GNUNET_SOCIAL_ModifierCallback) (void *cls, 128(*GNUNET_SOCIAL_ModifierCallback) (void *cls,
127 const struct GNUNET_PSYC_MessageModifier *msg, 129 const struct GNUNET_MessageHeader *msg,
128 uint64_t message_id, 130 uint64_t message_id,
129 enum GNUNET_ENV_Operator oper, 131 enum GNUNET_ENV_Operator oper,
130 const char *name, 132 const char *name,
131 const void *value, 133 const void *value,
132 uint16_t value_size); 134 uint16_t value_size,
135 uint16_t full_value_size);
133 136
134 137
135/** 138/**
@@ -185,6 +188,9 @@ typedef void
185/** 188/**
186 * Create a try-and-slice instance. 189 * Create a try-and-slice instance.
187 * 190 *
191 * A slicer processes incoming messages and notifies callbacks about matching
192 * methods or modifiers encountered.
193 *
188 * @return A new try-and-slice construct. 194 * @return A new try-and-slice construct.
189 */ 195 */
190struct GNUNET_SOCIAL_Slicer * 196struct GNUNET_SOCIAL_Slicer *
@@ -194,45 +200,107 @@ GNUNET_SOCIAL_slicer_create (void);
194/** 200/**
195 * Add a method to the try-and-slice instance. 201 * Add a method to the try-and-slice instance.
196 * 202 *
197 * A slicer processes messages and calls methods that match a message. A match 203 * The callbacks are called for messages with a matching @a method_name prefix.
198 * happens whenever the method name of a message starts with the method_name
199 * parameter given here.
200 * 204 *
201 * @param slicer The try-and-slice instance to extend. 205 * @param slicer
202 * @param method_name Name of the given method, use empty string for default. 206 * The try-and-slice instance to extend.
203 * @param method Method to invoke. 207 * @param method_name
204 * @param method_cls Closure for method. 208 * Name of the given method, use empty string to match all.
209 * @param method_cb
210 * Method handler invoked upon a matching message.
211 * @param modifier_cb
212 * Modifier handler, invoked after @a method_cb
213 * for each modifier in the message.
214 * @param data_cb
215 * Data handler, invoked after @a modifier_cb for each data fragment.
216 * @param eom_cb
217 * Invoked upon reaching the end of a matching message.
218 * @param cls
219 * Closure for the callbacks.
205 */ 220 */
206void 221void
207GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 222GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
208 const char *method_name, 223 const char *method_name,
209 GNUNET_SOCIAL_MethodCallback method_cb, 224 GNUNET_SOCIAL_MethodCallback method_cb,
210 GNUNET_SOCIAL_ModifierCallback modifier_cb, 225 GNUNET_SOCIAL_ModifierCallback modifier_cb,
211 GNUNET_SOCIAL_DataCallback data_cb, 226 GNUNET_SOCIAL_DataCallback data_cb,
212 GNUNET_SOCIAL_EndOfMessageCallback eom_cb, 227 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
213 void *cls); 228 void *cls);
229
230/**
231 * Remove a registered method from the try-and-slice instance.
232 *
233 * Removes one matching handler registered with the given
234 * @a method_name and callbacks.
235 *
236 * @param slicer
237 * The try-and-slice instance.
238 * @param method_name
239 * Name of the method to remove.
240 * @param method_cb
241 * Method handler.
242 * @param modifier_cb
243 * Modifier handler.
244 * @param data_cb
245 * Data handler.
246 * @param eom_cb
247 * End of message handler.
248 *
249 * @return #GNUNET_OK if a method handler was removed,
250 * #GNUNET_NO if no handler matched the given method name and callbacks.
251 */
252int
253GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
254 const char *method_name,
255 GNUNET_SOCIAL_MethodCallback method_cb,
256 GNUNET_SOCIAL_ModifierCallback modifier_cb,
257 GNUNET_SOCIAL_DataCallback data_cb,
258 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
259
260
261/**
262 * Watch a place for changed objects.
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.
270 * @param cls
271 * Closure for callback.
272 */
273void
274GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
275 const char *object_filter,
276 GNUNET_SOCIAL_ModifierCallback modifier_cb,
277 void *cls);
214 278
215 279
216/** 280/**
217 * Remove a registered method handler from the try-and-slice instance. 281 * Remove a registered modifier from the try-and-slice instance.
282 *
283 * Removes one matching handler registered with the given
284 * @a object_filter and callback.
218 * 285 *
219 * @param slicer The try-and-slice instance. 286 * @param slicer
220 * @param method_name Name of the method to remove. 287 * The try-and-slice instance.
221 * @param method Method handler. 288 * @param object_filter
289 * Object prefix to match.
290 * @param modifier_cb
291 * Function to call when encountering a state modifier changes.
222 */ 292 */
223int 293int
224GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 294GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
225 const char *method_name, 295 const char *object_filter,
226 GNUNET_SOCIAL_MethodCallback method_cb, 296 GNUNET_SOCIAL_ModifierCallback modifier_cb);
227 GNUNET_SOCIAL_ModifierCallback modifier_cb,
228 GNUNET_SOCIAL_DataCallback data_cb,
229 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
230 297
231 298
232/** 299/**
233 * Destroy a given try-and-slice instance. 300 * Destroy a given try-and-slice instance.
234 * 301 *
235 * @param slicer slicer to destroy 302 * @param slicer
303 * Slicer to destroy
236 */ 304 */
237void 305void
238GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer); 306GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
@@ -826,38 +894,6 @@ void
826GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist); 894GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
827 895
828 896
829struct GNUNET_SOCIAL_WatchHandle;
830
831/**
832 * Watch a place for changed objects.
833 *
834 * @param place
835 * Place to watch.
836 * @param object_filter
837 * Object prefix to match.
838 * @param var_cb
839 * Function to call when an object/state var changes.
840 * @param cls
841 * Closure for callback.
842 *
843 * @return Handle that can be used to cancel watching.
844 */
845struct GNUNET_SOCIAL_WatchHandle *
846GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
847 const char *object_filter,
848 GNUNET_PSYC_StateVarCallback var_cb,
849 void *cls);
850
851
852/**
853 * Cancel watching a place for changed objects.
854 *
855 * @param wh Watch handle to cancel.
856 */
857void
858GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh);
859
860
861struct GNUNET_SOCIAL_LookHandle; 897struct GNUNET_SOCIAL_LookHandle;
862 898
863 899
diff --git a/src/psycstore/psyc_util_lib.c b/src/psycstore/psyc_util_lib.c
index f6dd4e593..54ae626c5 100644
--- a/src/psycstore/psyc_util_lib.c
+++ b/src/psycstore/psyc_util_lib.c
@@ -590,9 +590,10 @@ transmit_notify_env (void *cls, uint16_t *data_size, void *data, uint8_t *oper,
590 590
591 if (name_size + tmit->mod->value_size <= *data_size) 591 if (name_size + tmit->mod->value_size <= *data_size)
592 { 592 {
593 *data_size = name_size + tmit->mod->value_size; 593 value_size = tmit->mod->value_size;
594 *data_size = name_size + value_size;
594 } 595 }
595 else 596 else /* full modifier does not fit in data, continuation needed */
596 { 597 {
597 value_size = *data_size - name_size; 598 value_size = *data_size - name_size;
598 tmit->mod_value = tmit->mod->value + value_size; 599 tmit->mod_value = tmit->mod->value + value_size;
diff --git a/src/social/social_api.c b/src/social/social_api.c
index 20d0dc8b8..c4045975a 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -179,10 +179,14 @@ struct GNUNET_CONTAINER_MultiHashMap *nyms;
179struct GNUNET_SOCIAL_Slicer 179struct GNUNET_SOCIAL_Slicer
180{ 180{
181 /** 181 /**
182 * Message handlers: method_name -> SlicerCallbacks 182 * Method handlers: method_name -> SlicerMethodCallbacks
183 */ 183 */
184 struct GNUNET_CONTAINER_MultiHashMap *handlers; 184 struct GNUNET_CONTAINER_MultiHashMap *method_handlers;
185 185
186 /**
187 * Modifier handlers: modifier name -> SlicerModifierCallbacks
188 */
189 struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers;
186 190
187 /** 191 /**
188 * Currently being processed message part. 192 * Currently being processed message part.
@@ -200,6 +204,16 @@ struct GNUNET_SOCIAL_Slicer
200 char *method_name; 204 char *method_name;
201 205
202 /** 206 /**
207 * Name of currently processed modifier.
208 */
209 char *mod_name;
210
211 /**
212 * Value of currently processed modifier.
213 */
214 char *mod_value;
215
216 /**
203 * Public key of the nym the current message originates from. 217 * Public key of the nym the current message originates from.
204 */ 218 */
205 struct GNUNET_CRYPTO_EcdsaPublicKey nym_key; 219 struct GNUNET_CRYPTO_EcdsaPublicKey nym_key;
@@ -208,13 +222,38 @@ struct GNUNET_SOCIAL_Slicer
208 * Size of @a method_name (including terminating \0). 222 * Size of @a method_name (including terminating \0).
209 */ 223 */
210 uint16_t method_name_size; 224 uint16_t method_name_size;
225
226 /**
227 * Size of @a modifier_name (including terminating \0).
228 */
229 uint16_t mod_name_size;
230
231 /**
232 * Size of modifier value fragment.
233 */
234 uint16_t mod_value_size;
235
236 /**
237 * Full size of modifier value.
238 */
239 uint16_t mod_full_value_size;
240
241 /**
242 * Remaining bytes from the value of the current modifier.
243 */
244 uint16_t mod_value_remaining;
245
246 /**
247 * Operator of currently processed modifier.
248 */
249 uint8_t mod_oper;
211}; 250};
212 251
213 252
214/** 253/**
215 * Callbacks for a slicer method handler. 254 * Callbacks for a slicer method handler.
216 */ 255 */
217struct SlicerCallbacks 256struct SlicerMethodCallbacks
218{ 257{
219 GNUNET_SOCIAL_MethodCallback method_cb; 258 GNUNET_SOCIAL_MethodCallback method_cb;
220 GNUNET_SOCIAL_ModifierCallback modifier_cb; 259 GNUNET_SOCIAL_ModifierCallback modifier_cb;
@@ -224,32 +263,43 @@ struct SlicerCallbacks
224}; 263};
225 264
226 265
227struct SlicerRemoveClosure 266struct SlicerMethodRemoveClosure
228{ 267{
229 struct GNUNET_SOCIAL_Slicer *slicer; 268 struct GNUNET_SOCIAL_Slicer *slicer;
230 struct SlicerCallbacks rm_cbs; 269 struct SlicerMethodCallbacks rm_cbs;
231}; 270};
232 271
233 272
234/** 273/**
235 * Handle for an announcement request. 274 * Callbacks for a slicer method handler.
236 */ 275 */
237struct GNUNET_SOCIAL_Announcement 276struct SlicerModifierCallbacks
238{ 277{
278 GNUNET_SOCIAL_ModifierCallback modifier_cb;
279 void *cls;
280};
281
239 282
283struct SlicerModifierRemoveClosure
284{
285 struct GNUNET_SOCIAL_Slicer *slicer;
286 struct SlicerModifierCallbacks rm_cbs;
240}; 287};
241 288
242 289
243/** 290/**
244 * A talk request. 291 * Handle for an announcement request.
245 */ 292 */
246struct GNUNET_SOCIAL_TalkRequest 293struct GNUNET_SOCIAL_Announcement
247{ 294{
248 295
249}; 296};
250 297
251 298
252struct GNUNET_SOCIAL_WatchHandle 299/**
300 * A talk request.
301 */
302struct GNUNET_SOCIAL_TalkRequest
253{ 303{
254 304
255}; 305};
@@ -368,21 +418,15 @@ nym_destroy (struct GNUNET_SOCIAL_Nym *nym)
368 418
369 419
370/** 420/**
371 * Call a handler for an incoming message part. 421 * Call a method handler for an incoming message part.
372 *
373 * @param cls
374 * @param key
375 * @param value
376 *
377 * @return
378 */ 422 */
379int 423int
380slicer_handler_notify (void *cls, const struct GNUNET_HashCode *key, 424slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
381 void *value) 425 void *value)
382{ 426{
383 struct GNUNET_SOCIAL_Slicer *slicer = cls; 427 struct GNUNET_SOCIAL_Slicer *slicer = cls;
384 const struct GNUNET_MessageHeader *msg = slicer->msg; 428 const struct GNUNET_MessageHeader *msg = slicer->msg;
385 struct SlicerCallbacks *cbs = value; 429 struct SlicerMethodCallbacks *cbs = value;
386 uint16_t ptype = ntohs (msg->type); 430 uint16_t ptype = ntohs (msg->type);
387 431
388 switch (ptype) 432 switch (ptype)
@@ -406,9 +450,10 @@ slicer_handler_notify (void *cls, const struct GNUNET_HashCode *key,
406 break; 450 break;
407 struct GNUNET_PSYC_MessageModifier * 451 struct GNUNET_PSYC_MessageModifier *
408 mod = (struct GNUNET_PSYC_MessageModifier *) msg; 452 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
409 cbs->modifier_cb (cbs->cls, mod, slicer->message_id, 453 cbs->modifier_cb (cbs->cls, &mod->header, slicer->message_id,
410 mod->oper, (const char *) &mod[1], 454 mod->oper, (const char *) &mod[1],
411 (const void *) &mod[1] + ntohs (mod->name_size), 455 (const void *) &mod[1] + ntohs (mod->name_size),
456 ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size),
412 ntohs (mod->value_size)); 457 ntohs (mod->value_size));
413 break; 458 break;
414 } 459 }
@@ -417,7 +462,10 @@ slicer_handler_notify (void *cls, const struct GNUNET_HashCode *key,
417 { 462 {
418 if (NULL == cbs->modifier_cb) 463 if (NULL == cbs->modifier_cb)
419 break; 464 break;
420 /* FIXME: concatenate until done */ 465 cbs->modifier_cb (cbs->cls, msg, slicer->message_id,
466 slicer->mod_oper, slicer->mod_name, &msg[1],
467 ntohs (msg->size) - sizeof (*msg),
468 slicer->mod_full_value_size);
421 break; 469 break;
422 } 470 }
423 471
@@ -448,6 +496,23 @@ slicer_handler_notify (void *cls, const struct GNUNET_HashCode *key,
448 496
449 497
450/** 498/**
499 * Call a method handler for an incoming message part.
500 */
501int
502slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
503 void *value)
504{
505 struct GNUNET_SOCIAL_Slicer *slicer = cls;
506 struct SlicerModifierCallbacks *cbs = value;
507
508 cbs->modifier_cb (cbs->cls, slicer->msg, slicer->message_id, slicer->mod_oper,
509 slicer->mod_name, slicer->mod_value,
510 slicer->mod_value_size, slicer->mod_full_value_size);
511 return GNUNET_YES;
512}
513
514
515/**
451 * Process an incoming message part and call matching handlers. 516 * Process an incoming message part and call matching handlers.
452 * 517 *
453 * @param cls 518 * @param cls
@@ -486,6 +551,52 @@ slicer_message (void *cls, uint64_t message_id, uint64_t fragment_offset,
486 ptype, ntohs (msg->size), message_id, slicer->method_name); 551 ptype, ntohs (msg->size), message_id, slicer->method_name);
487 552
488 slicer->msg = msg; 553 slicer->msg = msg;
554
555 /* try-and-slice modifier */
556
557 switch (ptype)
558 {
559 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
560 {
561 struct GNUNET_PSYC_MessageModifier *
562 mod = (struct GNUNET_PSYC_MessageModifier *) msg;
563 slicer->mod_oper = mod->oper;
564 slicer->mod_name_size = ntohs (mod->name_size);
565 slicer->mod_name = GNUNET_malloc (slicer->mod_name_size);
566 memcpy (slicer->mod_name, &mod[1], slicer->mod_name_size);
567 slicer->mod_value = (char *) &mod[1] + slicer->mod_name_size;
568 slicer->mod_full_value_size = ntohs (mod->value_size);
569 slicer->mod_value_remaining = slicer->mod_full_value_size;
570 slicer->mod_value_size
571 = ntohs (mod->header.size) - sizeof (*mod) - slicer->mod_name_size;
572 }
573 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
574 if (ptype == GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT)
575 {
576 slicer->mod_value = (char *) &msg[1];
577 slicer->mod_value_size = ntohs (msg->size) - sizeof (*msg);
578 }
579 slicer->mod_value_remaining -= slicer->mod_value_size;
580 char *name = GNUNET_malloc (slicer->mod_name_size);
581 memcpy (name, slicer->mod_name, slicer->mod_name_size);
582 do
583 {
584 struct GNUNET_HashCode key;
585 uint16_t name_len = strlen (name);
586 GNUNET_CRYPTO_hash (name, name_len, &key);
587 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
588 slicer_modifier_handler_notify,
589 slicer);
590 char *p = strrchr (name, '_');
591 if (NULL == p)
592 break;
593 *p = '\0';
594 } while (1);
595 GNUNET_free (name);
596 }
597
598 /* try-and-slice method */
599
489 char *name = GNUNET_malloc (slicer->method_name_size); 600 char *name = GNUNET_malloc (slicer->method_name_size);
490 memcpy (name, slicer->method_name, slicer->method_name_size); 601 memcpy (name, slicer->method_name, slicer->method_name_size);
491 do 602 do
@@ -493,31 +604,47 @@ slicer_message (void *cls, uint64_t message_id, uint64_t fragment_offset,
493 struct GNUNET_HashCode key; 604 struct GNUNET_HashCode key;
494 uint16_t name_len = strlen (name); 605 uint16_t name_len = strlen (name);
495 GNUNET_CRYPTO_hash (name, name_len, &key); 606 GNUNET_CRYPTO_hash (name, name_len, &key);
496 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->handlers, &key, 607 GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
497 &slicer_handler_notify, slicer); 608 slicer_method_handler_notify,
609 slicer);
498 char *p = strrchr (name, '_'); 610 char *p = strrchr (name, '_');
499 if (NULL == p) 611 if (NULL == p)
500 break; 612 break;
501 *p = '\0'; 613 *p = '\0';
502 } while (1); 614 } while (1);
503 GNUNET_free (name); 615 GNUNET_free (name);
504 slicer->msg = NULL;
505 616
506 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) 617 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
507 GNUNET_free (slicer->method_name); 618 GNUNET_free (slicer->method_name);
619
620 if (0 == slicer->mod_value_remaining && NULL != slicer->mod_name)
621 {
622 GNUNET_free (slicer->mod_name);
623 slicer->mod_name = NULL;
624 slicer->mod_name_size = 0;
625 slicer->mod_value_size = 0;
626 slicer->mod_full_value_size = 0;
627 slicer->mod_oper = 0;
628 }
629
630 slicer->msg = NULL;
508} 631}
509 632
510 633
511/** 634/**
512 * Create a try-and-slice instance. 635 * Create a try-and-slice instance.
513 * 636 *
637 * A slicer processes incoming messages and notifies callbacks about matching
638 * methods or modifiers encountered.
639 *
514 * @return A new try-and-slice construct. 640 * @return A new try-and-slice construct.
515 */ 641 */
516struct GNUNET_SOCIAL_Slicer * 642struct GNUNET_SOCIAL_Slicer *
517GNUNET_SOCIAL_slicer_create (void) 643GNUNET_SOCIAL_slicer_create (void)
518{ 644{
519 struct GNUNET_SOCIAL_Slicer *slicer = GNUNET_malloc (sizeof (*slicer)); 645 struct GNUNET_SOCIAL_Slicer *slicer = GNUNET_malloc (sizeof (*slicer));
520 slicer->handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); 646 slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
647 slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
521 return slicer; 648 return slicer;
522} 649}
523 650
@@ -525,53 +652,62 @@ GNUNET_SOCIAL_slicer_create (void)
525/** 652/**
526 * Add a method to the try-and-slice instance. 653 * Add a method to the try-and-slice instance.
527 * 654 *
528 * A slicer processes messages and calls methods that match a message. A match 655 * The callbacks are called for messages with a matching @a method_name prefix.
529 * happens whenever the method name of a message starts with the method_name
530 * parameter given here.
531 * 656 *
532 * @param slicer The try-and-slice instance to extend. 657 * @param slicer
533 * @param method_name Name of the given method, use empty string for default. 658 * The try-and-slice instance to extend.
534 * @param method Method to invoke. 659 * @param method_name
535 * @param method_cls Closure for method. 660 * Name of the given method, use empty string to match all.
661 * @param method_cb
662 * Method handler invoked upon a matching message.
663 * @param modifier_cb
664 * Modifier handler, invoked after @a method_cb
665 * for each modifier in the message.
666 * @param data_cb
667 * Data handler, invoked after @a modifier_cb for each data fragment.
668 * @param eom_cb
669 * Invoked upon reaching the end of a matching message.
670 * @param cls
671 * Closure for the callbacks.
536 */ 672 */
537void 673void
538GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 674GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
539 const char *method_name, 675 const char *method_name,
540 GNUNET_SOCIAL_MethodCallback method_cb, 676 GNUNET_SOCIAL_MethodCallback method_cb,
541 GNUNET_SOCIAL_ModifierCallback modifier_cb, 677 GNUNET_SOCIAL_ModifierCallback modifier_cb,
542 GNUNET_SOCIAL_DataCallback data_cb, 678 GNUNET_SOCIAL_DataCallback data_cb,
543 GNUNET_SOCIAL_EndOfMessageCallback eom_cb, 679 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
544 void *cls) 680 void *cls)
545{ 681{
546 struct GNUNET_HashCode key; 682 struct GNUNET_HashCode key;
547 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key); 683 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
548 684
549 struct SlicerCallbacks *cbs = GNUNET_malloc (sizeof (*cbs)); 685 struct SlicerMethodCallbacks *cbs = GNUNET_malloc (sizeof (*cbs));
550 cbs->method_cb = method_cb; 686 cbs->method_cb = method_cb;
551 cbs->modifier_cb = modifier_cb; 687 cbs->modifier_cb = modifier_cb;
552 cbs->data_cb = data_cb; 688 cbs->data_cb = data_cb;
553 cbs->eom_cb = eom_cb; 689 cbs->eom_cb = eom_cb;
554 cbs->cls = cls; 690 cbs->cls = cls;
555 691
556 GNUNET_CONTAINER_multihashmap_put (slicer->handlers, &key, cbs, 692 GNUNET_CONTAINER_multihashmap_put (slicer->method_handlers, &key, cbs,
557 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 693 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
558} 694}
559 695
560 696
561int 697int
562slicer_remove_handler (void *cls, const struct GNUNET_HashCode *key, void *value) 698slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
563{ 699{
564 struct SlicerRemoveClosure *rm_cls = cls; 700 struct SlicerMethodRemoveClosure *rm_cls = cls;
565 struct GNUNET_SOCIAL_Slicer *slicer = rm_cls->slicer; 701 struct GNUNET_SOCIAL_Slicer *slicer = rm_cls->slicer;
566 struct SlicerCallbacks *rm_cbs = &rm_cls->rm_cbs; 702 struct SlicerMethodCallbacks *rm_cbs = &rm_cls->rm_cbs;
567 struct SlicerCallbacks *cbs = value; 703 struct SlicerMethodCallbacks *cbs = value;
568 704
569 if (cbs->method_cb == rm_cbs->method_cb 705 if (cbs->method_cb == rm_cbs->method_cb
570 && cbs->modifier_cb == rm_cbs->modifier_cb 706 && cbs->modifier_cb == rm_cbs->modifier_cb
571 && cbs->data_cb == rm_cbs->data_cb 707 && cbs->data_cb == rm_cbs->data_cb
572 && cbs->eom_cb == rm_cbs->eom_cb) 708 && cbs->eom_cb == rm_cbs->eom_cb)
573 { 709 {
574 GNUNET_CONTAINER_multihashmap_remove (slicer->handlers, key, cbs); 710 GNUNET_CONTAINER_multihashmap_remove (slicer->method_handlers, key, cbs);
575 GNUNET_free (cbs); 711 GNUNET_free (cbs);
576 return GNUNET_NO; 712 return GNUNET_NO;
577 } 713 }
@@ -582,29 +718,39 @@ slicer_remove_handler (void *cls, const struct GNUNET_HashCode *key, void *value
582/** 718/**
583 * Remove a registered method from the try-and-slice instance. 719 * Remove a registered method from the try-and-slice instance.
584 * 720 *
585 * Removes the first matching handler registered with @a method and the given callbacks. 721 * Removes one matching handler registered with the given
722 * @a method_name and callbacks.
586 * 723 *
587 * @param slicer The try-and-slice instance. 724 * @param slicer
588 * @param method_name Name of the method to remove. 725 * The try-and-slice instance.
589 * @param method Method handler. 726 * @param method_name
727 * Name of the method to remove.
728 * @param method_cb
729 * Method handler.
730 * @param modifier_cb
731 * Modifier handler.
732 * @param data_cb
733 * Data handler.
734 * @param eom_cb
735 * End of message handler.
590 * 736 *
591 * @return #GNUNET_OK if a method handler was removed, 737 * @return #GNUNET_OK if a method handler was removed,
592 * #GNUNET_NO if no handler matched the given method name and callbacks. 738 * #GNUNET_NO if no handler matched the given method name and callbacks.
593 */ 739 */
594int 740int
595GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 741GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
596 const char *method_name, 742 const char *method_name,
597 GNUNET_SOCIAL_MethodCallback method_cb, 743 GNUNET_SOCIAL_MethodCallback method_cb,
598 GNUNET_SOCIAL_ModifierCallback modifier_cb, 744 GNUNET_SOCIAL_ModifierCallback modifier_cb,
599 GNUNET_SOCIAL_DataCallback data_cb, 745 GNUNET_SOCIAL_DataCallback data_cb,
600 GNUNET_SOCIAL_EndOfMessageCallback eom_cb) 746 GNUNET_SOCIAL_EndOfMessageCallback eom_cb)
601{ 747{
602 struct GNUNET_HashCode key; 748 struct GNUNET_HashCode key;
603 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key); 749 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
604 750
605 struct SlicerRemoveClosure rm_cls; 751 struct SlicerMethodRemoveClosure rm_cls;
606 rm_cls.slicer = slicer; 752 rm_cls.slicer = slicer;
607 struct SlicerCallbacks *rm_cbs = &rm_cls.rm_cbs; 753 struct SlicerMethodCallbacks *rm_cbs = &rm_cls.rm_cbs;
608 rm_cbs->method_cb = method_cb; 754 rm_cbs->method_cb = method_cb;
609 rm_cbs->modifier_cb = modifier_cb; 755 rm_cbs->modifier_cb = modifier_cb;
610 rm_cbs->data_cb = data_cb; 756 rm_cbs->data_cb = data_cb;
@@ -612,18 +758,101 @@ GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer,
612 758
613 return 759 return
614 (GNUNET_SYSERR 760 (GNUNET_SYSERR
615 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->handlers, &key, 761 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->method_handlers, &key,
616 &slicer_remove_handler, 762 slicer_method_remove,
617 &rm_cls)) 763 &rm_cls))
618 ? GNUNET_NO 764 ? GNUNET_NO
619 : GNUNET_OK; 765 : GNUNET_OK;
620} 766}
621 767
622 768
769/**
770 * Watch a place for changed objects.
771 *
772 * @param slicer
773 * The try-and-slice instance.
774 * @param object_filter
775 * Object prefix to match.
776 * @param modifier_cb
777 * Function to call when encountering a state modifier.
778 * @param cls
779 * Closure for callback.
780 */
781void
782GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
783 const char *object_filter,
784 GNUNET_SOCIAL_ModifierCallback modifier_cb,
785 void *cls)
786{
787 struct SlicerModifierCallbacks *cbs = GNUNET_malloc (sizeof *cbs);
788 cbs->modifier_cb = modifier_cb;
789 cbs->cls = cls;
790
791 struct GNUNET_HashCode key;
792 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
793 GNUNET_CONTAINER_multihashmap_put (slicer->modifier_handlers, &key, cbs,
794 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
795}
796
797
798int
799slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
800{
801 struct SlicerModifierRemoveClosure *rm_cls = cls;
802 struct GNUNET_SOCIAL_Slicer *slicer = rm_cls->slicer;
803 struct SlicerModifierCallbacks *rm_cbs = &rm_cls->rm_cbs;
804 struct SlicerModifierCallbacks *cbs = value;
805
806 if (cbs->modifier_cb == rm_cbs->modifier_cb)
807 {
808 GNUNET_CONTAINER_multihashmap_remove (slicer->modifier_handlers, key, cbs);
809 GNUNET_free (cbs);
810 return GNUNET_NO;
811 }
812 return GNUNET_YES;
813}
814
815
816/**
817 * Remove a registered modifier from the try-and-slice instance.
818 *
819 * Removes one matching handler registered with the given
820 * @a object_filter and @a modifier_cb.
821 *
822 * @param slicer
823 * The try-and-slice instance.
824 * @param object_filter
825 * Object prefix to match.
826 * @param modifier_cb
827 * Function to call when encountering a state modifier changes.
828 */
829int
830GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
831 const char *object_filter,
832 GNUNET_SOCIAL_ModifierCallback modifier_cb)
833{
834 struct GNUNET_HashCode key;
835 GNUNET_CRYPTO_hash (object_filter, strlen (object_filter), &key);
836
837 struct SlicerModifierRemoveClosure rm_cls;
838 rm_cls.slicer = slicer;
839 struct SlicerModifierCallbacks *rm_cbs = &rm_cls.rm_cbs;
840 rm_cbs->modifier_cb = modifier_cb;
841
842 return
843 (GNUNET_SYSERR
844 == GNUNET_CONTAINER_multihashmap_get_multiple (slicer->modifier_handlers, &key,
845 slicer_modifier_remove,
846 &rm_cls))
847 ? GNUNET_NO
848 : GNUNET_OK;
849 }
850
851
623int 852int
624slicer_free_handler (void *cls, const struct GNUNET_HashCode *key, void *value) 853slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value)
625{ 854{
626 struct SlicerCallbacks *cbs = value; 855 struct SlicerMethodCallbacks *cbs = value;
627 GNUNET_free (cbs); 856 GNUNET_free (cbs);
628 return GNUNET_YES; 857 return GNUNET_YES;
629} 858}
@@ -638,9 +867,9 @@ slicer_free_handler (void *cls, const struct GNUNET_HashCode *key, void *value)
638void 867void
639GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer) 868GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer)
640{ 869{
641 GNUNET_CONTAINER_multihashmap_iterate (slicer->handlers, &slicer_free_handler, 870 GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
642 NULL); 871 slicer_method_free, NULL);
643 GNUNET_CONTAINER_multihashmap_destroy (slicer->handlers); 872 GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers);
644 GNUNET_free (slicer); 873 GNUNET_free (slicer);
645} 874}
646 875
@@ -1598,32 +1827,38 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
1598 struct GuestEnterRequest * 1827 struct GuestEnterRequest *
1599 req = (struct GuestEnterRequest *) plc->connect_msg; 1828 req = (struct GuestEnterRequest *) plc->connect_msg;
1600 uint16_t req_size = ntohs (req->header.size); 1829 uint16_t req_size = ntohs (req->header.size);
1601
1602 struct GNUNET_PeerIdentity *relays = NULL;
1603 uint16_t relay_count = ntohs (rec->relay_count); 1830 uint16_t relay_count = ntohs (rec->relay_count);
1604 1831
1605 if (0 < relay_count) 1832 if (0 < relay_count)
1606 { 1833 {
1607 uint16_t relay_size = relay_count * sizeof (struct GNUNET_PeerIdentity); 1834 if (rd->data_size == sizeof (*rec) + relay_count * sizeof (struct GNUNET_PeerIdentity))
1608 struct GuestEnterRequest *
1609 req2 = GNUNET_malloc (req_size + relay_size);
1610
1611 req2->header.size = htons (req_size + relay_size);
1612 req2->header.type = req->header.type;
1613 req2->guest_key = req->guest_key;
1614
1615 uint16_t p = sizeof (*req);
1616 if (0 < relay_size)
1617 { 1835 {
1618 memcpy ((char *) req2 + p, relays, relay_size); 1836 struct GNUNET_PeerIdentity *relays = (struct GNUNET_PeerIdentity *) &rec[1];
1619 p += relay_size; 1837 uint16_t relay_size = relay_count * sizeof (struct GNUNET_PeerIdentity);
1838 struct GuestEnterRequest *
1839 req2 = GNUNET_malloc (req_size + relay_size);
1840
1841 req2->header.size = htons (req_size + relay_size);
1842 req2->header.type = req->header.type;
1843 req2->guest_key = req->guest_key;
1844
1845 uint16_t p = sizeof (*req);
1846 if (0 < relay_size)
1847 {
1848 memcpy ((char *) req2 + p, relays, relay_size);
1849 p += relay_size;
1850 }
1851
1852 memcpy ((char *) req + p, &req[1], req_size - sizeof (*req));
1853
1854 plc->connect_msg = &req2->header;
1855 GNUNET_free (req);
1856 req = req2;
1857 }
1858 else
1859 {
1860 GNUNET_break_op (0);
1620 } 1861 }
1621
1622 memcpy ((char *) req + p, &req[1], req_size - sizeof (*req));
1623
1624 plc->connect_msg = &req2->header;
1625 GNUNET_free (req);
1626 req = req2;
1627 } 1862 }
1628 1863
1629 req->place_key = rec->place_key; 1864 req->place_key = rec->place_key;
@@ -1807,42 +2042,6 @@ GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *gst)
1807} 2042}
1808 2043
1809 2044
1810/**
1811 * Watch a place for changed objects.
1812 *
1813 * @param place
1814 * Place to watch.
1815 * @param object_filter
1816 * Object prefix to match.
1817 * @param var_cb
1818 * Function to call when an object/state var changes.
1819 * @param cls
1820 * Closure for callback.
1821 *
1822 * @return Handle that can be used to cancel watching.
1823 */
1824struct GNUNET_SOCIAL_WatchHandle *
1825GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
1826 const char *object_filter,
1827 GNUNET_PSYC_StateVarCallback var_cb,
1828 void *cls)
1829{
1830 return NULL;
1831}
1832
1833
1834/**
1835 * Cancel watching a place for changed objects.
1836 *
1837 * @param wh Watch handle to cancel.
1838 */
1839void
1840GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh)
1841{
1842
1843}
1844
1845
1846static struct GNUNET_SOCIAL_HistoryRequest * 2045static struct GNUNET_SOCIAL_HistoryRequest *
1847place_history_replay (struct GNUNET_SOCIAL_Place *plc, 2046place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1848 uint64_t start_message_id, 2047 uint64_t start_message_id,
diff --git a/src/social/test_social.c b/src/social/test_social.c
index dbcf822f8..93e7c9bf2 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -36,7 +36,7 @@
36#include "gnunet_core_service.h" 36#include "gnunet_core_service.h"
37#include "gnunet_identity_service.h" 37#include "gnunet_identity_service.h"
38 38
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) 39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
40 40
41#define DATA2ARG(data) data, sizeof (data) 41#define DATA2ARG(data) data, sizeof (data)
42 42
@@ -101,7 +101,7 @@ struct TransmitClosure
101 101
102struct ResultClosure { 102struct ResultClosure {
103 uint32_t n; 103 uint32_t n;
104}; 104} mod_foo_bar_rcls;
105 105
106uint8_t join_req_count; 106uint8_t join_req_count;
107struct GNUNET_PSYC_Message *join_resp; 107struct GNUNET_PSYC_Message *join_resp;
@@ -504,23 +504,44 @@ guest_recv_method (void *cls,
504 "Test #%u: Guest received method for message ID %" PRIu64 ":\n" 504 "Test #%u: Guest received method for message ID %" PRIu64 ":\n"
505 "%s (flags: %x)\n", 505 "%s (flags: %x)\n",
506 test, message_id, method_name, flags); 506 test, message_id, method_name, flags);
507 /* FIXME: check message */ 507 /** @todo FIXME: check message */
508} 508}
509 509
510 510
511static void 511static void
512guest_recv_modifier (void *cls, 512guest_recv_modifier (void *cls,
513 const struct GNUNET_PSYC_MessageModifier *mod, 513 const struct GNUNET_MessageHeader *msg,
514 uint64_t message_id, 514 uint64_t message_id,
515 enum GNUNET_ENV_Operator oper, 515 enum GNUNET_ENV_Operator oper,
516 const char *name, 516 const char *name,
517 const void *value, 517 const void *value,
518 uint16_t value_size) 518 uint16_t value_size,
519 uint16_t full_value_size)
519{ 520{
520 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 521 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
521 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n" 522 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n"
522 "%c%s: %.*s\n", 523 "%c%s: %.*s (size: %u)\n",
523 test, message_id, oper, name, value_size, value); 524 test, message_id, oper, name, value_size, value, value_size);
525 /** @todo FIXME: check modifier */
526}
527
528static void
529guest_recv_mod_foo_bar (void *cls,
530 const struct GNUNET_MessageHeader *msg,
531 uint64_t message_id,
532 enum GNUNET_ENV_Operator oper,
533 const char *name,
534 const void *value,
535 uint16_t value_size,
536 uint16_t full_value_size)
537{
538 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
539 "Test #%u: Guest received modifier matching _foo_bar for message ID %" PRIu64 ":\n"
540 "%c%s: %.*s (size: %u)\n",
541 test, message_id, oper, name, value_size, value, value_size);
542 struct ResultClosure *rc = cls;
543 rc->n++;
544 /** @todo FIXME: check modifier */
524} 545}
525 546
526 547
@@ -536,6 +557,7 @@ guest_recv_data (void *cls,
536 "Test #%u: Guest received data for message ID %" PRIu64 ":\n" 557 "Test #%u: Guest received data for message ID %" PRIu64 ":\n"
537 "%.*s\n", 558 "%.*s\n",
538 test, message_id, data_size, data); 559 test, message_id, data_size, data);
560 /** @todo FIXME: check data */
539} 561}
540 562
541 563
@@ -592,18 +614,19 @@ host_recv_method (void *cls,
592 "Test #%u: Host received method for message ID %" PRIu64 ":\n" 614 "Test #%u: Host received method for message ID %" PRIu64 ":\n"
593 "%s\n", 615 "%s\n",
594 test, message_id, method_name); 616 test, message_id, method_name);
595 /* FIXME: check message */ 617 /** @todo FIXME: check message */
596} 618}
597 619
598 620
599static void 621static void
600host_recv_modifier (void *cls, 622host_recv_modifier (void *cls,
601 const struct GNUNET_PSYC_MessageModifier *mod, 623 const struct GNUNET_MessageHeader *msg,
602 uint64_t message_id, 624 uint64_t message_id,
603 enum GNUNET_ENV_Operator oper, 625 enum GNUNET_ENV_Operator oper,
604 const char *name, 626 const char *name,
605 const void *value, 627 const void *value,
606 uint16_t value_size) 628 uint16_t value_size,
629 uint16_t full_value_size)
607{ 630{
608 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 631 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
609 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n" 632 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n"
@@ -657,7 +680,7 @@ host_recv_eom (void *cls,
657 break; 680 break;
658 681
659 case TEST_GUEST_TALK: 682 case TEST_GUEST_TALK:
660 guest_history_replay (); 683 guest_history_replay ();
661 break; 684 break;
662 685
663 default: 686 default:
@@ -695,6 +718,9 @@ host_announce ()
695{ 718{
696 test = TEST_HOST_ANNOUNCE; 719 test = TEST_HOST_ANNOUNCE;
697 720
721 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
722 "Test #%u: Host announcement.\n", test);
723
698 tmit = (struct TransmitClosure) {}; 724 tmit = (struct TransmitClosure) {};
699 tmit.env = GNUNET_ENV_environment_create (); 725 tmit.env = GNUNET_ENV_environment_create ();
700 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 726 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN,
@@ -720,8 +746,15 @@ host_announce ()
720static void 746static void
721host_announce2 () 747host_announce2 ()
722{ 748{
749 GNUNET_assert (2 == mod_foo_bar_rcls.n);
750 GNUNET_SOCIAL_slicer_modifier_remove (guest_slicer, "_foo_bar",
751 guest_recv_mod_foo_bar);
752
723 test = TEST_HOST_ANNOUNCE2; 753 test = TEST_HOST_ANNOUNCE2;
724 754
755 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
756 "Test #%u: Host announcement.\n", test);
757
725 tmit = (struct TransmitClosure) {}; 758 tmit = (struct TransmitClosure) {};
726 tmit.env = GNUNET_ENV_environment_create (); 759 tmit.env = GNUNET_ENV_environment_create ();
727 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 760 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN,
@@ -748,8 +781,8 @@ guest_recv_entry_decision (void *cls,
748 const struct GNUNET_PSYC_Message *entry_resp) 781 const struct GNUNET_PSYC_Message *entry_resp)
749{ 782{
750 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 783 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
751 "Guest received entry decision (try %u): %d.\n", 784 "Test #%u: Guest received entry decision (try %u): %d.\n",
752 join_req_count, is_admitted); 785 test, join_req_count, is_admitted);
753 786
754 if (NULL != entry_resp) 787 if (NULL != entry_resp)
755 { 788 {
@@ -762,7 +795,7 @@ guest_recv_entry_decision (void *cls,
762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
763 "%s\n%.*s\n", 796 "%s\n%.*s\n",
764 method_name, data_size, data); 797 method_name, data_size, data);
765 /* FIXME: check response message */ 798 /** @todo FIXME: check response message */
766 } 799 }
767 800
768 switch (test) 801 switch (test)
@@ -795,8 +828,8 @@ host_answer_door (void *cls,
795 join_req_count++; 828 join_req_count++;
796 829
797 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 830 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
798 "Host received entry request from guest (try %u).\n", 831 "Test #%u: Host received entry request from guest (try %u).\n",
799 join_req_count); 832 test, join_req_count);
800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 833 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
801 "%s\n%.*s\n", 834 "%s\n%.*s\n",
802 method_name, data_size, data); 835 method_name, data_size, data);
@@ -827,7 +860,8 @@ host_answer_door (void *cls,
827static void 860static void
828guest_recv_local_enter (void *cls, int result, uint64_t max_message_id) 861guest_recv_local_enter (void *cls, int result, uint64_t max_message_id)
829{ 862{
830 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Guest entered to local place.\n"); 863 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
864 "Test #%u: Guest entered to local place.\n", test);
831 865
832} 866}
833 867
@@ -835,7 +869,8 @@ guest_recv_local_enter (void *cls, int result, uint64_t max_message_id)
835static void 869static void
836guest_enter () 870guest_enter ()
837{ 871{
838 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as guest.\n"); 872 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
873 "Test #%u: Entering to place as guest.\n", test);
839 874
840 struct GuestEnterMessage *emsg = &guest_enter_msg; 875 struct GuestEnterMessage *emsg = &guest_enter_msg;
841 876
@@ -865,11 +900,13 @@ id_guest_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
865 guest_ego = ego; 900 guest_ego = ego;
866 901
867 guest_slicer = GNUNET_SOCIAL_slicer_create (); 902 guest_slicer = GNUNET_SOCIAL_slicer_create ();
868 GNUNET_SOCIAL_slicer_add (guest_slicer, "", 903 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "",
869 &guest_recv_method, &guest_recv_modifier, 904 guest_recv_method, guest_recv_modifier,
870 &guest_recv_data, &guest_recv_eom, NULL); 905 guest_recv_data, guest_recv_eom, NULL);
906 GNUNET_SOCIAL_slicer_modifier_add (guest_slicer, "_foo_bar",
907 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
871 test = TEST_HOST_ANSWER_DOOR_ADMIT; 908 test = TEST_HOST_ANSWER_DOOR_ADMIT;
872 //host_announce (); 909
873 guest_enter (); 910 guest_enter ();
874} 911}
875 912
@@ -906,9 +943,9 @@ id_host_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
906 host_ego = ego; 943 host_ego = ego;
907 944
908 host_slicer = GNUNET_SOCIAL_slicer_create (); 945 host_slicer = GNUNET_SOCIAL_slicer_create ();
909 GNUNET_SOCIAL_slicer_add (host_slicer, "", 946 GNUNET_SOCIAL_slicer_method_add (host_slicer, "",
910 &host_recv_method, &host_recv_modifier, 947 &host_recv_method, &host_recv_modifier,
911 &host_recv_data, &host_recv_eom, NULL); 948 &host_recv_data, &host_recv_eom, NULL);
912 949
913 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); 950 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n");
914 hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key, 951 hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key,