- fix
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.c
index 3e8cd50e253a4b864a00eaccbdb20fa88219ecc0..e1201eb2bdd6e4fcd1882675cd45c7d6b95a32ce 100644 (file)
@@ -339,6 +339,16 @@ struct MacEndpoint
    */
   struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
 
+  /**
+   * Message delay for fragmentation context
+   */
+  struct GNUNET_TIME_Relative msg_delay;
+
+  /**
+   * ACK delay for fragmentation context
+   */
+  struct GNUNET_TIME_Relative ack_delay;
+
   /**
    * Desired transmission power for this MAC
    */
@@ -790,7 +800,9 @@ free_fragment_message (struct FragmentMessage *fm)
     GNUNET_HELPER_send_cancel (fm->sh);
     fm->sh = NULL;
   }
-  GNUNET_FRAGMENT_context_destroy (fm->fragcontext, NULL, NULL);
+  GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
+                                                                  &endpoint->msg_delay,
+                                                                  &endpoint->ack_delay);
   if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (fm->timeout_task);
@@ -861,9 +873,8 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
   fm->fragcontext =
     GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
                                    &plugin->tracker,
-                                   GNUNET_TIME_UNIT_MILLISECONDS,
-                                   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                                                  100),
+                                   endpoint->msg_delay,
+                                   endpoint->ack_delay,
                                    msg,
                                    &transmit_fragment, fm);
   fm->timeout_task =
@@ -963,6 +974,10 @@ create_macendpoint (struct Plugin *plugin,
                                      pos, 
                                      &wlan_data_message_handler,
                                      &send_ack);
+
+  pos->msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
+  pos->ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+                                                                                                 100);
   pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
   pos->timeout_task =
       GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
@@ -1156,10 +1171,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
     plugin->env->receive (plugin->env->cls, 
                          &tmpsource,
                          hdr, 
-                         ats, NUM_ATS,
                          mas->session,
                          (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
                          (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
+    plugin->env->update_address_metrics (plugin->env->cls,
+               &tmpsource,
+                         (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
+                         (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress),
+               mas->session,
+        (struct GNUNET_ATS_Information *) &ats, NUM_ATS);
     break;
   case GNUNET_MESSAGE_TYPE_FRAGMENT:
     if (NULL == mas->endpoint)
@@ -1274,10 +1294,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
     plugin->env->receive (plugin->env->cls, 
                          &mas->session->target,
                          hdr, 
-                         ats, NUM_ATS,
                          mas->session,
                          (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
                          (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
+    plugin->env->update_address_metrics (plugin->env->cls,
+               &mas->session->target,
+                         (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
+                         (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress),
+               mas->session,
+        (struct GNUNET_ATS_Information *) &ats, NUM_ATS);
     break;
   }
   return GNUNET_OK;
@@ -1688,6 +1713,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
   struct Plugin *plugin;
   char *interface;
   unsigned long long testmode;
+  char *binary;
 
   /* check for 'special' mode */
   if (NULL == env->receive)
@@ -1715,14 +1741,17 @@ libgnunet_plugin_transport_wlan_init (void *cls)
                               "transport-wlan", "TESTMODE");
     return NULL;
   }
+  binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-transport-wlan");
   if ( (0 == testmode) &&
-       (GNUNET_YES != GNUNET_OS_check_helper_binary ("gnunet-helper-transport-wlan")) )
+       (GNUNET_YES != GNUNET_OS_check_helper_binary (binary)) )
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
         _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
         "gnunet-helper-transport-wlan");
+    GNUNET_free (binary);
     return NULL;
   }
+    GNUNET_free (binary);
   if (GNUNET_YES !=
       GNUNET_CONFIGURATION_get_value_string
       (env->cfg, "transport-wlan", "INTERFACE",