- correct port
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.c
index f2b38b0e85581da0ee5408fb17fa923e0fe72c77..4510ae12c754879509cd7ac92355da536b5c9283 100644 (file)
 #define IEEE80211_FC0_TYPE_CTL                  0x04
 #define IEEE80211_FC0_TYPE_DATA                 0x08
 
-/*
- * Structure of an internet header, naked of options.
- */
-struct iph
-{
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-  unsigned int ip_hl:4;         /* header length */
-  unsigned int ip_v:4;          /* version */
-#endif
-#if __BYTE_ORDER == __BIG_ENDIAN
-  unsigned int ip_v:4;          /* version */
-  unsigned int ip_hl:4;         /* header length */
-#endif
-  u_int8_t ip_tos;              /* type of service */
-  u_short ip_len;               /* total length */
-  u_short ip_id;                /* identification */
-  u_short ip_off;               /* fragment offset field */
-#define IP_RF 0x8000            /* reserved fragment flag */
-#define IP_DF 0x4000            /* dont fragment flag */
-#define IP_MF 0x2000            /* more fragments flag */
-#define IP_OFFMASK 0x1fff       /* mask for fragmenting bits */
-  u_int8_t ip_ttl;              /* time to live */
-  u_int8_t ip_p;                /* protocol */
-  u_short ip_sum;               /* checksum */
-  struct in_addr ip_src, ip_dst;        /* source and dest address */
-};
-
-struct udphdr
-{
-  u_int16_t source;
-  u_int16_t dest;
-  u_int16_t len;
-  u_int16_t check;
-};
+GNUNET_NETWORK_STRUCT_BEGIN
 
 /*
  * generic definitions for IEEE 802.11 frames
@@ -167,11 +134,8 @@ struct ieee80211_frame
   u_int8_t i_addr3[IEEE80211_ADDR_LEN];
   u_int8_t i_seq[2];
   u_int8_t llc[4];
-#if DEBUG_wlan_ip_udp_packets_on_air > 1
-  struct iph ip;
-  struct udphdr udp;
-#endif
 } GNUNET_PACKED;
+GNUNET_NETWORK_STRUCT_END
 
 /**
  * Encapsulation of all of the state of the plugin.
@@ -209,22 +173,22 @@ struct Plugin
   struct GNUNET_SERVER_MessageStreamTokenizer *data_tokenizer;
 
   /**
-   * stdout pipe handle for the gnunet-wlan-helper process
+   * stdout pipe handle for the gnunet-helper-transport-wlan process
    */
   struct GNUNET_DISK_PipeHandle *server_stdout;
 
   /**
-   * stdout file handle for the gnunet-wlan-helper process
+   * stdout file handle for the gnunet-helper-transport-wlan process
    */
   const struct GNUNET_DISK_FileHandle *server_stdout_handle;
 
   /**
-   * stdin pipe handle for the gnunet-wlan-helper process
+   * stdin pipe handle for the gnunet-helper-transport-wlan process
    */
   struct GNUNET_DISK_PipeHandle *server_stdin;
 
   /**
-   * stdin file handle for the gnunet-wlan-helper process
+   * stdin file handle for the gnunet-helper-transport-wlan process
    */
   const struct GNUNET_DISK_FileHandle *server_stdin_handle;
 
@@ -354,6 +318,9 @@ struct Sessionqueue
   struct Sessionqueue *next;
   struct Sessionqueue *prev;
   struct Session *content;
