gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 01/20: first steps towards usable dhtu


From: gnunet
Subject: [gnunet] 01/20: first steps towards usable dhtu
Date: Sat, 19 Feb 2022 16:20:41 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit ba9296269617c157baffb59a6240c87ae5935e95
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jan 10 21:51:53 2022 +0100

    first steps towards usable dhtu
---
 src/dht/Makefile.am                     |   1 -
 src/dht/gnunet-service-dht.c            | 286 ++++++++++++++++++++++++----
 src/dht/gnunet-service-dht.h            |   8 +
 src/dht/gnunet-service-dht_neighbours.c | 235 +++++++++++------------
 src/dht/gnunet-service-dht_neighbours.h |  46 +++++
 src/dht/gnunet-service-dht_nse.c        | 121 ------------
 src/dht/gnunet-service-dht_nse.h        |  52 -----
 src/dht/plugin_block_dht.c              | 325 +++++++++++++++++---------------
 src/dhtu/plugin_dhtu_gnunet.c           |  30 +--
 src/dhtu/plugin_dhtu_ip.c               | 264 +++++++++++++-------------
 src/include/Makefile.am                 |   1 +
 src/include/gnunet_block_lib.h          |   6 +
 src/include/gnunet_dhtu_plugin.h        |  23 +--
 src/include/gnunet_hello_uri_lib.h      | 169 +++++++++++++++++
 14 files changed, 917 insertions(+), 650 deletions(-)

diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index be48fab02..44439f66f 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -59,7 +59,6 @@ gnunet_service_dht_SOURCES = \
  gnunet-service-dht.c gnunet-service-dht.h \
  gnunet-service-dht_datacache.c gnunet-service-dht_datacache.h \
  gnunet-service-dht_hello.c gnunet-service-dht_hello.h \
- gnunet-service-dht_nse.c gnunet-service-dht_nse.h \
  gnunet-service-dht_neighbours.c gnunet-service-dht_neighbours.h \
  gnunet-service-dht_routing.c gnunet-service-dht_routing.h
 gnunet_service_dht_LDADD = \
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index da46dcfee..6f2573d26 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -27,8 +27,6 @@
 #include "platform.h"
 #include "gnunet_block_lib.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_transport_service.h"
-#include "gnunet_transport_hello_service.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_dht_service.h"
 #include "gnunet_statistics_service.h"
@@ -36,44 +34,223 @@
 #include "gnunet-service-dht_datacache.h"
 #include "gnunet-service-dht_hello.h"
 #include "gnunet-service-dht_neighbours.h"
-#include "gnunet-service-dht_nse.h"
 #include "gnunet-service-dht_routing.h"
 
+
+/**
+ * Information we keep per underlay.
+ */
+struct Underlay
+{
+
+  /**
+   * Kept in a DLL.
+   */
+  struct Underlay *next;
+
+  /**
+   * Kept in a DLL.
+   */
+  struct Underlay *prev;
+
+  /**
+   * Environment for this underlay.
+   */
+  struct GNUNET_DHTU_PluginEnvironment env;
+
+  /**
+   * Underlay API handle.
+   */
+  struct GNUNET_DHTU_PluginFunctions *dhtu;
+
+  /**
+   * current network size estimate for this underlay.
+   */
+  double network_size_estimate;
+
+  /**
+   * Name of the underlay (i.e. "gnunet" or "ip").
+   */
+  char *name;
+};
+
+
+/**
+ * An address of this peer.
+ */
+struct MyAddress
+{
+  /**
+   * Kept in a DLL.
+   */
+  struct MyAddress *next;
+
+  /**
+   * Kept in a DLL.
+   */
+  struct MyAddress *prev;
+
+  /**
+   * Underlay handle for the address.
+   */
+  struct GNUNET_DHTU_Source *source;
+
+  /**
+   * Textual representation of the address.
+   */
+  char *url;
+
+  /**
+   * Underlay of this address.
+   */
+  struct Underlay *u;
+};
+
+
 /**
  * Our HELLO
  */
 struct GNUNET_MessageHeader *GDS_my_hello;
 
 /**
- * Handle to get our current HELLO.
+ * Handles for the DHT underlays.
+ */
+static struct Underlay *u_head;
+
+/**
+ * Handles for the DHT underlays.
+ */
+static struct Underlay *u_tail;
+
+/**
+ * Head of addresses of this peer.
+ */
+static struct MyAddress *a_head;
+
+/**
+ * Tail of addresses of this peer.
  */
-static struct GNUNET_TRANSPORT_HelloGetHandle *ghh;
+static struct MyAddress *a_tail;
 
 /**
  * Hello address expiration
  */
 struct GNUNET_TIME_Relative hello_expiration;
 
+/**
+ * log of the current network size estimate, used as the point where
+ * we switch between random and deterministic routing.
+ */
+static double log_of_network_size_estimate;
 
-#include "gnunet-service-dht_clients.c"
+
+/**
+ * Callback that is called when network size estimate is updated.
+ *
+ * @param cls a `struct Underlay`
+ * @param timestamp time when the estimate was received from the server (or 
created by the server)
+ * @param logestimate the log(Base 2) value of the current network size 
estimate
+ * @param std_dev standard deviation for the estimate
+ *
+ */
+static void
+update_network_size_estimate (void *cls,
+                              struct GNUNET_TIME_Absolute timestamp,
+                              double logestimate,
+                              double std_dev)
+{
+  struct Underlay *u = cls;
+  double sum = 0.0;
+
+  GNUNET_STATISTICS_update (GDS_stats,
+                            "# Network size estimates received",
+                            1,
+                            GNUNET_NO);
+  /* do not allow estimates < 0.5 */
+  u->network_size_estimate = pow (2.0,
+                                  GNUNET_MAX (0.5,
+                                              logestimate));
+  for (struct Underlay *p; NULL != p; p = p->next)
+    sum += p->network_size_estimate;
+  if (sum <= 2.0)
+    log_of_network_size_estimate = 0.5;
+  else
+    log_of_network_size_estimate = log2 (sum);
+}
 
 
 /**
- * Receive the HELLO from transport service, free current and replace
- * if necessary.
+ * Return the current NSE
  *
- * @param cls NULL
- * @param message HELLO message of peer
+ * @return the current NSE as a logarithm
+ */
+double
+GDS_NSE_get (void)
+{
+  return log_of_network_size_estimate;
+}
+
+
+#include "gnunet-service-dht_clients.c"
+
+
+/**
+ * Update our HELLO with all of our our addresses.
  */
 static void
-process_hello (void *cls,
-               const struct GNUNET_MessageHeader *message)
+update_hello (void)
 {
   GNUNET_free (GDS_my_hello);
-  GDS_my_hello = GNUNET_malloc (ntohs (message->size));
-  GNUNET_memcpy (GDS_my_hello,
-                 message,
-                 ntohs (message->size));
+  // FIXME: build new HELLO properly!
+}
+
+
+/**
+ * Function to call with new addresses of this peer.
+ *
+ * @param cls the closure
+ * @param address address under which we are likely reachable,
+ *           pointer will remain valid until @e address_del_cb is called; to 
be used for HELLOs. Example: "ip+udp://$PID/1.1.1.1:2086/"
+ * @param source handle for sending from this address, NULL if we can only 
receive
+ * @param[out] ctx storage space for DHT to use in association with this 
address
+ */
+static void
+u_address_add (void *cls,
+               const char *address,
+               struct GNUNET_DHTU_Source *source,
+               void **ctx)
+{
+  struct Underlay *u = cls;
+  struct MyAddress *a;
+
+  a = GNUNET_new (struct MyAddress);
+  a->source = source;
+  a->url = GNUNET_strdup (address);
+  a->u = u;
+  GNUNET_CONTAINER_DLL_insert (a_head,
+                               a_tail,
+                               a);
+  *ctx = a;
+  update_hello ();
+}
+
+
+/**
+ * Function to call with expired addresses of this peer.
+ *
+ * @param[in] ctx storage space used by the DHT in association with this 
address
+ */
+static void
+u_address_del (void *ctx)
+{
+  struct MyAddress *a = ctx;
+
+  GNUNET_CONTAINER_DLL_remove (a_head,
+                               a_tail,
+                               a);
+  GNUNET_free (a->url);
+  GNUNET_free (a);
+  update_hello ();
 }
 
 
