aboutsummaryrefslogtreecommitdiff
path: root/src/dv/plugin_transport_dv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dv/plugin_transport_dv.c')
-rw-r--r--src/dv/plugin_transport_dv.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 1f9a32fe4..93792e0d9 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -429,7 +429,7 @@ free_session (struct Session *session)
429 */ 429 */
430static void 430static void
431handle_dv_disconnect (void *cls, 431handle_dv_disconnect (void *cls,
432 const struct GNUNET_PeerIdentity *peer) 432 const struct GNUNET_PeerIdentity *peer)
433{ 433{
434 struct Plugin *plugin = cls; 434 struct Plugin *plugin = cls;
435 struct Session *session; 435 struct Session *session;
@@ -543,8 +543,8 @@ dv_plugin_send (void *cls,
543 * @param target peer from which to disconnect 543 * @param target peer from which to disconnect
544 */ 544 */
545static void 545static void
546dv_plugin_disconnect (void *cls, 546dv_plugin_disconnect_peer (void *cls,
547 const struct GNUNET_PeerIdentity *target) 547 const struct GNUNET_PeerIdentity *target)
548{ 548{
549 struct Plugin *plugin = cls; 549 struct Plugin *plugin = cls;
550 struct Session *session; 550 struct Session *session;
@@ -572,6 +572,39 @@ dv_plugin_disconnect (void *cls,
572 572
573 573
574/** 574/**
575 * Function that can be used to force the plugin to disconnect
576 * from the given peer and cancel all previous transmissions
577 * (and their continuations).
578 *
579 * @param cls closure with the `struct Plugin *`
580 * @param session which session to disconnect
581 * @return #GNUNET_OK
582 */
583static int
584dv_plugin_disconnect_session (void *cls,
585 struct Session *session)
586{
587 struct PendingRequest *pr;
588
589 while (NULL != (pr = session->pr_head))
590 {
591 GNUNET_CONTAINER_DLL_remove (session->pr_head,
592 session->pr_tail,
593 pr);
594 GNUNET_DV_send_cancel (pr->th);
595 pr->th = NULL;
596 if (NULL != pr->transmit_cont)
597 pr->transmit_cont (pr->transmit_cont_cls,
598 &session->sender,
599 GNUNET_SYSERR, 0, 0);
600 GNUNET_free (pr);
601 }
602 session->active = GNUNET_NO;
603 return GNUNET_OK;
604}
605
606
607/**
575 * Convert the transports address to a nice, human-readable 608 * Convert the transports address to a nice, human-readable
576 * format. 609 * format.
577 * 610 *
@@ -759,7 +792,8 @@ libgnunet_plugin_transport_dv_init (void *cls)
759 api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); 792 api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
760 api->cls = plugin; 793 api->cls = plugin;
761 api->send = &dv_plugin_send; 794 api->send = &dv_plugin_send;
762 api->disconnect = &dv_plugin_disconnect; 795 api->disconnect_peer = &dv_plugin_disconnect_peer;
796 api->disconnect_session = &dv_plugin_disconnect_session;
763 api->address_pretty_printer = &dv_plugin_address_pretty_printer; 797 api->address_pretty_printer = &dv_plugin_address_pretty_printer;
764 api->check_address = &dv_plugin_check_address; 798 api->check_address = &dv_plugin_check_address;
765 api->address_to_string = &dv_plugin_address_to_string; 799 api->address_to_string = &dv_plugin_address_to_string;