+#if !HAVE_UNALIGNED_64_ACCESS
+  void *dummy;                  /* for alignment, see #1909 */
+#endif
 };
 
 /**
@@ -396,6 +363,38 @@ struct Plugin_Session_pair
   struct Session *session;
 };
 
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Header for messages which need fragmentation
+ */
+struct WlanHeader
+{
+
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * checksum/error correction
+   */
+  uint32_t crc GNUNET_PACKED;
+
+  /**
+   * To whom are we talking to (set to our identity
+   * if we are still waiting for the welcome message)
+   */
+  struct GNUNET_PeerIdentity target;
+
+  /**
+   *  Where the packet came from
+   */
+  struct GNUNET_PeerIdentity source;
+
+// followed by payload
+
+};
+GNUNET_NETWORK_STRUCT_END
+
 /**
  * Information kept for each message that is yet to
  * be transmitted.
@@ -740,7 +739,7 @@ hexdump (const void *mem, unsigned length)
       else
         t += sprintf (t, "  ");
 
-      t += sprintf (t, j % 2 ? " " : "-");
+      t += sprintf (t, (j % 2) ? " " : "-");
     }
 
     t += sprintf (t, "  ");
@@ -1063,8 +1062,9 @@ set_next_send (struct Plugin *const plugin)
   struct GNUNET_TIME_Relative next_send;
 
   //abort if helper is not running
-  if (plugin->helper_is_running == GNUNET_NO){
-      return;
+  if (plugin->helper_is_running == GNUNET_NO)
+  {
+    return;
   }
 
   //cancel old task
@@ -1310,46 +1310,16 @@ getWlanHeader (struct ieee80211_frame *Header,
 
   Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA;
   Header->i_fc[1] = 0x00;
-  memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid));
+  memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet));
   memcpy (&Header->i_addr2, plugin->mac_address.mac,
           sizeof (plugin->mac_address));
   memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress));
 
   tmp16 = (uint16_t *) Header->i_dur;
-  *tmp16 = (uint16_t) htole16 ((size * 1000000) / rate + 290);
+  *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
   Header->llc[0] = WLAN_LLC_DSAP_FIELD;
   Header->llc[1] = WLAN_LLC_SSAP_FIELD;
 
-#if DEBUG_wlan_ip_udp_packets_on_air > 1
-  uint crc = 0;
-  uint16_t *x;
-  int count;
-
-  Header->ip.ip_dst.s_addr = *((uint32_t *) & to_mac_addr->mac[2]);
-  Header->ip.ip_src.s_addr = *((uint32_t *) & plugin->mac_address.mac[2]);
-  Header->ip.ip_v = 4;
-  Header->ip.ip_hl = 5;
-  Header->ip.ip_p = 17;
-  Header->ip.ip_ttl = 1;
-  Header->ip.ip_len = htons (size + 8);
-  Header->ip.ip_sum = 0;
-  x = (uint16_t *) & Header->ip;
-  count = sizeof (struct iph);
-  while (count > 1)
-  {
-    /* This is the inner loop */
-    crc += (unsigned short) *x++;
-    count -= 2;
-  }
-  /* Add left-over byte, if any */
-  if (count > 0)
-    crc += *(unsigned char *) x;
-  crc = (crc & 0xffff) + (crc >> 16);
-  Header->ip.ip_sum = htons (~(unsigned short) crc);
-  Header->udp.len = htons (size - sizeof (struct ieee80211_frame));
-
-#endif
-
   return GNUNET_YES;
 }
 
