gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit e5f00fda52a45ebd22716debf0d9af36fb6fce0a
parent 980eec8b79b63b445530cd42778a772e8a67b820
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 16 Jan 2022 20:03:37 +0100

-DHT: get tests to pass

Diffstat:
Msrc/dht/gnunet-service-dht_neighbours.c | 20++++++++++++--------
Msrc/dhtu/plugin_dhtu_gnunet.c | 32++++++++++++++++----------------
Msrc/hello/hello-uri.c | 2++
3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c @@ -1604,6 +1604,7 @@ GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, prm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT); prm->header.size = htons (sizeof (buf)); prm->type = htonl (bd->type); + prm->reserved = htonl (0); prm->put_path_length = htonl (ppl); prm->get_path_length = htonl (get_path_length); prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); @@ -1668,14 +1669,15 @@ check_dht_p2p_put (void *cls, /** * Core handler for p2p put requests. * - * @param cls closure with the `struct PeerInfo` of the sender + * @param cls closure with the `struct Target` of the sender * @param message message */ static void handle_dht_p2p_put (void *cls, const struct PeerPutMessage *put) { - struct PeerInfo *peer = cls; + struct Target *t = cls; + struct PeerInfo *peer = t->pi; uint16_t msize = ntohs (put->header.size); enum GNUNET_DHT_RouteOption options = (enum GNUNET_DHT_RouteOption) ntohl (put->options); @@ -1982,7 +1984,7 @@ handle_local_result (void *cls, /** * Check validity of p2p get request. * - * @param cls closure with the `struct PeerInfo` of the sender + * @param cls closure with the `struct Target` of the sender * @param get the message * @return #GNUNET_OK if the message is well-formed */ @@ -2006,14 +2008,15 @@ check_dht_p2p_get (void *cls, /** * Core handler for p2p get requests. * - * @param cls closure with the `struct PeerInfo` of the sender + * @param cls closure with the `struct Target` of the sender * @param get the message */ static void handle_dht_p2p_get (void *cls, const struct PeerGetMessage *get) { - struct PeerInfo *peer = cls; + struct Target *t = cls; + struct PeerInfo *peer = t->pi; uint16_t msize = ntohs (get->header.size); uint32_t xquery_size = ntohl (get->xquery_size); uint32_t hop_count = ntohl (get->hop_count); @@ -2295,7 +2298,8 @@ static void handle_dht_p2p_result (void *cls, const struct PeerResultMessage *prm) { - struct PeerInfo *peer = cls; + struct Target *t = cls; + struct PeerInfo *peer = t->pi; uint16_t msize = ntohs (prm->header.size); uint32_t get_path_length = ntohl (prm->get_path_length); struct GDS_DATACACHE_BlockData bd = { @@ -2433,7 +2437,8 @@ static void handle_dht_p2p_hello (void *cls, const struct GNUNET_MessageHeader *hello) { - struct PeerInfo *peer = cls; + struct Target *t = cls; + struct PeerInfo *peer = t->pi; GNUNET_free (peer->hello); peer->hello_size = 0; @@ -2517,7 +2522,6 @@ GDS_NEIGHBOURS_broadcast (const struct GNUNET_MessageHeader *msg) if (count >= bucket_size) break; /* we only consider first #bucket_size entries per bucket */ count++; - GNUNET_break (0); do_send (pos, msg); } diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c @@ -234,9 +234,9 @@ hello_offered_cb (void *cls) * @param address target address to connect to */ static void -ip_try_connect (void *cls, - const struct GNUNET_PeerIdentity *pid, - const char *address) +gnunet_try_connect (void *cls, + const struct GNUNET_PeerIdentity *pid, + const char *address) { struct Plugin *plugin = cls; struct GNUNET_HELLO_Message *hello = NULL; @@ -272,8 +272,8 @@ ip_try_connect (void *cls, * @param target connection to keep alive */ static struct GNUNET_DHTU_PreferenceHandle * -ip_hold (void *cls, - struct GNUNET_DHTU_Target *target) +gnunet_hold (void *cls, + struct GNUNET_DHTU_Target *target) { struct Plugin *plugin = cls; struct GNUNET_DHTU_PreferenceHandle *ph; @@ -301,7 +301,7 @@ ip_hold (void *cls, * @param target connection to keep alive */ static void -ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) +gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph) { struct GNUNET_DHTU_Target *target = ph->target; struct Plugin *plugin = target->plugin; @@ -339,12 +339,12 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) * @param finished_cb_cls closure for @a finished_cb */ static void -ip_send (void *cls, - struct GNUNET_DHTU_Target *target, - const void *msg, - size_t msg_size, - GNUNET_SCHEDULER_TaskCallback finished_cb, - void *finished_cb_cls) +gnunet_send (void *cls, + struct GNUNET_DHTU_Target *target, + const void *msg, + size_t msg_size, + GNUNET_SCHEDULER_TaskCallback finished_cb, + void *finished_cb_cls) { struct GNUNET_MQ_Envelope *env; struct GNUNET_MessageHeader *cmsg; @@ -607,10 +607,10 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls) plugin->env = env; api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); api->cls = plugin; - api->try_connect = &ip_try_connect; - api->hold = &ip_hold; - api->drop = &ip_drop; - api->send = &ip_send; + api->try_connect = &gnunet_try_connect; + api->hold = &gnunet_hold; + api->drop = &gnunet_drop; + api->send = &gnunet_send; plugin->ats = GNUNET_ATS_connectivity_init (env->cfg); plugin->core = GNUNET_CORE_connect (env->cfg, plugin, diff --git a/src/hello/hello-uri.c b/src/hello/hello-uri.c @@ -813,6 +813,8 @@ GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, struct Address *nxt; *pid = builder->pid; + if (NULL == uc) + return; for (struct Address *a = builder->a_head; NULL != a; a = nxt)