@@ -85,16 +262,10 @@ process_hello (void *cls,
 static void
 shutdown_task (void *cls)
 {
-  if (NULL != ghh)
-  {
-    GNUNET_TRANSPORT_hello_get_cancel (ghh);
-    ghh = NULL;
-  }
   GDS_NEIGHBOURS_done ();
   GDS_DATACACHE_done ();
   GDS_ROUTING_done ();
   GDS_HELLO_done ();
-  GDS_NSE_done ();
   if (NULL != GDS_block_context)
   {
     GNUNET_BLOCK_context_destroy (GDS_block_context);
@@ -112,6 +283,57 @@ shutdown_task (void *cls)
 }
 
 
+/**
+ * Function iterating over all configuration sections.
+ * Loads plugins for enabled DHT underlays.
+ *
+ * @param cls NULL
+ * @param section configuration section to inspect
+ */
+static void
+load_underlay (void *cls,
+               const char *section)
+{
+  struct Underlay *u;
+  char *libname;
+
+  (void) cls;
+  if (0 != strncasecmp (section,
+                        "dhtu-",
+                        strlen ("dhtu-")))
+    return;
+  if (GNUNET_YES !=
+      GNUNET_CONFIGURATION_get_value_yesno (GDS_cfg,
+                                            section,
+                                            "ENABLED"))
+    return;
+  section += strlen ("dhtu-");
+  u = GNUNET_new (struct Underlay);
+  u->env.cls = u;
+  u->env.address_add_cb = &u_address_add;
+  u->env.address_del_cb = &u_address_del;
+  u->env.network_size_cb = &update_network_size_estimate;
+  u->env.connect_cb = &GDS_u_connect;
+  u->env.disconnect_cb = &GDS_u_disconnect;
+  u->env.receive_cb = &GDS_u_receive;
+  GNUNET_asprintf (&libname,
+                   "libgnunet_plugin_dhtu_%s",
+                   section);
+  u->dhtu = GNUNET_PLUGIN_load (libname,
+                                &u->env);
+  if (NULL == u->dhtu)
+  {
+    GNUNET_free (libname);
+    GNUNET_free (u);
+    return;
+  }
+  u->name = GNUNET_strdup (section);
+  GNUNET_CONTAINER_DLL_insert (u_head,
+                               u_tail,
+                               u);
+}
+
+
 /**
  * Process dht requests.
  *
@@ -137,23 +359,21 @@ run (void *cls,
   GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg);
   GDS_stats = GNUNET_STATISTICS_create ("dht",
                                         GDS_cfg);
-  GNUNET_SERVICE_suspend (GDS_service);
   GDS_CLIENTS_init ();
   GDS_ROUTING_init ();
-  GDS_NSE_init ();
   GDS_DATACACHE_init ();
-  GDS_HELLO_init ();
-  if (GNUNET_OK != GDS_NEIGHBOURS_init ())
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                 NULL);
+  GNUNET_CONFIGURATION_iterate_sections (GDS_cfg,
+                                         &load_underlay,
+                                         NULL);
+  if (NULL == u_head)
   {
-    shutdown_task (NULL);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "No DHT underlays configured!\n");
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
-  ghh = GNUNET_TRANSPORT_hello_get (GDS_cfg,
-                                    GNUNET_TRANSPORT_AC_GLOBAL,
-                                    &process_hello,
-                                    NULL);
 }
 
 
diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h
index 367ff426e..687e2d4d3 100644
--- a/src/dht/gnunet-service-dht.h
+++ b/src/dht/gnunet-service-dht.h
@@ -128,4 +128,12 @@ GDS_CLIENTS_process_put (enum GNUNET_DHT_RouteOption 
options,
                          uint32_t hop_count,
                          uint32_t desired_replication_level);
 
+/**
+ * Return the current NSE
+ *
+ * @return the current NSE as a logarithm
+ */
+double
+GDS_NSE_get (void);
+
 #endif
diff --git a/src/dht/gnunet-service-dht_neighbours.c 
b/src/dht/gnunet-service-dht_neighbours.c
index cf150ea0c..bc473df69 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -28,13 +28,10 @@
 #include "gnunet_constants.h"
 #include "gnunet_protocols.h"
 #include "gnunet_signatures.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_core_service.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet-service-dht.h"
 #include "gnunet-service-dht_hello.h"
 #include "gnunet-service-dht_neighbours.h"
-#include "gnunet-service-dht_nse.h"
 #include "gnunet-service-dht_routing.h"
 #include "dht.h"
 
@@ -278,12 +275,12 @@ struct PeerInfo
   /**
    * Handle for sending messages to this peer.
    */
-  struct GNUNET_MQ_Handle *mq;
+  struct GNUNET_DHTU_Target *target;
 
   /**
    * What is the identity of the peer?
    */
-  const struct GNUNET_PeerIdentity *id;
+  struct GNUNET_PeerIdentity id;
 
   /**
    * Hash of @e id.
@@ -332,7 +329,7 @@ struct ConnectInfo
   /**
    * Handle to active connectivity suggestion operation, or NULL.
    */
-  struct GNUNET_ATS_ConnectivitySuggestHandle *sh;
+  struct GNUNET_DHTU_PreferenceHandle *ph;
 
   /**
    * How much would we like to connect to this peer?
@@ -399,16 +396,6 @@ static struct GNUNET_PeerIdentity my_identity;
  */
 struct GNUNET_HashCode my_identity_hash;
 
-/**
- * Handle to CORE.
- */
-static struct GNUNET_CORE_Handle *core_api;
-
-/**
- * Handle to ATS connectivity.
- */
-static struct GNUNET_ATS_ConnectivityHandle *ats_ch;
-
 /**
  * Our private key.
  */
@@ -517,10 +504,10 @@ free_connect_info (void *cls,
                  GNUNET_CONTAINER_multipeermap_remove (all_desired_peers,
                                                        peer,
                                                        ci));
-  if (NULL != ci->sh)
+  if (NULL != ci->ph)
   {
-    GNUNET_ATS_connectivity_suggest_cancel (ci->sh);
-    ci->sh = NULL;
+    // ci->u->drop (ci->ph); // FIXME!
+    ci->ph = NULL;
   }
   if (NULL != ci->oh)
   {
@@ -597,14 +584,18 @@ try_connect (const struct GNUNET_PeerIdentity *pid,
                                            h,
                                            &offer_hello_done,
                                            ci);
-  if ( (NULL != ci->sh) &&
+  if ( (NULL != ci->ph) &&
        (ci->strength != strength) )
-    GNUNET_ATS_connectivity_suggest_cancel (ci->sh);
+  {
+    // ci->u_api->drop (ci->ph);
+    ci->ph = NULL;
+  }
   if (ci->strength != strength)
   {
-    ci->sh = GNUNET_ATS_connectivity_suggest (ats_ch,
-                                              pid,
-                                              strength);
+#if FIXME
+    ci->ph = ci->u_api->hold (ci->u_api->cls,
+                              TARGET);
+#endif
     ci->strength = strength;
   }
 }
@@ -719,7 +710,7 @@ send_find_peer_message (void *cls)
     struct GNUNET_CONTAINER_BloomFilter *peer_bf;
 
     bg = GNUNET_BLOCK_group_create (GDS_block_context,
-                                    GNUNET_BLOCK_TYPE_DHT_HELLO,
+                                    GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
                                     GNUNET_CRYPTO_random_u32 (
                                       GNUNET_CRYPTO_QUALITY_WEAK,
                                       UINT32_MAX),
@@ -736,7 +727,7 @@ send_find_peer_message (void *cls)
                                            DHT_BLOOM_SIZE,
                                            GNUNET_CONSTANTS_BLOOMFILTER_K);
     if (GNUNET_OK !=
-        GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
+        GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
                                    GNUNET_DHT_RO_FIND_PEER
                                    | GNUNET_DHT_RO_RECORD_ROUTE,
                                    FIND_PEER_REPLICATION_LEVEL,
@@ -764,18 +755,11 @@ send_find_peer_message (void *cls)
 }
 
 
-/**
- * Method called whenever a peer connects.
- *
- * @param cls closure
- * @param peer peer identity this notification is about
- * @param mq message queue for sending messages to @a peer
- * @return our `struct PeerInfo` for @a peer
- */
-static void *
-handle_core_connect (void *cls,
-                     const struct GNUNET_PeerIdentity *peer,
-                     struct GNUNET_MQ_Handle *mq)
+void
+GDS_u_connect (void *cls,
+               struct GNUNET_DHTU_Target *target,
+               const struct GNUNET_PeerIdentity *pid,
+               void **ctx)
 {
   struct PeerInfo *pi;
   struct PeerBucket *bucket;
@@ -783,23 +767,23 @@ handle_core_connect (void *cls,
   (void) cls;
   /* Check for connect to self message */
   if (0 == GNUNET_memcmp (&my_identity,
-                          peer))
-    return NULL;
+                          pid))
+    return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Connected to peer %s\n",
-              GNUNET_i2s (peer));
+              GNUNET_i2s (pid));
   GNUNET_assert (NULL ==
                  GNUNET_CONTAINER_multipeermap_get (all_connected_peers,
-                                                    peer));
+                                                    pid));
   GNUNET_STATISTICS_update (GDS_stats,
                             "# peers connected",
                             1,
                             GNUNET_NO);
   pi = GNUNET_new (struct PeerInfo);
-  pi->id = peer;
-  pi->mq = mq;
-  GNUNET_CRYPTO_hash (peer,
-                      sizeof(struct GNUNET_PeerIdentity),
+  pi->id = *pid;
+  pi->target = target;
+  GNUNET_CRYPTO_hash (pid,
+                      sizeof(*pid),
                       &pi->phash);
   pi->peer_bucket = find_bucket (&pi->phash);
   GNUNET_assert ( (pi->peer_bucket >= 0) &&
@@ -813,7 +797,7 @@ handle_core_connect (void *cls,
                                (unsigned int) pi->peer_bucket + 1);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_multipeermap_put (all_connected_peers,
-                                                    pi->id,
+                                                    &pi->id,
                                                     pi,
                                                     
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   if (bucket->peers_size <= bucket_size)
@@ -829,39 +813,34 @@ handle_core_connect (void *cls,
     find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message,
                                                NULL);
   }
-  return pi;
+  *ctx = pi;
 }
 
 
 /**
  * Method called whenever a peer disconnects.
  *
- * @param cls closure
- * @param peer peer identity this notification is about
- * @param internal_cls our `struct PeerInfo` for @a peer
+ * @param ctx context
  */
-static void
-handle_core_disconnect (void *cls,
-                        const struct GNUNET_PeerIdentity *peer,
-                        void *internal_cls)
+void
+GDS_u_disconnect (void *ctx)
 {
-  struct PeerInfo *to_remove = internal_cls;
+  struct PeerInfo *to_remove = ctx;
   struct PeerBucket *bucket;
 
-  (void) cls;
   /* Check for disconnect from self message (on shutdown) */
   if (NULL == to_remove)
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Disconnected from peer %s\n",
-              GNUNET_i2s (peer));
+              GNUNET_i2s (&to_remove->id));
   GNUNET_STATISTICS_update (GDS_stats,
                             "# peers connected",
                             -1,
                             GNUNET_NO);
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multipeermap_remove (all_connected_peers,
-                                                       peer,
+                                                       &to_remove->id,
                                                        to_remove));
   if ( (0 == GNUNET_CONTAINER_multipeermap_size (all_connected_peers)) &&
        (GNUNET_YES != disable_try_connect))
@@ -1073,7 +1052,7 @@ select_peer (const struct GNUNET_HashCode *key,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Excluded peer `%s' due to BF match in greedy routing 
for %s\n",
-                      GNUNET_i2s (pos->id),
+                      GNUNET_i2s (&pos->id),
                       GNUNET_h2s (key));
           continue;
         }
@@ -1140,7 +1119,7 @@ select_peer (const struct GNUNET_HashCode *key,
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Selected peer `%s' in greedy routing for %s\n",
-                GNUNET_i2s (chosen->id),
+                GNUNET_i2s (&chosen->id),
                 GNUNET_h2s (key));
     return chosen;
   } /* end of 'greedy' peer selection */
@@ -1170,7 +1149,7 @@ select_peer (const struct GNUNET_HashCode *key,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Excluded peer `%s' due to BF match in random routing 
for %s\n",
-                      GNUNET_i2s (pos->id),
+                      GNUNET_i2s (&pos->id),
                       GNUNET_h2s (key));
           continue;             /* Ignore filtered peers */
         }
@@ -1209,7 +1188,7 @@ select_peer (const struct GNUNET_HashCode *key,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Selected peer `%s' in random routing for %s\n",
-                      GNUNET_i2s (pos->id),
+                      GNUNET_i2s (&pos->id),
                       GNUNET_h2s (key));
           return pos;
         }
@@ -1371,6 +1350,7 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
     struct PeerPutMessage *ppm;
     struct GNUNET_DHT_PathElement *pp;
 
+#if FIXME_LEGACY
     if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER)
     {
       /* skip */
@@ -1381,11 +1361,12 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
       skip_count++;
       continue;
     }
+#endif
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Routing PUT for %s after %u hops to %s\n",
                 GNUNET_h2s (&bd->key),
                 (unsigned int) hop_count,
-                GNUNET_i2s (target->id));
+                GNUNET_i2s (&target->id));
     env = GNUNET_MQ_msg_extra (ppm,
                                msize,
                                GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
@@ -1417,15 +1398,17 @@ GDS_NEIGHBOURS_handle_put (const struct 
GDS_DATACACHE_BlockData *bd,
                  bd->data_size,
                  bd->expiration_time,
                  &pp[put_path_length - 1].pred,
-                 target->id,
+                 &target->id,
                  &pp[put_path_length - 1].sig);
     }
 
     GNUNET_memcpy (&pp[put_path_length],
                    bd->data,
                    bd->data_size);
+#if FIXME
     GNUNET_MQ_send (target->mq,
                     env);
+#endif
   }
   GNUNET_free (targets);
   GNUNET_STATISTICS_update (GDS_stats,
@@ -1508,6 +1491,7 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
     struct PeerGetMessage *pgm;
     char *xq;
 
+#if FIXME
     if (GNUNET_MQ_get_length (target->mq) >= MAXIMUM_PENDING_PER_PEER)
     {
       /* skip */
@@ -1518,11 +1502,12 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
       skip_count++;
       continue;
     }
+#endif
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Routing GET for %s after %u hops to %s\n",
                 GNUNET_h2s (key),
                 (unsigned int) hop_count,
-                GNUNET_i2s (target->id));
+                GNUNET_i2s (&target->id));
     env = GNUNET_MQ_msg_extra (pgm,
                                msize,
                                GNUNET_MESSAGE_TYPE_DHT_P2P_GET);
@@ -1547,8 +1532,10 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
     GNUNET_memcpy (&xq[xquery_size],
                    reply_bf,
                    reply_bf_size);
+#if FIXME
     GNUNET_MQ_send (target->mq,
                     env);
+#endif
   }
   GNUNET_STATISTICS_update (GDS_stats,
                             "# GET messages queued for transmission",
@@ -1622,6 +1609,7 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
     GNUNET_break (0);
     return;
   }
+#if FIXME
   if (GNUNET_MQ_get_length (pi->mq) >= MAXIMUM_PENDING_PER_PEER)
   {
     /* skip */
@@ -1634,11 +1622,11 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
                 GNUNET_h2s (&bd->key));
     return;
   }
-
+#endif
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Forwarding reply for key %s to peer %s\n",
               GNUNET_h2s (query_hash),
-              GNUNET_i2s (pi->id));
+              GNUNET_i2s (&pi->id));
   GNUNET_STATISTICS_update (GDS_stats,
                             "# RESULT messages queued for transmission",
                             1,
@@ -1668,36 +1656,16 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi,
                bd->data_size,
                bd->expiration_time,
                &paths[ppl + get_path_length - 1].pred,
-               pi->id,
+               &pi->id,
                &paths[ppl + get_path_length - 1].sig);
   }
   GNUNET_memcpy (&paths[ppl + get_path_length],
                  bd->data,
                  bd->data_size);
+#if FIXME
   GNUNET_MQ_send (pi->mq,
                   env);
-}
-
-
-/**
- * To be called on core init.
- *
- * @param cls service closure
- * @param identity the public identity of this peer
- */
-static void
-core_init (void *cls,
-           const struct GNUNET_PeerIdentity *identity)
-{
-  (void) cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "CORE called, I am %s\n",
-              GNUNET_i2s (identity));
-  my_identity = *identity;
-  GNUNET_CRYPTO_hash (identity,
-                      sizeof(struct GNUNET_PeerIdentity),
-                      &my_identity_hash);
-  GNUNET_SERVICE_resume (GDS_service);
+#endif
 }
 
 
