REST/NAMESTORE: rework API
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.c
index a42f1a94018b22e298a52159cee6a3ce6ee12072..e1a93bf884d6843ea2137a3f0da3becca8a7e8f8 100644 (file)
@@ -1,50 +1,54 @@
 /*
   This file is part of GNUnet
-  (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2010-2014 GNUnet e.V.
 
-  GNUnet is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published
-  by the Free Software Foundation; either version 3, or (at your
-  option) any later version.
+  GNUnet is free software: you can redistribute it and/or modify it
+  under the terms of the GNU Affero General Public License as published
+  by the Free Software Foundation, either version 3 of the License,
+  or (at your option) any later version.
 
   GNUnet is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
+  Affero General Public License for more details.
+  You should have received a copy of the GNU Affero General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-  You should have received a copy of the GNU General Public License
-  along with GNUnet; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-  Boston, MA 02111-1307, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
  * @file transport/plugin_transport_wlan.c
- * @brief transport plugin for wlan
+ * @brief transport plugin for wlan and/or bluetooth
  * @author David Brodski
  * @author Christian Grothoff
+ *
+ * BUILD_WLAN or BUILD_BLUETOOTH must be defined such that the respective
+ * variant of this code is compiled.
  */
 #include "platform.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_protocols.h"
-#include "gnunet_util_lib.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include "gnunet_transport_plugin.h"
 #include "plugin_transport_wlan.h"
-#include "gnunet_common.h"
-#include "gnunet_crypto_lib.h"
 #include "gnunet_fragmentation_lib.h"
 #include "gnunet_constants.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__)
 
+#if BUILD_WLAN
+/* begin case wlan */
 #define PLUGIN_NAME "wlan"
+#define CONFIG_NAME "transport-wlan"
+#define HELPER_NAME "gnunet-helper-transport-wlan"
+#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
+#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init
+#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__)
 
-/**
- * Max size of packet (that we give to the WLAN driver for transmission)
- */
-#define WLAN_MTU 1430
 
 /**
  * time out of a mac endpoint
  */
 #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
 
+
+/* end case wlan */
+#elif BUILD_BLUETOOTH
+/* begin case bluetooth */
+
+#define PLUGIN_NAME "bluetooth"
+#define CONFIG_NAME "transport-bluetooth"
+#define HELPER_NAME "gnunet-helper-transport-bluetooth"
+/* yes, this is correct, we use the same dummy driver as 'wlan' */
+#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
+#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_bluetooth_init
+#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_bluetooth_done
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-bluetooth",__VA_ARGS__)
+
+/**
+ * time out of a mac endpoint
+ */
+#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60)
+
+
+/**
+ * We reduce the frequence of HELLO beacons in relation to
+ * the number of MAC addresses currently visible to us.
+ * This is the multiplication factor.
+ */
+#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+/* end case bluetooth */
+#else
+#error need to build wlan or bluetooth
+#endif
+
+
+
+/**
+ * Functions with this signature are called whenever a
+ * complete message is received by the tokenizer.
+ *
+ * Do not call #GNUNET_SERVER_mst_destroy from within
+ * the scope of this callback.
+ *
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
+ */
+typedef int
+(*GNUNET_SERVER_MessageTokenizerCallback) (void *cls,
+                                           void *client,
+                                           const struct GNUNET_MessageHeader *message);
+
+
+/* Include legacy message stream tokenizer that was removed from util (for now) */
+#include "tcp_server_mst_legacy.c"
+
+
+/**
+ * Max size of packet (that we give to the WLAN driver for transmission)
+ */
+#define WLAN_MTU 1430
+
+
+/**
+ * Which network scope do we belong to?
+ */
+#if BUILD_WLAN
+static const enum GNUNET_NetworkType scope = GNUNET_NT_WLAN;
+#else
+static const enum GNUNET_NetworkType scope = GNUNET_NT_BT;
+#endif
+
+
 /**
  * Maximum number of messages in defragmentation queue per MAC
  */
@@ -163,7 +239,7 @@ struct PendingMessage
   /**
    * Timeout task (for this message).
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  struct GNUNET_SCHEDULER_Task * timeout_task;
 
 };
 
@@ -171,7 +247,7 @@ struct PendingMessage
 /**
  * Session handle for connections with other peers.
  */