@@ -1405,7 +1375,7 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
 
 
 /**
- * We have been notified that wlan-helper has written something to stdout.
+ * We have been notified that gnunet-helper-transport-wlan has written something to stdout.
  * Handle the output, then reschedule this function to be called again once
  * more is available.
  *
@@ -1434,7 +1404,7 @@ wlan_plugin_helper_read (void *cls,
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
                      _
-                     ("Finished reading from wlan-helper stdout with code: %d\n"),
+                     ("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"),
                      bytes);
 #endif
     return;
@@ -1450,7 +1420,7 @@ wlan_plugin_helper_read (void *cls,
 }
 
 /**
- * Start the gnunet-wlan-helper process.
+ * Start the gnunet-helper-transport-wlan process.
  *
  * @param plugin the transport plugin
  * @return GNUNET_YES if process was started, GNUNET_SYSERR on error
@@ -1458,23 +1428,24 @@ wlan_plugin_helper_read (void *cls,
 static int
 wlan_transport_start_wlan_helper (struct Plugin *plugin)
 {
-  const char *filenamehw = "gnunet-transport-wlan-helper";
-  const char *filenameloopback = "gnunet-transport-wlan-helper-dummy";
+  const char *filenamehw = "gnunet-helper-transport-wlan";
+  const char *filenameloopback = "gnunet-helper-transport-wlan-dummy";
   char *absolute_filename = NULL;
 
-  if (plugin->helper_is_running == GNUNET_YES){
+  if (plugin->helper_is_running == GNUNET_YES)
+  {
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
                      "wlan_transport_start_wlan_helper not needed, helper already running!");
 #endif
-      return GNUNET_YES;
+    return GNUNET_YES;
   }
 
-  plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
+  plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
   if (plugin->server_stdout == NULL)
     return GNUNET_SYSERR;
 
-  plugin->server_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
+  plugin->server_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
   if (plugin->server_stdin == NULL)
     return GNUNET_SYSERR;
 
@@ -1482,7 +1453,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
   {
     if (GNUNET_OS_check_helper_binary (filenameloopback) == GNUNET_YES)
     {
-      absolute_filename = strdup (filenameloopback);
+      absolute_filename = GNUNET_strdup (filenameloopback);
     }
     else
     {
@@ -1509,27 +1480,27 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
 
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
-                     "Starting gnunet-wlan-helper process cmd: %s %s %i\n",
+                     "Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n",
                      filenamehw, plugin->interface, plugin->testmode);
 #endif
 
     if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
     {
       plugin->server_proc =
-          GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+         GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                    filenamehw, filenamehw, plugin->interface,
                                    NULL);
     }
     else if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_NO)
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
-                       "gnunet-transport-wlan-helper is not suid, please change it or look at the doku\n");
+                       "gnunet-helper-transport-wlan is not suid, please change it or look at the doku\n");
       GNUNET_break (0);
     }
     else
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
-                       "gnunet-transport-wlan-helper not found, please look if it exists and is the $PATH variable!\n");
+                       "gnunet-helper-transport-wlan not found, please look if it exists and is the $PATH variable!\n");
       GNUNET_break (0);
     }
 
@@ -1539,11 +1510,11 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
 
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
-                     "Starting gnunet-transport-wlan-helper-dummy loopback 1 process cmd: %s %s %i\n",
+                     "Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n",
                      absolute_filename, plugin->interface, plugin->testmode);
 #endif
     plugin->server_proc =
-        GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+        GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                  absolute_filename, absolute_filename, "1",
                                  NULL);
     if (plugin->server_proc == NULL)
@@ -1558,12 +1529,12 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
   {
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
-                     "Starting gnunet-transport-wlan-helper-dummy loopback 2 process cmd: %s %s %i\n",
+                     "Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n",
                      absolute_filename, plugin->interface, plugin->testmode);
 #endif
 
     plugin->server_proc =
-        GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+        GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                  absolute_filename, absolute_filename, "2",
                                  NULL);
     if (plugin->server_proc == NULL)
@@ -1580,7 +1551,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
   {
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
-                     "Failed to start gnunet-transport-wlan-helper process\n");
+                     "Failed to start gnunet-helper-transport-wlan process\n");
 #endif
     return GNUNET_SYSERR;
   }
@@ -1605,7 +1576,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
 
 #if DEBUG_wlan
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
-                   "Adding server_read_task for the wlan-helper\n");
+                   "Adding server_read_task for the gnunet-helper-transport-wlan\n");
 #endif
 
   plugin->server_read_task =
@@ -1618,7 +1589,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
 }
 
 /**
- * Stops the gnunet-wlan-helper process.
+ * Stops the gnunet-helper-transport-wlan process.
  *
  * @param plugin the transport plugin
  * @return GNUNET_YES if process was started, GNUNET_SYSERR on error
@@ -1631,12 +1602,13 @@ wlan_transport_stop_wlan_helper (struct Plugin *plugin)
                    "Stoping WLAN helper process\n");
 #endif
 
-  if (plugin->helper_is_running == GNUNET_NO){
+  if (plugin->helper_is_running == GNUNET_NO)
+  {
 #if DEBUG_wlan
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
                      "wlan_transport_stop_wlan_helper not needed, helper already stopped!");
 #endif
-      return GNUNET_YES;
+    return GNUNET_YES;
   }
 
   if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1832,7 +1804,7 @@ send_hello_beacon (struct Plugin *plugin)
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
                      _
-                     ("Error writing to wlan healper. errno == %d, ERROR: %s\n"),
+                     ("Error writing to wlan helper. errno == %d, ERROR: %s\n"),
                      errno, strerror (errno));
     finish = GNUNET_malloc (sizeof (struct Finish_send));
     finish->plugin = plugin;
@@ -2047,7 +2019,7 @@ send_ack (struct Plugin *plugin)
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
                      _
-                     ("Error writing to wlan healper. errno == %d, ERROR: %s\n"),
+                     ("Error writing to wlan helper. errno == %d, ERROR: %s\n"),
                      errno, strerror (errno));
     finish = GNUNET_malloc (sizeof (struct Finish_send));
     finish->plugin = plugin;
@@ -2142,7 +2114,7 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       {
         GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
                          _
-                         ("Error writing to wlan healper. errno == %d, ERROR: %s\n"),
+                         ("Error writing to wlan helper. errno == %d, ERROR: %s\n"),
                          errno, strerror (errno));
 
         finish->head_of_next_write = fm->frag;
@@ -2219,37 +2191,75 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
   return GNUNET_SYSERR;
 }
 
+
+/**
+ * Creates a new outbound session the transport service will use to send data to the
+ * peer
+ *
+ * @param cls the plugin
+ * @param address the address
+ * @return the session or NULL of max connections exceeded
+ */
+
+static struct Session *
+wlan_plugin_get_session (void *cls,
+                  const struct GNUNET_HELLO_Address *address)
+{
+  struct Plugin *plugin = cls;
+  struct Session * s = NULL;
+
+  GNUNET_assert (plugin != NULL);
+  GNUNET_assert (address != NULL);
+
+  if (GNUNET_OK == wlan_plugin_address_suggested (plugin,
+            address->address,
+            address->address_length))
+  {
+    s = get_session (plugin, address->address, &address->peer);
+  }
+  else
+  {
+    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
+                     _("Wlan Address len %d is wrong\n"), address->address_length);
+    return s;
+  }
+
+  return s;
+}
+
 /**
  * Function that can be used by the transport service to transmit
- * a message using the plugin.
+ * a message using the plugin.   Note that in the case of a
+ * peer disconnecting, the continuation MUST be called
+ * prior to the disconnect notification itself.  This function
+ * will be called with this peer's HELLO message to initiate
+ * a fresh connection to another peer.
  *
  * @param cls closure
- * @param target who should receive this message
- * @param priority how important is the message
+ * @param session which session must be used
  * @param msgbuf the message to transmit
  * @param msgbuf_size number of bytes in 'msgbuf'
- * @param timeout when should we time out
- * @param session which session must be used (or NULL for "any")
- * @param addr the address to use (can be NULL if the plugin
- *                is "on its own" (i.e. re-use existing TCP connection))
- * @param addrlen length of the address in bytes
- * @param force_address GNUNET_YES if the plugin MUST use the given address,
- *                otherwise the plugin may use other addresses or
- *                existing connections (if available)
+ * @param priority how important is the message (most plugins will
+ *                 ignore message priority and just FIFO)
+ * @param to how long to wait at most for the transmission (does not
+ *                require plugins to discard the message after the timeout,
+ *                just advisory for the desired delay; most plugins will ignore
+ *                this as well)
  * @param cont continuation to call once the message has
  *        been transmitted (or if the transport is ready
  *        for the next transmission call; or if the
- *        peer disconnected...)
+ *        peer disconnected...); can be NULL
  * @param cont_cls closure for cont
  * @return number of bytes used (on the physical network, with overheads);
  *         -1 on hard errors (i.e. address invalid); 0 is a legal value
  *         and does NOT mean that the message was not transmitted (DV)
  */
 static ssize_t
-wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
-                  const char *msgbuf, size_t msgbuf_size, unsigned int priority,
-                  struct GNUNET_TIME_Relative timeout, struct Session *session,
-                  const void *addr, size_t addrlen, int force_address,
+wlan_plugin_send (void *cls,
+                  struct Session *session,
+                  const char *msgbuf, size_t msgbuf_size,
+                  unsigned int priority,
+                  struct GNUNET_TIME_Relative to,
                   GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
 {
   struct Plugin *plugin = cls;
@@ -2257,27 +2267,9 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
   struct WlanHeader *wlanheader;
 
   GNUNET_assert (plugin != NULL);
-  //check if msglen > 0
+  GNUNET_assert (session != NULL);
   GNUNET_assert (msgbuf_size > 0);
 
-  //get session if needed
-  if (session == NULL)
-  {
-    if (wlan_plugin_address_suggested (plugin, addr, addrlen) == GNUNET_OK)
-    {
-      session = get_session (plugin, addr, target);
-    }
-    else
-    {
-      GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
-                       _("Wlan Address len %d is wrong\n"), addrlen);
-      return -1;
-    }
-  }
-
-  GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1,
-                            GNUNET_NO);
-
   //queue message:
 
   //queue message in session
@@ -2299,7 +2291,7 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
   //copy msg to buffer, not fragmented / segmented yet, but with message header
   wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
   wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
