Check that you are not present in trail twice
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.c
index 5aaa66c1e9e03bfb469f804e687788ab6bc19c2a..0d72c1e0f3fad7147ace95c1eb73b1428470b979 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet
-  (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
+  (C) 2010-2014 Christian Grothoff (and other contributing authors)
 
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
 
 /**
  * @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"
 
+#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__)
 
-#define PLUGIN_NAME "wlan"
+/**
+ * time out of a mac endpoint
+ */
+#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
 
 /**
- * Max size of packet (that we give to the WLAN driver for transmission)
+ * 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 WLAN_MTU 1430
+#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, 2)
+#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, 2)
+#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
+
+/**
+ * Max size of packet (that we give to the WLAN driver for transmission)
+ */
+#define WLAN_MTU 1430
+
+
 
 /**
  * Maximum number of messages in defragmentation queue per MAC
@@ -187,7 +228,7 @@ struct Session
 
   /**
    * We keep all sessions in a DLL at their respective
-   * 'struct MACEndpoint'.
+   * `struct MACEndpoint *`.
    */
   struct Session *prev;
 
@@ -201,16 +242,6 @@ struct Session
    */
   struct GNUNET_HELLO_Address *address;
 
-  /**
-   * Head of messages currently pending for transmission to this peer.
-   */
-  struct PendingMessage *pending_message_head;
-
-  /**
-   * Tail of messages currently pending for transmission to this peer.
-   */
-  struct PendingMessage *pending_message_tail;
-
   /**
    * When should this session time out?
    */
@@ -221,16 +252,6 @@ struct Session
    */
   GNUNET_SCHEDULER_TaskIdentifier timeout_task;
 
-  /**
-   * Number of bytes waiting for transmission to this peer.
-   */
-  unsigned long long bytes_in_queue;
-
-  /**
-   * Number of messages waiting for transmission to this peer.
-   */
-  unsigned int msgs_in_queue;
-
 };
 
 
@@ -432,10 +453,11 @@ 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 defragmentation.
+   * Tokenizer for demultiplexing of data packets resulting from
+   * defragmentation.
    */
   struct GNUNET_SERVER_MessageStreamTokenizer *fragment_data_tokenizer;
 
@@ -515,7 +537,9 @@ struct MacAndSession
  * Print MAC addresses nicely.
  *
  * @param mac the mac address
- * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function
+ * @return string to a static buffer with
+ * the human-readable mac, will be overwritten during the next call to
+ * this function
  */
 static const char *
 mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac)
@@ -587,11 +611,11 @@ notify_session_monitor (struct Plugin *plugin,
   memset (&info, 0, sizeof (info));
   info.state = state;
   info.is_inbound = GNUNET_SYSERR; /* hard to say */
-  // info.num_msg_pending = session->msgs_in_queue; // FIXME
-  // info.num_bytes_pending = session->bytes_in_queue; // FIXME
-  info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS;
+  info.num_msg_pending = 0; /* we queue per MAC, not per peer */
+  info.num_bytes_pending = 0; /* we queue per MAC, not per peer */
+  info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */
   info.session_timeout = session->timeout;
-  info.address = session->address; // ?
+  info.address = session->address;
   plugin->sic (plugin->sic_cls,
                session,
                &info);
@@ -678,7 +702,6 @@ send_ack (void *cls, uint32_t msg_id,
     GNUNET_break (0);
     return;
   }
-
   if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
   {
     GNUNET_break (0);
@@ -699,7 +722,7 @@ send_ack (void *cls, uint32_t msg_id,
                          GNUNET_NO /* dropping ACKs is bad */,
                          NULL, NULL))
     GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                              _("# WLAN ACKs sent"),
+                              _("# ACKs sent"),
                              1, GNUNET_NO);
 }
 
@@ -719,7 +742,8 @@ wlan_data_message_handler (void *cls,
   struct MacAndSession mas;
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           _("# WLAN messages defragmented"), 1,
+                           _("# Messages defragmented"),
+                            1,
                            GNUNET_NO);
   mas.session = NULL;
   mas.endpoint = endpoint;
@@ -742,24 +766,14 @@ wlan_plugin_disconnect_session (void *cls,
                                 struct Session *session)
 {
   struct MacEndpoint *endpoint = session->mac;
-  struct PendingMessage *pm;
+  struct Plugin *plugin = endpoint->plugin;
 
-  endpoint->plugin->env->session_end (endpoint->plugin->env->cls,
-                                     session->address,
-                                     session);
-  while (NULL != (pm = session->pending_message_head))
-  {
-    GNUNET_CONTAINER_DLL_remove (session->pending_message_head,
-                                 session->pending_message_tail,
-                                 pm);
-    if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task)
-    {
-      GNUNET_SCHEDULER_cancel (pm->timeout_task);
-      pm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
-    }
-    GNUNET_free (pm->msg);
-    GNUNET_free (pm);
-  }
+  plugin->env->session_end (plugin->env->cls,
+                            session->address,
+                            session);
+  notify_session_monitor (plugin,
+                          session,
+                          GNUNET_TRANSPORT_SS_DOWN);
   GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
                               endpoint->sessions_tail,
                                session);
@@ -768,8 +782,9 @@ wlan_plugin_disconnect_session (void *cls,
     GNUNET_SCHEDULER_cancel (session->timeout_task);
     session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                            _("# WLAN sessions allocated"), -1,
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            _("# Sessions allocated"),
+                            -1,
                             GNUNET_NO);
   GNUNET_HELLO_address_free (session->address);
   GNUNET_free (session);
@@ -796,7 +811,7 @@ 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
+ * @param tc unused
  */
 static void
 session_timeout (void *cls,
@@ -855,7 +870,7 @@ create_session (struct MacEndpoint *endpoint,
   struct Session *session;
 
   GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
-                            _("# WLAN sessions allocated"),
+                            _("# Sessions allocated"),
                             1,
                             GNUNET_NO);
   session = GNUNET_new (struct Session);
@@ -873,6 +888,9 @@ create_session (struct MacEndpoint *endpoint,
   session->timeout_task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout,
                                     session);
+  notify_session_monitor (endpoint->plugin,
+                          session,
+                          GNUNET_TRANSPORT_SS_UP);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Created new session %p for peer `%s' with endpoint %s\n",
        session,
@@ -908,7 +926,8 @@ get_session (struct MacEndpoint *endpoint,
  * the next fragment.
  *
  * @param cls the `struct FragmentMessage *`
- * @param result result of the operation (#GNUNET_OK on success, #GNUNET_NO if the helper died, #GNUNET_SYSERR
+ * @param result result of the operation (#GNUNET_OK on success,
+ *        #GNUNET_NO if the helper died, #GNUNET_SYSERR
  *        if the helper was stopped)
  */
 static void
@@ -940,10 +959,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;
   {
@@ -964,15 +982,17 @@ 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"),
-                               1, GNUNET_NO);
+      GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
+                                _("# 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);
   }
 }
@@ -988,10 +1008,12 @@ free_fragment_message (struct FragmentMessage *fm)
 {
   struct MacEndpoint *endpoint = fm->macendpoint;
 
-  GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"),
+  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
+                            _("# messages pending (with fragmentation)"),
                            -1, GNUNET_NO);
   GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
-                               endpoint->sending_messages_tail, fm);
+                               endpoint->sending_messages_tail,
+                               fm);
   if (NULL != fm->sh)
   {
     GNUNET_HELPER_send_cancel (fm->sh);
@@ -1013,7 +1035,7 @@ free_fragment_message (struct FragmentMessage *fm)
  * A FragmentMessage has timed out.  Remove it.
  *
  * @param cls pointer to the 'struct FragmentMessage'
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
+ * @param tc unused
  */
 static void
 fragmentmessage_timeout (void *cls,
@@ -1067,13 +1089,13 @@ 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,
+    GNUNET_FRAGMENT_context_create (plugin->env->stats,
+                                    WLAN_MTU,
                                    &plugin->tracker,
                                    endpoint->msg_delay,
                                    endpoint->ack_delay,
@@ -1101,7 +1123,7 @@ free_macendpoint (struct MacEndpoint *endpoint)
   struct Session *session;
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                           _("# WLAN MAC endpoints allocated"),
+                           _("# MAC endpoints allocated"),
                             -1,
                             GNUNET_NO);
   while (NULL != (session = endpoint->sessions_head))
@@ -1132,7 +1154,7 @@ free_macendpoint (struct MacEndpoint *endpoint)
 /**
  * A MAC endpoint is timing out.  Clean up.
  *
- * @param cls pointer to the `struct MacEndpoint`
+ * @param cls pointer to the `struct MacEndpoint *`
  * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
  */
 static void
@@ -1170,21 +1192,14 @@ 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;
   pos->defrag =
-    GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
+    GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
+                                      WLAN_MTU,
                                      MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
                                      pos,
                                      &wlan_data_message_handler,
@@ -1196,9 +1211,12 @@ create_macendpoint (struct Plugin *plugin,
   pos->timeout_task =
       GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
                                     pos);
-  GNUNET_CONTAINER_DLL_insert (plugin->mac_head, plugin->mac_tail, pos);
+  GNUNET_CONTAINER_DLL_insert (plugin->mac_head,
+                               plugin->mac_tail,
+                               pos);
   plugin->mac_count++;
-  GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
+  GNUNET_STATISTICS_update (plugin->env->stats,
+                            _("# MAC endpoints allocated"),
                            1, GNUNET_NO);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "New MAC endpoint `%s'\n",
@@ -1220,7 +1238,11 @@ static enum GNUNET_ATS_Network_Type
 wlan_plugin_get_network (void *cls,
                          struct Session *session)
 {
+#if BUILD_WLAN
   return GNUNET_ATS_NET_WLAN;
+#else
+  return GNUNET_ATS_NET_BT;
+#endif
 }
 
 
@@ -1252,7 +1274,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);
 }
 
@@ -1339,8 +1362,9 @@ wlan_plugin_send (void *cls,
   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,
@@ -1377,11 +1401,15 @@ process_data (void *cls,
   uint16_t msize;
 
   ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
+#if BUILD_WLAN
   ats.value = htonl (GNUNET_ATS_NET_WLAN);
+#else
+  ats.value = htonl (GNUNET_ATS_NET_BT);
+#endif
   msize = ntohs (hdr->size);
 
   GNUNET_STATISTICS_update (plugin->env->stats,
-                            "# bytes received via WLAN",
+                            "# bytes received",
                             msize, GNUNET_NO);
 
   switch (ntohs (hdr->type))
@@ -1389,7 +1417,8 @@ process_data (void *cls,
   case GNUNET_MESSAGE_TYPE_HELLO:
 
     if (GNUNET_OK !=
-       GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
+       GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
+                             &tmpsource))
     {
       GNUNET_break_op (0);
       break;
@@ -1409,16 +1438,21 @@ 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);
+    address = GNUNET_HELLO_address_allocate (&tmpsource,
+                                             PLUGIN_NAME,
+                                             &mas->endpoint->wlan_addr,
+                                             sizeof (mas->endpoint->wlan_addr),
+                                             GNUNET_HELLO_ADDRESS_INFO_INBOUND);
     plugin->env->receive (plugin->env->cls,
-        address, mas->session, hdr);
+                          address,
+                          mas->session,
+                          hdr);
     plugin->env->update_address_metrics (plugin->env->cls,
-        address, mas->session, &ats, 1);
+                                         address,
+                                         mas->session,
+                                         &ats, 1);
     GNUNET_HELLO_address_free (address);
     break;
   case GNUNET_MESSAGE_TYPE_FRAGMENT:
@@ -1434,7 +1468,9 @@ process_data (void *cls,
                                         &mas->endpoint->wlan_addr,
                                         sizeof (mas->endpoint->wlan_addr)));
     GNUNET_STATISTICS_update (plugin->env->stats,
-                              _("# fragments received via WLAN"), 1, GNUNET_NO);
+                              _("# fragments received"),
+                              1,
+                              GNUNET_NO);
     (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
                                              hdr);
     break;
@@ -1444,7 +1480,8 @@ process_data (void *cls,
       GNUNET_break (0);
       break;
     }
-    GNUNET_STATISTICS_update (plugin->env->stats, _("# ACKs received via WLAN"),
+    GNUNET_STATISTICS_update (plugin->env->stats,
+                              _("# ACKs received"),
                              1, GNUNET_NO);
     for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
     {
@@ -1460,7 +1497,11 @@ process_data (void *cls,
        mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
        if (NULL != fm->cont)
        {
-         fm->cont (fm->cont_cls, &fm->target, GNUNET_OK, fm->size_payload, fm->size_on_wire);
+         fm->cont (fm->cont_cls,
+                    &fm->target,
+                    GNUNET_OK,
+                    fm->size_payload,
+                    fm->size_on_wire);
          fm->cont = NULL;
        }
         free_fragment_message (fm);
@@ -1499,15 +1540,17 @@ 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;
     }
     if (ntohl (wlanheader->crc) !=
-       GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
+       GNUNET_CRYPTO_crc32_n (&wlanheader[1],
+                               msize - sizeof (struct WlanHeader)))
     {
       GNUNET_STATISTICS_update (plugin->env->stats,
-                               _("# WLAN DATA messages discarded due to CRC32 error"), 1,
+                               _("# DATA messages discarded due to CRC32 error"),
+                                1,
                                GNUNET_NO);
       break;
     }
@@ -1515,20 +1558,25 @@ process_data (void *cls,
     if (NULL == (xmas.session = lookup_session (mas->endpoint,
                                                 &wlanheader->sender)))
     {
-      xmas.session = create_session (mas->endpoint, &wlanheader->sender);
+      xmas.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, address, xmas.session, NULL, 0);
+      plugin->env->session_start (NULL,
+                                  address,
+                                  xmas.session,
+                                  NULL, 0);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
           "Notifying transport about peer `%s''s new session %p \n",
-           GNUNET_i2s (&wlanheader->sender), xmas.session);
+           GNUNET_i2s (&wlanheader->sender),
+           xmas.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);
@@ -1556,13 +1604,13 @@ process_data (void *cls,
         (unsigned int) ntohs (hdr->type),
         GNUNET_i2s (&mas->session->target));
     plugin->env->receive (plugin->env->cls,
-        mas->session->address,
-        mas->session,
-        hdr);
+                          mas->session->address,
+                          mas->session,
+                          hdr);
     plugin->env->update_address_metrics (plugin->env->cls,
-        mas->session->address,
-        mas->session,
-        &ats, 1);
+                                         mas->session->address,
+                                         mas->session,
+                                         &ats, 1);
     break;
   }
   return GNUNET_OK;
@@ -1609,8 +1657,12 @@ handle_helper_message (void *cls, void *client,
       wa.mac = plugin->mac_address;
       wa.options = htonl(plugin->options);
       my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
-          PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE);
-      plugin->env->notify_address (plugin->env->cls, GNUNET_NO, my_address);
+                                                  PLUGIN_NAME,
+                                                  &wa, sizeof (wa),
+                                                  GNUNET_HELLO_ADDRESS_INFO_NONE);
+      plugin->env->notify_address (plugin->env->cls,
+                                   GNUNET_NO,
+                                   my_address);
       GNUNET_HELLO_address_free (my_address);
     }
     plugin->mac_address = cm->mac;
@@ -1620,13 +1672,17 @@ handle_helper_message (void *cls, void *client,
     wa.mac = plugin->mac_address;
     wa.options = htonl(plugin->options);
     my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
-        PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE);
+                                                PLUGIN_NAME,
+                                                &wa, sizeof (wa),
+                                                GNUNET_HELLO_ADDRESS_INFO_NONE);
 
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
         mac_to_string (&cm->mac),
         GNUNET_i2s (plugin->env->my_identity));
-    plugin->env->notify_address (plugin->env->cls, GNUNET_YES, my_address);
+    plugin->env->notify_address (plugin->env->cls,
+                                 GNUNET_YES,
+                                 my_address);
     GNUNET_HELLO_address_free (my_address);
     break;
   case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
@@ -1634,7 +1690,7 @@ 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))
     {
@@ -1669,7 +1725,7 @@ 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",
@@ -1696,7 +1752,6 @@ handle_helper_message (void *cls, void *client,
 }
 
 
-
 /**
  * Task to (periodically) send a HELLO beacon
  *
@@ -1732,7 +1787,8 @@ send_hello_beacon (void *cls,
                            &radioHeader->header,
                            GNUNET_YES /* can drop */,
                            NULL, NULL))
-      GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent via WLAN"),
+      GNUNET_STATISTICS_update (plugin->env->stats,
+                                _("# HELLO beacons sent"),
                                1, GNUNET_NO);
   }
   plugin->beacon_task =
@@ -1834,7 +1890,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;
@@ -1848,19 +1904,20 @@ libgnunet_plugin_transport_wlan_done (void *cls)
     GNUNET_free (api);
     return NULL;
   }
-
   if (GNUNET_YES == plugin->have_mac)
   {
     memset (&wa, 0, sizeof(wa));
     wa.options = htonl (plugin->options);
     wa.mac = plugin->mac_address;
     address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
-        PLUGIN_NAME, &wa, sizeof (struct WlanAddress),
-        GNUNET_HELLO_ADDRESS_INFO_NONE);
+                                             PLUGIN_NAME,
+                                             &wa, sizeof (struct WlanAddress),
+                                             GNUNET_HELLO_ADDRESS_INFO_NONE);
 
-    plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address);
+    plugin->env->notify_address (plugin->env->cls,
+                                 GNUNET_NO,
+                                 address);
     plugin->have_mac = GNUNET_NO;
-
     GNUNET_HELLO_address_free (address);
   }
 
@@ -1871,7 +1928,8 @@ libgnunet_plugin_transport_wlan_done (void *cls)
   }
   if (NULL != plugin->suid_helper)
   {
-    GNUNET_HELPER_stop (plugin->suid_helper, GNUNET_NO);
+    GNUNET_HELPER_stop (plugin->suid_helper,
+                        GNUNET_NO);
     plugin->suid_helper = NULL;
   }
   endpoint_next = plugin->mac_head;
@@ -1895,7 +1953,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;
@@ -1927,7 +1985,7 @@ wlan_plugin_string_to_address (void *cls,
   char plugin[5];
   uint32_t options;
 
-  if ((NULL == addr) || (addrlen == 0))
+  if ((NULL == addr) || (0 == addrlen))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1946,7 +2004,8 @@ wlan_plugin_string_to_address (void *cls,
   if (8 != SSCANF (addr,
                   "%4s.%u.%X:%X:%X:%X:%X:%X",
                   plugin, &options,
-                  &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
+                  &a[0], &a[1], &a[2],
+                   &a[3], &a[4], &a[5]))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -2011,7 +2070,7 @@ wlan_plugin_update_session_timeout (void *cls,
                                     const struct GNUNET_PeerIdentity *peer,
                                     struct Session *session)
 {
-  GNUNET_assert (session->timeout_task != GNUNET_SCHEDULER_NO_TASK);
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != session->timeout_task);
   session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
 }
 
@@ -2043,12 +2102,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;
 
@@ -2068,47 +2127,55 @@ 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 *
@@ -2126,33 +2193,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,