@@ -1759,7 +1727,7 @@ handle_dht_p2p_put (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "PUT for `%s' from %s\n",
               GNUNET_h2s (&put->key),
-              GNUNET_i2s (peer->id));
+              GNUNET_i2s (&peer->id));
   if (GNUNET_TIME_absolute_is_past (bd.expiration_time))
   {
     GNUNET_STATISTICS_update (GDS_stats,
@@ -1841,7 +1809,7 @@ handle_dht_p2p_put (void *cls,
         }
         GNUNET_break (0 !=
                       GNUNET_memcmp (&pp[i].pred,
-                                     peer->id));
+                                     &peer->id));
       }
       if (0 !=
           GNUNET_DHT_verify_path (&bd.key,
@@ -1860,7 +1828,7 @@ handle_dht_p2p_put (void *cls,
       GNUNET_memcpy (pp,
                      put_path,
                      putlen * sizeof(struct GNUNET_DHT_PathElement));
-      pp[putlen].pred = *peer->id;
+      pp[putlen].pred = peer->id;
       /* zero-out signature, not valid until we actually do forward! */
       memset (&pp[putlen].sig,
               0,
@@ -1924,7 +1892,7 @@ handle_find_peer (struct PeerInfo *pi,
   struct PeerInfo *peer;
   unsigned int choice;
   struct GDS_DATACACHE_BlockData bd = {
-    .type = GNUNET_BLOCK_TYPE_DHT_HELLO
+    .type = GNUNET_BLOCK_TYPE_DHT_URL_HELLO
   };
 
   /* first, check about our own HELLO */
@@ -1939,7 +1907,7 @@ handle_find_peer (struct PeerInfo *pi,
     GNUNET_break (bd.data_size >= sizeof(struct GNUNET_MessageHeader));
     if (GNUNET_BLOCK_REPLY_OK_MORE ==
         GNUNET_BLOCK_check_reply (GDS_block_context,
-                                  GNUNET_BLOCK_TYPE_DHT_HELLO,
+                                  GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
                                   bg,
                                   &my_identity_hash,
                                   NULL, 0,
@@ -2003,12 +1971,12 @@ handle_find_peer (struct PeerInfo *pi,
         return;                 /* no non-masked peer available */
       if (NULL == peer)
         peer = bucket->head;
-      hello = GDS_HELLO_get (peer->id);
+      hello = GDS_HELLO_get (&peer->id);
     } while ( (NULL == hello) ||
               (GNUNET_BLOCK_REPLY_OK_MORE !=
                GNUNET_BLOCK_check_reply (
                  GDS_block_context,
-                 GNUNET_BLOCK_TYPE_DHT_HELLO,
+                 GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
                  bg,
                  &peer->phash,
                  NULL, 0, /* xquery */
@@ -2170,7 +2138,7 @@ handle_dht_p2p_get (void *cls,
     }
 
     /* remember request for routing replies */
-    GDS_ROUTING_add (peer->id,
+    GDS_ROUTING_add (&peer->id,
                      type,
                      bg,      /* bg now owned by routing, but valid at least 
until end of this function! */
                      options,
@@ -2363,7 +2331,7 @@ handle_dht_p2p_result (void *cls,
   }
 
   /* if we got a HELLO, consider it for our own routing table */
-  if (GNUNET_BLOCK_TYPE_DHT_HELLO == bd.type)
+  if (GNUNET_BLOCK_TYPE_DHT_URL_HELLO == bd.type)
   {
     const struct GNUNET_MessageHeader *h = bd.data;
     struct GNUNET_PeerIdentity pid;
@@ -2397,7 +2365,7 @@ handle_dht_p2p_result (void *cls,
      so, truncate it instead of expanding. */
   for (unsigned int i = 0; i <= get_path_length; i++)
     if (0 == GNUNET_memcmp (&get_path[i].pred,
-                            peer->id))
+                            &peer->id))
     {
       process_reply_with_path (&bd,
                                &prm->key,
@@ -2412,7 +2380,7 @@ handle_dht_p2p_result (void *cls,
     GNUNET_memcpy (xget_path,
                    get_path,
                    get_path_length * sizeof(struct GNUNET_DHT_PathElement));
-    xget_path[get_path_length].pred = *peer->id;
+    xget_path[get_path_length].pred = peer->id;
     memset (&xget_path[get_path_length].sig,
             0,
             sizeof (xget_path[get_path_length].sig));
@@ -2423,24 +2391,57 @@ handle_dht_p2p_result (void *cls,
 }
 
 
-enum GNUNET_GenericReturnValue
-GDS_NEIGHBOURS_init ()
+void
+GDS_u_receive (void *cls,
+               void **tctx,
+               void **sctx,
+               const void *message,
+               size_t message_size)
 {
+  struct PeerInfo *pi = *tctx;
   struct GNUNET_MQ_MessageHandler core_handlers[] = {
     GNUNET_MQ_hd_var_size (dht_p2p_get,
                            GNUNET_MESSAGE_TYPE_DHT_P2P_GET,
                            struct PeerGetMessage,
-                           NULL),
+                           pi),
     GNUNET_MQ_hd_var_size (dht_p2p_put,
                            GNUNET_MESSAGE_TYPE_DHT_P2P_PUT,
                            struct PeerPutMessage,
-                           NULL),
+                           pi),
     GNUNET_MQ_hd_var_size (dht_p2p_result,
                            GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT,
                            struct PeerResultMessage,
-                           NULL),
+                           pi),
     GNUNET_MQ_handler_end ()
   };
+  const struct GNUNET_MessageHeader *mh = message;
+
+  (void) cls; /* the 'struct Underlay' */
+  (void) sctx; /* our receiver address */
+  if (message_size < sizeof (*mh))
+  {
+    GNUNET_break_op (0);
+    return;
+  }
+  if (message_size != ntohs (mh->size))
+  {
+    GNUNET_break_op (0);
+    return;
+  }
+  if (GNUNET_OK !=
+      GNUNET_MQ_handle_message (core_handlers,
+                                mh))
+  {
+    GNUNET_break_op (0);
+    return;
+  }
+}
+
+
+enum GNUNET_GenericReturnValue
+GDS_NEIGHBOURS_init ()
+{
+
   unsigned long long temp_config_num;
 
   disable_try_connect
@@ -2482,16 +2483,12 @@ GDS_NEIGHBOURS_init ()
     }
     GNUNET_free (keyfile);
   }
+  GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key,
+                                      &my_identity.public_key);
+  GNUNET_CRYPTO_hash (&my_identity,
+                      sizeof(struct GNUNET_PeerIdentity),
+                      &my_identity_hash);
 
-  ats_ch = GNUNET_ATS_connectivity_init (GDS_cfg);
-  core_api = GNUNET_CORE_connect (GDS_cfg,
-                                  NULL,
-                                  &core_init,
-                                  &handle_core_connect,
-                                  &handle_core_disconnect,
-                                  core_handlers);
-  if (NULL == core_api)
-    return GNUNET_SYSERR;
   all_connected_peers = GNUNET_CONTAINER_multipeermap_create (256,
                                                               GNUNET_YES);
   all_desired_peers = GNUNET_CONTAINER_multipeermap_create (256,
@@ -2503,10 +2500,8 @@ GDS_NEIGHBOURS_init ()
 void
 GDS_NEIGHBOURS_done ()
 {
-  if (NULL == core_api)
+  if (NULL == all_connected_peers)
     return;
-  GNUNET_CORE_disconnect (core_api);
-  core_api = NULL;
   GNUNET_assert (0 ==
                  GNUNET_CONTAINER_multipeermap_size (all_connected_peers));
   GNUNET_CONTAINER_multipeermap_destroy (all_connected_peers);
@@ -2516,8 +2511,6 @@ GDS_NEIGHBOURS_done ()
                                          NULL);
   GNUNET_CONTAINER_multipeermap_destroy (all_desired_peers);
   all_desired_peers = NULL;
-  GNUNET_ATS_connectivity_done (ats_ch);
-  ats_ch = NULL;
   GNUNET_assert (NULL == find_peer_task);
 }
 
diff --git a/src/dht/gnunet-service-dht_neighbours.h 
b/src/dht/gnunet-service-dht_neighbours.h
index 35bbb125d..e1a553f06 100644
--- a/src/dht/gnunet-service-dht_neighbours.h
+++ b/src/dht/gnunet-service-dht_neighbours.h
@@ -30,6 +30,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_block_lib.h"
 #include "gnunet_dht_service.h"
+#include "gnunet_dhtu_plugin.h"
 #include "gnunet-service-dht_datacache.h"
 
 /**
@@ -136,6 +137,51 @@ GDS_am_closest_peer (const struct GNUNET_HashCode *key,
                      const struct GNUNET_CONTAINER_BloomFilter *bloom);
 
 
+/**
+ * Function to call when we connect to a peer and can henceforth transmit to
+ * that peer.
+ *
+ * @param cls the closure
+ * @param target handle to the target,
+ *    pointer will remain valid until @e disconnect_cb is called
+ * @para pid peer identity,
+ *    pointer will remain valid until @e disconnect_cb is called
+ * @param[out] ctx storage space for DHT to use in association with this target
+ */
+void
+GDS_u_connect (void *cls,
+               struct GNUNET_DHTU_Target *target,
+               const struct GNUNET_PeerIdentity *pid,
+               void **ctx);
+
+/**
+ * Function to call when we disconnected from a peer and can henceforth
+ * cannot transmit to that peer anymore.
+ *
+ * @param[in] ctx storage space used by the DHT in association with this target
+ */
+void
+GDS_u_disconnect (void *ctx);
+
+
+/**
+ * Function to call when we receive a message.
+ *
+ * @param cls the closure
+ * @param origin where the message originated from
+ * @param[in,out] tctx ctx of target address where we received the message from
+ * @param[in,out] sctx ctx of our own source address at which we received the 
message
+ * @param message the message we received @param message_size number of
+ * bytes in @a message
+ */
+void
+GDS_u_receive (void *cls,
+               void **tctx,
+               void **sctx,
+               const void *message,
+               size_t message_size);
+
+
 /**
  * Initialize neighbours subsystem.
  *
diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c
deleted file mode 100644
index 58f18816a..000000000
--- a/src/dht/gnunet-service-dht_nse.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-     This file is part of GNUnet.
-     Copyright (C) 2009, 2010, 2011 GNUnet e.V.
-
-     GNUnet is free software: you can redistribute it and/or modify it
-     under the terms of the GNU Affero General Public License as published
-     by the Free Software Foundation, either version 3 of the License,
-     or (at your option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     Affero General Public License for more details.
-
-     You should have received a copy of the GNU Affero General Public License
-     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-     SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file dht/gnunet-service-dht_nse.c
- * @brief GNUnet DHT integration with NSE
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_nse_service.h"
-#include "gnunet-service-dht.h"
-#include "gnunet-service-dht_nse.h"
-
-/**
- * log of the current network size estimate, used as the point where
- * we switch between random and deterministic routing.  Default
- * value of 4.0 is used if NSE module is not available (i.e. not
- * configured).
- */
-static double log_of_network_size_estimate = 4.0;
-
-/**
- * Network size estimation handle.
- */
-static struct GNUNET_NSE_Handle *nse;
-
-
-/**
- * Callback that is called when network size estimate is updated.
- *
- * @param cls closure
- * @param timestamp time when the estimate was received from the server (or 
created by the server)
- * @param logestimate the log(Base 2) value of the current network size 
estimate
- * @param std_dev standard deviation for the estimate
- *
- */
-static void
-update_network_size_estimate (void *cls,
-                              struct GNUNET_TIME_Absolute timestamp,
-                              double logestimate,
-                              double std_dev)
-{
-  GNUNET_STATISTICS_update (GDS_stats,
-                            "# Network size estimates received",
-                            1, GNUNET_NO);
-  /* do not allow estimates < 0.5 */
-  log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate);
-}
-
-
-/**
- * Return the log of the current network size estimate.
- *
- * @return log of NSE
- */
-double
-GDS_NSE_get ()
-{
-  return log_of_network_size_estimate;
-}
-
-
-/**
- * Initialize NSE subsystem.
- */
-void
-GDS_NSE_init ()
-{
-  unsigned long long hops;
-
-  if ( (GNUNET_YES ==
-        GNUNET_CONFIGURATION_have_value (GDS_cfg,
-                                         "dht",
-                                         "FORCE_NSE")) &&
-       (GNUNET_OK ==
-        GNUNET_CONFIGURATION_get_value_number (GDS_cfg,
-                                               "dht",
-                                               "FORCE_NSE",
-                                               &hops)) )
-  {
-    log_of_network_size_estimate = (double) hops;
-    return;
-  }
-  nse = GNUNET_NSE_connect (GDS_cfg,
-                            &update_network_size_estimate,
-                            NULL);
-}
-
-
-/**
- * Shutdown NSE subsystem.
- */
-void
-GDS_NSE_done ()
-{
-  if (NULL != nse)
-  {
-    GNUNET_NSE_disconnect (nse);
-    nse = NULL;
-  }
-}
-
-
-/* end of gnunet-service-dht_nse.c */
diff --git a/src/dht/gnunet-service-dht_nse.h b/src/dht/gnunet-service-dht_nse.h
deleted file mode 100644
index e99389e74..000000000
--- a/src/dht/gnunet-service-dht_nse.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-     This file is part of GNUnet.
-     Copyright (C) 2011 GNUnet e.V.
-
-     GNUnet is free software: you can redistribute it and/or modify it
-     under the terms of the GNU Affero General Public License as published
-     by the Free Software Foundation, either version 3 of the License,
-     or (at your option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     Affero General Public License for more details.
-
-     You should have received a copy of the GNU Affero General Public License
-     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-     SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file dht/gnunet-service-dht_nse.h
- * @brief GNUnet DHT integration with NSE
- * @author Christian Grothoff
- */
-#ifndef GNUNET_SERVICE_DHT_NSE_H
-#define GNUNET_SERVICE_DHT_NSE_H
-
-
-/**
- * Return the log of the current network size estimate.
- *
- * @return log of NSE
- */
-double
-GDS_NSE_get (void);
-
-
-/**
- * Initialize NSE subsystem.
- */
-void
-GDS_NSE_init (void);
-
-
-/**
- * Shutdown NSE subsystem.
- */
-void
-GDS_NSE_done (void);
-
-#endif
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 7c6fb9ed6..a6a2104ce 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -116,45 +116,51 @@ block_plugin_dht_evaluate (void *cls,
                            const void *reply_block,
                            size_t reply_block_size)
 {
-  const struct GNUNET_HELLO_Message *hello;
-  struct GNUNET_PeerIdentity pid;
-  const struct GNUNET_MessageHeader *msg;
-  struct GNUNET_HashCode phash;
-
-  if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
-    return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
-  if (0 != xquery_size)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-  }
-  if (NULL == reply_block)
-    return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
-  if (reply_block_size < sizeof(struct GNUNET_MessageHeader))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
-  }
-  msg = reply_block;
-  if (reply_block_size != ntohs (msg->size))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
-  }
-  hello = reply_block;
-  if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
+  switch (type)
   {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  case GNUNET_BLOCK_TYPE_DHT_HELLO:
+    {
+      const struct GNUNET_HELLO_Message *hello;
+      struct GNUNET_PeerIdentity pid;
+      const struct GNUNET_MessageHeader *msg;
+      struct GNUNET_HashCode phash;
+
+      if (0 != xquery_size)
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
+      }
+      if (NULL == reply_block)
+        return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+      if (reply_block_size < sizeof(struct GNUNET_MessageHeader))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+      }
+      msg = reply_block;
+      if (reply_block_size != ntohs (msg->size))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+      }
+      hello = reply_block;
+      if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+      }
+      GNUNET_CRYPTO_hash (&pid,
+                          sizeof(pid),
+                          &phash);
+      if (GNUNET_YES ==
+          GNUNET_BLOCK_GROUP_bf_test_and_set (group,
+                                              &phash))
+        return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+      return GNUNET_BLOCK_EVALUATION_OK_MORE;
+    }
+  default:
+    return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
   }
-  GNUNET_CRYPTO_hash (&pid,
-                      sizeof(pid),
-                      &phash);
-  if (GNUNET_YES ==
-      GNUNET_BLOCK_GROUP_bf_test_and_set (group,
-                                          &phash))
-    return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
-  return GNUNET_BLOCK_EVALUATION_OK_MORE;
 }
 
 
@@ -171,19 +177,23 @@ block_plugin_dht_evaluate (void *cls,
  */
 static enum GNUNET_GenericReturnValue
 block_plugin_dht_check_query (void *cls,
-                                    enum GNUNET_BLOCK_Type type,
-                                    const struct GNUNET_HashCode *query,
-                                    const void *xquery,
-                                    size_t xquery_size)
+                              enum GNUNET_BLOCK_Type type,
+                              const struct GNUNET_HashCode *query,
+                              const void *xquery,
+                              size_t xquery_size)
 {
-  if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
-    return GNUNET_SYSERR;
-  if (0 != xquery_size)
+  switch (type)
   {
-    GNUNET_break_op (0);
-    return GNUNET_NO;
+  case GNUNET_BLOCK_TYPE_DHT_HELLO:
+    if (0 != xquery_size)
+    {
+      GNUNET_break_op (0);
+      return GNUNET_NO;
+    }
+    return GNUNET_OK;
+  default:
+    return GNUNET_SYSERR;
   }
-  return GNUNET_OK;
 }
 
 
@@ -199,37 +209,43 @@ block_plugin_dht_check_query (void *cls,
  */
 static enum GNUNET_GenericReturnValue
 block_plugin_dht_check_block (void *cls,
-                                    enum GNUNET_BLOCK_Type type,
-                                    const struct GNUNET_HashCode *query,
-                                    const void *block,
-                                    size_t block_size)
+                              enum GNUNET_BLOCK_Type type,
+                              const struct GNUNET_HashCode *query,
+                              const void *block,
+                              size_t block_size)
 {
-  const struct GNUNET_HELLO_Message *hello;
-  struct GNUNET_PeerIdentity pid;
-  const struct GNUNET_MessageHeader *msg;
-
-  if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
-    return GNUNET_SYSERR;
-  if (block_size < sizeof(struct GNUNET_MessageHeader))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_NO;
-  }
-  msg = block;
-  if (block_size != ntohs (msg->size))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_NO;
-  }
-  hello = block;
-  if (GNUNET_OK !=
-      GNUNET_HELLO_get_id (hello,
-                           &pid))
+  switch (type)
   {
-    GNUNET_break_op (0);
-    return GNUNET_NO;
+  case GNUNET_BLOCK_TYPE_DHT_HELLO:
+    {
+      const struct GNUNET_HELLO_Message *hello;
+      struct GNUNET_PeerIdentity pid;
+      const struct GNUNET_MessageHeader *msg;
+
+      if (block_size < sizeof(struct GNUNET_MessageHeader))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_NO;
+      }
+      msg = block;
+      if (block_size != ntohs (msg->size))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_NO;
+      }
+      hello = block;
+      if (GNUNET_OK !=
+          GNUNET_HELLO_get_id (hello,
+                               &pid))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_NO;
+      }
+      return GNUNET_OK;
+    }
+  default:
+    return GNUNET_SYSERR;
   }
-  return GNUNET_OK;
 }
 
 
@@ -251,49 +267,55 @@ block_plugin_dht_check_block (void *cls,
  */
 static enum GNUNET_BLOCK_ReplyEvaluationResult
 block_plugin_dht_check_reply (
-                                        void *cls,
-                                        enum GNUNET_BLOCK_Type type,
-                                    struct GNUNET_BLOCK_Group *group,
-                                    const struct GNUNET_HashCode *query,
-                                    const void *xquery,
-                                    size_t xquery_size,
-                                    const void *reply_block,
-                                    size_t reply_block_size)
+  void *cls,
+  enum GNUNET_BLOCK_Type type,
+  struct GNUNET_BLOCK_Group *group,
+  const struct GNUNET_HashCode *query,
+  const void *xquery,
+  size_t xquery_size,
+  const void *reply_block,
+  size_t reply_block_size)
 {
-  const struct GNUNET_HELLO_Message *hello;
-  struct GNUNET_PeerIdentity pid;
-  const struct GNUNET_MessageHeader *msg;
-  struct GNUNET_HashCode phash;
-
-  if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
-    return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
-  if (reply_block_size < sizeof(struct GNUNET_MessageHeader))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_REPLY_INVALID;
-  }
-  msg = reply_block;
-  if (reply_block_size != ntohs (msg->size))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_REPLY_INVALID;
-  }
-  hello = reply_block;
-  if (GNUNET_OK !=
-      GNUNET_HELLO_get_id (hello,
-                           &pid))
+  switch (type)
   {
-    GNUNET_break_op (0);
-    return GNUNET_BLOCK_REPLY_INVALID;
+  case GNUNET_BLOCK_TYPE_DHT_HELLO:
+    {
+      const struct GNUNET_HELLO_Message *hello;
+      struct GNUNET_PeerIdentity pid;
+      const struct GNUNET_MessageHeader *msg;
+      struct GNUNET_HashCode phash;
+
+      if (reply_block_size < sizeof(struct GNUNET_MessageHeader))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_REPLY_INVALID;
+      }
+      msg = reply_block;
+      if (reply_block_size != ntohs (msg->size))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_REPLY_INVALID;
+      }
+      hello = reply_block;
+      if (GNUNET_OK !=
+          GNUNET_HELLO_get_id (hello,
+                               &pid))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_BLOCK_REPLY_INVALID;
+      }
+      GNUNET_CRYPTO_hash (&pid,
+                          sizeof(pid),
+                          &phash);
+      if (GNUNET_YES ==
+          GNUNET_BLOCK_GROUP_bf_test_and_set (group,
+                                              &phash))
+        return GNUNET_BLOCK_REPLY_OK_DUPLICATE;
+      return GNUNET_BLOCK_REPLY_OK_MORE;
+    }
+  default:
+    return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
   }
-  GNUNET_CRYPTO_hash (&pid,
-                      sizeof(pid),
-                      &phash);
-  if (GNUNET_YES ==
-      GNUNET_BLOCK_GROUP_bf_test_and_set (group,
-                                          &phash))
-    return GNUNET_BLOCK_REPLY_OK_DUPLICATE;
-  return GNUNET_BLOCK_REPLY_OK_MORE;
 }
 
 
@@ -315,41 +337,47 @@ block_plugin_dht_get_key (void *cls,
                           size_t block_size,
                           struct GNUNET_HashCode *key)
 {
-  const struct GNUNET_MessageHeader *msg;
-  const struct GNUNET_HELLO_Message *hello;
-  struct GNUNET_PeerIdentity *pid;
-
-  if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
-    return GNUNET_SYSERR;
-  if (block_size < sizeof(struct GNUNET_MessageHeader))
-  {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
-                     "block-dht",
-                     _ ("Block not of type %u\n"),
-                     GNUNET_BLOCK_TYPE_DHT_HELLO);
-    return GNUNET_NO;
-  }
-  msg = block;
-  if (block_size != ntohs (msg->size))
-  {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
-                     "block-dht",
-                     _ ("Size mismatch for block with type %u\n"),
-                     GNUNET_BLOCK_TYPE_DHT_HELLO);
-    return GNUNET_NO;
-  }
-  hello = block;
-  memset (key, 0, sizeof(*key));
-  pid = (struct GNUNET_PeerIdentity *) key;
-  if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid))
+  switch (type)
   {
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
-                     "block-dht",
-                     _ ("Block of type %u is malformed\n"),
-                     GNUNET_BLOCK_TYPE_DHT_HELLO);
-    return GNUNET_NO;
+  case GNUNET_BLOCK_TYPE_DHT_HELLO:
+    {
+      const struct GNUNET_MessageHeader *msg;
+      const struct GNUNET_HELLO_Message *hello;
+      struct GNUNET_PeerIdentity *pid;
+
+      if (block_size < sizeof(struct GNUNET_MessageHeader))
+      {
+        GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                         "block-dht",
+                         _ ("Block not of type %u\n"),
+                         GNUNET_BLOCK_TYPE_DHT_HELLO);
+        return GNUNET_NO;
+      }
+      msg = block;
+      if (block_size != ntohs (msg->size))
+      {
+        GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                         "block-dht",
+                         _ ("Size mismatch for block with type %u\n"),
+                         GNUNET_BLOCK_TYPE_DHT_HELLO);
+        return GNUNET_NO;
+      }
+      hello = block;
+      memset (key, 0, sizeof(*key));
+      pid = (struct GNUNET_PeerIdentity *) key;
+      if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid))
+      {
+        GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                         "block-dht",
+                         _ ("Block of type %u is malformed\n"),
+                         GNUNET_BLOCK_TYPE_DHT_HELLO);
+        return GNUNET_NO;
+      }
+      return GNUNET_OK;
+    }
+  default:
+    return GNUNET_SYSERR;
   }
-  return GNUNET_OK;
 }
 
 
@@ -361,6 +389,7 @@ libgnunet_plugin_block_dht_init (void *cls)
 {
   static enum GNUNET_BLOCK_Type types[] = {
     GNUNET_BLOCK_TYPE_DHT_HELLO,
+    // FIXME: add GNUNET_BLOCK_TYPE_DHT_URL_HELLO,
     GNUNET_BLOCK_TYPE_ANY       /* end of list */
   };
   struct GNUNET_BLOCK_PluginFunctions *api;
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index 2163af941..a75c47ce3 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -69,11 +69,6 @@ struct HelloHandle
 struct GNUNET_DHTU_Source
 {
 
-  /**
-   * Hash of @e pid, position of this peer in the DHT overlay.
-   */
-  struct GNUNET_DHTU_HashKey id;
-
   /**
    * Application context for this source.
    */
@@ -124,11 +119,6 @@ struct GNUNET_DHTU_Target
    */
   struct GNUNET_PeerIdentity pid;
 
-  /**
-   * Hash of @e pid, position of this peer in the DHT overlay.
-   */
-  struct GNUNET_DHTU_HashKey id;
-
   /**
    * Preference counter, length of the @a ph_head DLL.
    */
@@ -240,10 +230,12 @@ hello_offered_cb (void *cls)
  * Request creation of a session with a peer at the given @a address.
  *
  * @param cls closure (internal context for the plugin)
+ * @param pid target identity of the peer to connect to
  * @param address target address to connect to
  */
 static void
 ip_try_connect (void *cls,
+                struct GNUNET_PeerIdentity *pid,
                 const char *address)
 {
   struct Plugin *plugin = cls;
@@ -251,16 +243,13 @@ ip_try_connect (void *cls,
   struct HelloHandle *hh;
   struct GNUNET_CRYPTO_EddsaPublicKey pubkey;
 
+  (void) pid; /* will be needed with future address URIs */
   if (GNUNET_OK !=
       GNUNET_HELLO_parse_uri (address,
                               &pubkey,
                               &hello,
                               &GPI_plugins_find))
-  {
-    GNUNET_break (0);
     return;
-  }
-
   hh = GNUNET_new (struct HelloHandle);
   hh->plugin = plugin;
   GNUNET_CONTAINER_DLL_insert (plugin->hh_head,
@@ -394,12 +383,9 @@ core_connect_cb (void *cls,
   target->plugin = plugin;
   target->mq = mq;
   target->pid = *peer;
-  GNUNET_CRYPTO_hash (peer,
-                      sizeof (*peer),
-                      &target->id.sha512);
   plugin->env->connect_cb (plugin->env->cls,
                            target,
-                           &target->id,
+                           &target->pid,
                            &target->app_ctx);
   return target;
 }
@@ -461,11 +447,7 @@ peerinfo_cb (void *cls,
                                    &GPI_plugins_find);
   if (NULL == addr)
     return;
-  GNUNET_CRYPTO_hash (peer,
-                      sizeof (*peer),
-                      &plugin->src.id.sha512);
   plugin->env->address_add_cb (plugin->env->cls,
-                               &plugin->src.id,
                                addr,
                                &plugin->src,
                                &plugin->src.app_ctx);
@@ -584,6 +566,10 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls)
   }
   if (NULL != plugin->nse)
     GNUNET_NSE_disconnect (plugin->nse);
+  plugin->env->network_size_cb (plugin->env->cls,
+                                GNUNET_TIME_UNIT_FOREVER_ABS,
+                                0.0,
+                                0.0);
   if (NULL != plugin->core)
     GNUNET_CORE_disconnect (plugin->core);
   if (NULL != plugin->ats)
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 8eec6294b..7c01e5baf 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     Copyright (C) 2021 GNUnet e.V.
+     Copyright (C) 2021, 2022 GNUnet e.V.
 
      GNUnet is free software: you can redistribute it and/or modify it
      under the terms of the GNU Affero General Public License as published
@@ -55,18 +55,13 @@ struct GNUNET_DHTU_Source
    */
   struct GNUNET_DHTU_Source *prev;
 
-  /**
-   * Position of this peer in the DHT.
-   */
-  struct GNUNET_DHTU_HashKey id;
-
   /**
    * Application context for this source.
    */
   void *app_ctx;
 
   /**
-   * Address in URL form ("ip+udp://$IP:$PORT")
+   * Address in URL form ("ip+udp://$PID/$IP:$PORT")
    */
   char *address;
 
@@ -121,9 +116,9 @@ struct GNUNET_DHTU_Target
   struct GNUNET_DHTU_PreferenceHandle *ph_tail;
 
   /**
-   * Position of this peer in the DHT.
+   * Peer's identity.
    */
-  struct GNUNET_DHTU_HashKey id;
+  struct GNUNET_PeerIdentity pid;
 
   /**
    * Target IP address.
@@ -217,14 +212,19 @@ struct Plugin
   char *port;
 
   /**
-   * How often have we scanned for IPs?
+   * My UDP socket.
    */
-  unsigned int scan_generation;
+  struct GNUNET_NETWORK_Handle *sock;
 
   /**
-   * My UDP socket.
+   * My identity.
    */
-  struct GNUNET_NETWORK_Handle *sock;
+  struct GNUNET_PeerIdentity my_id;
+
+  /**
+   * How often have we scanned for IPs?
+   */
+  unsigned int scan_generation;
 };
 
 
@@ -232,12 +232,14 @@ struct Plugin
  * Create a target to which we may send traffic.
  *
  * @param plugin our plugin
+ * @param pid presumed identity of the target
  * @param addr target address
  * @param addrlen number of bytes in @a addr
  * @return new target object
  */
 static struct GNUNET_DHTU_Target *
 create_target (struct Plugin *plugin,
+               const struct GNUNET_PeerIdentity *pid,
                const struct sockaddr *addr,
                socklen_t addrlen)
 {
@@ -275,42 +277,16 @@ create_target (struct Plugin *plugin,
   }
   dst = GNUNET_new (struct GNUNET_DHTU_Target);
   dst->addrlen = addrlen;
+  dst->pid = *pid;
   memcpy (&dst->addr,
           addr,
           addrlen);
-  switch (addr->sa_family)
-  {
-  case AF_INET:
-    {
-      const struct sockaddr_in *s4 = (const struct sockaddr_in *) addr;
-
-      GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
-      GNUNET_CRYPTO_hash (&s4->sin_addr,
-                          sizeof (struct in_addr),
-                          &dst->id.sha512);
-    }
-    break;
-  case AF_INET6:
-    {
-      const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *) addr;
-
-      GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
-      GNUNET_CRYPTO_hash (&s6->sin6_addr,
-                          sizeof (struct in6_addr),
-                          &dst->id.sha512);
-    }
-    break;
-  default:
-    GNUNET_break (0);
-    GNUNET_free (dst);
-    return NULL;
-  }
   GNUNET_CONTAINER_DLL_insert (plugin->dst_head,
                                plugin->dst_tail,
                                dst);
   plugin->env->connect_cb (plugin->env->cls,
                            dst,
-                           &dst->id,
+                           &dst->pid,
                            &dst->app_ctx);
   return dst;
 }
@@ -321,6 +297,7 @@ create_target (struct Plugin *plugin,
  * create one!
  *
  * @param plugin the plugin handle
+ * @param pid presumed identity of the target
  * @param src source target is from, or NULL if unknown
  * @param addr socket address to find
  * @param addrlen number of bytes in @a addr
@@ -328,6 +305,7 @@ create_target (struct Plugin *plugin,
  */
 static struct GNUNET_DHTU_Target *
 find_target (struct Plugin *plugin,
+             const struct GNUNET_PeerIdentity *pid,
              const void *addr,
              size_t addrlen)
 {
@@ -342,6 +320,7 @@ find_target (struct Plugin *plugin,
   if (NULL == dst)
   {
     dst = create_target (plugin,
+                         pid,
                          (const struct sockaddr *) addr,
                          addrlen);
     GNUNET_assert (GNUNET_YES ==
@@ -370,10 +349,12 @@ find_target (struct Plugin *plugin,
  * Request creation of a session with a peer at the given @a address.
  *
  * @param cls closure (internal context for the plugin)
+ * @param pid identity of the target peer
  * @param address target address to connect to
  */
 static void
 ip_try_connect (void *cls,
+                struct GNUNET_PeerIdentity *pid,
                 const char *address)
 {
   struct Plugin *plugin = cls;
@@ -384,24 +365,19 @@ ip_try_connect (void *cls,
     .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV
   };
   struct addrinfo *result = NULL;
+  char *epid;
 
   if (0 !=
       strncmp (address,
                "ip+",
                strlen ("ip+")))
-  {
-    GNUNET_break (0);
     return;
-  }
   address += strlen ("ip+");
   if (0 !=
       strncmp (address,
                "udp://",
                strlen ("udp://")))
-  {
-    GNUNET_break (0);
     return;
-  }
   address += strlen ("udp://");
   addr = GNUNET_strdup (address);
   colon = strchr (addr, ':');
@@ -426,6 +402,7 @@ ip_try_connect (void *cls,
   }
   GNUNET_free (addr);
   (void) find_target (plugin,
+                      pid,
                       result->ai_addr,
                       result->ai_addrlen);
   freeaddrinfo (result);
@@ -499,10 +476,17 @@ ip_send (void *cls,
          void *finished_cb_cls)
 {
   struct Plugin *plugin = cls;
-
+  char buf[sizeof (plugin->my_id) + msg_size];
+
+  memcpy (buf,
+          &plugin->my_id,
+          sizeof (plugin->my_id));
+  memcpy (&buf[sizeof (plugin->my_id)],
+          msg,
+          msg_size);
   GNUNET_NETWORK_socket_sendto (plugin->sock,
-                                msg,
-                                msg_size,
+                                buf,
+                                sizeof (buf),
                                 (const struct sockaddr *) &target->addr,
                                 target->addrlen);
   finished_cb (finished_cb_cls);
@@ -523,6 +507,7 @@ create_source (struct Plugin *plugin,
                socklen_t addrlen)
 {
   struct GNUNET_DHTU_Source *src;
+  char *pid;
 
   src = GNUNET_new (struct GNUNET_DHTU_Source);
   src->addrlen = addrlen;
@@ -538,9 +523,6 @@ create_source (struct Plugin *plugin,
       char buf[INET_ADDRSTRLEN];
 
       GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
-      GNUNET_CRYPTO_hash (&s4->sin_addr,
-                          sizeof (struct in_addr),
-                          &src->id.sha512);
       GNUNET_asprintf (&src->address,
                        "ip+udp://%s:%u",
                        inet_ntop (AF_INET,
@@ -556,9 +538,6 @@ create_source (struct Plugin *plugin,
       char buf[INET6_ADDRSTRLEN];
 
       GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
-      GNUNET_CRYPTO_hash (&s6->sin6_addr,
-                          sizeof (struct in6_addr),
-                          &src->id.sha512);
       GNUNET_asprintf (&src->address,
                        "ip+udp://[%s]:%u",
                        inet_ntop (AF_INET6,
@@ -570,6 +549,7 @@ create_source (struct Plugin *plugin,
     break;
   default:
     GNUNET_break (0);
+    GNUNET_free (pid);
     GNUNET_free (src);
     return NULL;
   }
@@ -577,7 +557,6 @@ create_source (struct Plugin *plugin,
                                plugin->src_tail,
                                src);
   plugin->env->address_add_cb (plugin->env->cls,
-                               &src->id,
                                src->address,
                                src,
                                &src->app_ctx);
@@ -597,7 +576,7 @@ create_source (struct Plugin *plugin,
  * @param addrlen length of the address
  * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
  */
-static int
+static enum GNUNET_GenericReturnValue
 process_ifcs (void *cls,
               const char *name,
               int isDefault,
@@ -704,7 +683,8 @@ read_cb (void *cls)
 {
   struct Plugin *plugin = cls;
   ssize_t ret;
-  char buf[65536];
+  const struct GNUNET_PeerIdentity *pid;
+  char buf[65536] GNUNET_ALIGN;
   struct sockaddr_storage sa;
   struct iovec iov = {
     .iov_base = buf,
@@ -719,98 +699,101 @@ read_cb (void *cls)
     .msg_control = ctl,
     .msg_controllen = sizeof (ctl)
   };
+  struct GNUNET_DHTU_Target *dst = NULL;
+  struct GNUNET_DHTU_Source *src = NULL;
+  struct cmsghdr *cmsg;
 
   ret = recvmsg  (GNUNET_NETWORK_get_fd (plugin->sock),
                   &mh,
                   MSG_DONTWAIT);
-  if (ret >= 0)
+  plugin->read_task = GNUNET_SCHEDULER_add_read_net (
+    GNUNET_TIME_UNIT_FOREVER_REL,
+    plugin->sock,
+    &read_cb,
+    plugin);
+  if (ret < 0)
+    return; /* read failure, hopefully EAGAIN */
+  if (ret < sizeof (*pid))
   {
-    struct GNUNET_DHTU_Target *dst = NULL;
-    struct GNUNET_DHTU_Source *src = NULL;
-    struct cmsghdr *cmsg;
-
-    /* find IP where we received message */
-    for (cmsg = CMSG_FIRSTHDR (&mh);
-         NULL != cmsg;
-         cmsg = CMSG_NXTHDR (&mh,
-                             cmsg))
+    GNUNET_break_op (0);
+    return;
+  }
+  /* find IP where we received message */
+  for (cmsg = CMSG_FIRSTHDR (&mh);
+       NULL != cmsg;
+       cmsg = CMSG_NXTHDR (&mh,
+                           cmsg))
+  {
+    if ( (cmsg->cmsg_level == IPPROTO_IP) &&
+         (cmsg->cmsg_type == IP_PKTINFO) )
     {
-      if ( (cmsg->cmsg_level == IPPROTO_IP) &&
-           (cmsg->cmsg_type == IP_PKTINFO) )
+      if (CMSG_LEN (sizeof (struct in_pktinfo)) ==
+          cmsg->cmsg_len)
       {
-        if (CMSG_LEN (sizeof (struct in_pktinfo)) ==
-            cmsg->cmsg_len)
+        struct in_pktinfo pi;
+
+        memcpy (&pi,
+                CMSG_DATA (cmsg),
+                sizeof (pi));
         {
-          struct in_pktinfo pi;
-
-          memcpy (&pi,
-                  CMSG_DATA (cmsg),
-                  sizeof (pi));
-          {
-            struct sockaddr_in sa = {
-              .sin_family = AF_INET,
-              .sin_addr = pi.ipi_addr
-            };
-
-            src = find_source (plugin,
-                               &sa,
-                               sizeof (sa));
-          }
-          break;
+          struct sockaddr_in sa = {
+            .sin_family = AF_INET,
+            .sin_addr = pi.ipi_addr
+          };
+
+          src = find_source (plugin,
+                             &sa,
+                             sizeof (sa));
         }
-        else
-          GNUNET_break (0);
+        break;
       }
-      if ( (cmsg->cmsg_level == IPPROTO_IPV6) &&
-           (cmsg->cmsg_type == IPV6_RECVPKTINFO) )
+      else
+        GNUNET_break (0);
+    }
+    if ( (cmsg->cmsg_level == IPPROTO_IPV6) &&
+         (cmsg->cmsg_type == IPV6_RECVPKTINFO) )
+    {
+      if (CMSG_LEN (sizeof (struct in6_pktinfo)) ==
+          cmsg->cmsg_len)
       {
-        if (CMSG_LEN (sizeof (struct in6_pktinfo)) ==
-            cmsg->cmsg_len)
+        struct in6_pktinfo pi;
+
+        memcpy (&pi,
+                CMSG_DATA (cmsg),
+                sizeof (pi));
         {
-          struct in6_pktinfo pi;
-
-          memcpy (&pi,
-                  CMSG_DATA (cmsg),
-                  sizeof (pi));
-          {
-            struct sockaddr_in6 sa = {
-              .sin6_family = AF_INET6,
-              .sin6_addr = pi.ipi6_addr,
-              .sin6_scope_id = pi.ipi6_ifindex
-            };
-
-            src = find_source (plugin,
-                               &sa,
-                               sizeof (sa));
-            break;
-          }
+          struct sockaddr_in6 sa = {
+            .sin6_family = AF_INET6,
+            .sin6_addr = pi.ipi6_addr,
+            .sin6_scope_id = pi.ipi6_ifindex
+          };
+
+          src = find_source (plugin,
+                             &sa,
+                             sizeof (sa));
+          break;
         }
-        else
-          GNUNET_break (0);
       }
-    }
-    dst = find_target (plugin,
-                       &sa,
-                       mh.msg_namelen);
-    if ( (NULL == src) ||
-         (NULL == dst) )
-    {
-      GNUNET_break (0);
-    }
-    else
-    {
-      plugin->env->receive_cb (plugin->env->cls,
-                               dst->app_ctx,
-                               src->app_ctx,
-                               buf,
-                               ret);
+      else
+        GNUNET_break (0);
     }
   }
-  plugin->read_task = GNUNET_SCHEDULER_add_read_net (
-    GNUNET_TIME_UNIT_FOREVER_REL,
-    plugin->sock,
-    &read_cb,
-    plugin);
+  pid = (const struct GNUNET_PeerIdentity *) buf;
+  dst = find_target (plugin,
+                     pid,
+                     &sa,
+                     mh.msg_namelen);
+  if ( (NULL == src) ||
+       (NULL == dst) )
+  {
+    GNUNET_break (0);
+    return;
+  }
+  plugin->env->receive_cb (plugin->env->cls,
+                           dst->app_ctx,
+                           src->app_ctx,
+                           &buf[sizeof(*pid)],
+                           ret - sizeof (*pid));
 }
 
 
@@ -874,6 +857,13 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
   plugin = GNUNET_new (struct Plugin);
   plugin->env = env;
   plugin->port = port;
+  if (GNUNET_OK !=
+      GNUNET_CRYPTO_get_peer_identity (env->cfg,
+                                       &plugin->my_id))
+  {
+    GNUNET_free (plugin);
+    return NULL;
+  }
   af = AF_INET6;
   sock = socket (af,
                  SOCK_DGRAM,
@@ -1017,6 +1007,10 @@ libgnunet_plugin_dhtu_ip_done (void *cls)
     GNUNET_free (src->address);
     GNUNET_free (src);
   }
+  plugin->env->network_size_cb (plugin->env->cls,
+                                GNUNET_TIME_UNIT_FOREVER_ABS,
+                                0.0,
+                                0.0);
   GNUNET_CONTAINER_multihashmap_destroy (plugin->dsts);
   GNUNET_SCHEDULER_cancel (plugin->scan_task);
   GNUNET_break (0 ==
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index e4b02b8ee..8808f6802 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -57,6 +57,7 @@ gnunetinclude_HEADERS = \
   gnunet_gnsrecord_plugin.h \
   gnu_name_system_record_types.h \
   gnunet_hello_lib.h \
+  gnunet_hello_uri_lib.h \
   gnunet_helper_lib.h \
   gnunet_identity_service.h \
   gnunet_abe_lib.h \
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 5640209a6..f6db8d642 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -118,6 +118,12 @@ enum GNUNET_BLOCK_Type
    */
   GNUNET_BLOCK_TYPE_REVOCATION = 12,
 
+  /**
+   * Type of a block that contains a DHT-NG HELLO for a peer (for
+   * DHT and CADET find-peer operations).
+   */
+  GNUNET_BLOCK_TYPE_DHT_URL_HELLO = 13,
+
   /**
    * Block to store a cadet regex state
    */
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index 2c97d5848..b709ce9ae 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -58,15 +58,6 @@ struct GNUNET_DHTU_Target;
 struct GNUNET_DHTU_PreferenceHandle;
 
 
-/**
- * Key used to identify peer's position in the DHT.
- */
-struct GNUNET_DHTU_HashKey
-{
-  struct GNUNET_HashCode sha512;
-};
-
-
 /**
  * The datastore service will pass a pointer to a struct
  * of this type as the first and only argument to the
@@ -88,7 +79,6 @@ struct GNUNET_DHTU_PluginEnvironment
    * Function to call with new addresses of this peer.
    *
    * @param cls the closure
-   * @param key hash position of this address in the DHT
    * @param address address under which we are likely reachable,
    *           pointer will remain valid until @e address_del_cb is called; to 
be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/"
    * @param source handle for sending from this address, NULL if we can only 
receive
@@ -96,7 +86,6 @@ struct GNUNET_DHTU_PluginEnvironment
    */
   void
   (*address_add_cb)(void *cls,
-                    struct GNUNET_DHTU_HashKey *key,
                     const char *address,
                     struct GNUNET_DHTU_Source *source,
                     void **ctx);
@@ -128,18 +117,16 @@ struct GNUNET_DHTU_PluginEnvironment
    * that peer.
    *
    * @param cls the closure
-   * @param pk public key of the target,
-   *    pointer will remain valid until @e disconnect_cb is called
-   * @para peer_id hash position of the peer,
-   *    pointer will remain valid until @e disconnect_cb is called
    * @param target handle to the target,
    *    pointer will remain valid until @e disconnect_cb is called
+   * @para pid peer identity,
+   *    pointer will remain valid until @e disconnect_cb is called
    * @param[out] ctx storage space for DHT to use in association with this 
target
    */
   void
   (*connect_cb)(void *cls,
                 struct GNUNET_DHTU_Target *target,
-                struct GNUNET_DHTU_HashKey *key,
+                const struct GNUNET_PeerIdentity *pid,
                 void **ctx);
 
   /**
@@ -185,10 +172,12 @@ struct GNUNET_DHTU_PluginFunctions
    * Request creation of a session with a peer at the given @a address.
    *
    * @param cls closure (internal context for the plugin)
-   * @param address target address to connect to
+   * @param pid target identity of the peer to connect to
+   * @param address target address URI to connect to
    */
   void
   (*try_connect) (void *cls,
+                  struct GNUNET_PeerIdentity *pid,
                   const char *address);
 
 
diff --git a/src/include/gnunet_hello_uri_lib.h 
b/src/include/gnunet_hello_uri_lib.h
new file mode 100644
index 000000000..0f61384d1
--- /dev/null
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -0,0 +1,169 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2022 GNUnet e.V.
+
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @author Christian Grothoff
+ * @file
+ * Helper library for handling HELLO URIs
+ *
+ * @defgroup hello_uri  Hello_Uri library
+ * Helper library for handling HELLO URIs
+ *
+ * @{
+ */
+
+#ifndef GNUNET_HELLO_URI_LIB_H
+#define GNUNET_HELLO_URI_LIB_H
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+#include "gnunet_util_lib.h"
+
+
+/**
+ * Context for building (or parsing) HELLO URIs.
+ */
+struct GNUNET_HELLO_Builder;
+
+
+/**
+ * Allocate builder.
+ *
+ * @param pid peer the builder is for
+ * @return new builder
+ */
+struct GNUNET_HELLO_Builder *
+GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid);
+
+
+/**
+ * Release resources of a @a builder.
+ *
+ * @param[in] builder to free
+ */
+void
+GNUNET_HELLO_builder_free (struct GNUNET_HELLO_Builder *builder);
+
+
+/**
+ * Parse @a msg into builder.
+ *
+ * @param msg message to parse
+ * @return builder, NULL on failure
+ */
+struct GNUNET_HELLO_Builder *
+GNUNET_HELLO_builder_from_msg (const struct GNUNET_MessageHeader *msg);
+
+
+/**
+ * Parse GNUnet HELLO @a url into builder.
+ *
+ * @param url URL to parse
+ * @return builder, NULL on failure
+ */
+struct GNUNET_HELLO_Builder *
+GNUNET_HELLO_builder_from_url (const char *url);
+
+
+/**
+ * Generate HELLO message from a @a builder
+ *
+ * @param builder builder to serialize
+ * @return HELLO message matching @a builder
+ */
+struct GNUNET_MQ_Envelope *
+GNUNET_HELLO_builder_to_env (struct GNUNET_HELLO_Builder *builder);
+
+
+/**
+ * Generate GNUnet HELLO URI from a @a builder
+ *
+ * @param builder builder to serialize
+ * @return hello URI
+ */
+char *
+GNUNET_HELLO_builder_to_url (struct GNUNET_HELLO_Builder *builder);
+
+
+/**
+ * Add individual @a address to the @a builder
+ *
+ * @param[in,out] builder to update
+ * @param address address URI to add
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_HELLO_builder_add_address (struct GNUNET_HELLO_Builder *builder,
+                                  const char *address);
+
+
+/**
+ * Remove individual @a address from the @a builder
+ *
+ * @param[in,out] builder to update
+ * @param address address URI to remove
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder,
+                                  const char *address);
+
+
+/**
+ * Callback function used to extract URIs from a builder.
+ *
+ * @param cls closure
+ * @param uri one of the URIs
+ */
+typedef void
+(*GNUNET_HELLO_UriCallback) (void *cls,
+                             const char *uri);
+
+
+/**
+ * Iterate over URIs in a builder.
+ *
+ * @param builder builder to iterate over
+ * @param[out] pid set to the peer the @a builder is for
+ * @param uc callback invoked for each URI, can be NULL
+ * @param uc_cls closure for @a addrgen
+ */
+void
+GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder,
+                              struct GNUNET_PeerIdentity *pid,
+                              GNUNET_HELLO_UriCallback uc,
+                              void *uc_cls);
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/* ifndef GNUNET_HELLO_URI_LIB_H */
+#endif
+
+/** @} */ /* end of group */
+
+/* end of gnunet_hello_uri_lib.h */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]