aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-16 20:03:37 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-19 12:41:01 +0100
commite5f00fda52a45ebd22716debf0d9af36fb6fce0a (patch)
tree1bfbc2c21510fafc912bcb5a0c82b87418fc6248 /src
parent980eec8b79b63b445530cd42778a772e8a67b820 (diff)
downloadgnunet-e5f00fda52a45ebd22716debf0d9af36fb6fce0a.tar.gz
gnunet-e5f00fda52a45ebd22716debf0d9af36fb6fce0a.zip
-DHT: get tests to pass
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c20
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c32
-rw-r--r--src/hello/hello-uri.c2
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
index fc025fa18..63307dea2 100644
--- 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,
1604 prm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT); 1604 prm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT);
1605 prm->header.size = htons (sizeof (buf)); 1605 prm->header.size = htons (sizeof (buf));
1606 prm->type = htonl (bd->type); 1606 prm->type = htonl (bd->type);
1607 prm->reserved = htonl (0);
1607 prm->put_path_length = htonl (ppl); 1608 prm->put_path_length = htonl (ppl);
1608 prm->get_path_length = htonl (get_path_length); 1609 prm->get_path_length = htonl (get_path_length);
1609 prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); 1610 prm->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time);
@@ -1668,14 +1669,15 @@ check_dht_p2p_put (void *cls,
1668/** 1669/**
1669 * Core handler for p2p put requests. 1670 * Core handler for p2p put requests.
1670 * 1671 *
1671 * @param cls closure with the `struct PeerInfo` of the sender 1672 * @param cls closure with the `struct Target` of the sender
1672 * @param message message 1673 * @param message message
1673 */ 1674 */
1674static void 1675static void
1675handle_dht_p2p_put (void *cls, 1676handle_dht_p2p_put (void *cls,
1676 const struct PeerPutMessage *put) 1677 const struct PeerPutMessage *put)
1677{ 1678{
1678 struct PeerInfo *peer = cls; 1679 struct Target *t = cls;
1680 struct PeerInfo *peer = t->pi;
1679 uint16_t msize = ntohs (put->header.size); 1681 uint16_t msize = ntohs (put->header.size);
1680 enum GNUNET_DHT_RouteOption options 1682 enum GNUNET_DHT_RouteOption options
1681 = (enum GNUNET_DHT_RouteOption) ntohl (put->options); 1683 = (enum GNUNET_DHT_RouteOption) ntohl (put->options);
@@ -1982,7 +1984,7 @@ handle_local_result (void *cls,
1982/** 1984/**
1983 * Check validity of p2p get request. 1985 * Check validity of p2p get request.
1984 * 1986 *
1985 * @param cls closure with the `struct PeerInfo` of the sender 1987 * @param cls closure with the `struct Target` of the sender
1986 * @param get the message 1988 * @param get the message
1987 * @return #GNUNET_OK if the message is well-formed 1989 * @return #GNUNET_OK if the message is well-formed
1988 */ 1990 */
@@ -2006,14 +2008,15 @@ check_dht_p2p_get (void *cls,
2006/** 2008/**
2007 * Core handler for p2p get requests. 2009 * Core handler for p2p get requests.
2008 * 2010 *
2009 * @param cls closure with the `struct PeerInfo` of the sender 2011 * @param cls closure with the `struct Target` of the sender
2010 * @param get the message 2012 * @param get the message
2011 */ 2013 */
2012static void 2014static void
2013handle_dht_p2p_get (void *cls, 2015handle_dht_p2p_get (void *cls,
2014 const struct PeerGetMessage *get) 2016 const struct PeerGetMessage *get)
2015{ 2017{
2016 struct PeerInfo *peer = cls; 2018 struct Target *t = cls;
2019 struct PeerInfo *peer = t->pi;
2017 uint16_t msize = ntohs (get->header.size); 2020 uint16_t msize = ntohs (get->header.size);
2018 uint32_t xquery_size = ntohl (get->xquery_size); 2021 uint32_t xquery_size = ntohl (get->xquery_size);
2019 uint32_t hop_count = ntohl (get->hop_count); 2022 uint32_t hop_count = ntohl (get->hop_count);
@@ -2295,7 +2298,8 @@ static void
2295handle_dht_p2p_result (void *cls, 2298handle_dht_p2p_result (void *cls,
2296 const struct PeerResultMessage *prm) 2299 const struct PeerResultMessage *prm)
2297{ 2300{
2298 struct PeerInfo *peer = cls; 2301 struct Target *t = cls;
2302 struct PeerInfo *peer = t->pi;
2299 uint16_t msize = ntohs (prm->header.size); 2303 uint16_t msize = ntohs (prm->header.size);
2300 uint32_t get_path_length = ntohl (prm->get_path_length); 2304 uint32_t get_path_length = ntohl (prm->get_path_length);
2301 struct GDS_DATACACHE_BlockData bd = { 2305 struct GDS_DATACACHE_BlockData bd = {
@@ -2433,7 +2437,8 @@ static void
2433handle_dht_p2p_hello (void *cls, 2437handle_dht_p2p_hello (void *cls,
2434 const struct GNUNET_MessageHeader *hello) 2438 const struct GNUNET_MessageHeader *hello)
2435{ 2439{
2436 struct PeerInfo *peer = cls; 2440 struct Target *t = cls;
2441 struct PeerInfo *peer = t->pi;
2437 2442
2438 GNUNET_free (peer->hello); 2443 GNUNET_free (peer->hello);
2439 peer->hello_size = 0; 2444 peer->hello_size = 0;
@@ -2517,7 +2522,6 @@ GDS_NEIGHBOURS_broadcast (const struct GNUNET_MessageHeader *msg)
2517 if (count >= bucket_size) 2522 if (count >= bucket_size)
2518 break; /* we only consider first #bucket_size entries per bucket */ 2523 break; /* we only consider first #bucket_size entries per bucket */
2519 count++; 2524 count++;
2520 GNUNET_break (0);
2521 do_send (pos, 2525 do_send (pos,
2522 msg); 2526 msg);
2523 } 2527 }
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index 493fd5119..fe97f4919 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -234,9 +234,9 @@ hello_offered_cb (void *cls)
234 * @param address target address to connect to 234 * @param address target address to connect to
235 */ 235 */
236static void 236static void
237ip_try_connect (void *cls, 237gnunet_try_connect (void *cls,
238 const struct GNUNET_PeerIdentity *pid, 238 const struct GNUNET_PeerIdentity *pid,
239 const char *address) 239 const char *address)
240{ 240{
241 struct Plugin *plugin = cls; 241 struct Plugin *plugin = cls;
242 struct GNUNET_HELLO_Message *hello = NULL; 242 struct GNUNET_HELLO_Message *hello = NULL;
@@ -272,8 +272,8 @@ ip_try_connect (void *cls,
272 * @param target connection to keep alive 272 * @param target connection to keep alive
273 */ 273 */
274static struct GNUNET_DHTU_PreferenceHandle * 274static struct GNUNET_DHTU_PreferenceHandle *
275ip_hold (void *cls, 275gnunet_hold (void *cls,
276 struct GNUNET_DHTU_Target *target) 276 struct GNUNET_DHTU_Target *target)
277{ 277{
278 struct Plugin *plugin = cls; 278 struct Plugin *plugin = cls;
279 struct GNUNET_DHTU_PreferenceHandle *ph; 279 struct GNUNET_DHTU_PreferenceHandle *ph;
@@ -301,7 +301,7 @@ ip_hold (void *cls,
301 * @param target connection to keep alive 301 * @param target connection to keep alive
302 */ 302 */
303static void 303static void
304ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) 304gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
305{ 305{
306 struct GNUNET_DHTU_Target *target = ph->target; 306 struct GNUNET_DHTU_Target *target = ph->target;
307 struct Plugin *plugin = target->plugin; 307 struct Plugin *plugin = target->plugin;
@@ -339,12 +339,12 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
339 * @param finished_cb_cls closure for @a finished_cb 339 * @param finished_cb_cls closure for @a finished_cb
340 */ 340 */
341static void 341static void
342ip_send (void *cls, 342gnunet_send (void *cls,
343 struct GNUNET_DHTU_Target *target, 343 struct GNUNET_DHTU_Target *target,
344 const void *msg, 344 const void *msg,
345 size_t msg_size, 345 size_t msg_size,
346 GNUNET_SCHEDULER_TaskCallback finished_cb, 346 GNUNET_SCHEDULER_TaskCallback finished_cb,
347 void *finished_cb_cls) 347 void *finished_cb_cls)
348{ 348{
349 struct GNUNET_MQ_Envelope *env; 349 struct GNUNET_MQ_Envelope *env;
350 struct GNUNET_MessageHeader *cmsg; 350 struct GNUNET_MessageHeader *cmsg;
@@ -607,10 +607,10 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls)
607 plugin->env = env; 607 plugin->env = env;
608 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); 608 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
609 api->cls = plugin; 609 api->cls = plugin;
610 api->try_connect = &ip_try_connect; 610 api->try_connect = &gnunet_try_connect;
611 api->hold = &ip_hold; 611 api->hold = &gnunet_hold;
612 api->drop = &ip_drop; 612 api->drop = &gnunet_drop;
613 api->send = &ip_send; 613 api->send = &gnunet_send;
614 plugin->ats = GNUNET_ATS_connectivity_init (env->cfg); 614 plugin->ats = GNUNET_ATS_connectivity_init (env->cfg);
615 plugin->core = GNUNET_CORE_connect (env->cfg, 615 plugin->core = GNUNET_CORE_connect (env->cfg,
616 plugin, 616 plugin,
diff --git a/src/hello/hello-uri.c b/src/hello/hello-uri.c
index 355443455..e57d49e86 100644
--- 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,
813 struct Address *nxt; 813 struct Address *nxt;
814 814
815 *pid = builder->pid; 815 *pid = builder->pid;
816 if (NULL == uc)
817 return;
816 for (struct Address *a = builder->a_head; 818 for (struct Address *a = builder->a_head;
817 NULL != a; 819 NULL != a;
818 a = nxt) 820 a = nxt)