aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 0957676f2..3e1a6396c 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -597,8 +597,8 @@ send_ack (void *cls, uint32_t msg_id,
597 597
598 if (NULL == endpoint) 598 if (NULL == endpoint)
599 { 599 {
600 GNUNET_break (0); 600 GNUNET_break (0);
601 return; 601 return;
602 } 602 }
603 603
604 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 604 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -654,10 +654,12 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
654/** 654/**
655 * Free a session 655 * Free a session
656 * 656 *
657 * @param cls our `struct Plugin`.
657 * @param session the session free 658 * @param session the session free
658 */ 659 */
659static void 660static int
660free_session (struct Session *session) 661wlan_plugin_disconnect_session (void *cls,
662 struct Session *session)
661{ 663{
662 struct MacEndpoint *endpoint = session->mac; 664 struct MacEndpoint *endpoint = session->mac;
663 struct PendingMessage *pm; 665 struct PendingMessage *pm;
@@ -685,9 +687,11 @@ free_session (struct Session *session)
685 GNUNET_SCHEDULER_cancel (session->timeout_task); 687 GNUNET_SCHEDULER_cancel (session->timeout_task);
686 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 688 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
687 } 689 }
688 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN sessions allocated"), -1, 690 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
691 _("# WLAN sessions allocated"), -1,
689 GNUNET_NO); 692 GNUNET_NO);
690 GNUNET_free (session); 693 GNUNET_free (session);
694 return GNUNET_OK;
691} 695}
692 696
693 697
@@ -700,14 +704,15 @@ free_session (struct Session *session)
700static void 704static void
701session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 705session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
702{ 706{
703 struct Session * session = cls; 707 struct Session *session = cls;
704 struct GNUNET_TIME_Relative timeout; 708 struct GNUNET_TIME_Relative timeout;
705 709
706 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 710 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
707 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); 711 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout);
708 if (0 == timeout.rel_value_us) 712 if (0 == timeout.rel_value_us)
709 { 713 {
710 free_session (session); 714 wlan_plugin_disconnect_session (session->mac->plugin,
715 session);
711 return; 716 return;
712 } 717 }
713 session->timeout_task = 718 session->timeout_task =
@@ -804,7 +809,7 @@ get_session (struct MacEndpoint *endpoint,
804 * the next fragment. 809 * the next fragment.
805 * 810 *
806 * @param cls the 'struct FragmentMessage' 811 * @param cls the 'struct FragmentMessage'
807 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR 812 * @param result result of the operation (#GNUNET_OK on success, #GNUNET_NO if the helper died, #GNUNET_SYSERR
808 * if the helper was stopped) 813 * if the helper was stopped)
809 */ 814 */
810static void 815static void
@@ -894,8 +899,8 @@ free_fragment_message (struct FragmentMessage *fm)
894 fm->sh = NULL; 899 fm->sh = NULL;
895 } 900 }
896 GNUNET_FRAGMENT_context_destroy (fm->fragcontext, 901 GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
897 &endpoint->msg_delay, 902 &endpoint->msg_delay,
898 &endpoint->ack_delay); 903 &endpoint->ack_delay);
899 if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK) 904 if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
900 { 905 {
901 GNUNET_SCHEDULER_cancel (fm->timeout_task); 906 GNUNET_SCHEDULER_cancel (fm->timeout_task);
@@ -944,7 +949,7 @@ fragmentmessage_timeout (void *cls,
944static void 949static void
945send_with_fragmentation (struct MacEndpoint *endpoint, 950send_with_fragmentation (struct MacEndpoint *endpoint,
946 struct GNUNET_TIME_Relative timeout, 951 struct GNUNET_TIME_Relative timeout,
947 const struct GNUNET_PeerIdentity *target, 952 const struct GNUNET_PeerIdentity *target,
948 const struct GNUNET_MessageHeader *msg, 953 const struct GNUNET_MessageHeader *msg,
949 size_t payload_size, 954 size_t payload_size,
950 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 955 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
@@ -994,7 +999,8 @@ free_macendpoint (struct MacEndpoint *endpoint)
994 GNUNET_STATISTICS_update (plugin->env->stats, 999 GNUNET_STATISTICS_update (plugin->env->stats,
995 _("# WLAN MAC endpoints allocated"), -1, GNUNET_NO); 1000 _("# WLAN MAC endpoints allocated"), -1, GNUNET_NO);
996 while (NULL != (session = endpoint->sessions_head)) 1001 while (NULL != (session = endpoint->sessions_head))
997 free_session (session); 1002 wlan_plugin_disconnect_session (plugin,
1003 session);
998 while (NULL != (fm = endpoint->sending_messages_head)) 1004 while (NULL != (fm = endpoint->sending_messages_head))
999 free_fragment_message (fm); 1005 free_fragment_message (fm);
1000 GNUNET_CONTAINER_DLL_remove (plugin->mac_head, 1006 GNUNET_CONTAINER_DLL_remove (plugin->mac_head,
@@ -1142,7 +1148,8 @@ wlan_plugin_get_session (void *cls,
1142 * @param target peer from which to disconnect 1148 * @param target peer from which to disconnect
1143 */ 1149 */
1144static void 1150static void
1145wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) 1151wlan_plugin_disconnect_peer (void *cls,
1152 const struct GNUNET_PeerIdentity *target)
1146{ 1153{
1147 struct Plugin *plugin = cls; 1154 struct Plugin *plugin = cls;
1148 struct Session *session; 1155 struct Session *session;
@@ -1153,7 +1160,7 @@ wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
1153 if (0 == memcmp (target, &session->target, 1160 if (0 == memcmp (target, &session->target,
1154 sizeof (struct GNUNET_PeerIdentity))) 1161 sizeof (struct GNUNET_PeerIdentity)))
1155 { 1162 {
1156 free_session (session); 1163 wlan_plugin_disconnect_session (plugin, session);
1157 break; /* inner-loop only (in case peer has another MAC as well!) */ 1164 break; /* inner-loop only (in case peer has another MAC as well!) */
1158 } 1165 }
1159} 1166}
@@ -1959,7 +1966,8 @@ libgnunet_plugin_transport_wlan_init (void *cls)
1959 api->cls = plugin; 1966 api->cls = plugin;
1960 api->send = &wlan_plugin_send; 1967 api->send = &wlan_plugin_send;
1961 api->get_session = &wlan_plugin_get_session; 1968 api->get_session = &wlan_plugin_get_session;
1962 api->disconnect = &wlan_plugin_disconnect; 1969 api->disconnect_peer = &wlan_plugin_disconnect_peer;
1970 api->disconnect_session = &wlan_plugin_disconnect_session;
1963 api->address_pretty_printer = &wlan_plugin_address_pretty_printer; 1971 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
1964 api->check_address = &wlan_plugin_address_suggested; 1972 api->check_address = &wlan_plugin_address_suggested;
1965 api->address_to_string = &wlan_plugin_address_to_string; 1973 api->address_to_string = &wlan_plugin_address_to_string;