-struct Session
+struct GNUNET_ATS_Session
 {
   /**
    * To whom are we talking to (set to our identity
@@ -183,13 +259,13 @@ struct Session
    * We keep all sessions in a DLL at their respective
    * `struct MACEndpoint *`.
    */
-  struct Session *next;
+  struct GNUNET_ATS_Session *next;
 
   /**
    * We keep all sessions in a DLL at their respective
    * `struct MACEndpoint *`.
    */
-  struct Session *prev;
+  struct GNUNET_ATS_Session *prev;
 
   /**
    * MAC endpoint with the address of this peer.
@@ -209,7 +285,7 @@ struct Session
   /**
    * Timeout task (for the session).
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  struct GNUNET_SCHEDULER_Task * timeout_task;
 
 };
 
@@ -259,13 +335,19 @@ struct FragmentMessage
   /**
    * Timeout task.
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  struct GNUNET_SCHEDULER_Task * timeout_task;
 
   /**
    * Continuation to call when we're done with this message.
    */
   GNUNET_TRANSPORT_TransmitContinuation cont;
 
+  /**
+   * Message we need to fragment and transmit, NULL after the
+   * @e fragmentcontext has been created.
+   */
+  struct GNUNET_MessageHeader *msg;
+
   /**
    * Closure for @e cont
    */
@@ -308,12 +390,12 @@ struct MacEndpoint
   /**
    * Head of sessions that use this MAC.
    */
-  struct Session *sessions_head;
+  struct GNUNET_ATS_Session *sessions_head;
 
   /**
    * Tail of sessions that use this MAC.
    */
-  struct Session *sessions_tail;
+  struct GNUNET_ATS_Session *sessions_tail;
 
   /**
    * Head of messages we are currently sending to this MAC.
@@ -338,7 +420,7 @@ struct MacEndpoint
   /**
    * Timeout task.
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  struct GNUNET_SCHEDULER_Task * timeout_task;
 
   /**
    * count of messages in the fragment out queue for this mac endpoint
@@ -412,7 +494,7 @@ struct Plugin
   /**
    * The interface of the wlan card given to us by the user.
    */
-  char *interface;
+  char *wlan_interface;
 
   /**
    * Tokenizer for demultiplexing of data packets resulting from
@@ -443,7 +525,7 @@ struct Plugin
   /**
    * Task that periodically sends a HELLO beacon via the helper.
    */
-  GNUNET_SCHEDULER_TaskIdentifier beacon_task;
+  struct GNUNET_SCHEDULER_Task *beacon_task;
 
   /**
    * Tracker for bandwidth limit
@@ -483,7 +565,7 @@ struct MacAndSession
   /**
    * NULL if the identity of the other peer is not known.
    */
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   /**
    * MAC address of the other peer, NULL if not known.
@@ -560,7 +642,7 @@ wlan_plugin_address_to_string (void *cls,
  */
 static void
 notify_session_monitor (struct Plugin *plugin,
-                        struct Session *session,
+                        struct GNUNET_ATS_Session *session,
                         enum GNUNET_TRANSPORT_SessionState state)
 {
   struct GNUNET_TRANSPORT_SessionInfo info;
@@ -647,7 +729,8 @@ get_wlan_header (struct Plugin *plugin,
  * @param hdr pointer to the hdr where the ack is stored
  */
 static void
-send_ack (void *cls, uint32_t msg_id,
+send_ack (void *cls,
+          uint32_t msg_id,
          const struct GNUNET_MessageHeader *hdr)
 {
   struct MacEndpoint *endpoint = cls;
@@ -661,28 +744,28 @@ send_ack (void *cls, uint32_t msg_id,
     GNUNET_break (0);
     return;
   }
-
-  if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  if (size >= GNUNET_MAX_MESSAGE_SIZE)
   {
     GNUNET_break (0);
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Sending ACK to helper\n");
+       "Sending ACK to %s\n",
+       mac_to_string (&endpoint->wlan_addr.mac));
   radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
   get_radiotap_header (endpoint, radio_header, size);
   get_wlan_header (endpoint->plugin,
                   &radio_header->frame,
                   &endpoint->wlan_addr.mac,
                   sizeof (endpoint->wlan_addr.mac));
-  memcpy (&radio_header[1], hdr, msize);
+  GNUNET_memcpy (&radio_header[1], hdr, msize);
   if (NULL !=
       GNUNET_HELPER_send (endpoint->plugin->suid_helper,
                          &radio_header->header,
                          GNUNET_NO /* dropping ACKs is bad */,
                          NULL, NULL))
     GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                              _("# WLAN ACKs sent"),
+                              _("# ACKs sent"),
                              1, GNUNET_NO);
 }
 
@@ -702,7 +785,7 @@ wlan_data_message_handler (void *cls,
   struct MacAndSession mas;
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           _("# WLAN messages defragmented"),
+                           _("# Messages defragmented"),
                             1,
                            GNUNET_NO);
   mas.session = NULL;
@@ -723,7 +806,7 @@ wlan_data_message_handler (void *cls,
  */
 static int
 wlan_plugin_disconnect_session (void *cls,
-                                struct Session *session)
+                                struct GNUNET_ATS_Session *session)
 {
   struct MacEndpoint *endpoint = session->mac;
   struct Plugin *plugin = endpoint->plugin;
@@ -733,17 +816,17 @@ wlan_plugin_disconnect_session (void *cls,
                             session);
   notify_session_monitor (plugin,
                           session,
-                          GNUNET_TRANSPORT_SS_DOWN);
+                          GNUNET_TRANSPORT_SS_DONE);
   GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
                               endpoint->sessions_tail,
                                session);
-  if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+  if (session->timeout_task != NULL)
   {
     GNUNET_SCHEDULER_cancel (session->timeout_task);
-    session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    session->timeout_task = NULL;
   }
   GNUNET_STATISTICS_update (plugin->env->stats,
-                            _("# WLAN sessions allocated"),
+                            _("# Sessions allocated"),
                             -1,
                             GNUNET_NO);
   GNUNET_HELLO_address_free (session->address);
@@ -771,16 +854,14 @@ wlan_plugin_query_keepalive_factor (void *cls)
  * A session is timing out.  Clean up.
  *
  * @param cls pointer to the Session
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
  */
 static void
-session_timeout (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext *tc)
+session_timeout (void *cls)
 {
-  struct Session *session = cls;
+  struct GNUNET_ATS_Session *session = cls;
   struct GNUNET_TIME_Relative left;
 
-  session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  session->timeout_task = NULL;
   left = GNUNET_TIME_absolute_get_remaining (session->timeout);
   if (0 != left.rel_value_us)
   {
@@ -803,11 +884,11 @@ session_timeout (void *cls,
  * @param peer peer identity to use for this session
  * @return returns the session or NULL
  */
-static struct Session *
+static struct GNUNET_ATS_Session *
 lookup_session (struct MacEndpoint *endpoint,
                 const struct GNUNET_PeerIdentity *peer)
 {
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   for (session = endpoint->sessions_head; NULL != session; session = session->next)
     if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)))
@@ -823,17 +904,17 @@ lookup_session (struct MacEndpoint *endpoint,
  * @param peer peer identity to use for this session
  * @return returns the session or NULL
  */
-static struct Session *
+static struct GNUNET_ATS_Session *
 create_session (struct MacEndpoint *endpoint,
                 const struct GNUNET_PeerIdentity *peer)
 {
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                            _("# WLAN sessions allocated"),
+                            _("# Sessions allocated"),
                             1,
                             GNUNET_NO);
-  session = GNUNET_new (struct Session);
+  session = GNUNET_new (struct GNUNET_ATS_Session);
   GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head,
                                     endpoint->sessions_tail,
                                    session);
@@ -848,7 +929,10 @@ create_session (struct MacEndpoint *endpoint,
   session->timeout_task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout,
                                     session);
-  notify_session_monitor (plugin,
+  notify_session_monitor (endpoint->plugin,
+                          session,
+                          GNUNET_TRANSPORT_SS_INIT);
+  notify_session_monitor (endpoint->plugin,
                           session,
                           GNUNET_TRANSPORT_SS_UP);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -868,11 +952,11 @@ create_session (struct MacEndpoint *endpoint,
  * @param peer peer identity to use for this session
  * @return returns the session
  */
-static struct Session *
+static struct GNUNET_ATS_Session *
 get_session (struct MacEndpoint *endpoint,
              const struct GNUNET_PeerIdentity *peer)
 {
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   if (NULL != (session = lookup_session (endpoint, peer)))
     return session;
@@ -896,7 +980,6 @@ fragment_transmission_done (void *cls,
 {
   struct FragmentMessage *fm = cls;
 
-
   fm->sh = NULL;
   GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
 }
@@ -919,10 +1002,9 @@ transmit_fragment (void *cls,
 
   if (NULL == endpoint)
   {
-       GNUNET_break (0);
-       return;
+    GNUNET_break (0);
+    return;
   }
-
   msize = ntohs (hdr->size);
   size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
   {
@@ -931,11 +1013,16 @@ transmit_fragment (void *cls,
 
     radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
     get_radiotap_header (endpoint, radio_header, size);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Sending %u bytes of data to MAC `%s'\n",
+        (unsigned int) msize,
+        mac_to_string (&endpoint->wlan_addr.mac));
+
     get_wlan_header (endpoint->plugin,
                     &radio_header->frame,
                     &endpoint->wlan_addr.mac,
                     sizeof (endpoint->wlan_addr.mac));
-    memcpy (&radio_header[1], hdr, msize);
+    GNUNET_memcpy (&radio_header[1], hdr, msize);
     GNUNET_assert (NULL == fm->sh);
     fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper,
                                 &radio_header->header,
@@ -943,17 +1030,21 @@ transmit_fragment (void *cls,
                                 &fragment_transmission_done, fm);
     fm->size_on_wire += size;
     if (NULL != fm->sh)
+    {
       GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                                _("# WLAN message fragments sent"),
+                                _("# message fragments sent"),
                                1,
                                 GNUNET_NO);
+    }
     else
+    {
       GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
+    }
     GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                              "# bytes currently in WLAN buffers",
+                              "# bytes currently in buffers",
                               -msize, GNUNET_NO);
     GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                              "# bytes transmitted via WLAN",
+                              "# bytes transmitted",
                               msize, GNUNET_NO);
   }
 }
@@ -970,7 +1061,7 @@ free_fragment_message (struct FragmentMessage *fm)
   struct MacEndpoint *endpoint = fm->macendpoint;
 
   GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                            _("# WLAN messages pending (with fragmentation)"),
+                            _("# messages pending (with fragmentation)"),
                            -1, GNUNET_NO);
   GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
                                endpoint->sending_messages_tail,
@@ -980,13 +1071,22 @@ free_fragment_message (struct FragmentMessage *fm)
     GNUNET_HELPER_send_cancel (fm->sh);
     fm->sh = NULL;
   }
-  GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
-                                   &endpoint->msg_delay,
-                                   &endpoint->ack_delay);
-  if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+  if (NULL != fm->msg)
+  {
+    GNUNET_free (fm->msg);
+    fm->msg = NULL;
+  }
+  if (NULL != fm->fragcontext)
+  {
+    GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
+                                     &endpoint->msg_delay,
+                                     &endpoint->ack_delay);
+    fm->fragcontext = NULL;
+  }
+  if (NULL != fm->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (fm->timeout_task);
-    fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    fm->timeout_task = NULL;
   }
   GNUNET_free (fm);
 }
@@ -996,15 +1096,13 @@ free_fragment_message (struct FragmentMessage *fm)
  * A FragmentMessage has timed out.  Remove it.
  *
  * @param cls pointer to the 'struct FragmentMessage'
- * @param tc unused
  */
 static void
-fragmentmessage_timeout (void *cls,
-                         const struct GNUNET_SCHEDULER_TaskContext *tc)
+fragmentmessage_timeout (void *cls)
 {
   struct FragmentMessage *fm = cls;
 
-  fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  fm->timeout_task = NULL;
   if (NULL != fm->cont)
   {
     fm->cont (fm->cont_cls,
@@ -1050,22 +1148,29 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
   fm->macendpoint = endpoint;
   fm->target = *target;
   fm->size_payload = payload_size;
-  fm->size_on_wire = 0;
   fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
   fm->cont = cont;
   fm->cont_cls = cont_cls;
   /* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */
-  fm->fragcontext =
-    GNUNET_FRAGMENT_context_create (plugin->env->stats,
-                                    WLAN_MTU,
-                                   &plugin->tracker,
-                                   endpoint->msg_delay,
-                                   endpoint->ack_delay,
-                                   msg,
-                                   &transmit_fragment, fm);
   fm->timeout_task =
     GNUNET_SCHEDULER_add_delayed (timeout,
-                                 &fragmentmessage_timeout, fm);
+                                  &fragmentmessage_timeout,
+                                  fm);
+  if (GNUNET_YES == plugin->have_mac)
+  {
+    fm->fragcontext =
+      GNUNET_FRAGMENT_context_create (plugin->env->stats,
+                                      WLAN_MTU,
+                                      &plugin->tracker,
+                                      fm->macendpoint->msg_delay,
+                                      fm->macendpoint->ack_delay,
+                                      msg,
+                                      &transmit_fragment, fm);
+  }
+  else
+  {
+    fm->msg = GNUNET_copy_message (msg);
+  }
   GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
                                    endpoint->sending_messages_tail,
                                    fm);
@@ -1082,10 +1187,10 @@ free_macendpoint (struct MacEndpoint *endpoint)
 {
   struct Plugin *plugin = endpoint->plugin;
   struct FragmentMessage *fm;
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           _("# WLAN MAC endpoints allocated"),
+                           _("# MAC endpoints allocated"),
                             -1,
                             GNUNET_NO);
   while (NULL != (session = endpoint->sessions_head))
@@ -1104,10 +1209,10 @@ free_macendpoint (struct MacEndpoint *endpoint)
   }
 
   plugin->mac_count--;
-  if (GNUNET_SCHEDULER_NO_TASK != endpoint->timeout_task)
+  if (NULL != endpoint->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (endpoint->timeout_task);
-    endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    endpoint->timeout_task = NULL;
   }
   GNUNET_free (endpoint);
 }
@@ -1117,16 +1222,14 @@ free_macendpoint (struct MacEndpoint *endpoint)
  * A MAC endpoint is timing out.  Clean up.
  *
  * @param cls pointer to the `struct MacEndpoint *`
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
  */
 static void
-macendpoint_timeout (void *cls,
-                     const struct GNUNET_SCHEDULER_TaskContext *tc)
+macendpoint_timeout (void *cls)
 {
   struct MacEndpoint *endpoint = cls;
   struct GNUNET_TIME_Relative timeout;
 
-  endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  endpoint->timeout_task = NULL;
   timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
   if (0 == timeout.rel_value_us)
   {
@@ -1154,16 +1257,8 @@ create_macendpoint (struct Plugin *plugin,
   struct MacEndpoint *pos;
 
   for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
-  {
     if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr)))
-    {
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing MAC endpoint `%s'\n",
-        wlan_plugin_address_to_string (NULL,
-                                       &pos->wlan_addr.mac,
-                                       sizeof (pos->wlan_addr)));
       return pos;
-    }
-  }
   pos = GNUNET_new (struct MacEndpoint);
   pos->wlan_addr = (*mac);
   pos->plugin = plugin;
@@ -1186,7 +1281,7 @@ create_macendpoint (struct Plugin *plugin,
                                pos);
   plugin->mac_count++;
   GNUNET_STATISTICS_update (plugin->env->stats,
-                            _("# WLAN MAC endpoints allocated"),
+                            _("# MAC endpoints allocated"),
                            1, GNUNET_NO);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "New MAC endpoint `%s'\n",
@@ -1204,11 +1299,34 @@ create_macendpoint (struct Plugin *plugin,
  * @param session the session
  * @return the network type in HBO or #GNUNET_SYSERR
  */
-static enum GNUNET_ATS_Network_Type
+static enum GNUNET_NetworkType
 wlan_plugin_get_network (void *cls,
-                         struct Session *session)
+                         struct GNUNET_ATS_Session *session)
 {
-  return GNUNET_ATS_NET_WLAN;
+#if BUILD_WLAN
+  return GNUNET_NT_WLAN;
+#else
+  return GNUNET_NT_BT;
+#endif
+}
+
+
+/**
+ * Function obtain the network type for an address.
+ *
+ * @param cls closure (`struct Plugin *`)
+ * @param address the address
+ * @return the network type
+ */
+static enum GNUNET_NetworkType
+wlan_plugin_get_network_for_address (void *cls,
+                                    const struct GNUNET_HELLO_Address *address)
+{
+#if BUILD_WLAN
+  return GNUNET_NT_WLAN;
+#else
+  return GNUNET_NT_BT;
+#endif
 }
 
 
@@ -1220,7 +1338,7 @@ wlan_plugin_get_network (void *cls,
  * @param address the address
  * @return the session or NULL of max connections exceeded
  */
-static struct Session *
+static struct GNUNET_ATS_Session *
 wlan_plugin_get_session (void *cls,
                         const struct GNUNET_HELLO_Address *address)
 {
@@ -1240,7 +1358,8 @@ wlan_plugin_get_session (void *cls,
        wlan_plugin_address_to_string (NULL,
                                       address->address,
                                       address->address_length));
-  endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address);
+  endpoint = create_macendpoint (plugin,
+                                 (struct WlanAddress *) address->address);
   return get_session (endpoint, &address->peer);
 }
 
@@ -1258,7 +1377,7 @@ wlan_plugin_disconnect_peer (void *cls,
                              const struct GNUNET_PeerIdentity *target)
 {
   struct Plugin *plugin = cls;
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
   struct MacEndpoint *endpoint;
 
   for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
@@ -1301,7 +1420,7 @@ wlan_plugin_disconnect_peer (void *cls,
  */
 static ssize_t
 wlan_plugin_send (void *cls,
-                  struct Session *session,
+                  struct GNUNET_ATS_Session *session,
                   const char *msgbuf, size_t msgbuf_size,
                   unsigned int priority,
                   struct GNUNET_TIME_Relative to,
@@ -1324,12 +1443,13 @@ wlan_plugin_send (void *cls,
   wlanheader->sender = *plugin->env->my_identity;
   wlanheader->target = session->target;
   wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
-  memcpy (&wlanheader[1], msgbuf, msgbuf_size);
-
+  GNUNET_memcpy (&wlanheader[1],
+          msgbuf,
+          msgbuf_size);
   GNUNET_STATISTICS_update (plugin->env->stats,
-                            "# bytes currently in WLAN buffers",
-                            msgbuf_size, GNUNET_NO);
-
+                            "# bytes currently in buffers",
+                            msgbuf_size,
+                            GNUNET_NO);
   send_with_fragmentation (session->mac,
                           to,
                           &session->target,
@@ -1356,20 +1476,16 @@ process_data (void *cls,
   struct Plugin *plugin = cls;
   struct GNUNET_HELLO_Address *address;
   struct MacAndSession *mas = client;
-  struct MacAndSession xmas;
-  struct GNUNET_ATS_Information ats;
   struct FragmentMessage *fm;
   struct GNUNET_PeerIdentity tmpsource;
   const struct WlanHeader *wlanheader;
   int ret;
   uint16_t msize;
 
-  ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-  ats.value = htonl (GNUNET_ATS_NET_WLAN);
   msize = ntohs (hdr->size);
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                            "# bytes received via WLAN",
+                            "# bytes received",
                             msize, GNUNET_NO);
 
   switch (ntohs (hdr->type))
@@ -1398,21 +1514,28 @@ process_data (void *cls,
                                         sizeof (mas->endpoint->wlan_addr)));
 
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             _("# HELLO messages received via WLAN"), 1,
+                             _("# HELLO messages received"), 1,
                              GNUNET_NO);
     address = GNUNET_HELLO_address_allocate (&tmpsource,
                                              PLUGIN_NAME,
                                              &mas->endpoint->wlan_addr,
                                              sizeof (mas->endpoint->wlan_addr),
-                                             GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+                                             GNUNET_HELLO_ADDRESS_INFO_NONE);
+    mas->session = lookup_session (mas->endpoint,
+                                   &tmpsource);
+    if (NULL == mas->session)
+    {
+      mas->session = create_session (mas->endpoint,
+                                     &tmpsource);
+      plugin->env->session_start (plugin->env->cls,
+                                  address,
+                                  mas->session,
+                                  scope);
+    }
     plugin->env->receive (plugin->env->cls,
                           address,
                           mas->session,
                           hdr);
-    plugin->env->update_address_metrics (plugin->env->cls,
-                                         address,
-                                         mas->session,
-                                         &ats, 1);
     GNUNET_HELLO_address_free (address);
     break;
   case GNUNET_MESSAGE_TYPE_FRAGMENT:
@@ -1428,7 +1551,7 @@ process_data (void *cls,
                                         &mas->endpoint->wlan_addr,
                                         sizeof (mas->endpoint->wlan_addr)));
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              _("# fragments received via WLAN"),
+                              _("# fragments received"),
                               1,
                               GNUNET_NO);
     (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
@@ -1441,7 +1564,7 @@ process_data (void *cls,
       break;
     }
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              _("# ACKs received via WLAN"),
+                              _("# ACKs received"),
                              1, GNUNET_NO);
     for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
     {
@@ -1477,11 +1600,12 @@ process_data (void *cls,
         break;
       }
     }
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "ACK not matched against any active fragmentation with MAC `%s'\n",
-         wlan_plugin_address_to_string (NULL,
-                                        &mas->endpoint->wlan_addr,
-                                        sizeof (mas->endpoint->wlan_addr)));
+    if (NULL == fm)
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "ACK not matched against any active fragmentation with MAC `%s'\n",
+           wlan_plugin_address_to_string (NULL,
+                                          &mas->endpoint->wlan_addr,
+                                          sizeof (mas->endpoint->wlan_addr)));
     break;
   case GNUNET_MESSAGE_TYPE_WLAN_DATA:
     if (NULL == mas->endpoint)
@@ -1500,7 +1624,7 @@ process_data (void *cls,
                     sizeof (struct GNUNET_PeerIdentity)))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "WLAN data for `%s', not for me, ignoring\n",
+          "Data for `%s', not for me, ignoring\n",
           GNUNET_i2s (&wlanheader->target));
       break;
     }
@@ -1509,39 +1633,39 @@ process_data (void *cls,
                                msize - sizeof (struct WlanHeader)))
     {
       GNUNET_STATISTICS_update (plugin->env->stats,
-                               _("# WLAN DATA messages discarded due to CRC32 error"),
+                               _("# DATA messages discarded due to CRC32 error"),
                                 1,
                                GNUNET_NO);
       break;
     }
-    xmas.endpoint = mas->endpoint;
-    if (NULL == (xmas.session = lookup_session (mas->endpoint,
-                                                &wlanheader->sender)))
+    mas->session = lookup_session (mas->endpoint,
+                                   &wlanheader->sender);
+    if (NULL == mas->session)
     {
-      xmas.session = create_session (mas->endpoint,
+      mas->session = create_session (mas->endpoint,
                                      &wlanheader->sender);
       address = GNUNET_HELLO_address_allocate (&wlanheader->sender,
                                                PLUGIN_NAME,
                                                &mas->endpoint->wlan_addr,
                                                sizeof (struct WlanAddress),
                                                GNUNET_HELLO_ADDRESS_INFO_NONE);
-      plugin->env->session_start (NULL,
+      plugin->env->session_start (plugin->env->cls,
                                   address,
-                                  xmas.session,
-                                  NULL, 0);
+                                  mas->session,
+                                  scope);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "Notifying transport about peer `%s''s new session %p \n",
+           "Notifying transport about peer `%s''s new session %p \n",
            GNUNET_i2s (&wlanheader->sender),
-           xmas.session);
+           mas->session);
       GNUNET_HELLO_address_free (address);
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Processing %u bytes of WLAN DATA from peer `%s'\n",
+         "Processing %u bytes of DATA from peer `%s'\n",
         (unsigned int) msize,
         GNUNET_i2s (&wlanheader->sender));