-  memcpy (&(wlanheader->target), target, sizeof (struct GNUNET_PeerIdentity));
+  memcpy (&(wlanheader->target), &session->target, sizeof (struct GNUNET_PeerIdentity));
   memcpy (&(wlanheader->source), plugin->env->my_identity,
           sizeof (struct GNUNET_PeerIdentity));
   wlanheader->crc = 0;
@@ -2310,7 +2302,7 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
 
   newmsg->transmit_cont = cont;
   newmsg->transmit_cont_cls = cont_cls;
-  newmsg->timeout = GNUNET_TIME_relative_to_absolute (timeout);
+  newmsg->timeout = GNUNET_TIME_relative_to_absolute (to);
 
   newmsg->timeout.abs_value = newmsg->timeout.abs_value - 500;
 
@@ -2333,9 +2325,9 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
   check_fragment_queue (plugin);
   //FIXME not the correct size
   return msgbuf_size;
-
 }
 
+
 /**
  * function to free a mac endpoint
  * @param plugin pointer to the plugin struct
@@ -2374,7 +2366,7 @@ free_macendpoint (struct Plugin *plugin, struct MacEndpoint *endpoint)
  * function to free a session
  * @param plugin pointer to the plugin
  * @param queue pointer to the sessionqueue element to free
- * @param free_macendpoint if GNUNET_YES and mac endpoint would be empty, free mac endpoint
+ * @param do_free_macendpoint if GNUNET_YES and mac endpoint would be empty, free mac endpoint
  */
 static void
 free_session (struct Plugin *plugin, struct Sessionqueue *queue,
@@ -2601,13 +2593,15 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
     temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
     crc = ntohl (wlanheader->crc);
     wlanheader->crc = 0;
-    if (GNUNET_CRYPTO_crc32_n ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
+    if (GNUNET_CRYPTO_crc32_n
+        ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
     {
       //wrong crc, dispose message
       GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
                        "Wlan message header crc was wrong: %u != %u\n",
                        GNUNET_CRYPTO_crc32_n ((char *) wlanheader,
-                                             ntohs (wlanheader->header.size)), crc);
+                                              ntohs (wlanheader->header.size)),
+                       crc);
       hexdump ((void *) hdr, ntohs (hdr->size));
       return;
     }
@@ -2717,11 +2711,12 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
   GNUNET_assert (cls != NULL);
   struct Session *session = (struct Session *) client;
   struct Plugin *plugin = (struct Plugin *) cls;
+  struct GNUNET_ATS_Information ats[2];
 
-  struct GNUNET_ATS_Information distance;
-
-  distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
-  distance.value = htonl (1);
+  ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
+  ats[0].value = htonl (1);
+  ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+  ats[1].value = htonl (GNUNET_ATS_NET_WLAN);
 
 #if DEBUG_wlan
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
@@ -2733,7 +2728,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
 #endif
 
   plugin->env->receive (plugin->env->cls, &(session->target), hdr,
-                        (const struct GNUNET_ATS_Information *) &distance, 1,
+                        (const struct GNUNET_ATS_Information *) &ats, 2,
                         session, (const char *) &session->mac->addr,
                         sizeof (session->mac->addr));
 }
@@ -3086,7 +3081,7 @@ wlan_process_helper (void *cls, void *client,
 
     //check for bssid
     if (memcmp
-        (&(wlanIeeeHeader->i_addr3), &mac_bssid,
+        (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet,
          sizeof (struct MacAddress)) == 0)
     {
       //check for broadcast or mac
@@ -3166,7 +3161,7 @@ wlan_process_helper (void *cls, void *client,
     break;
   case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
     //TODO more control messages
-    if (ntohs (hdr->size) != sizeof (struct Wlan_Helper_Control_Message))
+    if (ntohs (hdr->size) != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage))
     {
       GNUNET_break (0);
       /* FIXME: restart SUID process */
@@ -3285,6 +3280,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
   api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
   api->cls = plugin;
   api->send = &wlan_plugin_send;
+  api->get_session = &wlan_plugin_get_session;
   api->disconnect = &wlan_plugin_disconnect;
   api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
   api->check_address = &wlan_plugin_address_suggested;