aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-16 18:51:27 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-19 12:41:01 +0100
commit980eec8b79b63b445530cd42778a772e8a67b820 (patch)
tree3552b52fd3883c449e1b67639a21726069b2060f /src
parent7236e5f83a621ab972f9ae6eda5b9562aba3217b (diff)
downloadgnunet-980eec8b79b63b445530cd42778a772e8a67b820.tar.gz
gnunet-980eec8b79b63b445530cd42778a772e8a67b820.zip
-fix port initialization in addr
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-dht.c7
-rw-r--r--src/dht/gnunet-service-dht_clients.c1
-rw-r--r--src/dhtu/dhtu.conf2
-rw-r--r--src/dhtu/plugin_dhtu_ip.c47
-rw-r--r--src/util/network.c3
5 files changed, 54 insertions, 6 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 6ae56d427..4b0a290b9 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -382,6 +382,7 @@ shutdown_task (void *cls)
382 GNUNET_BLOCK_context_destroy (GDS_block_context); 382 GNUNET_BLOCK_context_destroy (GDS_block_context);
383 GDS_block_context = NULL; 383 GDS_block_context = NULL;
384 } 384 }
385 GDS_CLIENTS_stop ();
385 if (NULL != GDS_stats) 386 if (NULL != GDS_stats)
386 { 387 {
387 GNUNET_STATISTICS_destroy (GDS_stats, 388 GNUNET_STATISTICS_destroy (GDS_stats,
@@ -393,7 +394,11 @@ shutdown_task (void *cls)
393 GNUNET_HELLO_builder_free (GDS_my_hello); 394 GNUNET_HELLO_builder_free (GDS_my_hello);
394 GDS_my_hello = NULL; 395 GDS_my_hello = NULL;
395 } 396 }
396 GDS_CLIENTS_stop (); 397 if (NULL != hello_task)
398 {
399 GNUNET_SCHEDULER_cancel (hello_task);
400 hello_task = NULL;
401 }
397} 402}
398 403
399 404
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 88db7b0ea..e5819b193 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -1090,6 +1090,7 @@ handle_dht_local_hello_get (void *cls,
1090 GNUNET_free (url); 1090 GNUNET_free (url);
1091 GNUNET_MQ_send (ch->mq, 1091 GNUNET_MQ_send (ch->mq,
1092 env); 1092 env);
1093 GNUNET_SERVICE_client_continue (ch->client);
1093} 1094}
1094 1095
1095 1096
diff --git a/src/dhtu/dhtu.conf b/src/dhtu/dhtu.conf
index 438cd0955..ea5ade752 100644
--- a/src/dhtu/dhtu.conf
+++ b/src/dhtu/dhtu.conf
@@ -3,3 +3,5 @@ ENABLED = YES
3 3
4[dhtu-ip] 4[dhtu-ip]
5ENABLED = NO 5ENABLED = NO
6NSE = 4
7UDP_PORT = 6666
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 998a7903b..123a372b6 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -225,6 +225,11 @@ struct Plugin
225 * How often have we scanned for IPs? 225 * How often have we scanned for IPs?
226 */ 226 */
227 unsigned int scan_generation; 227 unsigned int scan_generation;
228
229 /**
230 * Port as a 16-bit value.
231 */
232 uint16_t port16;
228}; 233};
229 234
230 235
@@ -598,9 +603,37 @@ process_ifcs (void *cls,
598 return GNUNET_OK; 603 return GNUNET_OK;
599 } 604 }
600 } 605 }
601 (void) create_source (plugin, 606 switch (addr->sa_family)
602 addr, 607 {
603 addrlen); 608 case AF_INET:
609 {
610 struct sockaddr_in v4;
611
612 GNUNET_assert (sizeof(v4) == addrlen);
613 memcpy (&v4,
614 addr,
615 addrlen);
616 v4.sin_port = htons (plugin->port16);
617 (void) create_source (plugin,
618 (const struct sockaddr *) &v4,
619 sizeof (v4));
620 break;
621 }
622 case AF_INET6:
623 {
624 struct sockaddr_in6 v6;
625
626 GNUNET_assert (sizeof(v6) == addrlen);
627 memcpy (&v6,
628 addr,
629 addrlen);
630 v6.sin6_port = htons (plugin->port16);
631 (void) create_source (plugin,
632 (const struct sockaddr *) &v6,
633 sizeof (v6));
634 break;
635 }
636 }
604 return GNUNET_OK; 637 return GNUNET_OK;
605} 638}
606 639
@@ -854,6 +887,7 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
854 plugin = GNUNET_new (struct Plugin); 887 plugin = GNUNET_new (struct Plugin);
855 plugin->env = env; 888 plugin->env = env;
856 plugin->port = port; 889 plugin->port = port;
890 plugin->port16 = (uint16_t) nport;
857 if (GNUNET_OK != 891 if (GNUNET_OK !=
858 GNUNET_CRYPTO_get_peer_identity (env->cfg, 892 GNUNET_CRYPTO_get_peer_identity (env->cfg,
859 &plugin->my_id)) 893 &plugin->my_id))
@@ -1009,8 +1043,13 @@ libgnunet_plugin_dhtu_ip_done (void *cls)
1009 0.0, 1043 0.0,
1010 0.0); 1044 0.0);
1011 GNUNET_CONTAINER_multihashmap_destroy (plugin->dsts); 1045 GNUNET_CONTAINER_multihashmap_destroy (plugin->dsts);
1046 if (NULL != plugin->read_task)
1047 {
1048 GNUNET_SCHEDULER_cancel (plugin->read_task);
1049 plugin->read_task = NULL;
1050 }
1012 GNUNET_SCHEDULER_cancel (plugin->scan_task); 1051 GNUNET_SCHEDULER_cancel (plugin->scan_task);
1013 GNUNET_break (0 == 1052 GNUNET_break (GNUNET_OK ==
1014 GNUNET_NETWORK_socket_close (plugin->sock)); 1053 GNUNET_NETWORK_socket_close (plugin->sock));
1015 GNUNET_free (plugin->port); 1054 GNUNET_free (plugin->port);
1016 GNUNET_free (plugin); 1055 GNUNET_free (plugin);
diff --git a/src/util/network.c b/src/util/network.c
index 688c37665..2f77bc54e 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -350,7 +350,8 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
350 350
351 if (h->fd >= FD_SETSIZE) 351 if (h->fd >= FD_SETSIZE)
352 { 352 {
353 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (h)); 353 GNUNET_break (GNUNET_OK ==
354 GNUNET_NETWORK_socket_close (h));
354 errno = EMFILE; 355 errno = EMFILE;
355 return GNUNET_SYSERR; 356 return GNUNET_SYSERR;
356 } 357 }