-    xmas.session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+    mas->session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
-                                     &xmas,
+                                     mas,
                                      (const char *) &wlanheader[1],
                                      msize - sizeof (struct WlanHeader),
                                      GNUNET_YES,
@@ -1567,25 +1691,73 @@ process_data (void *cls,
                           mas->session->address,
                           mas->session,
                           hdr);
-    plugin->env->update_address_metrics (plugin->env->cls,
-                                         mas->session->address,
-                                         mas->session,
-                                         &ats, 1);
     break;
   }
   return GNUNET_OK;
 }
 
 
+/**
+ * Task to (periodically) send a HELLO beacon
+ *
+ * @param cls pointer to the plugin struct
+ */
+static void
+send_hello_beacon (void *cls)
+{
+  struct Plugin *plugin = cls;
+  uint16_t size;
+  uint16_t hello_size;
+  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
+  const struct GNUNET_MessageHeader *hello;
+
+  hello = plugin->env->get_our_hello ();
+  if (NULL != hello)
+  {
+    hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
+    GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
+    size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
+  {
+    char buf[size] GNUNET_ALIGN;
+
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Sending %u byte HELLO beacon\n",
+        (unsigned int) size);
+    radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
+    get_radiotap_header (NULL, radioHeader, size);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Broadcasting %u bytes of data to MAC `%s'\n",
+        (unsigned int) size,
+        mac_to_string (&bc_all_mac));
+    get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
+    GNUNET_memcpy (&radioHeader[1], hello, hello_size);
+    if (NULL !=
+       GNUNET_HELPER_send (plugin->suid_helper,
+                           &radioHeader->header,
+                           GNUNET_YES /* can drop */,
+                           NULL, NULL))
+      GNUNET_STATISTICS_update (plugin->env->stats,
+                                _("# HELLO beacons sent"),
+                               1, GNUNET_NO);
+  } }
+  plugin->beacon_task =
+    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+                                 (HELLO_BEACON_SCALING_FACTOR,
+                                  plugin->mac_count + 1),
+                                 &send_hello_beacon,
+                                 plugin);
+
+}
+
+
 /**
  * Function used for to process the data from the suid process
  *
  * @param cls the plugin handle
- * @param client client that send the data (not used)
  * @param hdr header of the GNUNET_MessageHeader
  */
 static int
-handle_helper_message (void *cls, void *client,
+handle_helper_message (void *cls,
                       const struct GNUNET_MessageHeader *hdr)
 {
   struct Plugin *plugin = cls;
@@ -1595,6 +1767,8 @@ handle_helper_message (void *cls, void *client,
   struct WlanAddress wa;
   struct MacAndSession mas;
   uint16_t msize;
+  struct FragmentMessage *fm;
+  struct MacEndpoint *endpoint;
 
   msize = ntohs (hdr->size);
   switch (ntohs (hdr->type))
@@ -1624,9 +1798,38 @@ handle_helper_message (void *cls, void *client,
                                    GNUNET_NO,
                                    my_address);
       GNUNET_HELLO_address_free (my_address);
+      plugin->mac_address = cm->mac;
+    }
+    else
+    {
+      plugin->mac_address = cm->mac;
+      plugin->have_mac = GNUNET_YES;
+      for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
+      {
+        for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next)
+        {
+          if (NULL != fm->fragcontext)
+          {
+            GNUNET_break (0); /* should not happen */
+            continue;
+          }
+          fm->fragcontext =
+            GNUNET_FRAGMENT_context_create (plugin->env->stats,
+                                            WLAN_MTU,
+                                            &plugin->tracker,
+                                            fm->macendpoint->msg_delay,
+                                            fm->macendpoint->ack_delay,
+                                            fm->msg,
+                                            &transmit_fragment, fm);
+          GNUNET_free (fm->msg);
+          fm->msg = NULL;
+        }
+      }
+      GNUNET_break (NULL == plugin->beacon_task);
+      plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
+                                                      plugin);
+
     }
-    plugin->mac_address = cm->mac;
-    plugin->have_mac = GNUNET_YES;
 
     memset (&wa, 0, sizeof (struct WlanAddress));
     wa.mac = plugin->mac_address;
@@ -1650,14 +1853,13 @@ handle_helper_message (void *cls, void *client,
         "Got data message from helper with %u bytes\n",
         msize);
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              _("# DATA messages received via WLAN"), 1,
+                              _("# DATA messages received"), 1,
                               GNUNET_NO);
     if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
     {
-      GNUNET_break (0);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "Size of packet is too small (%u bytes)\n",
-          msize);
+          "Size of packet is too small (%u bytes < %u)\n",
+          msize,  sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage));
       break;
     }
     rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
@@ -1685,12 +1887,20 @@ handle_helper_message (void *cls, void *client,
     }
 
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             _("# WLAN DATA messages processed"),
+                             _("# DATA messages processed"),
                              1, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Receiving %u bytes of data from MAC `%s'\n",
         (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
         mac_to_string (&rxinfo->frame.addr2));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Receiving %u bytes of data to MAC `%s'\n",
+        (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
+        mac_to_string (&rxinfo->frame.addr1));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Receiving %u bytes of data with BSSID MAC `%s'\n",
+        (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
+        mac_to_string (&rxinfo->frame.addr3));
     wa.mac = rxinfo->frame.addr2;
     wa.options = htonl (0);
     mas.endpoint = create_macendpoint (plugin, &wa);
@@ -1703,64 +1913,16 @@ handle_helper_message (void *cls, void *client,
     break;
   default:
     GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
+    LOG (GNUNET_ERROR_TYPE_ERROR,
         "Unexpected message of type %u (%u bytes)",
-        ntohs (hdr->type), ntohs (hdr->size));
+        ntohs (hdr->type),
+        ntohs (hdr->size));
     break;
   }
   return GNUNET_OK;
 }
 
 
