diff options
author | t3sserakt <t3ss@posteo.de> | 2021-03-04 10:43:15 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-03-04 11:31:11 +0100 |
commit | 1d6759045c958205201ae051d196a9e846b9ebd2 (patch) | |
tree | ee5ad3fae44ea5cb4792598cf1b7e852c8398df5 /src | |
parent | e5d31aa52e4983bffce3eca6ca601bbb8f4a302a (diff) | |
parent | df757453c5f64540a58b6abb465963ca685de83f (diff) | |
download | gnunet-1d6759045c958205201ae051d196a9e846b9ebd2.tar.gz gnunet-1d6759045c958205201ae051d196a9e846b9ebd2.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnu_name_system_record_types.h | 138 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 104 | ||||
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 15 | ||||
-rw-r--r-- | src/reclaim/plugin_gnsrecord_reclaim.c | 3 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 42 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 93 | ||||
-rw-r--r-- | src/transport/test_transport_api2_tcp_peer1.conf | 3 | ||||
-rw-r--r-- | src/transport/test_transport_api2_tcp_peer2.conf | 3 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 83 | ||||
-rw-r--r-- | src/transport/transport-testing2.h | 5 | ||||
-rw-r--r-- | src/util/.gitignore | 1 | ||||
-rw-r--r-- | src/util/Makefile.am | 9 | ||||
-rw-r--r-- | src/util/gnunet-base32.c | 152 | ||||
-rw-r--r-- | src/util/gnunet-scrypt.c | 7 |
15 files changed, 489 insertions, 170 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 39a67acc4..048ae00a2 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -53,6 +53,7 @@ gnunetinclude_HEADERS = \ | |||
53 | gnunet_gnsrecord_lib.h \ | 53 | gnunet_gnsrecord_lib.h \ |
54 | gnunet_gnsrecord_json_lib.h \ | 54 | gnunet_gnsrecord_json_lib.h \ |
55 | gnunet_gnsrecord_plugin.h \ | 55 | gnunet_gnsrecord_plugin.h \ |
56 | gnu_name_system_record_types.h \ | ||
56 | gnunet_hello_lib.h \ | 57 | gnunet_hello_lib.h \ |
57 | gnunet_helper_lib.h \ | 58 | gnunet_helper_lib.h \ |
58 | gnunet_identity_service.h \ | 59 | gnunet_identity_service.h \ |
diff --git a/src/include/gnu_name_system_record_types.h b/src/include/gnu_name_system_record_types.h new file mode 100644 index 000000000..b2cf45dc8 --- /dev/null +++ b/src/include/gnu_name_system_record_types.h | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012-2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
21 | #define GNU_NAME_SYSTEM_RECORD_TYPES_H | ||
22 | |||
23 | /** | ||
24 | * WARNING: | ||
25 | * This header is generated! | ||
26 | * In order to add GNS record types, you must register | ||
27 | * them in GANA, and then use the header generation script | ||
28 | * to create an update of this file. You may then replace this | ||
29 | * file with the update. | ||
30 | */ | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
35 | } | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | |||
40 | /** | ||
41 | * GNS zone transfer | ||
42 | */ | ||
43 | #define GNUNET_GNSRECORD_TYPE_PKEY 65536 | ||
44 | |||
45 | /** | ||
46 | * GNS nick names | ||
47 | */ | ||
48 | #define GNUNET_GNSRECORD_TYPE_NICK 65537 | ||
49 | |||
50 | /** | ||
51 | * legacy hostnames | ||
52 | */ | ||
53 | #define GNUNET_GNSRECORD_TYPE_LEHO 65538 | ||
54 | |||
55 | /** | ||
56 | * VPN resolution | ||
57 | */ | ||
58 | #define GNUNET_GNSRECORD_TYPE_VPN 65539 | ||
59 | |||
60 | /** | ||
61 | * Delegation to DNS | ||
62 | */ | ||
63 | #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540 | ||
64 | |||
65 | /** | ||
66 | * Boxed records (see TLSA/SRV handling in GNS) | ||
67 | */ | ||
68 | #define GNUNET_GNSRECORD_TYPE_BOX 65541 | ||
69 | |||
70 | /** | ||
71 | * social place for SecuShare | ||
72 | */ | ||
73 | #define GNUNET_GNSRECORD_TYPE_PLACE 65542 | ||
74 | |||
75 | /** | ||
76 | * Endpoint for conversation | ||
77 | */ | ||
78 | #define GNUNET_GNSRECORD_TYPE_PHONE 65543 | ||
79 | |||
80 | /** | ||
81 | * identity attribute | ||
82 | */ | ||
83 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544 | ||
84 | |||
85 | /** | ||
86 | * local ticket reference | ||
87 | */ | ||
88 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545 | ||
89 | |||
90 | /** | ||
91 | * For ABD policies | ||
92 | */ | ||
93 | #define GNUNET_GNSRECORD_TYPE_DELEGATE 65548 | ||
94 | |||
95 | /** | ||
96 | * For ABD reverse lookups | ||
97 | */ | ||
98 | #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549 | ||
99 | |||
100 | /** | ||
101 | * for reclaim records | ||
102 | */ | ||
103 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550 | ||
104 | |||
105 | /** | ||
106 | * For reclaim OIDC client names. | ||
107 | */ | ||
108 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552 | ||
109 | |||
110 | /** | ||
111 | * Used reclaimID OIDC client redirect URIs. | ||
112 | */ | ||
113 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 | ||
114 | |||
115 | /** | ||
116 | * Record type for an attribute attestation (e.g. JWT). | ||
117 | */ | ||
118 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554 | ||
119 | |||
120 | /** | ||
121 | * Record type for a presentation of a credential. | ||
122 | */ | ||
123 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 | ||
124 | |||
125 | /** | ||
126 | * Record type for EDKEY zone delegations. | ||
127 | */ | ||
128 | #define GNUNET_GNSRECORD_TYPE_EDKEY 65556 | ||
129 | |||
130 | |||
131 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
132 | { | ||
133 | #endif | ||
134 | #ifdef __cplusplus | ||
135 | } | ||
136 | #endif | ||
137 | |||
138 | #endif | ||
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 0bf2ceed7..aff56146e 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -55,109 +55,9 @@ extern "C" { | |||
55 | #define GNUNET_GNSRECORD_TYPE_ANY 0 | 55 | #define GNUNET_GNSRECORD_TYPE_ANY 0 |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Record type for GNS zone transfer ("PKEY"). | 58 | * Include the record types generated from GANA |
59 | */ | 59 | */ |
60 | #define GNUNET_GNSRECORD_TYPE_PKEY GNUNET_IDENTITY_TYPE_ECDSA | 60 | #include "gnu_name_system_record_types.h" |
61 | |||
62 | /** | ||
63 | * Record type for GNS nick names ("NICK"). | ||
64 | */ | ||
65 | #define GNUNET_GNSRECORD_TYPE_NICK 65537 | ||
66 | |||
67 | /** | ||
68 | * Record type for GNS legacy hostnames ("LEHO"). | ||
69 | */ | ||
70 | #define GNUNET_GNSRECORD_TYPE_LEHO 65538 | ||
71 | |||
72 | /** | ||
73 | * Record type for VPN resolution | ||
74 | */ | ||
75 | #define GNUNET_GNSRECORD_TYPE_VPN 65539 | ||
76 | |||
77 | /** | ||
78 | * Record type for delegation to DNS. | ||
79 | */ | ||
80 | #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540 | ||
81 | |||
82 | /** | ||
83 | * Record type for a boxed record (see TLSA/SRV handling in GNS). | ||
84 | */ | ||
85 | #define GNUNET_GNSRECORD_TYPE_BOX 65541 | ||
86 | |||
87 | /** | ||
88 | * Record type for a social place. | ||
89 | */ | ||
90 | #define GNUNET_GNSRECORD_TYPE_PLACE 65542 | ||
91 | |||
92 | /** | ||
93 | * Record type for a phone (of CONVERSATION). | ||
94 | */ | ||
95 | #define GNUNET_GNSRECORD_TYPE_PHONE 65543 | ||
96 | |||
97 | /** | ||
98 | * Record type for identity attributes (of RECLAIM). | ||
99 | */ | ||
100 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544 | ||
101 | |||
102 | /** | ||
103 | * Record type for local ticket references | ||
104 | */ | ||
105 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545 | ||
106 | |||
107 | /** | ||
108 | * 65546 reserved | ||
109 | */ | ||
110 | |||
111 | /** | ||
112 | * 65547 deleted, free to use | ||
113 | */ | ||
114 | |||
115 | /** | ||
116 | * Record type for policies | ||
117 | */ | ||
118 | #define GNUNET_GNSRECORD_TYPE_DELEGATE 65548 | ||
119 | |||
120 | /** | ||
121 | * Record type for reverse lookups | ||
122 | */ | ||
123 | #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549 | ||
124 | |||
125 | /** | ||
126 | * Record type for reclaim records | ||
127 | */ | ||
128 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550 | ||
129 | |||
130 | /** | ||
131 | * Record type for RECLAIM master | ||
132 | */ | ||
133 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER 65551 | ||
134 | |||
135 | /** | ||
136 | * Record type for reclaim OIDC clients | ||
137 | */ | ||
138 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552 | ||
139 | |||
140 | /** | ||
141 | * Record type for reclaim OIDC redirect URIs | ||
142 | */ | ||
143 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 | ||
144 | |||
145 | /** | ||
146 | * Record type for an attribute attestation | ||
147 | */ | ||
148 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554 | ||
149 | |||
150 | /** | ||
151 | * Record type for a presentation of a credential (used | ||
152 | * in a ticket record set) | ||
153 | */ | ||
154 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 | ||
155 | |||
156 | /** | ||
157 | * Record type for EDKEY delegations. | ||
158 | */ | ||
159 | #define GNUNET_GNSRECORD_TYPE_EDKEY GNUNET_IDENTITY_TYPE_EDDSA | ||
160 | |||
161 | 61 | ||
162 | /** | 62 | /** |
163 | * Flags that can be set for a record. | 63 | * Flags that can be set for a record. |
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index c92e4d3f0..959d088f9 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -77,6 +77,8 @@ static unsigned int num_clients; | |||
77 | static void | 77 | static void |
78 | do_shutdown () | 78 | do_shutdown () |
79 | { | 79 | { |
80 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
81 | "Shutting down peerstore, bye.\n"); | ||
80 | if (NULL != db_lib_name) | 82 | if (NULL != db_lib_name) |
81 | { | 83 | { |
82 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db)); | 84 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db)); |
@@ -105,6 +107,8 @@ do_shutdown () | |||
105 | static void | 107 | static void |
106 | shutdown_task (void *cls) | 108 | shutdown_task (void *cls) |
107 | { | 109 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
111 | "Priming PEERSTORE for shutdown.\n"); | ||
108 | in_shutdown = GNUNET_YES; | 112 | in_shutdown = GNUNET_YES; |
109 | if (0 == num_clients) /* Only when no connected clients. */ | 113 | if (0 == num_clients) /* Only when no connected clients. */ |
110 | do_shutdown (); | 114 | do_shutdown (); |
@@ -176,6 +180,8 @@ client_connect_cb (void *cls, | |||
176 | struct GNUNET_MQ_Handle *mq) | 180 | struct GNUNET_MQ_Handle *mq) |
177 | { | 181 | { |
178 | num_clients++; | 182 | num_clients++; |
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
184 | "A client connected (now %u)\n", num_clients); | ||
179 | return client; | 185 | return client; |
180 | } | 186 | } |
181 | 187 | ||
@@ -195,7 +201,7 @@ client_disconnect_it (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
195 | { | 201 | { |
196 | GNUNET_assert (GNUNET_YES == | 202 | GNUNET_assert (GNUNET_YES == |
197 | GNUNET_CONTAINER_multihashmap_remove (watchers, key, value)); | 203 | GNUNET_CONTAINER_multihashmap_remove (watchers, key, value)); |
198 | num_clients++; | 204 | num_clients++; /* Watchers do not count */ |
199 | } | 205 | } |
200 | return GNUNET_OK; | 206 | return GNUNET_OK; |
201 | } | 207 | } |
@@ -212,12 +218,14 @@ client_disconnect_cb (void *cls, | |||
212 | struct GNUNET_SERVICE_Client *client, | 218 | struct GNUNET_SERVICE_Client *client, |
213 | void *app_cls) | 219 | void *app_cls) |
214 | { | 220 | { |
215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A client disconnected, cleaning up.\n"); | 221 | num_clients--; |
216 | if (NULL != watchers) | 222 | if (NULL != watchers) |
217 | GNUNET_CONTAINER_multihashmap_iterate (watchers, | 223 | GNUNET_CONTAINER_multihashmap_iterate (watchers, |
218 | &client_disconnect_it, | 224 | &client_disconnect_it, |
219 | client); | 225 | client); |
220 | num_clients--; | 226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
227 | "A client disconnected (%u remaining).\n", | ||
228 | num_clients); | ||
221 | if ((0 == num_clients) && in_shutdown) | 229 | if ((0 == num_clients) && in_shutdown) |
222 | do_shutdown (); | 230 | do_shutdown (); |
223 | } | 231 | } |
@@ -540,6 +548,7 @@ run (void *cls, | |||
540 | char *database; | 548 | char *database; |
541 | 549 | ||
542 | in_shutdown = GNUNET_NO; | 550 | in_shutdown = GNUNET_NO; |
551 | num_clients = 0; | ||
543 | cfg = c; | 552 | cfg = c; |
544 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, | 553 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, |
545 | "peerstore", | 554 | "peerstore", |
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c index 60c49fd6a..9e4f0a5c4 100644 --- a/src/reclaim/plugin_gnsrecord_reclaim.c +++ b/src/reclaim/plugin_gnsrecord_reclaim.c | |||
@@ -50,7 +50,6 @@ value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) | |||
50 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE: | 50 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE: |
51 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: | 51 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: |
52 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: | 52 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: |
53 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: | ||
54 | case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL: | 53 | case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL: |
55 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: | 54 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: |
56 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); | 55 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); |
@@ -87,7 +86,6 @@ string_to_value (void *cls, uint32_t type, const char *s, void **data, | |||
87 | return GNUNET_OK; | 86 | return GNUNET_OK; |
88 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE: | 87 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE: |
89 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: | 88 | case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF: |
90 | case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: | ||
91 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: | 89 | case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: |
92 | case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL: | 90 | case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL: |
93 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: | 91 | case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION: |
@@ -112,7 +110,6 @@ static struct | |||
112 | { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF }, | 110 | { "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF }, |
113 | { "RECLAIM_CREDENTIAL", GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL }, | 111 | { "RECLAIM_CREDENTIAL", GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL }, |
114 | { "RECLAIM_PRESENTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION }, | 112 | { "RECLAIM_PRESENTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION }, |
115 | { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER }, | ||
116 | { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, | 113 | { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, |
117 | { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, | 114 | { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, |
118 | { "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET }, | 115 | { "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET }, |
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 273dbac48..c8a4c0375 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -739,7 +739,6 @@ struct Addresses | |||
739 | }; | 739 | }; |
740 | 740 | ||
741 | 741 | ||
742 | |||
743 | /** | 742 | /** |
744 | * Maximum queue length before we stop reading towards the transport service. | 743 | * Maximum queue length before we stop reading towards the transport service. |
745 | */ | 744 | */ |
@@ -953,6 +952,9 @@ queue_destroy (struct Queue *queue) | |||
953 | else | 952 | else |
954 | GNUNET_free (queue); | 953 | GNUNET_free (queue); |
955 | 954 | ||
955 | if (NULL == lt) | ||
956 | return; | ||
957 | |||
956 | if ((! shutdown_running) && (NULL == lt->listen_task)) | 958 | if ((! shutdown_running) && (NULL == lt->listen_task)) |
957 | { | 959 | { |
958 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 960 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1193,6 +1195,7 @@ setup_cipher (const struct GNUNET_HashCode *dh, | |||
1193 | 0)); | 1195 | 0)); |
1194 | } | 1196 | } |
1195 | 1197 | ||
1198 | |||
1196 | /** | 1199 | /** |
1197 | * Callback called when peerstore store operation for rekey monotime value is finished. | 1200 | * Callback called when peerstore store operation for rekey monotime value is finished. |
1198 | * @param cls Queue context the store operation was executed. | 1201 | * @param cls Queue context the store operation was executed. |
@@ -1210,6 +1213,7 @@ rekey_monotime_store_cb (void *cls, int success) | |||
1210 | queue->rekey_monotime_sc = NULL; | 1213 | queue->rekey_monotime_sc = NULL; |
1211 | } | 1214 | } |
1212 | 1215 | ||
1216 | |||
1213 | /** | 1217 | /** |
1214 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY | 1218 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY |
1215 | * where found. | 1219 | * where found. |
@@ -1266,6 +1270,7 @@ rekey_monotime_cb (void *cls, | |||
1266 | queue); | 1270 | queue); |
1267 | } | 1271 | } |
1268 | 1272 | ||
1273 | |||
1269 | /** | 1274 | /** |
1270 | * Setup cipher of @a queue for decryption. | 1275 | * Setup cipher of @a queue for decryption. |
1271 | * | 1276 | * |
@@ -1344,6 +1349,7 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey) | |||
1344 | setup_in_cipher (&rekey->ephemeral, queue); | 1349 | setup_in_cipher (&rekey->ephemeral, queue); |
1345 | } | 1350 | } |
1346 | 1351 | ||
1352 | |||
1347 | /** | 1353 | /** |
1348 | * Callback called when peerstore store operation for handshake ack monotime value is finished. | 1354 | * Callback called when peerstore store operation for handshake ack monotime value is finished. |
1349 | * @param cls Queue context the store operation was executed. | 1355 | * @param cls Queue context the store operation was executed. |
@@ -1362,6 +1368,7 @@ handshake_ack_monotime_store_cb (void *cls, int success) | |||
1362 | queue->handshake_ack_monotime_sc = NULL; | 1368 | queue->handshake_ack_monotime_sc = NULL; |
1363 | } | 1369 | } |
1364 | 1370 | ||
1371 | |||
1365 | /** | 1372 | /** |
1366 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK | 1373 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK |
1367 | * where found. | 1374 | * where found. |
@@ -1420,6 +1427,7 @@ handshake_ack_monotime_cb (void *cls, | |||
1420 | queue); | 1427 | queue); |
1421 | } | 1428 | } |
1422 | 1429 | ||
1430 | |||
1423 | /** | 1431 | /** |
1424 | * Sending challenge with TcpConfirmationAck back to sender of ephemeral key. | 1432 | * Sending challenge with TcpConfirmationAck back to sender of ephemeral key. |
1425 | * | 1433 | * |
@@ -1465,6 +1473,7 @@ send_challenge (struct ChallengeNonceP challenge, struct Queue *queue) | |||
1465 | "sending challenge done\n"); | 1473 | "sending challenge done\n"); |
1466 | } | 1474 | } |
1467 | 1475 | ||
1476 | |||
1468 | /** | 1477 | /** |
1469 | * Setup cipher for outgoing data stream based on target and | 1478 | * Setup cipher for outgoing data stream based on target and |
1470 | * our ephemeral private key. | 1479 | * our ephemeral private key. |
@@ -1545,6 +1554,7 @@ inject_rekey (struct Queue *queue) | |||
1545 | setup_out_cipher (queue); | 1554 | setup_out_cipher (queue); |
1546 | } | 1555 | } |
1547 | 1556 | ||
1557 | |||
1548 | /** | 1558 | /** |
1549 | * We have been notified that our socket is ready to write. | 1559 | * We have been notified that our socket is ready to write. |
1550 | * Then reschedule this function to be called again once more is available. | 1560 | * Then reschedule this function to be called again once more is available. |
@@ -1634,6 +1644,7 @@ queue_write (void *cls) | |||
1634 | queue); | 1644 | queue); |
1635 | } | 1645 | } |
1636 | 1646 | ||
1647 | |||
1637 | /** | 1648 | /** |
1638 | * Test if we have received a full message in plaintext. | 1649 | * Test if we have received a full message in plaintext. |
1639 | * If so, handle it. | 1650 | * If so, handle it. |
@@ -1975,6 +1986,7 @@ queue_read (void *cls) | |||
1975 | queue_finish (queue); | 1986 | queue_finish (queue); |
1976 | } | 1987 | } |
1977 | 1988 | ||
1989 | |||
1978 | /** | 1990 | /** |
1979 | * Convert a `struct sockaddr_in6 to a `struct sockaddr *` | 1991 | * Convert a `struct sockaddr_in6 to a `struct sockaddr *` |
1980 | * | 1992 | * |
@@ -2001,6 +2013,7 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, | |||
2001 | return in; | 2013 | return in; |
2002 | } | 2014 | } |
2003 | 2015 | ||
2016 | |||
2004 | /** | 2017 | /** |
2005 | * Convert a `struct sockaddr_in4 to a `struct sockaddr *` | 2018 | * Convert a `struct sockaddr_in4 to a `struct sockaddr *` |
2006 | * | 2019 | * |
@@ -2024,6 +2037,7 @@ tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4, | |||
2024 | return in; | 2037 | return in; |
2025 | } | 2038 | } |
2026 | 2039 | ||
2040 | |||
2027 | /** | 2041 | /** |
2028 | * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *` | 2042 | * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *` |
2029 | * | 2043 | * |
@@ -2083,6 +2097,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port) | |||
2083 | return po; | 2097 | return po; |
2084 | } | 2098 | } |
2085 | 2099 | ||
2100 | |||
2086 | /** | 2101 | /** |
2087 | * This Method extracts the address part of the BINDTO string. | 2102 | * This Method extracts the address part of the BINDTO string. |
2088 | * | 2103 | * |
@@ -2117,7 +2132,8 @@ extract_address (const char *bindto) | |||
2117 | start++; /* skip over '['*/ | 2132 | start++; /* skip over '['*/ |
2118 | cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ | 2133 | cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ |
2119 | } | 2134 | } |
2120 | else { | 2135 | else |
2136 | { | ||
2121 | token = strtok_r (cp, "]", &rest); | 2137 | token = strtok_r (cp, "]", &rest); |
2122 | if (strlen (bindto) == strlen (token)) | 2138 | if (strlen (bindto) == strlen (token)) |
2123 | { | 2139 | { |
@@ -2139,6 +2155,7 @@ extract_address (const char *bindto) | |||
2139 | return start; | 2155 | return start; |
2140 | } | 2156 | } |
2141 | 2157 | ||
2158 | |||
2142 | /** | 2159 | /** |
2143 | * This Method extracts the port part of the BINDTO string. | 2160 | * This Method extracts the port part of the BINDTO string. |
2144 | * | 2161 | * |
@@ -2217,6 +2234,7 @@ extract_port (const char *addr_and_port) | |||
2217 | return port; | 2234 | return port; |
2218 | } | 2235 | } |
2219 | 2236 | ||
2237 | |||
2220 | /** | 2238 | /** |
2221 | * Convert TCP bind specification to a `struct sockaddr *` | 2239 | * Convert TCP bind specification to a `struct sockaddr *` |
2222 | * | 2240 | * |
@@ -2245,7 +2263,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2245 | bindto); | 2263 | bindto); |
2246 | 2264 | ||
2247 | 2265 | ||
2248 | |||
2249 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | 2266 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) |
2250 | { | 2267 | { |
2251 | // colon = strrchr (cp, ':'); | 2268 | // colon = strrchr (cp, ':'); |
@@ -2263,7 +2280,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2263 | port = extract_port (bindto); | 2280 | port = extract_port (bindto); |
2264 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); | 2281 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); |
2265 | } | 2282 | } |
2266 | else{ | 2283 | else |
2284 | { | ||
2267 | GNUNET_assert (0); | 2285 | GNUNET_assert (0); |
2268 | } | 2286 | } |
2269 | 2287 | ||
@@ -2272,6 +2290,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2272 | return in; | 2290 | return in; |
2273 | } | 2291 | } |
2274 | 2292 | ||
2293 | |||
2275 | /** | 2294 | /** |
2276 | * Signature of functions implementing the sending functionality of a | 2295 | * Signature of functions implementing the sending functionality of a |
2277 | * message queue. | 2296 | * message queue. |
@@ -2510,6 +2529,7 @@ start_initial_kx_out (struct Queue *queue) | |||
2510 | transmit_kx (queue, &epub); | 2529 | transmit_kx (queue, &epub); |
2511 | } | 2530 | } |
2512 | 2531 | ||
2532 | |||
2513 | /** | 2533 | /** |
2514 | * Callback called when peerstore store operation for handshake monotime is finished. | 2534 | * Callback called when peerstore store operation for handshake monotime is finished. |
2515 | * @param cls Queue context the store operation was executed. | 2535 | * @param cls Queue context the store operation was executed. |
@@ -2527,6 +2547,7 @@ handshake_monotime_store_cb (void *cls, int success) | |||
2527 | queue->handshake_monotime_sc = NULL; | 2547 | queue->handshake_monotime_sc = NULL; |
2528 | } | 2548 | } |
2529 | 2549 | ||
2550 | |||
2530 | /** | 2551 | /** |
2531 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE | 2552 | * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE |
2532 | * where found. | 2553 | * where found. |
@@ -2585,6 +2606,7 @@ handshake_monotime_cb (void *cls, | |||
2585 | queue); | 2606 | queue); |
2586 | } | 2607 | } |
2587 | 2608 | ||
2609 | |||
2588 | /** | 2610 | /** |
2589 | * We have received the first bytes from the other side on a @a queue. | 2611 | * We have received the first bytes from the other side on a @a queue. |
2590 | * Decrypt the @a tc contained in @a ibuf and check the signature. | 2612 | * Decrypt the @a tc contained in @a ibuf and check the signature. |
@@ -2651,6 +2673,7 @@ free_proto_queue (struct ProtoQueue *pq) | |||
2651 | GNUNET_free (pq); | 2673 | GNUNET_free (pq); |
2652 | } | 2674 | } |
2653 | 2675 | ||
2676 | |||
2654 | /** | 2677 | /** |
2655 | * Read from the socket of the proto queue until we have enough data | 2678 | * Read from the socket of the proto queue until we have enough data |
2656 | * to upgrade to full queue. | 2679 | * to upgrade to full queue. |
@@ -2892,6 +2915,7 @@ queue_read_kx (void *cls) | |||
2892 | queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); | 2915 | queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); |
2893 | } | 2916 | } |
2894 | 2917 | ||
2918 | |||
2895 | /** | 2919 | /** |
2896 | * Function called by the transport service to initialize a | 2920 | * Function called by the transport service to initialize a |
2897 | * message queue given address information about another peer. | 2921 | * message queue given address information about another peer. |
@@ -2991,6 +3015,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2991 | return GNUNET_OK; | 3015 | return GNUNET_OK; |
2992 | } | 3016 | } |
2993 | 3017 | ||
3018 | |||
2994 | /** | 3019 | /** |
2995 | * Iterator over all ListenTasks to clean up. | 3020 | * Iterator over all ListenTasks to clean up. |
2996 | * | 3021 | * |
@@ -3021,6 +3046,7 @@ get_lt_delete_it (void *cls, | |||
3021 | return GNUNET_OK; | 3046 | return GNUNET_OK; |
3022 | } | 3047 | } |
3023 | 3048 | ||
3049 | |||
3024 | /** | 3050 | /** |
3025 | * Iterator over all message queues to clean up. | 3051 | * Iterator over all message queues to clean up. |
3026 | * | 3052 | * |
@@ -3042,6 +3068,7 @@ get_queue_delete_it (void *cls, | |||
3042 | return GNUNET_OK; | 3068 | return GNUNET_OK; |
3043 | } | 3069 | } |
3044 | 3070 | ||
3071 | |||
3045 | /** | 3072 | /** |
3046 | * Shutdown the UNIX communicator. | 3073 | * Shutdown the UNIX communicator. |
3047 | * | 3074 | * |
@@ -3182,6 +3209,7 @@ nat_address_cb (void *cls, | |||
3182 | } | 3209 | } |
3183 | } | 3210 | } |
3184 | 3211 | ||
3212 | |||
3185 | /** | 3213 | /** |
3186 | * This method adds addresses to the DLL, that are later register at the NAT service. | 3214 | * This method adds addresses to the DLL, that are later register at the NAT service. |
3187 | */ | 3215 | */ |
@@ -3211,6 +3239,7 @@ add_addr (struct sockaddr *in, socklen_t in_len) | |||
3211 | addrs_lens++; | 3239 | addrs_lens++; |
3212 | } | 3240 | } |
3213 | 3241 | ||
3242 | |||
3214 | /** | 3243 | /** |
3215 | * This method launch network interactions for each address we like to bind to. | 3244 | * This method launch network interactions for each address we like to bind to. |
3216 | * | 3245 | * |
@@ -3336,7 +3365,7 @@ init_socket (struct sockaddr *addr, | |||
3336 | if (NULL == queue_map) | 3365 | if (NULL == queue_map) |
3337 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 3366 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
3338 | 3367 | ||
3339 | if (NULL == ch ) | 3368 | if (NULL == ch) |
3340 | ch = GNUNET_TRANSPORT_communicator_connect (cfg, | 3369 | ch = GNUNET_TRANSPORT_communicator_connect (cfg, |
3341 | COMMUNICATOR_CONFIG_SECTION, | 3370 | COMMUNICATOR_CONFIG_SECTION, |
3342 | COMMUNICATOR_ADDRESS_PREFIX, | 3371 | COMMUNICATOR_ADDRESS_PREFIX, |
@@ -3360,6 +3389,7 @@ init_socket (struct sockaddr *addr, | |||
3360 | 3389 | ||
3361 | } | 3390 | } |
3362 | 3391 | ||
3392 | |||
3363 | /** | 3393 | /** |
3364 | * This method reads from the DLL addrs_head to register them at the NAT service. | 3394 | * This method reads from the DLL addrs_head to register them at the NAT service. |
3365 | */ | 3395 | */ |
@@ -3421,6 +3451,7 @@ nat_register () | |||
3421 | } | 3451 | } |
3422 | } | 3452 | } |
3423 | 3453 | ||
3454 | |||
3424 | /** | 3455 | /** |
3425 | * This method is the callback called by the resolver API, and wraps method init_socket. | 3456 | * This method is the callback called by the resolver API, and wraps method init_socket. |
3426 | * | 3457 | * |
@@ -3476,6 +3507,7 @@ init_socket_resolv (void *cls, | |||
3476 | } | 3507 | } |
3477 | } | 3508 | } |
3478 | 3509 | ||
3510 | |||
3479 | /** | 3511 | /** |
3480 | * Setup communicator and launch network interactions. | 3512 | * Setup communicator and launch network interactions. |
3481 | * | 3513 | * |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index f57d08395..3cba49250 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -2772,6 +2772,11 @@ static unsigned int pa_count; | |||
2772 | */ | 2772 | */ |
2773 | static struct GNUNET_TIME_Absolute hello_mono_time; | 2773 | static struct GNUNET_TIME_Absolute hello_mono_time; |
2774 | 2774 | ||
2775 | /** | ||
2776 | * Indication if we have received a shutdown signal | ||
2777 | * and are in the process of cleaning up. | ||
2778 | */ | ||
2779 | static int in_shutdown; | ||
2775 | 2780 | ||
2776 | /** | 2781 | /** |
2777 | * Get an offset into the transmission history buffer for `struct | 2782 | * Get an offset into the transmission history buffer for `struct |
@@ -2805,6 +2810,7 @@ free_incoming_request (struct IncomingRequest *ir) | |||
2805 | GNUNET_assert (ir_total > 0); | 2810 | GNUNET_assert (ir_total > 0); |
2806 | ir_total--; | 2811 | ir_total--; |
2807 | GNUNET_PEERSTORE_watch_cancel (ir->wc); | 2812 | GNUNET_PEERSTORE_watch_cancel (ir->wc); |
2813 | ir->wc = NULL; | ||
2808 | GNUNET_free (ir); | 2814 | GNUNET_free (ir); |
2809 | } | 2815 | } |
2810 | 2816 | ||
@@ -3333,6 +3339,8 @@ free_neighbour (struct Neighbour *neighbour) | |||
3333 | GNUNET_CONTAINER_multipeermap_remove (neighbours, | 3339 | GNUNET_CONTAINER_multipeermap_remove (neighbours, |
3334 | &neighbour->pid, | 3340 | &neighbour->pid, |
3335 | neighbour)); | 3341 | neighbour)); |
3342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3343 | "Freeing neighbour\n"); | ||
3336 | if (NULL != neighbour->reassembly_map) | 3344 | if (NULL != neighbour->reassembly_map) |
3337 | { | 3345 | { |
3338 | GNUNET_CONTAINER_multihashmap32_iterate (neighbour->reassembly_map, | 3346 | GNUNET_CONTAINER_multihashmap32_iterate (neighbour->reassembly_map, |
@@ -3499,6 +3507,8 @@ check_link_down (void *cls) | |||
3499 | struct GNUNET_TIME_Absolute dvh_timeout; | 3507 | struct GNUNET_TIME_Absolute dvh_timeout; |
3500 | struct GNUNET_TIME_Absolute q_timeout; | 3508 | struct GNUNET_TIME_Absolute q_timeout; |
3501 | 3509 | ||
3510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3511 | "Checking if link is down\n"); | ||
3502 | vl->visibility_task = NULL; | 3512 | vl->visibility_task = NULL; |
3503 | dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS; | 3513 | dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS; |
3504 | if (NULL != dv) | 3514 | if (NULL != dv) |
@@ -3660,6 +3670,7 @@ stop_peer_request (void *cls, | |||
3660 | struct PeerRequest *pr = value; | 3670 | struct PeerRequest *pr = value; |
3661 | 3671 | ||
3662 | GNUNET_PEERSTORE_watch_cancel (pr->wc); | 3672 | GNUNET_PEERSTORE_watch_cancel (pr->wc); |
3673 | pr->wc = NULL; | ||
3663 | GNUNET_assert ( | 3674 | GNUNET_assert ( |
3664 | GNUNET_YES == | 3675 | GNUNET_YES == |
3665 | GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests, | 3676 | GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests, |
@@ -3671,6 +3682,9 @@ stop_peer_request (void *cls, | |||
3671 | } | 3682 | } |
3672 | 3683 | ||
3673 | 3684 | ||
3685 | static void | ||
3686 | do_shutdown (void *cls); | ||
3687 | |||
3674 | /** | 3688 | /** |
3675 | * Called whenever a client is disconnected. Frees our | 3689 | * Called whenever a client is disconnected. Frees our |
3676 | * resources associated with that client. | 3690 | * resources associated with that client. |
@@ -3688,16 +3702,20 @@ client_disconnect_cb (void *cls, | |||
3688 | 3702 | ||
3689 | (void) cls; | 3703 | (void) cls; |
3690 | (void) client; | 3704 | (void) client; |
3691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3692 | "Client %p disconnected, cleaning up.\n", | ||
3693 | tc); | ||
3694 | GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); | 3705 | GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); |
3695 | switch (tc->type) | 3706 | switch (tc->type) |
3696 | { | 3707 | { |
3697 | case CT_NONE: | 3708 | case CT_NONE: |
3709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3710 | "Unknown Client %p disconnected, cleaning up.\n", | ||
3711 | tc); | ||
3698 | break; | 3712 | break; |
3699 | 3713 | ||
3700 | case CT_CORE: { | 3714 | case CT_CORE: { |
3715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3716 | "CORE Client %p disconnected, cleaning up.\n", | ||
3717 | tc); | ||
3718 | |||
3701 | struct PendingMessage *pm; | 3719 | struct PendingMessage *pm; |
3702 | 3720 | ||
3703 | while (NULL != (pm = tc->details.core.pending_msg_head)) | 3721 | while (NULL != (pm = tc->details.core.pending_msg_head)) |
@@ -3712,9 +3730,17 @@ client_disconnect_cb (void *cls, | |||
3712 | break; | 3730 | break; |
3713 | 3731 | ||
3714 | case CT_MONITOR: | 3732 | case CT_MONITOR: |
3733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3734 | "MONITOR Client %p disconnected, cleaning up.\n", | ||
3735 | tc); | ||
3736 | |||
3715 | break; | 3737 | break; |
3716 | 3738 | ||
3717 | case CT_COMMUNICATOR: { | 3739 | case CT_COMMUNICATOR: { |
3740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3741 | "COMMUNICATOR Client %p disconnected, cleaning up.\n", | ||
3742 | tc); | ||
3743 | |||
3718 | struct Queue *q; | 3744 | struct Queue *q; |
3719 | struct AddressListEntry *ale; | 3745 | struct AddressListEntry *ale; |
3720 | 3746 | ||
@@ -3727,6 +3753,10 @@ client_disconnect_cb (void *cls, | |||
3727 | break; | 3753 | break; |
3728 | 3754 | ||
3729 | case CT_APPLICATION: | 3755 | case CT_APPLICATION: |
3756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3757 | "APPLICATION Client %p disconnected, cleaning up.\n", | ||
3758 | tc); | ||
3759 | |||
3730 | GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests, | 3760 | GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests, |
3731 | &stop_peer_request, | 3761 | &stop_peer_request, |
3732 | tc); | 3762 | tc); |
@@ -3734,6 +3764,12 @@ client_disconnect_cb (void *cls, | |||
3734 | break; | 3764 | break; |
3735 | } | 3765 | } |
3736 | GNUNET_free (tc); | 3766 | GNUNET_free (tc); |
3767 | if ((GNUNET_YES == in_shutdown) && (NULL == clients_head)) | ||
3768 | { | ||
3769 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3770 | "Our last client disconnected\n"); | ||
3771 | do_shutdown (cls); | ||
3772 | } | ||
3737 | } | 3773 | } |
3738 | 3774 | ||
3739 | 3775 | ||
@@ -4163,7 +4199,6 @@ queue_send_msg (struct Queue *queue, | |||
4163 | struct GNUNET_TRANSPORT_SendMessageTo *smt; | 4199 | struct GNUNET_TRANSPORT_SendMessageTo *smt; |
4164 | struct GNUNET_MQ_Envelope *env; | 4200 | struct GNUNET_MQ_Envelope *env; |
4165 | 4201 | ||
4166 | // queue->idle = GNUNET_NO; | ||
4167 | GNUNET_log ( | 4202 | GNUNET_log ( |
4168 | GNUNET_ERROR_TYPE_DEBUG, | 4203 | GNUNET_ERROR_TYPE_DEBUG, |
4169 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", | 4204 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", |
@@ -5164,9 +5199,12 @@ handle_del_address (void *cls, | |||
5164 | ale->address); | 5199 | ale->address); |
5165 | free_address_list_entry (ale); | 5200 | free_address_list_entry (ale); |
5166 | GNUNET_SERVICE_client_continue (tc->client); | 5201 | GNUNET_SERVICE_client_continue (tc->client); |
5202 | return; | ||
5167 | } | 5203 | } |
5168 | GNUNET_break (0); | 5204 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
5169 | GNUNET_SERVICE_client_drop (tc->client); | 5205 | "Communicator removed address we did not even have.\n"); |
5206 | GNUNET_SERVICE_client_continue (tc->client); | ||
5207 | // GNUNET_SERVICE_client_drop (tc->client); | ||
5170 | } | 5208 | } |
5171 | 5209 | ||
5172 | 5210 | ||
@@ -8832,6 +8870,8 @@ transmit_on_queue (void *cls) | |||
8832 | queue->idle = GNUNET_YES; | 8870 | queue->idle = GNUNET_YES; |
8833 | return; | 8871 | return; |
8834 | } | 8872 | } |
8873 | /* There is a message pending, we are certainly not idle */ | ||
8874 | queue->idle = GNUNET_NO; | ||
8835 | 8875 | ||
8836 | /* Given selection in `sc`, do transmission */ | 8876 | /* Given selection in `sc`, do transmission */ |
8837 | pm = sc.best; | 8877 | pm = sc.best; |
@@ -8940,7 +8980,8 @@ transmit_on_queue (void *cls) | |||
8940 | 8980 | ||
8941 | OPTIMIZE: Note that in the future this heuristic should likely | 8981 | OPTIMIZE: Note that in the future this heuristic should likely |
8942 | be improved further (measure RTT stability, consider message | 8982 | be improved further (measure RTT stability, consider message |
8943 | urgency and size when delaying ACKs, etc.) */update_pm_next_attempt (pm, | 8983 | urgency and size when delaying ACKs, etc.) */ |
8984 | update_pm_next_attempt (pm, | ||
8944 | GNUNET_TIME_relative_to_absolute ( | 8985 | GNUNET_TIME_relative_to_absolute ( |
8945 | GNUNET_TIME_relative_multiply (queue->pd.aged_rtt, | 8986 | GNUNET_TIME_relative_multiply (queue->pd.aged_rtt, |
8946 | 4))); | 8987 | 4))); |
@@ -9072,7 +9113,6 @@ handle_send_message_ack (void *cls, | |||
9072 | NULL != queue; | 9113 | NULL != queue; |
9073 | queue = queue->next_client) | 9114 | queue = queue->next_client) |
9074 | { | 9115 | { |
9075 | queue->idle = GNUNET_YES; | ||
9076 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9116 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
9077 | } | 9117 | } |
9078 | } | 9118 | } |
@@ -9083,7 +9123,6 @@ handle_send_message_ack (void *cls, | |||
9083 | "# Transmission throttled due to queue queue limit", | 9123 | "# Transmission throttled due to queue queue limit", |
9084 | -1, | 9124 | -1, |
9085 | GNUNET_NO); | 9125 | GNUNET_NO); |
9086 | qe->queue->idle = GNUNET_YES; | ||
9087 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9126 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
9088 | } | 9127 | } |
9089 | 9128 | ||
@@ -10058,13 +10097,17 @@ do_shutdown (void *cls) | |||
10058 | struct LearnLaunchEntry *lle; | 10097 | struct LearnLaunchEntry *lle; |
10059 | 10098 | ||
10060 | (void) cls; | 10099 | (void) cls; |
10061 | 10100 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, | |
10062 | //GNUNET_CONTAINER_multipeermap_iterate (neighbours, | 10101 | &free_neighbour_cb, NULL); |
10063 | //&free_neighbour_cb, NULL); | 10102 | if (NULL != validation_task) |
10064 | if (NULL != peerstore) | ||
10065 | { | 10103 | { |
10066 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); | 10104 | GNUNET_SCHEDULER_cancel (validation_task); |
10067 | peerstore = NULL; | 10105 | validation_task = NULL; |
10106 | } | ||
10107 | if (NULL != dvlearn_task) | ||
10108 | { | ||
10109 | GNUNET_SCHEDULER_cancel (dvlearn_task); | ||
10110 | dvlearn_task = NULL; | ||
10068 | } | 10111 | } |
10069 | if (NULL != GST_stats) | 10112 | if (NULL != GST_stats) |
10070 | { | 10113 | { |
@@ -10110,6 +10153,13 @@ do_shutdown (void *cls) | |||
10110 | GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); | 10153 | GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); |
10111 | GNUNET_free (lle); | 10154 | GNUNET_free (lle); |
10112 | } | 10155 | } |
10156 | if (NULL != peerstore) | ||
10157 | { | ||
10158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
10159 | "Disconnecting from PEERSTORE service\n"); | ||
10160 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); | ||
10161 | peerstore = NULL; | ||
10162 | } | ||
10113 | GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map); | 10163 | GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map); |
10114 | dvlearn_map = NULL; | 10164 | dvlearn_map = NULL; |
10115 | GNUNET_CONTAINER_heap_destroy (validation_heap); | 10165 | GNUNET_CONTAINER_heap_destroy (validation_heap); |
@@ -10117,6 +10167,16 @@ do_shutdown (void *cls) | |||
10117 | GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL); | 10167 | GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL); |
10118 | GNUNET_CONTAINER_multipeermap_destroy (dv_routes); | 10168 | GNUNET_CONTAINER_multipeermap_destroy (dv_routes); |
10119 | dv_routes = NULL; | 10169 | dv_routes = NULL; |
10170 | GNUNET_SCHEDULER_shutdown (); | ||
10171 | } | ||
10172 | |||
10173 | |||
10174 | static void | ||
10175 | shutdown_task (void *cls) | ||
10176 | { | ||
10177 | in_shutdown = GNUNET_YES; | ||
10178 | if (NULL == clients_head) | ||
10179 | do_shutdown (cls); | ||
10120 | } | 10180 | } |
10121 | 10181 | ||
10122 | 10182 | ||
@@ -10136,6 +10196,7 @@ run (void *cls, | |||
10136 | (void) service; | 10196 | (void) service; |
10137 | /* setup globals */ | 10197 | /* setup globals */ |
10138 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); | 10198 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); |
10199 | in_shutdown = GNUNET_NO; | ||
10139 | GST_cfg = c; | 10200 | GST_cfg = c; |
10140 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | 10201 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
10141 | pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES); | 10202 | pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES); |
@@ -10165,7 +10226,7 @@ run (void *cls, | |||
10165 | "My identity is `%s'\n", | 10226 | "My identity is `%s'\n", |
10166 | GNUNET_i2s_full (&GST_my_identity)); | 10227 | GNUNET_i2s_full (&GST_my_identity)); |
10167 | GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); | 10228 | GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); |
10168 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 10229 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
10169 | peerstore = GNUNET_PEERSTORE_connect (GST_cfg); | 10230 | peerstore = GNUNET_PEERSTORE_connect (GST_cfg); |
10170 | if (NULL == peerstore) | 10231 | if (NULL == peerstore) |
10171 | { | 10232 | { |
diff --git a/src/transport/test_transport_api2_tcp_peer1.conf b/src/transport/test_transport_api2_tcp_peer1.conf index 417a855ad..745ed6887 100644 --- a/src/transport/test_transport_api2_tcp_peer1.conf +++ b/src/transport/test_transport_api2_tcp_peer1.conf | |||
@@ -6,12 +6,15 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/ | |||
6 | BINARY = gnunet-service-tng | 6 | BINARY = gnunet-service-tng |
7 | PLUGINS = tcp | 7 | PLUGINS = tcp |
8 | #PREFIX = valgrind --log-file=/tmp/vg_peer1-%p | 8 | #PREFIX = valgrind --log-file=/tmp/vg_peer1-%p |
9 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock | ||
9 | 10 | ||
10 | [communicator-tcp] | 11 | [communicator-tcp] |
11 | BINARY = gnunet-communicator-tcp | 12 | BINARY = gnunet-communicator-tcp |
12 | BINDTO = 60002 | 13 | BINDTO = 60002 |
13 | DISABLE_V6 = YES | 14 | DISABLE_V6 = YES |
14 | IMMEDIATE_START = YES | 15 | IMMEDIATE_START = YES |
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock | ||
17 | #PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p | ||
15 | 18 | ||
16 | [peerstore] | 19 | [peerstore] |
17 | IMMEDIATE_START = YES | 20 | IMMEDIATE_START = YES |
diff --git a/src/transport/test_transport_api2_tcp_peer2.conf b/src/transport/test_transport_api2_tcp_peer2.conf index 949bd95f3..022468bcd 100644 --- a/src/transport/test_transport_api2_tcp_peer2.conf +++ b/src/transport/test_transport_api2_tcp_peer2.conf | |||
@@ -5,12 +5,15 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p2/ | |||
5 | [transport] | 5 | [transport] |
6 | BINARY = gnunet-service-tng | 6 | BINARY = gnunet-service-tng |
7 | #PREFIX = valgrind --log-file=/tmp/vg_peer2-%p | 7 | #PREFIX = valgrind --log-file=/tmp/vg_peer2-%p |
8 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p2.sock | ||
8 | 9 | ||
9 | [communicator-tcp] | 10 | [communicator-tcp] |
10 | BINARY = gnunet-communicator-tcp | 11 | BINARY = gnunet-communicator-tcp |
11 | BINDTO = 60003 | 12 | BINDTO = 60003 |
12 | DISABLE_V6 = YES | 13 | DISABLE_V6 = YES |
13 | IMMEDIATE_START = YES | 14 | IMMEDIATE_START = YES |
15 | #PREFIX = valgrind --log-file=/tmp/vg_comm2-%p | ||
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p2.sock | ||
14 | 17 | ||
15 | [peerstore] | 18 | [peerstore] |
16 | IMMEDIATE_START = YES | 19 | IMMEDIATE_START = YES |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index d553a3961..eaa8a5f15 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -328,6 +328,8 @@ notify_disconnect (void *cls, | |||
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | static void | ||
332 | retrieve_hello (void *cls); | ||
331 | 333 | ||
332 | static void | 334 | static void |
333 | hello_iter_cb (void *cb_cls, | 335 | hello_iter_cb (void *cb_cls, |
@@ -338,14 +340,15 @@ hello_iter_cb (void *cb_cls, | |||
338 | if ((NULL == record) && (NULL == emsg)) | 340 | if ((NULL == record) && (NULL == emsg)) |
339 | { | 341 | { |
340 | p->pic = NULL; | 342 | p->pic = NULL; |
341 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n"); | 343 | if (NULL != p->start_cb) |
344 | p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p); | ||
342 | return; | 345 | return; |
343 | } | 346 | } |
344 | //Check record type et al? | 347 | // Check record type et al? |
345 | p->hello_size = record->value_size; | 348 | p->hello_size = record->value_size; |
346 | p->hello = GNUNET_malloc (p->hello_size); | 349 | p->hello = GNUNET_malloc (p->hello_size); |
347 | memcpy (p->hello, record->value, p->hello_size); | 350 | memcpy (p->hello, record->value, p->hello_size); |
348 | p->hello[p->hello_size-1] = '\0'; | 351 | p->hello[p->hello_size - 1] = '\0'; |
349 | 352 | ||
350 | GNUNET_PEERSTORE_iterate_cancel (p->pic); | 353 | GNUNET_PEERSTORE_iterate_cancel (p->pic); |
351 | p->pic = NULL; | 354 | p->pic = NULL; |
@@ -360,13 +363,12 @@ hello_iter_cb (void *cb_cls, | |||
360 | } | 363 | } |
361 | } | 364 | } |
362 | 365 | ||
366 | |||
363 | static void | 367 | static void |
364 | retrieve_hello(void *cls) | 368 | retrieve_hello (void *cls) |
365 | { | 369 | { |
366 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; | 370 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
367 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 371 | p->rh_task = NULL; |
368 | "Getting hello...\n"); | ||
369 | |||
370 | p->pic = GNUNET_PEERSTORE_iterate (p->ph, | 372 | p->pic = GNUNET_PEERSTORE_iterate (p->ph, |
371 | "transport", | 373 | "transport", |
372 | &p->id, | 374 | &p->id, |
@@ -377,7 +379,6 @@ retrieve_hello(void *cls) | |||
377 | } | 379 | } |
378 | 380 | ||
379 | 381 | ||
380 | |||
381 | /** | 382 | /** |
382 | * Start a peer with the given configuration | 383 | * Start a peer with the given configuration |
383 | * @param tth the testing handle | 384 | * @param tth the testing handle |
@@ -535,11 +536,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct | |||
535 | // FIXME Error handling | 536 | // FIXME Error handling |
536 | p->ah = GNUNET_TRANSPORT_application_init (p->cfg); | 537 | p->ah = GNUNET_TRANSPORT_application_init (p->cfg); |
537 | GNUNET_assert (NULL != p->ah); | 538 | GNUNET_assert (NULL != p->ah); |
538 | // FIXME Error handleing | 539 | // FIXME Error handling |
539 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 540 | p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p); |
540 | retrieve_hello, | ||
541 | p); | ||
542 | //GNUNET_assert (NULL != p->pic); | ||
543 | 541 | ||
544 | return p; | 542 | return p; |
545 | } | 543 | } |
@@ -650,6 +648,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
650 | struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth; | 648 | struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth; |
651 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; | 649 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; |
652 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn; | 650 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn; |
651 | /* shutdown */ | ||
652 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
653 | "Stopping peer %u (`%s')\n", | ||
654 | p->no, | ||
655 | GNUNET_i2s (&p->id)); | ||
653 | 656 | ||
654 | for (cc = tth->cc_head; NULL != cc; cc = ccn) | 657 | for (cc = tth->cc_head; NULL != cc; cc = ccn) |
655 | { | 658 | { |
@@ -660,7 +663,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
660 | } | 663 | } |
661 | if (NULL != p->pic) | 664 | if (NULL != p->pic) |
662 | { | 665 | { |
663 | //GNUNET_PEERSTORE_iterate_cancel (p->pic); | 666 | GNUNET_PEERSTORE_iterate_cancel (p->pic); |
664 | p->pic = NULL; | 667 | p->pic = NULL; |
665 | } | 668 | } |
666 | if (NULL != p->th) | 669 | if (NULL != p->th) |
@@ -668,19 +671,6 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
668 | GNUNET_TRANSPORT_core_disconnect (p->th); | 671 | GNUNET_TRANSPORT_core_disconnect (p->th); |
669 | p->th = NULL; | 672 | p->th = NULL; |
670 | } | 673 | } |
671 | if (NULL != p->peer) | ||
672 | { | ||
673 | if (GNUNET_OK != | ||
674 | GNUNET_TESTING_peer_stop (p->peer)) | ||
675 | { | ||
676 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
677 | "Testing lib failed to stop peer %u (`%s')\n", | ||
678 | p->no, | ||
679 | GNUNET_i2s (&p->id)); | ||
680 | } | ||
681 | GNUNET_TESTING_peer_destroy (p->peer); | ||
682 | p->peer = NULL; | ||
683 | } | ||
684 | if (NULL != p->ats) | 674 | if (NULL != p->ats) |
685 | { | 675 | { |
686 | GNUNET_ATS_connectivity_done (p->ats); | 676 | GNUNET_ATS_connectivity_done (p->ats); |
@@ -693,9 +683,25 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
693 | } | 683 | } |
694 | if (NULL != p->ph) | 684 | if (NULL != p->ph) |
695 | { | 685 | { |
686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
687 | "Disconnecting from PEERSTORE service\n"); | ||
696 | GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO); | 688 | GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO); |
697 | p->ph = NULL; | 689 | p->ph = NULL; |
698 | } | 690 | } |
691 | |||
692 | if (NULL != p->peer) | ||
693 | { | ||
694 | if (GNUNET_OK != | ||
695 | GNUNET_TESTING_peer_stop (p->peer)) | ||
696 | { | ||
697 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
698 | "Testing lib failed to stop peer %u (`%s')\n", | ||
699 | p->no, | ||
700 | GNUNET_i2s (&p->id)); | ||
701 | } | ||
702 | GNUNET_TESTING_peer_destroy (p->peer); | ||
703 | p->peer = NULL; | ||
704 | } | ||
699 | if (NULL != p->hello) | 705 | if (NULL != p->hello) |
700 | { | 706 | { |
701 | GNUNET_free (p->hello); | 707 | GNUNET_free (p->hello); |
@@ -718,6 +724,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
718 | "Peer %u (`%s') stopped\n", | 724 | "Peer %u (`%s') stopped\n", |
719 | p->no, | 725 | p->no, |
720 | GNUNET_i2s (&p->id)); | 726 | GNUNET_i2s (&p->id)); |
727 | if (NULL != p->rh_task) | ||
728 | GNUNET_SCHEDULER_cancel (p->rh_task); | ||
729 | p->rh_task = NULL; | ||
721 | GNUNET_free (p); | 730 | GNUNET_free (p); |
722 | } | 731 | } |
723 | 732 | ||
@@ -728,16 +737,16 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
728 | * FIXME maybe schedule the application_validate somehow | 737 | * FIXME maybe schedule the application_validate somehow |
729 | */ | 738 | */ |
730 | /* | 739 | /* |
731 | static void | 740 | static void |
732 | hello_offered (void *cls) | 741 | hello_offered (void *cls) |
733 | { | 742 | { |
734 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | 743 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; |
735 | 744 | ||
736 | cc->oh = NULL; | 745 | cc->oh = NULL; |
737 | cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 746 | cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
738 | &offer_hello, | 747 | &offer_hello, |
739 | cc); | 748 | cc); |
740 | }*/ | 749 | }*/ |
741 | 750 | ||
742 | 751 | ||
743 | /** | 752 | /** |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index 8c0f03556..db8700df9 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -145,6 +145,11 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext | |||
145 | GNUNET_SCHEDULER_TaskCallback start_cb; | 145 | GNUNET_SCHEDULER_TaskCallback start_cb; |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Hello get task | ||
149 | */ | ||
150 | struct GNUNET_SCHEDULER_Task *rh_task; | ||
151 | |||
152 | /** | ||
148 | * Closure for the @a nc and @a nd callbacks | 153 | * Closure for the @a nc and @a nd callbacks |
149 | */ | 154 | */ |
150 | void *cb_cls; | 155 | void *cb_cls; |
diff --git a/src/util/.gitignore b/src/util/.gitignore index 8556ee7b8..7c7b7045d 100644 --- a/src/util/.gitignore +++ b/src/util/.gitignore | |||
@@ -80,3 +80,4 @@ python27_location | |||
80 | perf_malloc | 80 | perf_malloc |
81 | perf_mq | 81 | perf_mq |
82 | perf_scheduler | 82 | perf_scheduler |
83 | gnunet-base32 | ||
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 33fe26e34..6b9e083a7 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -152,9 +152,10 @@ libexec_PROGRAMS = \ | |||
152 | gnunet-timeout | 152 | gnunet-timeout |
153 | 153 | ||
154 | bin_PROGRAMS = \ | 154 | bin_PROGRAMS = \ |
155 | gnunet-resolver \ | 155 | gnunet-base32 \ |
156 | gnunet-config \ | 156 | gnunet-config \ |
157 | gnunet-crypto-tvg \ | 157 | gnunet-crypto-tvg \ |
158 | gnunet-resolver \ | ||
158 | $(GNUNET_ECC) \ | 159 | $(GNUNET_ECC) \ |
159 | $(GNUNET_SCRYPT) \ | 160 | $(GNUNET_SCRYPT) \ |
160 | gnunet-uri | 161 | gnunet-uri |
@@ -203,6 +204,12 @@ gnunet_ecc_LDADD = \ | |||
203 | libgnunetutil.la \ | 204 | libgnunetutil.la \ |
204 | $(GN_LIBINTL) -lgcrypt | 205 | $(GN_LIBINTL) -lgcrypt |
205 | 206 | ||
207 | gnunet_base32_SOURCES = \ | ||
208 | gnunet-base32.c | ||
209 | gnunet_base32_LDADD = \ | ||
210 | libgnunetutil.la \ | ||
211 | $(GN_LIBINTL) | ||
212 | |||
206 | gnunet_scrypt_SOURCES = \ | 213 | gnunet_scrypt_SOURCES = \ |
207 | gnunet-scrypt.c | 214 | gnunet-scrypt.c |
208 | gnunet_scrypt_LDADD = \ | 215 | gnunet_scrypt_LDADD = \ |
diff --git a/src/util/gnunet-base32.c b/src/util/gnunet-base32.c new file mode 100644 index 000000000..2c797f56e --- /dev/null +++ b/src/util/gnunet-base32.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file util/gnunet-base32.c | ||
23 | * @brief tool to encode/decode from/to the Crockford Base32 encoding GNUnet uses | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | |||
29 | |||
30 | /** | ||
31 | * The main function of gnunet-base32 | ||
32 | * | ||
33 | * @param argc number of arguments from the command line | ||
34 | * @param argv command line arguments | ||
35 | * @return 0 ok, 1 on error | ||
36 | */ | ||
37 | int | ||
38 | main (int argc, | ||
39 | char *const *argv) | ||
40 | { | ||
41 | int decode = 0; | ||
42 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
43 | GNUNET_GETOPT_option_flag ('d', | ||
44 | "decode", | ||
45 | gettext_noop ("run decoder modus, otherwise runs as encoder"), | ||
46 | &decode), | ||
47 | GNUNET_GETOPT_option_help ("Crockford base32 encoder/decoder"), | ||
48 | GNUNET_GETOPT_option_version (PACKAGE_VERSION), | ||
49 | GNUNET_GETOPT_OPTION_END | ||
50 | }; | ||
51 | int ret; | ||
52 | char *in; | ||
53 | unsigned int in_size; | ||
54 | ssize_t iret; | ||
55 | char *out; | ||
56 | size_t out_size; | ||
57 | |||
58 | if (GNUNET_OK != | ||
59 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
60 | &argc, &argv)) | ||
61 | return 2; | ||
62 | ret = GNUNET_GETOPT_run ("gnunet-base32", | ||
63 | options, | ||
64 | argc, | ||
65 | argv); | ||
66 | if (ret < 0) | ||
67 | return 1; | ||
68 | if (0 == ret) | ||
69 | return 0; | ||
70 | in_size = 0; | ||
71 | in = NULL; | ||
72 | iret = 1; | ||
73 | while (iret > 0) | ||
74 | { | ||
75 | /* read in blocks of 4k */ | ||
76 | char buf[4092]; | ||
77 | |||
78 | iret = read (0, | ||
79 | buf, | ||
80 | sizeof (buf)); | ||
81 | if (iret < 0) | ||
82 | { | ||
83 | GNUNET_free (in); | ||
84 | return 2; | ||
85 | } | ||
86 | if (iret > 0) | ||
87 | { | ||
88 | if (iret + in_size < in_size) | ||
89 | { | ||
90 | GNUNET_break (0); | ||
91 | GNUNET_free (in); | ||
92 | return 1; | ||
93 | } | ||
94 | GNUNET_array_grow (in, | ||
95 | in_size, | ||
96 | in_size + iret); | ||
97 | memcpy (&in[in_size - iret], | ||
98 | buf, | ||
99 | iret); | ||
100 | } | ||
101 | } | ||
102 | if (decode) | ||
103 | { | ||
104 | /* This formula can overestimate by 1 byte, so we try both | ||
105 | out_size and out_size-1 below */ | ||
106 | out_size = in_size * 5 / 8; | ||
107 | out = GNUNET_malloc (out_size); | ||
108 | if (GNUNET_OK != | ||
109 | GNUNET_STRINGS_string_to_data (in, | ||
110 | in_size, | ||
111 | out, | ||
112 | out_size)) | ||
113 | { | ||
114 | out_size--; | ||
115 | if (GNUNET_OK != | ||
116 | GNUNET_STRINGS_string_to_data (in, | ||
117 | in_size, | ||
118 | out, | ||
119 | out_size)) | ||
120 | { | ||
121 | GNUNET_free (out); | ||
122 | GNUNET_free (in); | ||
123 | return 3; | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | out = GNUNET_STRINGS_data_to_string_alloc (in, | ||
130 | in_size); | ||
131 | out_size = strlen (out); | ||
132 | } | ||
133 | { | ||
134 | size_t pos = 0; | ||
135 | |||
136 | while (pos < out_size) | ||
137 | { | ||
138 | iret = write (1, | ||
139 | &out[pos], | ||
140 | out_size - pos); | ||
141 | if (iret <= 0) | ||
142 | return 4; | ||
143 | pos += iret; | ||
144 | } | ||
145 | } | ||
146 | GNUNET_free (out); | ||
147 | GNUNET_free_nz ((void *) argv); | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | |||
152 | /* end of gnunet-uri.c */ | ||
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c index 5c3dfc12e..fe8b6769f 100644 --- a/src/util/gnunet-scrypt.c +++ b/src/util/gnunet-scrypt.c | |||
@@ -290,8 +290,8 @@ run (void *cls, | |||
290 | int | 290 | int |
291 | main (int argc, char *const *argv) | 291 | main (int argc, char *const *argv) |
292 | { | 292 | { |
293 | struct GNUNET_GETOPT_CommandLineOption options[] = | 293 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
294 | { GNUNET_GETOPT_option_ulong ( | 294 | GNUNET_GETOPT_option_ulong ( |
295 | 'b', | 295 | 'b', |
296 | "bits", | 296 | "bits", |
297 | "BITS", | 297 | "BITS", |
@@ -315,7 +315,8 @@ main (int argc, char *const *argv) | |||
315 | gettext_noop ( | 315 | gettext_noop ( |
316 | "time to wait between calculations"), | 316 | "time to wait between calculations"), |
317 | &proof_find_delay), | 317 | &proof_find_delay), |
318 | GNUNET_GETOPT_OPTION_END }; | 318 | GNUNET_GETOPT_OPTION_END |
319 | }; | ||
319 | int ret; | 320 | int ret; |
320 | 321 | ||
321 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 322 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |