fix #3275 with solution from https://gnunet.org/bugs/view.php?id=3275#c8029
[oweals/gnunet.git] / src / exit / gnunet-daemon-exit.c
index 5b1f5b6811f608742089942d1d6e10f7a16893f2..c29638559b6baea02a500e7d658d41378ce9342d 100644 (file)
@@ -184,22 +184,22 @@ struct RedirectInformation
 
 
 /**
- * Queue of messages to a tunnel.
+ * Queue of messages to a channel.
  */
-struct TunnelMessageQueue
+struct ChannelMessageQueue
 {
   /**
    * This is a doubly-linked list.
    */
-  struct TunnelMessageQueue *next;
+  struct ChannelMessageQueue *next;
 
   /**
    * This is a doubly-linked list.
    */
-  struct TunnelMessageQueue *prev;
+  struct ChannelMessageQueue *prev;
 
   /**
-   * Payload to send via the tunnel.
+   * Payload to send via the channel.
    */
   const void *payload;
 
@@ -212,32 +212,32 @@ struct TunnelMessageQueue
 
 /**
  * This struct is saved into connections_map to allow finding the
- * right tunnel given an IP packet from TUN.  It is also associated
- * with the tunnel's closure so we can find it again for the next
- * message from the tunnel.
+ * right channel given an IP packet from TUN.  It is also associated
+ * with the channel's closure so we can find it again for the next
+ * message from the channel.
  */
-struct TunnelState
+struct ChannelState
 {
   /**
-   * Mesh tunnel that is used for this connection.
+   * Mesh channel that is used for this connection.
    */
-  struct GNUNET_MESH_Tunnel *tunnel;
+  struct GNUNET_MESH_Channel *channel;
 
   /**
-   * Who is the other end of this tunnel.
+   * Who is the other end of this channel.
    * FIXME is this needed? Only used for debugging messages
    */
   struct GNUNET_PeerIdentity peer;
 
   /**
-   * Active tunnel transmission request (or NULL).
+   * Active channel transmission request (or NULL).
    */
   struct GNUNET_MESH_TransmitHandle *th;
 
   /**
-   * #GNUNET_NO if this is a tunnel for TCP/UDP,
-   * #GNUNET_YES if this is a tunnel for DNS,
-   * #GNUNET_SYSERR if the tunnel is not yet initialized.
+   * #GNUNET_NO if this is a channel for TCP/UDP,
+   * #GNUNET_YES if this is a channel for DNS,
+   * #GNUNET_SYSERR if the channel is not yet initialized.
    */
   int is_dns;
 
@@ -262,14 +262,14 @@ struct TunnelState
       struct LocalService *serv;
 
       /**
-       * Head of DLL of messages for this tunnel.
+       * Head of DLL of messages for this channel.
        */
-      struct TunnelMessageQueue *head;
+      struct ChannelMessageQueue *head;
 
       /**
-       * Tail of DLL of messages for this tunnel.
+       * Tail of DLL of messages for this channel.
        */
-      struct TunnelMessageQueue *tail;
+      struct ChannelMessageQueue *tail;
 
       /**
        * Primary redirection information for this connection.
@@ -375,7 +375,7 @@ static struct GNUNET_MESH_Handle *mesh_handle;
 
 /**
  * This hashmaps contains the mapping from peer, service-descriptor,
- * source-port and destination-port to a struct TunnelState
+ * source-port and destination-port to a struct ChannelState
  */
 static struct GNUNET_CONTAINER_MultiHashMap *connections_map;
 
@@ -400,9 +400,9 @@ static struct GNUNET_CONTAINER_MultiHashMap *udp_services;
 static struct GNUNET_CONTAINER_MultiHashMap *tcp_services;
 
 /**
- * Array of all open DNS requests from tunnels.
+ * Array of all open DNS requests from channels.
  */
-static struct TunnelState *tunnels[UINT16_MAX + 1];
+static struct ChannelState *channels[UINT16_MAX + 1];
 
 /**
  * Handle to the DNS Stub resolver.
@@ -462,10 +462,10 @@ static int ipv6_enabled;
 
 
 /**
- * We got a reply from DNS for a request of a MESH tunnel.  Send it
- * via the tunnel (after changing the request ID back).
+ * We got a reply from DNS for a request of a MESH channel.  Send it
+ * via the channel (after changing the request ID back).
  *
- * @param cls the 'struct TunnelState'
+ * @param cls the 'struct ChannelState'
  * @param size number of bytes available in buf
  * @param buf where to copy the reply
  * @return number of bytes written to buf
@@ -475,7 +475,7 @@ transmit_reply_to_mesh (void *cls,
                        size_t size,
                        void *buf)
 {
-  struct TunnelState *ts = cls;
+  struct ChannelState *ts = cls;
   size_t off;
   size_t ret;
   char *cbuf = buf;
@@ -523,26 +523,26 @@ process_dns_result (void *cls,
                    const struct GNUNET_TUN_DnsHeader *dns,
                    size_t r)
 {
-  struct TunnelState *ts;
+  struct ChannelState *ts;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Processing DNS result from stub resolver\n");
   GNUNET_assert (NULL == cls);
-  /* Handle case that this is a reply to a request from a MESH DNS tunnel */
-  ts = tunnels[dns->id];
+  /* Handle case that this is a reply to a request from a MESH DNS channel */
+  ts = channels[dns->id];
   if ( (NULL == ts) ||
        (ts->specifics.dns.rs != rs) )
     return;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Got a response from the stub resolver for DNS request received via MESH!\n");
-  tunnels[dns->id] = NULL;
+  channels[dns->id] = NULL;
   GNUNET_free_non_null (ts->specifics.dns.reply);
   ts->specifics.dns.reply = GNUNET_malloc (r);
   ts->specifics.dns.reply_length = r;
   memcpy (ts->specifics.dns.reply, dns, r);
   if (NULL != ts->th)
     GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
-  ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
+  ts->th = GNUNET_MESH_notify_transmit_ready (ts->channel,
                                              GNUNET_NO,
                                              GNUNET_TIME_UNIT_FOREVER_REL,
                                              sizeof (struct GNUNET_MessageHeader) + r,
@@ -555,19 +555,19 @@ process_dns_result (void *cls,
  * Process a request via mesh to perform a DNS query.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our `struct TunnelState *`
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our `struct ChannelState *`
  * @param message the actual message
  *
  * @return #GNUNET_OK to keep the connection open,
  *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                     void **tunnel_ctx,
+receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+                     void **channel_ctx,
                      const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *ts = *tunnel_ctx;
+  struct ChannelState *ts = *channel_ctx;
   const struct GNUNET_TUN_DnsHeader *dns;
   size_t mlen = ntohs (message->size);
   size_t dlen = mlen - sizeof (struct GNUNET_MessageHeader);
@@ -583,7 +583,7 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == ts->is_dns)
   {
-    /* tunnel is DNS from now on */
+    /* channel is DNS from now on */
     ts->is_dns = GNUNET_YES;
   }
   if (dlen < sizeof (struct GNUNET_TUN_DnsHeader))
@@ -593,11 +593,11 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   dns = (const struct GNUNET_TUN_DnsHeader *) &message[1];
   ts->specifics.dns.original_id = dns->id;
-  if (tunnels[ts->specifics.dns.my_id] == ts)
-    tunnels[ts->specifics.dns.my_id] = NULL;
+  if (channels[ts->specifics.dns.my_id] == ts)
+    channels[ts->specifics.dns.my_id] = NULL;
   ts->specifics.dns.my_id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
                                                   UINT16_MAX + 1);
-  tunnels[ts->specifics.dns.my_id] = ts;
+  channels[ts->specifics.dns.my_id] = ts;
   memcpy (buf, dns, dlen);
   dout = (struct GNUNET_TUN_DnsHeader *) buf;
   dout->id = ts->specifics.dns.my_id;
@@ -676,9 +676,9 @@ hash_redirect_info (struct GNUNET_HashCode *hash,
  * @param state_key set to hash's state if non-NULL
  * @return NULL if we have no tracking information for this tuple
  */
-static struct TunnelState *
+static struct ChannelState *
 get_redirect_state (int af,
-                   int protocol,               
+                   int protocol,
                    const void *destination_ip,
                    uint16_t destination_port,
                    const void *local_ip,
@@ -687,7 +687,7 @@ get_redirect_state (int af,
 {
   struct RedirectInformation ri;
   struct GNUNET_HashCode key;
-  struct TunnelState *state;
+  struct ChannelState *state;
 
   if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) ||
        ( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) )
@@ -787,7 +787,7 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
   char key[sizeof (struct GNUNET_HashCode) + sizeof (uint16_t)];
   struct GNUNET_HashCode desc;
 
-  GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc);
+  GNUNET_TUN_service_name_to_hash (name, &desc);
   service->name = GNUNET_strdup (name);
   memcpy (&key[0], &destination_port, sizeof (uint16_t));
   memcpy (&key[sizeof(uint16_t)], &desc, sizeof (struct GNUNET_HashCode));
@@ -807,9 +807,9 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
 
 
 /**
- * MESH is ready to receive a message for the tunnel.  Transmit it.
+ * MESH is ready to receive a message for the channel.  Transmit it.
  *
- * @param cls the 'struct TunnelState'.
+ * @param cls the 'struct ChannelState'.
  * @param size number of bytes available in buf
  * @param buf where to copy the message
  * @return number of bytes copied to buf
@@ -817,9 +817,9 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
 static size_t
 send_to_peer_notify_callback (void *cls, size_t size, void *buf)
 {
-  struct TunnelState *s = cls;
-  struct GNUNET_MESH_Tunnel *tunnel = s->tunnel;
-  struct TunnelMessageQueue *tnq;
+  struct ChannelState *s = cls;
+  struct GNUNET_MESH_Channel *channel = s->channel;
+  struct ChannelMessageQueue *tnq;
 
   s->th = NULL;
   tnq = s->specifics.tcp_udp.head;
@@ -827,7 +827,7 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
     return 0;
   if (0 == size)
   {
-    s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
+    s->th = GNUNET_MESH_notify_transmit_ready (channel,
                                               GNUNET_NO /* corking */,
                                               GNUNET_TIME_UNIT_FOREVER_REL,
                                               tnq->len,
@@ -843,36 +843,36 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
                               tnq);
   GNUNET_free (tnq);
   if (NULL != (tnq = s->specifics.tcp_udp.head))
-    s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
+    s->th = GNUNET_MESH_notify_transmit_ready (channel,
                                               GNUNET_NO /* corking */,
                                               GNUNET_TIME_UNIT_FOREVER_REL,
                                               tnq->len,
                                               &send_to_peer_notify_callback,
                                               s);
   GNUNET_STATISTICS_update (stats,
-                           gettext_noop ("# Bytes transmitted via mesh tunnels"),
+                           gettext_noop ("# Bytes transmitted via mesh channels"),
                            size, GNUNET_NO);
   return size;
 }
 
 
 /**
- * Send the given packet via the mesh tunnel.
+ * Send the given packet via the mesh channel.
  *
- * @param s tunnel destination
+ * @param s channel destination
  * @param tnq message to queue
  */
 static void
-send_packet_to_mesh_tunnel (struct TunnelState *s,
-                           struct TunnelMessageQueue *tnq)
+send_packet_to_mesh_channel (struct ChannelState *s,
+                           struct ChannelMessageQueue *tnq)
 {
-  struct GNUNET_MESH_Tunnel *mesh_tunnel;
+  struct GNUNET_MESH_Channel *mesh_channel;
 
-  mesh_tunnel = s->tunnel;
+  mesh_channel = s->channel;
   GNUNET_assert (NULL != s);
   GNUNET_CONTAINER_DLL_insert_tail (s->specifics.tcp_udp.head, s->specifics.tcp_udp.tail, tnq);
   if (NULL == s->th)
-    s->th = GNUNET_MESH_notify_transmit_ready (mesh_tunnel,
+    s->th = GNUNET_MESH_notify_transmit_ready (mesh_channel,
                                                GNUNET_NO /* cork */,
                                               GNUNET_TIME_UNIT_FOREVER_REL,
                                               tnq->len,
@@ -899,8 +899,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
                  const void *destination_ip,
                  const void *source_ip)
 {
-  struct TunnelState *state;
-  struct TunnelMessageQueue *tnq;
+  struct ChannelState *state;
+  struct ChannelMessageQueue *tnq;
   struct GNUNET_EXIT_IcmpToVPNMessage *i2v;
   const struct GNUNET_TUN_IPv4Header *ipv4;
   const struct GNUNET_TUN_IPv6Header *ipv6;
@@ -1055,7 +1055,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
     return;
   }
   mlen = sizeof (struct GNUNET_EXIT_IcmpToVPNMessage) + pktlen - sizeof (struct GNUNET_TUN_IcmpHeader);
-  tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+  tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
   tnq->payload = &tnq[1];
   tnq->len = mlen;
   i2v = (struct GNUNET_EXIT_IcmpToVPNMessage *) &tnq[1];
@@ -1065,7 +1065,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
   memcpy (&i2v->icmp_header,
          icmp,
          pktlen);
-  send_packet_to_mesh_tunnel (state, tnq);
+  send_packet_to_mesh_channel (state, tnq);
 }
 
 
@@ -1087,8 +1087,8 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
                 const void *destination_ip,
                 const void *source_ip)
 {
-  struct TunnelState *state;
-  struct TunnelMessageQueue *tnq;
+  struct ChannelState *state;
+  struct ChannelMessageQueue *tnq;
   struct GNUNET_EXIT_UdpReplyMessage *urm;
   size_t mlen;
 
@@ -1131,7 +1131,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
     return;
   }
   mlen = sizeof (struct GNUNET_EXIT_UdpReplyMessage) + pktlen - sizeof (struct GNUNET_TUN_UdpHeader);
-  tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+  tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
   tnq->payload = &tnq[1];
   tnq->len = mlen;
   urm = (struct GNUNET_EXIT_UdpReplyMessage *) &tnq[1];
@@ -1142,7 +1142,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
   memcpy (&urm[1],
          &udp[1],
          pktlen - sizeof (struct GNUNET_TUN_UdpHeader));
-  send_packet_to_mesh_tunnel (state, tnq);
+  send_packet_to_mesh_channel (state, tnq);
 }
 
 
@@ -1164,11 +1164,11 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
                 const void *destination_ip,
                 const void *source_ip)
 {
-  struct TunnelState *state;
+  struct ChannelState *state;
   char buf[pktlen] GNUNET_ALIGN;
   struct GNUNET_TUN_TcpHeader *mtcp;
   struct GNUNET_EXIT_TcpDataMessage *tdm;
-  struct TunnelMessageQueue *tnq;
+  struct ChannelMessageQueue *tnq;
   size_t mlen;
 
   {
@@ -1220,7 +1220,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
     return;
   }
 
-  tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+  tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
   tnq->payload = &tnq[1];
   tnq->len = mlen;
   tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1];
@@ -1230,7 +1230,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
   memcpy (&tdm->tcp_header,
          buf,
          pktlen);
-  send_packet_to_mesh_tunnel (state, tnq);
+  send_packet_to_mesh_channel (state, tnq);
 }
 
 
@@ -1398,7 +1398,7 @@ setup_fresh_address (int af,
   local_address->af = af;
   local_address->proto = (uint8_t) proto;
   /* default "local" port range is often 32768--61000,
-     so we pick a random value in that range */        
+     so we pick a random value in that range */
   if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
        ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
     local_address->port = 0;
@@ -1429,7 +1429,7 @@ setup_fresh_address (int af,
       do
        {
          rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                                UINT32_MAX);   
+                                                UINT32_MAX);
          local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr;
        }
       while ( (local_address->address.ipv4.s_addr == addr.s_addr) ||
@@ -1486,7 +1486,7 @@ setup_fresh_address (int af,
  * We are starting a fresh connection (TCP or UDP) and need
  * to pick a source port and IP address (within the correct
  * range and address family) to associate replies with the
- * connection / correct mesh tunnel.  This function generates
+ * connection / correct mesh channel.  This function generates
  * a "fresh" source IP and source port number for a connection
  * After picking a good source address, this function sets up
  * the state in the 'connections_map' and 'connections_heap'
@@ -1497,17 +1497,17 @@ setup_fresh_address (int af,
  * @param state skeleton state to setup a record for; should
  *              'state->specifics.tcp_udp.ri.remote_address' filled in so that
  *              this code can determine which AF/protocol is
- *              going to be used (the 'tunnel' should also
+ *              going to be used (the 'channel' should also
  *              already be set); after calling this function,
  *              heap_node and the local_address will be
  *              also initialized (heap_node != NULL can be
  *              used to test if a state has been fully setup).
  */
 static void
-setup_state_record (struct TunnelState *state)
+setup_state_record (struct ChannelState *state)
 {
   struct GNUNET_HashCode key;
-  struct TunnelState *s;
+  struct ChannelState *s;
 
   /* generate fresh, unique address */
   do
@@ -1549,7 +1549,7 @@ setup_state_record (struct TunnelState *state)
     s = GNUNET_CONTAINER_heap_remove_root (connections_heap);
     GNUNET_assert (state != s);
     s->specifics.tcp_udp.heap_node = NULL;
-    GNUNET_MESH_tunnel_destroy (s->tunnel);
+    GNUNET_MESH_channel_destroy (s->channel);
     GNUNET_assert (GNUNET_OK ==
                   GNUNET_CONTAINER_multihashmap_remove (connections_map,
                                                         &s->specifics.tcp_udp.state_key,
@@ -1696,7 +1696,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
 
   GNUNET_TUN_initialize_ipv6_header (pkt6,
                                     protocol,
-                                    len,                               
+                                    len,
                                     &src_address->address.ipv6,
                                     &dst_address->address.ipv6);
 
@@ -1745,7 +1745,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
  * @param source_address IP and port to use for the TCP packet's source
  * @param tcp_header header template to use
  * @param payload payload of the TCP packet
- * @param payload_length number of bytes in 'payload'
+ * @param payload_length number of bytes in @a payload
  */
 static void
 send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
@@ -1796,7 +1796,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET:
       {
        struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV4);
        prepare_ipv4_packet (payload, payload_length,
                             IPPROTO_TCP,
@@ -1809,7 +1809,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET6:
       {
        struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV6);
        prepare_ipv6_packet (payload, payload_length,
                             IPPROTO_TCP,
@@ -1818,7 +1818,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
                             destination_address,
                             ipv6);
       }
-      break;   
+      break;
     default:
       GNUNET_assert (0);
       break;
@@ -1837,19 +1837,19 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
  * offered by this system.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our `struct ChannelState *`
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                     void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_service (void *cls,
+                     struct GNUNET_MESH_Channel *channel,
+                     void **channel_ctx,
                      const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_TcpServiceStartMessage *start;
   uint16_t pkt_len = ntohs (message->size);
 
@@ -1865,7 +1865,7 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -1900,11 +1900,14 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
              GNUNET_i2s (&state->peer),
              GNUNET_h2s (&start->service_descriptor),
              (unsigned int) ntohs (start->tcp_header.destination_port));
-  if (NULL == (state->specifics.tcp_udp.serv = find_service (tcp_services, &start->service_descriptor,
-                                                            ntohs (start->tcp_header.destination_port))))
+  if (NULL == (state->specifics.tcp_udp.serv =
+               find_service (tcp_services,
+                             &start->service_descriptor,
+                             ntohs (start->tcp_header.destination_port))))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-               _("No service found for %s on port %d!\n"),
+               _("No service %s found for %s on port %d!\n"),
+                GNUNET_h2s (&start->service_descriptor),
                "TCP",
                ntohs (start->tcp_header.destination_port));
     GNUNET_STATISTICS_update (stats,
@@ -1926,19 +1929,19 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
  * Process a request to forward TCP data to the Internet via this peer.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
  *
  * @return GNUNET_OK to keep the connection open,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                    void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+                    void **channel_ctx GNUNET_UNUSED,
                     const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_TcpInternetStartMessage *start;
   uint16_t pkt_len = ntohs (message->size);
   const struct in_addr *v4;
@@ -1958,7 +1961,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -2051,32 +2054,21 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
  * connection via this peer.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                 void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+                 void **channel_ctx GNUNET_UNUSED,
                  const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_TcpDataMessage *data;
   uint16_t pkt_len = ntohs (message->size);
 
-  if (GNUNET_YES == state->is_dns)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  if (GNUNET_SYSERR == state->is_dns)
-  {
-    /* tunnel is UDP/TCP from now on */
-    state->is_dns = GNUNET_NO;
-  }
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# Bytes received from MESH"),
                            pkt_len, GNUNET_NO);
@@ -2104,6 +2096,16 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
+  if (GNUNET_YES == state->is_dns)
+  {
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
+  }
+  if (GNUNET_SYSERR == state->is_dns)
+  {
+    /* channel is UDP/TCP from now on */
+    state->is_dns = GNUNET_NO;
+  }
 
   GNUNET_break_op (ntohl (data->reserved) == 0);
   {
@@ -2133,7 +2135,7 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
  * @param source_address IP to use for the ICMP packet's source
  * @param icmp_header ICMP header to send
  * @param payload payload of the ICMP packet (does NOT include ICMP header)
- * @param payload_length number of bytes of data in payload
+ * @param payload_length number of bytes of data in @a payload
  */
 static void
 send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
@@ -2185,7 +2187,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET:
       {
        struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV4);
        GNUNET_TUN_initialize_ipv4_header (ipv4,
                                           IPPROTO_ICMP,
@@ -2198,7 +2200,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET6:
       {
        struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV6);
        GNUNET_TUN_initialize_ipv6_header (ipv6,
                                           IPPROTO_ICMPV6,
@@ -2207,7 +2209,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
                                           &destination_address->address.ipv6);
        icmp = (struct GNUNET_TUN_IcmpHeader*) &ipv6[1];
       }
-      break;   
+      break;
     default:
       GNUNET_assert (0);
       break;
@@ -2230,15 +2232,15 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
 
 /**
  * Synthesize a plausible ICMP payload for an ICMPv4 error
- * response on the given tunnel.
+ * response on the given channel.
  *
- * @param state tunnel information
+ * @param state channel information
  * @param ipp IPv6 header to fill in (ICMP payload)
  * @param udp "UDP" header to fill in (ICMP payload); might actually
  *            also be the first 8 bytes of the TCP header
  */
 static void
-make_up_icmpv4_payload (struct TunnelState *state,
+make_up_icmpv4_payload (struct ChannelState *state,
                        struct GNUNET_TUN_IPv4Header *ipp,
                        struct GNUNET_TUN_UdpHeader *udp)
 {
@@ -2256,15 +2258,15 @@ make_up_icmpv4_payload (struct TunnelState *state,
 
 /**
  * Synthesize a plausible ICMP payload for an ICMPv6 error
- * response on the given tunnel.
+ * response on the given channel.
  *
- * @param state tunnel information
+ * @param state channel information
  * @param ipp IPv6 header to fill in (ICMP payload)
  * @param udp "UDP" header to fill in (ICMP payload); might actually
  *            also be the first 8 bytes of the TCP header
  */
 static void
-make_up_icmpv6_payload (struct TunnelState *state,
+make_up_icmpv6_payload (struct ChannelState *state,
                        struct GNUNET_TUN_IPv6Header *ipp,
                        struct GNUNET_TUN_UdpHeader *udp)
 {
@@ -2284,19 +2286,19 @@ make_up_icmpv6_payload (struct TunnelState *state,
  * Process a request to forward ICMP data to the Internet via this peer.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                    void **tunnel_ctx GNUNET_UNUSED,
+receive_icmp_remote (void *cls,
+                     struct GNUNET_MESH_Channel *channel,
+                    void **channel_ctx,
                     const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_IcmpInternetMessage *msg;
   uint16_t pkt_len = ntohs (message->size);
   const struct in_addr *v4;
@@ -2312,7 +2314,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -2333,7 +2335,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   if ( (NULL != state->specifics.tcp_udp.heap_node) &&
        (af != state->specifics.tcp_udp.ri.remote_address.af) )
   {
-    /* other peer switched AF on this tunnel; not allowed */
+    /* other peer switched AF on this channel; not allowed */
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
@@ -2490,7 +2492,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
  * @return number of bytes of payload we created in buf
  */
 static uint16_t
-make_up_icmp_service_payload (struct TunnelState *state,
+make_up_icmp_service_payload (struct ChannelState *state,
                              char *buf)
 {
   switch (state->specifics.tcp_udp.serv->address.af)
@@ -2535,19 +2537,19 @@ make_up_icmp_service_payload (struct TunnelState *state,
  * offered by this system.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                     void **tunnel_ctx,
+receive_icmp_service (void *cls,
+                      struct GNUNET_MESH_Channel *channel,
+                     void **channel_ctx,
                      const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_IcmpServiceMessage *msg;
   uint16_t pkt_len = ntohs (message->size);
   struct GNUNET_TUN_IcmpHeader icmp;
@@ -2561,7 +2563,7 @@ receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -2733,7 +2735,7 @@ receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel
  * @param destination_address IP and port to use for the UDP packet's destination
  * @param source_address IP and port to use for the UDP packet's source
  * @param payload payload of the UDP packet (does NOT include UDP header)
- * @param payload_length number of bytes of data in payload
+ * @param payload_length number of bytes of data in @a payload
  */
 static void
 send_udp_packet_via_tun (const struct SocketAddress *destination_address,
@@ -2783,7 +2785,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET:
       {
        struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV4);
        prepare_ipv4_packet (payload, payload_length,
                             IPPROTO_UDP,
@@ -2796,7 +2798,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
     case AF_INET6:
       {
        struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-       
+
        tun->proto = htons (ETH_P_IPV6);
        prepare_ipv6_packet (payload, payload_length,
                             IPPROTO_UDP,
@@ -2805,7 +2807,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
                             destination_address,
                             ipv6);
       }
-      break;   
+      break;
     default:
       GNUNET_assert (0);
       break;
@@ -2823,19 +2825,19 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
  * Process a request to forward UDP data to the Internet via this peer.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                    void **tunnel_ctx GNUNET_UNUSED,
+receive_udp_remote (void *cls,
+                    struct GNUNET_MESH_Channel *channel,
+                    void **channel_ctx,
                     const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_UdpInternetMessage *msg;
   uint16_t pkt_len = ntohs (message->size);
   const struct in_addr *v4;
@@ -2850,7 +2852,7 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -2934,19 +2936,19 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
  * offered by this system.
  *
  * @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
  * @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 static int
-receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-                     void **tunnel_ctx,
+receive_udp_service (void *cls,
+                     struct GNUNET_MESH_Channel *channel,
+                     void **channel_ctx,
                      const struct GNUNET_MessageHeader *message)
 {
-  struct TunnelState *state = *tunnel_ctx;
+  struct ChannelState *state = *channel_ctx;
   const struct GNUNET_EXIT_UdpServiceMessage *msg;
   uint16_t pkt_len = ntohs (message->size);
 
@@ -2957,7 +2959,7 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_SYSERR == state->is_dns)
   {
-    /* tunnel is UDP/TCP from now on */
+    /* channel is UDP/TCP from now on */
     state->is_dns = GNUNET_NO;
   }
   GNUNET_STATISTICS_update (stats,
@@ -2979,11 +2981,14 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
        GNUNET_i2s (&state->peer),
        GNUNET_h2s (&msg->service_descriptor),
        (unsigned int) ntohs (msg->destination_port));
-  if (NULL == (state->specifics.tcp_udp.serv = find_service (udp_services, &msg->service_descriptor,
-                                                            ntohs (msg->destination_port))))
+  if (NULL == (state->specifics.tcp_udp.serv =
+               find_service (udp_services,
+                             &msg->service_descriptor,
+                             ntohs (msg->destination_port))))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-               _("No service found for %s on port %d!\n"),
+               _("No service %s found for %s on port %d!\n"),
+                GNUNET_h2s (&msg->service_descriptor),
                "UDP",
                ntohs (msg->destination_port));
     GNUNET_STATISTICS_update (stats,
@@ -3003,51 +3008,55 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
 
 
 /**
- * Callback from GNUNET_MESH for new tunnels.
+ * Callback from GNUNET_MESH for new channels.
  *
  * @param cls closure
- * @param tunnel new handle to the tunnel
- * @param initiator peer that started the tunnel
+ * @param channel new handle to the channel
+ * @param initiator peer that started the channel
  * @param port destination port
- * @return initial tunnel context for the tunnel
+ * @param options channel options flags
+ * @return initial channel context for the channel
  */
 static void *
-new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
-            const struct GNUNET_PeerIdentity *initiator, uint32_t port)
+new_channel (void *cls,
+            struct GNUNET_MESH_Channel *channel,
+            const struct GNUNET_PeerIdentity *initiator,
+            uint32_t port, enum GNUNET_MESH_ChannelOption options)
 {
-  struct TunnelState *s = GNUNET_new (struct TunnelState);
+  struct ChannelState *s = GNUNET_new (struct ChannelState);
 
   s->is_dns = GNUNET_SYSERR;
   s->peer = *initiator;
   GNUNET_STATISTICS_update (stats,
-                           gettext_noop ("# Inbound MESH tunnels created"),
+                           gettext_noop ("# Inbound MESH channels created"),
                            1, GNUNET_NO);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received inbound tunnel from `%s'\n",
+             "Received inbound channel from `%s'\n",
              GNUNET_i2s (initiator));
-  s->tunnel = tunnel;
+  s->channel = channel;
   return s;
 }
 
 
 /**
- * Function called by mesh whenever an inbound tunnel is destroyed.
+ * Function called by mesh whenever an inbound channel is destroyed.
  * Should clean up any associated state.
  *
- * @param cls closure (set from GNUNET_MESH_connect)
- * @param tunnel connection to the other end (henceforth invalid)
- * @param tunnel_ctx place where local state associated
- *                   with the tunnel is stored
+ * @param cls closure (set from #GNUNET_MESH_connect)
+ * @param channel connection to the other end (henceforth invalid)
+ * @param channel_ctx place where local state associated
+ *                   with the channel is stored
  */
 static void
-clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
-              void *tunnel_ctx)
+clean_channel (void *cls,
+              const struct GNUNET_MESH_Channel *channel,
+              void *channel_ctx)
 {
-  struct TunnelState *s = tunnel_ctx;
-  struct TunnelMessageQueue *tnq;
+  struct ChannelState *s = channel_ctx;
+  struct ChannelMessageQueue *tnq;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Tunnel destroyed\n");
+       "Channel destroyed\n");
   if (GNUNET_SYSERR == s->is_dns)
   {
     GNUNET_free (s);
@@ -3055,8 +3064,8 @@ clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
   }
   if (GNUNET_YES == s->is_dns)
   {
-    if (tunnels[s->specifics.dns.my_id] == s)
-      tunnels[s->specifics.dns.my_id] = NULL;
+    if (channels[s->specifics.dns.my_id] == s)
+      channels[s->specifics.dns.my_id] = NULL;
     GNUNET_free_non_null (s->specifics.dns.reply);
   }
   else
@@ -3095,8 +3104,9 @@ clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
  * @param value value to free
  */
 static int
-free_iterate (void *cls GNUNET_UNUSED,
-              const struct GNUNET_HashCode * hash GNUNET_UNUSED, void *value)
+free_iterate (void *cls,
+              const struct GNUNET_HashCode * hash,
+              void *value)
 {
   GNUNET_free (value);
   return GNUNET_YES;
@@ -3107,7 +3117,7 @@ free_iterate (void *cls GNUNET_UNUSED,
  * Function scheduled as very last function, cleans up after us
  */
 static void
-cleanup (void *cls GNUNET_UNUSED,
+cleanup (void *cls,
          const struct GNUNET_SCHEDULER_TaskContext *tskctx)
 {
   unsigned int i;
@@ -3209,6 +3219,12 @@ add_services (int proto,
   char *hostname;
   char *hostport;
   struct LocalService *serv;
+  char *n;
+  size_t slen;
+
+  slen = strlen (name);
+  GNUNET_assert (slen >= 8);
+  n = GNUNET_strndup (name, slen - 8 /* remove .gnunet. */);
 
   for (redirect = strtok (cpy, " "); redirect != NULL;
        redirect = strtok (NULL, " "))
@@ -3216,7 +3232,7 @@ add_services (int proto,
     if (NULL == (hostname = strstr (redirect, ":")))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "option `%s' for domain `%s' is not formatted correctly!\n",
+                 _("Option `%s' for domain `%s' is not formatted correctly!\n"),
                  redirect,
                  name);
       continue;
@@ -3226,9 +3242,9 @@ add_services (int proto,
     if (NULL == (hostport = strstr (hostname, ":")))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "option `%s' for domain `%s' is not formatted correctly!\n",
-                 redirect,
-                 name);
+                  _("Option `%s' for domain `%s' is not formatted correctly!\n"),
+                  redirect,
+                  name);
       continue;
     }
     hostport[0] = '\0';
@@ -3240,14 +3256,16 @@ add_services (int proto,
     if (!((local_port > 0) && (local_port < 65536)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "`%s' is not a valid port number (for domain `%s')!", redirect,
-                 name);
+                  _("`%s' is not a valid port number (for domain `%s')!"),
+                  redirect,
+                  name);
       continue;
     }
     if (!((remote_port > 0) && (remote_port < 65536)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 "`%s' is not a valid port number (for domain `%s')!", hostport,
+                 _("`%s' is not a valid port number (for domain `%s')!"),
+                  hostport,
                  name);
       continue;
     }
@@ -3281,7 +3299,7 @@ add_services (int proto,
        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                    _("No addresses found for hostname `%s' of service `%s'!\n"),
                    hostname,
-                   name);
+                   n);
        GNUNET_free (serv);
        continue;
       }
@@ -3294,7 +3312,7 @@ add_services (int proto,
        {
          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                      _("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
-                     name);
+                     n);
          freeaddrinfo (res);
          GNUNET_free (serv);
          continue;
@@ -3306,11 +3324,11 @@ add_services (int proto,
        {
          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                      _("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
-                     name);
+                     n);
          freeaddrinfo (res);
          GNUNET_free (serv);
          continue;
-       }       
+       }
        serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
        break;
       default:
@@ -3318,17 +3336,18 @@ add_services (int proto,
        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                    _("No IP addresses found for hostname `%s' of service `%s'!\n"),
                    hostname,
-                   name);
+                   n);
        GNUNET_free (serv);
        continue;
       }
       freeaddrinfo (res);
     }
     store_service ((IPPROTO_UDP == proto) ? udp_services : tcp_services,
-                  name,
+                  n,
                   local_port,
                   serv);
   }
+  GNUNET_free (n);
 }
 
 
@@ -3339,7 +3358,7 @@ add_services (int proto,
  * @param section name of section in config, equal to hostname
  */
 static void
-read_service_conf (void *cls GNUNET_UNUSED, const char *section)
+read_service_conf (void *cls, const char *section)
 {
   char *cpy;
 
@@ -3441,8 +3460,9 @@ do_dht_put (void *cls,
  * @param cfg_ configuration
  */
 static void
-run (void *cls, char *const *args GNUNET_UNUSED,
-     const char *cfgfile GNUNET_UNUSED,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
   static struct GNUNET_MESH_MessageHandler handlers[] = {
@@ -3538,7 +3558,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
 
   dns_exit = NULL;
   if ( (GNUNET_YES ==
-       GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "ENABLE_DNS")) &&
+       GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "EXIT_DNS")) &&
        ( (GNUNET_OK !=
          GNUNET_CONFIGURATION_get_value_string (cfg, "exit",
                                                 "DNS_RESOLVER",
@@ -3552,20 +3572,14 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     GNUNET_free_non_null (dns_exit);
     dns_exit = NULL;
   }
-  if (NULL != dns_exit)
-    dnsstub = GNUNET_DNSSTUB_start (dns_exit);
-
-
   app_idx = 0;
   if (GNUNET_YES == ipv4_exit)
   {
-    // FIXME use regex to put info
     apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
     app_idx++;
   }
   if (GNUNET_YES == ipv6_exit)
   {
-    // FIXME use regex to put info
     apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
     app_idx++;
   }
@@ -3586,7 +3600,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
     app_idx++;
   }
-
+  GNUNET_free_non_null (dns_exit);
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
 
   if (GNUNET_OK !=
@@ -3670,6 +3684,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
        return;
       }
     exit_argv[5] = ipv4addr;
+    ipv4mask = NULL;
     if ( (GNUNET_SYSERR ==
          GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK",
                                                 &ipv4mask) ||
@@ -3677,6 +3692,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     {
       GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4MASK");
       GNUNET_SCHEDULER_shutdown ();
+      GNUNET_free_non_null (ipv4mask);
       return;
     }
     exit_argv[6] = ipv4mask;
@@ -3695,11 +3711,18 @@ run (void *cls, char *const *args GNUNET_UNUSED,
 
   connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
   connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+  if (0 == app_idx)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("No useful service enabled.  Exiting.\n"));
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
   mesh_handle
     = GNUNET_MESH_connect (cfg, NULL,
-                          &new_tunnel,
-                          &clean_tunnel, handlers,
-                           apptypes); // FIXME use ports
+                          &new_channel,
+                          &clean_channel, handlers,
+                           apptypes);
   if (NULL == mesh_handle)
   {
     GNUNET_SCHEDULER_shutdown ();
@@ -3713,7 +3736,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
                                                "exit",
-                                               "EXIT_RANGE_IPV4_REGEX",
+                                               "EXIT_RANGE_IPV4_POLICY",
                                                &policy))
       regex = NULL;
     else
@@ -3724,7 +3747,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
       (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
                              GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
                              "4", regex);
-      regex4 = GNUNET_REGEX_announce (cfg,                     
+      regex4 = GNUNET_REGEX_announce (cfg,
                                      prefixed_regex,
                                      REGEX_REFRESH_FREQUENCY,
                                      REGEX_MAX_PATH_LEN_IPV4);
@@ -3739,7 +3762,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
     if (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
                                                "exit",
-                                               "EXIT_RANGE_IPV6_REGEX",
+                                               "EXIT_RANGE_IPV6_POLICY",
                                                &policy))
       regex = NULL;
     else