-/**
- * Task to (periodically) send a HELLO beacon
- *
- * @param cls pointer to the plugin struct
- * @param tc scheduler context
- */
-static void
-send_hello_beacon (void *cls,
-                  const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  struct Plugin *plugin = cls;
-  uint16_t size;
-  uint16_t hello_size;
-  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
-  const struct GNUNET_MessageHeader *hello;
-
-  hello = plugin->env->get_our_hello ();
-  hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
-  GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
-  size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
-  {
-    char buf[size] GNUNET_ALIGN;
-
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Sending %u byte HELLO beacon\n",
-        (unsigned int) size);
-    radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
-    get_radiotap_header (NULL, radioHeader, size);
-    get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
-    memcpy (&radioHeader[1], hello, hello_size);
-    if (NULL !=
-       GNUNET_HELPER_send (plugin->suid_helper,
-                           &radioHeader->header,
-                           GNUNET_YES /* can drop */,
-                           NULL, NULL))
-      GNUNET_STATISTICS_update (plugin->env->stats,
-                                _("# HELLO beacons sent via WLAN"),
-                               1, GNUNET_NO);
-  }
-  plugin->beacon_task =
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                 (HELLO_BEACON_SCALING_FACTOR,
-                                  plugin->mac_count + 1),
-                                 &send_hello_beacon,
-                                 plugin);
-
-}
-
-
 /**
  * Another peer has suggested an address for this
  * peer and transport plugin.  Check that this could be a valid
@@ -1850,7 +2012,7 @@ wlan_plugin_address_pretty_printer (void *cls,
  * @param cls pointer to the api struct
  */
 void *
-libgnunet_plugin_transport_wlan_done (void *cls)
+LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
 {
   struct WlanAddress wa;
   struct GNUNET_HELLO_Address *address;
@@ -1864,7 +2026,6 @@ libgnunet_plugin_transport_wlan_done (void *cls)
     GNUNET_free (api);
     return NULL;
   }
-
   if (GNUNET_YES == plugin->have_mac)
   {
     memset (&wa, 0, sizeof(wa));
@@ -1882,10 +2043,10 @@ libgnunet_plugin_transport_wlan_done (void *cls)
     GNUNET_HELLO_address_free (address);
   }
 
-  if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task)
+  if (NULL != plugin->beacon_task)
   {
     GNUNET_SCHEDULER_cancel (plugin->beacon_task);
-    plugin->beacon_task = GNUNET_SCHEDULER_NO_TASK;
+    plugin->beacon_task = NULL;
   }
   if (NULL != plugin->suid_helper)
   {
@@ -1914,7 +2075,7 @@ libgnunet_plugin_transport_wlan_done (void *cls)
     GNUNET_SERVER_mst_destroy (plugin->helper_payload_tokenizer);
     plugin->helper_payload_tokenizer = NULL;
   }
-  GNUNET_free_non_null (plugin->interface);
+  GNUNET_free_non_null (plugin->wlan_interface);
   GNUNET_free (plugin);
   GNUNET_free (api);
   return NULL;
@@ -2000,7 +2161,7 @@ wlan_plugin_setup_monitor (void *cls,
 {
   struct Plugin *plugin = cls;
   struct MacEndpoint *mac;
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   plugin->sic = sic;
   plugin->sic_cls = sic_cls;
@@ -2008,9 +2169,14 @@ wlan_plugin_setup_monitor (void *cls,
   {
     for (mac = plugin->mac_head; NULL != mac; mac = mac->next)
       for (session = mac->sessions_head; NULL != session; session = session->next)
+      {
+        notify_session_monitor (plugin,
+                                session,
+                                GNUNET_TRANSPORT_SS_INIT);
         notify_session_monitor (plugin,
                                 session,
                                 GNUNET_TRANSPORT_SS_UP);
+      }
     sic (sic_cls, NULL, NULL);
   }
 }
@@ -2029,9 +2195,9 @@ wlan_plugin_setup_monitor (void *cls,
 static void
 wlan_plugin_update_session_timeout (void *cls,
                                     const struct GNUNET_PeerIdentity *peer,
-                                    struct Session *session)
+                                    struct GNUNET_ATS_Session *session)
 {
-  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != session->timeout_task);
+  GNUNET_assert (NULL != session->timeout_task);
   session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
 }
 
@@ -2049,7 +2215,7 @@ wlan_plugin_update_session_timeout (void *cls,
 static void
 wlan_plugin_update_inbound_delay (void *cls,
                                   const struct GNUNET_PeerIdentity *peer,
-                                  struct Session *session,
+                                  struct GNUNET_ATS_Session *session,
                                   struct GNUNET_TIME_Relative delay)
 {
   /* does nothing, as inbound delay is not supported by WLAN */
@@ -2063,12 +2229,12 @@ wlan_plugin_update_inbound_delay (void *cls,
  * @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error
  */
 void *
-libgnunet_plugin_transport_wlan_init (void *cls)
+LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
 {
   struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
   struct GNUNET_TRANSPORT_PluginFunctions *api;
   struct Plugin *plugin;
-  char *interface;
+  char *wlan_interface;
   unsigned long long testmode;
   char *binary;
 
@@ -2088,57 +2254,66 @@ libgnunet_plugin_transport_wlan_init (void *cls)
   testmode = 0;
   /* check configuration */
   if ( (GNUNET_YES ==
-       GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) &&
+       GNUNET_CONFIGURATION_have_value (env->cfg,
+                                         CONFIG_NAME,
+                                         "TESTMODE")) &&
        ( (GNUNET_SYSERR ==
-         GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
-                                                "TESTMODE", &testmode)) ||
+         GNUNET_CONFIGURATION_get_value_number (env->cfg,
+                                                 CONFIG_NAME,
+                                                "TESTMODE",
+                                                 &testmode)) ||
         (testmode > 2) ) )
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "transport-wlan", "TESTMODE");
+                              CONFIG_NAME,
+                               "TESTMODE");
     return NULL;
   }
-  binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-transport-wlan");
+  binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME);
   if ( (0 == testmode) &&
        (GNUNET_YES !=
-        GNUNET_OS_check_helper_binary (binary, GNUNET_YES, NULL)) )
+        GNUNET_OS_check_helper_binary (binary,
+                                       GNUNET_YES,
+                                       NULL)) )
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
         _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
-        "gnunet-helper-transport-wlan");
+        HELPER_NAME);
     GNUNET_free (binary);
     return NULL;
   }
     GNUNET_free (binary);
   if (GNUNET_YES !=
       GNUNET_CONFIGURATION_get_value_string (env->cfg,
-                                             "transport-wlan",
+                                             CONFIG_NAME,
                                              "INTERFACE",
-                                             &interface))
+                                             &wlan_interface))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "transport-wlan", "INTERFACE");
+                              CONFIG_NAME,
+                               "INTERFACE");
     return NULL;
   }
 
   plugin = GNUNET_new (struct Plugin);
-  plugin->interface = interface;
+  plugin->wlan_interface = wlan_interface;
   plugin->env = env;
   GNUNET_STATISTICS_set (plugin->env->stats,
-                         _("# WLAN sessions allocated"),
+                         _("# sessions allocated"),
                          0, GNUNET_NO);
   GNUNET_STATISTICS_set (plugin->env->stats,
-                         _("# WLAN MAC endpoints allocated"),
+                         _("# MAC endpoints allocated"),
                          0, 0);
   GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
                                  GNUNET_BANDWIDTH_value_init (100 * 1024 *
                                                               1024 / 8),
                                  100);
