aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--po/POTFILES.in7
-rw-r--r--src/Makefile.am1
-rw-r--r--src/dhtu/Makefile.am24
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c285
-rw-r--r--src/dhtu/plugin_dhtu_ip.c285
-rw-r--r--src/include/gnunet_dhtu_plugin.h4
7 files changed, 606 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 15a829f02..d0185ffe4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1# This file is part of GNUnet. 1# This file is part of GNUnet.
2# (C) 2001--2020 GNUnet e.V. 2# (C) 2001--2021 GNUnet e.V.
3# 3#
4# GNUnet is free software: you can redistribute it and/or modify it 4# GNUnet is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Affero General Public License as published 5# under the terms of the GNU Affero General Public License as published
@@ -1937,6 +1937,7 @@ src/datastore/Makefile
1937src/datastore/datastore.conf 1937src/datastore/datastore.conf
1938src/dht/Makefile 1938src/dht/Makefile
1939src/dht/dht.conf 1939src/dht/dht.conf
1940src/dhtu/Makefile
1940src/dns/Makefile 1941src/dns/Makefile
1941src/dns/dns.conf 1942src/dns/dns.conf
1942src/exit/Makefile 1943src/exit/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 996b8bda2..68b2f3e1f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -115,6 +115,8 @@ src/dht/gnunet-service-dht_nse.c
115src/dht/gnunet-service-dht_routing.c 115src/dht/gnunet-service-dht_routing.c
116src/dht/gnunet_dht_profiler.c 116src/dht/gnunet_dht_profiler.c
117src/dht/plugin_block_dht.c 117src/dht/plugin_block_dht.c
118src/dhtu/plugin_dhtu_gnunet.c
119src/dhtu/plugin_dhtu_ip.c
118src/dns/dns_api.c 120src/dns/dns_api.c
119src/dns/gnunet-dns-monitor.c 121src/dns/gnunet-dns-monitor.c
120src/dns/gnunet-dns-redirector.c 122src/dns/gnunet-dns-redirector.c
@@ -313,7 +315,6 @@ src/reclaim/plugin_rest_reclaim.c
313src/reclaim/reclaim_api.c 315src/reclaim/reclaim_api.c
314src/reclaim/reclaim_attribute.c 316src/reclaim/reclaim_attribute.c
315src/reclaim/reclaim_credential.c 317src/reclaim/reclaim_credential.c
316src/reclaim/test.c
317src/regex/gnunet-daemon-regexprofiler.c 318src/regex/gnunet-daemon-regexprofiler.c
318src/regex/gnunet-regex-profiler.c 319src/regex/gnunet-regex-profiler.c
319src/regex/gnunet-regex-simulation-profiler.c 320src/regex/gnunet-regex-simulation-profiler.c
@@ -413,6 +414,10 @@ src/testbed/gnunet_testbed_mpi_spawn.c
413src/testbed/testbed_api.c 414src/testbed/testbed_api.c
414src/testbed/testbed_api_barriers.c 415src/testbed/testbed_api_barriers.c
415src/testbed/testbed_api_cmd_controller.c 416src/testbed/testbed_api_cmd_controller.c
417src/testbed/testbed_api_cmd_netjail_start.c
418src/testbed/testbed_api_cmd_netjail_start_testbed.c
419src/testbed/testbed_api_cmd_netjail_stop.c
420src/testbed/testbed_api_cmd_netjail_stop_testbed.c
416src/testbed/testbed_api_cmd_peer.c 421src/testbed/testbed_api_cmd_peer.c
417src/testbed/testbed_api_cmd_peer_store.c 422src/testbed/testbed_api_cmd_peer_store.c
418src/testbed/testbed_api_cmd_tng_connect.c 423src/testbed/testbed_api_cmd_tng_connect.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 07b9cf1e9..5df85f9db 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,6 +74,7 @@ SUBDIRS = \
74 $(TESTBED) \ 74 $(TESTBED) \
75 $(ATS_TESTS) \ 75 $(ATS_TESTS) \
76 nse \ 76 nse \
77 dhtu \
77 dht \ 78 dht \
78 hostlist \ 79 hostlist \
79 topology \ 80 topology \
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
new file mode 100644
index 000000000..72b422812
--- /dev/null
+++ b/src/dhtu/Makefile.am
@@ -0,0 +1,24 @@
1# This Makefile.am is in the public domain
2AM_CPPFLAGS = -I$(top_srcdir)/src/include
3
4plugindir = $(libdir)/gnunet
5
6pkgcfgdir= $(pkgdatadir)/config.d/
7
8if USE_COVERAGE
9 AM_CFLAGS = --coverage -O0
10 XLIBS = -lgcov
11endif
12
13plugin_LTLIBRARIES = \
14 libgnunet_plugin_dhtu_ip.la
15
16libgnunet_plugin_dhtu_ip_la_SOURCES = \
17 plugin_dhtu_ip.c
18libgnunet_plugin_dhtu_ip_la_LIBADD = \
19 $(top_builddir)/src/util/libgnunetutil.la \
20 $(XLIBS) \
21 $(LTLIBINTL)
22libgnunet_plugin_dhtu_ip_la_LDFLAGS = \
23 $(GN_PLUGIN_LDFLAGS)
24
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
new file mode 100644
index 000000000..d6cd75242
--- /dev/null
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -0,0 +1,285 @@
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 * @author Christian Grothoff
23 *
24 * @file plugin_dhtu_ip.c
25 * @brief plain IP based DHT network underlay
26 */
27#include "platform.h"
28#incluce "gnunet_dhtu_plugin.h"
29
30/**
31 * Opaque handle that the underlay offers for our address to be used when
32 * sending messages to another peer.
33 */
34struct GNUNET_DHTU_Source
35{
36
37 /**
38 * Application context for this source.
39 */
40 void *app_ctx;
41};
42
43
44/**
45 * Opaque handle that the underlay offers for the target peer when sending
46 * messages to another peer.
47 */
48struct GNUNET_DHTU_Target
49{
50
51 /**
52 * Application context for this target.
53 */
54 void *app_ctx;
55
56 /**
57 * Head of preferences expressed for this target.
58 */
59 struct GNUNET_DHTU_PreferenceHandle *ph_head;
60
61 /**
62 * Tail of preferences expressed for this target.
63 */
64 struct GNUNET_DHTU_PreferenceHandle *ph_tail;
65
66 /**
67 * Preference counter, length of the @a ph_head DLL.
68 */
69 unsigned int ph_count;
70
71};
72
73/**
74 * Opaque handle expressing a preference of the DHT to
75 * keep a particular target connected.
76 */
77struct GNUNET_DHTU_PreferenceHandle
78{
79 /**
80 * Kept in a DLL.
81 */
82 struct GNUNET_DHTU_PreferenceHandle *next;
83
84 /**
85 * Kept in a DLL.
86 */
87 struct GNUNET_DHTU_PreferenceHandle *prev;
88
89 /**
90 * Target a preference was expressed for.
91 */
92 struct GNUNET_DHTU_Target *target;
93};
94
95
96/**
97 * Opaque handle for a private key used by this underlay.
98 */
99struct GNUNET_DHTU_PrivateKey
100{
101 /* we are IP, we do not do crypto */
102};
103
104
105/**
106 * Closure for all plugin functions.
107 */
108struct Plugin
109{
110 /**
111 * Callbacks into the DHT.
112 */
113 struct GNUNET_DHTU_PluginEnvironment *env;
114};
115
116
117/**
118 * Use our private key to sign a message.
119 *
120 * @param cls closure
121 * @param pk our private key to sign with
122 * @param purpose what to sign
123 * @param[out] signature, allocated on heap and returned
124 * @return -1 on error, otherwise number of bytes in @a sig
125 */
126static ssize_t
127ip_sign (void *cls,
128 const struct GNUNET_DHTU_PrivateKey *pk,
129 const struct GNUNET_DHTU_SignaturePurpose *purpose,
130 void **sig)
131{
132 return 0;
133}
134
135
136/**
137 * Verify signature in @a sig over @a purpose.
138 *
139 * @param cls closure
140 * @param pk public key to verify signature of
141 * @param purpose what was being signed
142 * @param sig signature data
143 * @param sig_size number of bytes in @a sig
144 * @return #GNUNET_OK if signature is valid
145 * #GNUNET_NO if signatures are not supported
146 * #GNUNET_SYSERR if signature is invalid
147 */
148static enum GNUNET_GenericReturnValue
149ip_verify (void *cls,
150 const struct GNUNET_DHTU_PublicKey *pk,
151 const struct GNUNET_DHTU_SignaturePurpose *purpose,
152 const void *sig,
153 size_t sig_size)
154{
155 return GNUNET_NO;
156}
157
158
159/**
160 * Request creation of a session with a peer at the given @a address.
161 *
162 * @param cls closure (internal context for the plugin)
163 * @param address target address to connect to
164 */
165static void
166ip_try_connect (void *cls,
167 const char *address)
168{
169 GNUNET_break (0);
170}
171
172
173/**
174 * Request underlay to keep the connection to @a target alive if possible.
175 * Hold may be called multiple times to express a strong preference to
176 * keep a connection, say because a @a target is in multiple tables.
177 *
178 * @param cls closure
179 * @param target connection to keep alive
180 */
181static struct GNUNET_DHTU_PreferenceHandle *
182ip_hold (void *cls,
183 struct GNUNET_DHTU_Target *target)
184{
185 struct GNUNET_DHTU_PreferenceHandle *ph;
186
187 ph = GNUNET_new (struct GNUNET_DHTU_PreferenceHandle);
188 ph->target = target;
189 GNUNET_CONTAINER_DLL_insert (target->ph_head,
190 target->ph_tail,
191 ph);
192 target->ph_count++;
193 return ph;
194}
195
196
197/**
198 * Do no long request underlay to keep the connection alive.
199 *
200 * @param cls closure
201 * @param target connection to keep alive
202 */
203static void
204ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
205{
206 struct GNUNET_DHTU_Target *target = ph->target;
207
208 GNUNET_CONTAINER_DLL_remove (target->ph_head,
209 target->ph_tail,
210 ph);
211 target->ph_count--;
212 GNUNET_free (ph);
213}
214
215
216/**
217 * Send message to some other participant over the network. Note that
218 * sending is not guaranteeing that the other peer actually received the
219 * message. For any given @a target, the DHT must wait for the @a
220 * finished_cb to be called before calling send() again.
221 *
222 * @param cls closure (internal context for the plugin)
223 * @param target receiver identification
224 * @param msg message
225 * @param msg_size number of bytes in @a msg
226 * @param finished_cb function called once transmission is done
227 * (not called if @a target disconnects, then only the
228 * disconnect_cb is called).
229 * @param finished_cb_cls closure for @a finished_cb
230 */
231static void
232ip_send (void *cls,
233 struct GNUNET_DHTU_Target *target,
234 const void *msg,
235 size_t msg_size,
236 GNUNET_SCHEDULER_TaskCallback finished_cb,
237 void *finished_cb_cls)
238{
239 GNUNET_break (0);
240}
241
242
243/**
244 * Entry point for the plugin.
245 *
246 * @param cls closure (the `struct GNUNET_DHTU_PluginEnvironment`)
247 * @return the plugin's API
248 */
249void *
250libgnunet_plugin_dhtu_ip_init (void *cls)
251{
252 struct GNUNET_DHTU_PluginEnvironment *env = cls;
253 struct GNUNET_DHTU_PluginFunctions *api;
254 struct Plugin *plugin;
255
256 plugin = GNUNET_new (struct Plugin);
257 plugin->env = env;
258 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
259 api->cls = plugin;
260 api->sign = &ip_sign;
261 api->verify = &ip_verify;
262 api->try_connect = &ip_try_connect;
263 api->hold = &ip_hold;
264 api->drop = &ip_drop;
265 api->send = &ip_send;
266 return api;
267}
268
269
270/**
271 * Exit point from the plugin.
272 *
273 * @param cls closure (our `struct Plugin`)
274 * @return NULL
275 */
276void *
277libgnunet_plugin_dhtu_gnunet_done (void *cls)
278{
279 struct GNUNET_DHTU_PluginFunctions *api = cls;
280 struct Plugin *plugin = api->cls;
281
282 GNUNET_free (plugin);
283 GNUNET_free (api);
284 return NULL;
285}
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
new file mode 100644
index 000000000..554c096e1
--- /dev/null
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -0,0 +1,285 @@
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 * @author Christian Grothoff
23 *
24 * @file plugin_dhtu_ip.c
25 * @brief plain IP based DHT network underlay
26 */
27#include "platform.h"
28#include "gnunet_dhtu_plugin.h"
29
30/**
31 * Opaque handle that the underlay offers for our address to be used when
32 * sending messages to another peer.
33 */
34struct GNUNET_DHTU_Source
35{
36
37 /**
38 * Application context for this source.
39 */
40 void *app_ctx;
41};
42
43
44/**
45 * Opaque handle that the underlay offers for the target peer when sending
46 * messages to another peer.
47 */
48struct GNUNET_DHTU_Target
49{
50
51 /**
52 * Application context for this target.
53 */
54 void *app_ctx;
55
56 /**
57 * Head of preferences expressed for this target.
58 */
59 struct GNUNET_DHTU_PreferenceHandle *ph_head;
60
61 /**
62 * Tail of preferences expressed for this target.
63 */
64 struct GNUNET_DHTU_PreferenceHandle *ph_tail;
65
66 /**
67 * Preference counter, length of the @a ph_head DLL.
68 */
69 unsigned int ph_count;
70
71};
72
73/**
74 * Opaque handle expressing a preference of the DHT to
75 * keep a particular target connected.
76 */
77struct GNUNET_DHTU_PreferenceHandle
78{
79 /**
80 * Kept in a DLL.
81 */
82 struct GNUNET_DHTU_PreferenceHandle *next;
83
84 /**
85 * Kept in a DLL.
86 */
87 struct GNUNET_DHTU_PreferenceHandle *prev;
88
89 /**
90 * Target a preference was expressed for.
91 */
92 struct GNUNET_DHTU_Target *target;
93};
94
95
96/**
97 * Opaque handle for a private key used by this underlay.
98 */
99struct GNUNET_DHTU_PrivateKey
100{
101 /* we are IP, we do not do crypto */
102};
103
104
105/**
106 * Closure for all plugin functions.
107 */
108struct Plugin
109{
110 /**
111 * Callbacks into the DHT.
112 */
113 struct GNUNET_DHTU_PluginEnvironment *env;
114};
115
116
117/**
118 * Use our private key to sign a message.
119 *
120 * @param cls closure
121 * @param pk our private key to sign with
122 * @param purpose what to sign
123 * @param[out] signature, allocated on heap and returned
124 * @return -1 on error, otherwise number of bytes in @a sig
125 */
126static ssize_t
127ip_sign (void *cls,
128 const struct GNUNET_DHTU_PrivateKey *pk,
129 const struct GNUNET_DHTU_SignaturePurpose *purpose,
130 void **sig)
131{
132 return 0;
133}
134
135
136/**
137 * Verify signature in @a sig over @a purpose.
138 *
139 * @param cls closure
140 * @param pk public key to verify signature of
141 * @param purpose what was being signed
142 * @param sig signature data
143 * @param sig_size number of bytes in @a sig
144 * @return #GNUNET_OK if signature is valid
145 * #GNUNET_NO if signatures are not supported
146 * #GNUNET_SYSERR if signature is invalid
147 */
148static enum GNUNET_GenericReturnValue
149ip_verify (void *cls,
150 const struct GNUNET_DHTU_PublicKey *pk,
151 const struct GNUNET_DHTU_SignaturePurpose *purpose,
152 const void *sig,
153 size_t sig_size)
154{
155 return GNUNET_NO;
156}
157
158
159/**
160 * Request creation of a session with a peer at the given @a address.
161 *
162 * @param cls closure (internal context for the plugin)
163 * @param address target address to connect to
164 */
165static void
166ip_try_connect (void *cls,
167 const char *address)
168{
169 GNUNET_break (0);
170}
171
172
173/**
174 * Request underlay to keep the connection to @a target alive if possible.
175 * Hold may be called multiple times to express a strong preference to
176 * keep a connection, say because a @a target is in multiple tables.
177 *
178 * @param cls closure
179 * @param target connection to keep alive
180 */
181static struct GNUNET_DHTU_PreferenceHandle *
182ip_hold (void *cls,
183 struct GNUNET_DHTU_Target *target)
184{
185 struct GNUNET_DHTU_PreferenceHandle *ph;
186
187 ph = GNUNET_new (struct GNUNET_DHTU_PreferenceHandle);
188 ph->target = target;
189 GNUNET_CONTAINER_DLL_insert (target->ph_head,
190 target->ph_tail,
191 ph);
192 target->ph_count++;
193 return ph;
194}
195
196
197/**
198 * Do no long request underlay to keep the connection alive.
199 *
200 * @param cls closure
201 * @param target connection to keep alive
202 */
203static void
204ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
205{
206 struct GNUNET_DHTU_Target *target = ph->target;
207
208 GNUNET_CONTAINER_DLL_remove (target->ph_head,
209 target->ph_tail,
210 ph);
211 target->ph_count--;
212 GNUNET_free (ph);
213}
214
215
216/**
217 * Send message to some other participant over the network. Note that
218 * sending is not guaranteeing that the other peer actually received the
219 * message. For any given @a target, the DHT must wait for the @a
220 * finished_cb to be called before calling send() again.
221 *
222 * @param cls closure (internal context for the plugin)
223 * @param target receiver identification
224 * @param msg message
225 * @param msg_size number of bytes in @a msg
226 * @param finished_cb function called once transmission is done
227 * (not called if @a target disconnects, then only the
228 * disconnect_cb is called).
229 * @param finished_cb_cls closure for @a finished_cb
230 */
231static void
232ip_send (void *cls,
233 struct GNUNET_DHTU_Target *target,
234 const void *msg,
235 size_t msg_size,
236 GNUNET_SCHEDULER_TaskCallback finished_cb,
237 void *finished_cb_cls)
238{
239 GNUNET_break (0);
240}
241
242
243/**
244 * Entry point for the plugin.
245 *
246 * @param cls closure (the `struct GNUNET_DHTU_PluginEnvironment`)
247 * @return the plugin's API
248 */
249void *
250libgnunet_plugin_dhtu_ip_init (void *cls)
251{
252 struct GNUNET_DHTU_PluginEnvironment *env = cls;
253 struct GNUNET_DHTU_PluginFunctions *api;
254 struct Plugin *plugin;
255
256 plugin = GNUNET_new (struct Plugin);
257 plugin->env = env;
258 api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
259 api->cls = plugin;
260 api->sign = &ip_sign;
261 api->verify = &ip_verify;
262 api->try_connect = &ip_try_connect;
263 api->hold = &ip_hold;
264 api->drop = &ip_drop;
265 api->send = &ip_send;
266 return api;
267}
268
269
270/**
271 * Exit point from the plugin.
272 *
273 * @param cls closure (our `struct Plugin`)
274 * @return NULL
275 */
276void *
277libgnunet_plugin_dhtu_ip_done (void *cls)
278{
279 struct GNUNET_DHTU_PluginFunctions *api = cls;
280 struct Plugin *plugin = api->cls;
281
282 GNUNET_free (plugin);
283 GNUNET_free (api);
284 return NULL;
285}
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index f87d36719..bcf61eaa2 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -27,6 +27,9 @@
27#ifndef PLUGIN_DHTU_H 27#ifndef PLUGIN_DHTU_H
28#define PLUGIN_DHTU_H 28#define PLUGIN_DHTU_H
29 29
30#include "gnunet_util_lib.h"
31
32
30#ifdef __cplusplus 33#ifdef __cplusplus
31extern "C" 34extern "C"
32{ 35{
@@ -270,7 +273,6 @@ struct GNUNET_DHTU_PluginFunctions
270 * Request creation of a session with a peer at the given @a address. 273 * Request creation of a session with a peer at the given @a address.
271 * 274 *
272 * @param cls closure (internal context for the plugin) 275 * @param cls closure (internal context for the plugin)
273 * @param pk public key of the target
274 * @param address target address to connect to 276 * @param address target address to connect to
275 */ 277 */
276 void 278 void