*/
struct GNUNET_CONTAINER_MultiHashMap *modifier_handlers;
+ /**
+ * Receive handle for incoming messages.
+ */
+ struct GNUNET_PSYC_ReceiveHandle *recv;
+
/**
* Currently being processed message part.
*/
/**
* Call a method handler for an incoming message part.
*/
-int
+static int
slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
void *value)
{
/**
* Call a method handler for an incoming message part.
*/
-int
+static int
slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
void *value)
{
}
+/**
+ * Process an incoming message and call matching handlers.
+ *
+ * @param slicer
+ * The slicer to use.
+ * @param msg
+ * The message as it arrived from the network.
+ */
+void
+GNUNET_PSYC_slicer_message (struct GNUNET_PSYC_Slicer *slicer,
+ const struct GNUNET_PSYC_MessageHeader *msg)
+{
+ GNUNET_PSYC_receive_message (slicer->recv, msg);
+}
+
+
/**
* Process an incoming message part and call matching handlers.
*
* The message part. as it arrived from the network.
*/
void
-GNUNET_PSYC_slicer_message (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
- uint64_t message_id, uint32_t flags, uint64_t fragment_offset,
- const struct GNUNET_MessageHeader *msg)
+GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
+ uint64_t message_id,
+ uint32_t flags,
+ uint64_t fragment_offset,
+ const struct GNUNET_MessageHeader *msg)
{
- struct GNUNET_PSYC_Slicer *slicer = cls;
slicer->nym_pub_key = *slave_pub_key;
uint16_t ptype = ntohs (msg->type);
struct GNUNET_PSYC_Slicer *slicer = GNUNET_malloc (sizeof (*slicer));
slicer->method_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
slicer->modifier_handlers = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
+ slicer->recv = GNUNET_PSYC_receive_create (NULL,
+ (GNUNET_PSYC_MessagePartCallback)
+ GNUNET_PSYC_slicer_message_part,
+ slicer);
return slicer;
}
}
-int
+static int
slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
{
struct SlicerMethodRemoveClosure *rm_cls = cls;
}
-int
+static int
slicer_modifier_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
{
struct SlicerModifierRemoveClosure *rm_cls = cls;
}
-int
+static int
slicer_method_free (void *cls, const struct GNUNET_HashCode *key, void *value)
{
struct SlicerMethodCallbacks *cbs = value;
}
+static int
+slicer_modifier_free (void *cls, const struct GNUNET_HashCode *key, void *value)
+{
+ struct SlicerModifierCallbacks *cbs = value;
+ GNUNET_free (cbs);
+ return GNUNET_YES;
+}
+
+
+/**
+ * Remove all registered method handlers.
+ *
+ * @param slicer
+ * Slicer to clear.
+ */
+void
+GNUNET_PSYC_slicer_method_clear (struct GNUNET_PSYC_Slicer *slicer)
+{
+ GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
+ slicer_method_free, NULL);
+}
+
+
+/**
+ * Remove all registered modifier handlers.
+ *
+ * @param slicer
+ * Slicer to clear.
+ */
+void
+GNUNET_PSYC_slicer_modifier_clear (struct GNUNET_PSYC_Slicer *slicer)
+{
+ GNUNET_CONTAINER_multihashmap_iterate (slicer->modifier_handlers,
+ slicer_modifier_free, NULL);
+}
+
+
+/**
+ * Remove all registered method & modifier handlers.
+ *
+ * @param slicer
+ * Slicer to clear.
+ */
+void
+GNUNET_PSYC_slicer_clear (struct GNUNET_PSYC_Slicer *slicer)
+{
+ GNUNET_PSYC_slicer_method_clear (slicer);
+ GNUNET_PSYC_slicer_modifier_clear (slicer);
+}
+
+
/**
* Destroy a given try-and-slice instance.
*
void
GNUNET_PSYC_slicer_destroy (struct GNUNET_PSYC_Slicer *slicer)
{
- GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
- slicer_method_free, NULL);
+ GNUNET_PSYC_slicer_clear (slicer);
GNUNET_CONTAINER_multihashmap_destroy (slicer->method_handlers);
+ GNUNET_CONTAINER_multihashmap_destroy (slicer->modifier_handlers);
+ GNUNET_PSYC_receive_destroy (slicer->recv);
GNUNET_free (slicer);
}