-  plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
-  plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
-  plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
-  plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
-                                                 plugin);
+  plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data,
+                                                              plugin);
+  plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data,
+                                                                    plugin);
+  plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data,
+                                                               plugin);
 
   plugin->options = 0;
 
@@ -2146,33 +2321,33 @@ libgnunet_plugin_transport_wlan_init (void *cls)
   switch ((unsigned int) testmode)
   {
   case 0: /* normal */
-    plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan";
-    plugin->helper_argv[1] = interface;
+    plugin->helper_argv[0] = (char *) HELPER_NAME;
+    plugin->helper_argv[1] = wlan_interface;
     plugin->helper_argv[2] = NULL;
     plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
-                                              "gnunet-helper-transport-wlan",
+                                              HELPER_NAME,
                                               plugin->helper_argv,
                                               &handle_helper_message,
                                               NULL,
                                               plugin);
     break;
   case 1: /* testmode, peer 1 */
-    plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+    plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
     plugin->helper_argv[1] = (char *) "1";
     plugin->helper_argv[2] = NULL;
     plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
-                                              "gnunet-helper-transport-wlan-dummy",
+                                              DUMMY_HELPER_NAME,
                                               plugin->helper_argv,
                                               &handle_helper_message,
                                               NULL,
                                               plugin);
     break;
   case 2: /* testmode, peer 2 */
-    plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+    plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
     plugin->helper_argv[1] = (char *) "2";
     plugin->helper_argv[2] = NULL;
     plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
-                                              "gnunet-helper-transport-wlan-dummy",
+                                              DUMMY_HELPER_NAME,
                                               plugin->helper_argv,
                                               &handle_helper_message,
                                               NULL,
@@ -2194,6 +2369,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
   api->address_to_string = &wlan_plugin_address_to_string;
   api->string_to_address = &wlan_plugin_string_to_address;
   api->get_network = &wlan_plugin_get_network;
+  api->get_network_for_address = &wlan_plugin_get_network_for_address;
   api->update_session_timeout = &wlan_plugin_update_session_timeout;
   api->update_inbound_delay = &wlan_plugin_update_inbound_delay;
   api->setup_monitor = &wlan_plugin_setup_monitor;