diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-10 21:51:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-19 12:39:55 +0100 |
commit | ba9296269617c157baffb59a6240c87ae5935e95 (patch) | |
tree | 7f82470cce894be0b3441f8150baea36d7138834 /src/include | |
parent | 25ef40ef768743a10b7b29881c267e0fdc9fc677 (diff) | |
download | gnunet-ba9296269617c157baffb59a6240c87ae5935e95.tar.gz gnunet-ba9296269617c157baffb59a6240c87ae5935e95.zip |
first steps towards usable dhtu
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_block_lib.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_dhtu_plugin.h | 23 | ||||
-rw-r--r-- | src/include/gnunet_hello_uri_lib.h | 169 |
4 files changed, 182 insertions, 17 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e4b02b8ee..8808f6802 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -57,6 +57,7 @@ gnunetinclude_HEADERS = \ | |||
57 | gnunet_gnsrecord_plugin.h \ | 57 | gnunet_gnsrecord_plugin.h \ |
58 | gnu_name_system_record_types.h \ | 58 | gnu_name_system_record_types.h \ |
59 | gnunet_hello_lib.h \ | 59 | gnunet_hello_lib.h \ |
60 | gnunet_hello_uri_lib.h \ | ||
60 | gnunet_helper_lib.h \ | 61 | gnunet_helper_lib.h \ |
61 | gnunet_identity_service.h \ | 62 | gnunet_identity_service.h \ |
62 | gnunet_abe_lib.h \ | 63 | gnunet_abe_lib.h \ |
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 5640209a6..f6db8d642 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -119,6 +119,12 @@ enum GNUNET_BLOCK_Type | |||
119 | GNUNET_BLOCK_TYPE_REVOCATION = 12, | 119 | GNUNET_BLOCK_TYPE_REVOCATION = 12, |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Type of a block that contains a DHT-NG HELLO for a peer (for | ||
123 | * DHT and CADET find-peer operations). | ||
124 | */ | ||
125 | GNUNET_BLOCK_TYPE_DHT_URL_HELLO = 13, | ||
126 | |||
127 | /** | ||
122 | * Block to store a cadet regex state | 128 | * Block to store a cadet regex state |
123 | */ | 129 | */ |
124 | GNUNET_BLOCK_TYPE_REGEX = 22, | 130 | GNUNET_BLOCK_TYPE_REGEX = 22, |
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h index 2c97d5848..b709ce9ae 100644 --- a/src/include/gnunet_dhtu_plugin.h +++ b/src/include/gnunet_dhtu_plugin.h | |||
@@ -59,15 +59,6 @@ struct GNUNET_DHTU_PreferenceHandle; | |||
59 | 59 | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Key used to identify peer's position in the DHT. | ||
63 | */ | ||
64 | struct GNUNET_DHTU_HashKey | ||
65 | { | ||
66 | struct GNUNET_HashCode sha512; | ||
67 | }; | ||
68 | |||
69 | |||
70 | /** | ||
71 | * The datastore service will pass a pointer to a struct | 62 | * The datastore service will pass a pointer to a struct |
72 | * of this type as the first and only argument to the | 63 | * of this type as the first and only argument to the |
73 | * entry point of each datastore plugin. | 64 | * entry point of each datastore plugin. |
@@ -88,7 +79,6 @@ struct GNUNET_DHTU_PluginEnvironment | |||
88 | * Function to call with new addresses of this peer. | 79 | * Function to call with new addresses of this peer. |
89 | * | 80 | * |
90 | * @param cls the closure | 81 | * @param cls the closure |
91 | * @param key hash position of this address in the DHT | ||
92 | * @param address address under which we are likely reachable, | 82 | * @param address address under which we are likely reachable, |
93 | * pointer will remain valid until @e address_del_cb is called; to be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/" | 83 | * pointer will remain valid until @e address_del_cb is called; to be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/" |
94 | * @param source handle for sending from this address, NULL if we can only receive | 84 | * @param source handle for sending from this address, NULL if we can only receive |
@@ -96,7 +86,6 @@ struct GNUNET_DHTU_PluginEnvironment | |||
96 | */ | 86 | */ |
97 | void | 87 | void |
98 | (*address_add_cb)(void *cls, | 88 | (*address_add_cb)(void *cls, |
99 | struct GNUNET_DHTU_HashKey *key, | ||
100 | const char *address, | 89 | const char *address, |
101 | struct GNUNET_DHTU_Source *source, | 90 | struct GNUNET_DHTU_Source *source, |
102 | void **ctx); | 91 | void **ctx); |
@@ -128,18 +117,16 @@ struct GNUNET_DHTU_PluginEnvironment | |||
128 | * that peer. | 117 | * that peer. |
129 | * | 118 | * |
130 | * @param cls the closure | 119 | * @param cls the closure |
131 | * @param pk public key of the target, | ||
132 | * pointer will remain valid until @e disconnect_cb is called | ||
133 | * @para peer_id hash position of the peer, | ||
134 | * pointer will remain valid until @e disconnect_cb is called | ||
135 | * @param target handle to the target, | 120 | * @param target handle to the target, |
136 | * pointer will remain valid until @e disconnect_cb is called | 121 | * pointer will remain valid until @e disconnect_cb is called |
122 | * @para pid peer identity, | ||
123 | * pointer will remain valid until @e disconnect_cb is called | ||
137 | * @param[out] ctx storage space for DHT to use in association with this target | 124 | * @param[out] ctx storage space for DHT to use in association with this target |
138 | */ | 125 | */ |
139 | void | 126 | void |
140 | (*connect_cb)(void *cls, | 127 | (*connect_cb)(void *cls, |
141 | struct GNUNET_DHTU_Target *target, | 128 | struct GNUNET_DHTU_Target *target, |
142 | struct GNUNET_DHTU_HashKey *key, | 129 | const struct GNUNET_PeerIdentity *pid, |
143 | void **ctx); | 130 | void **ctx); |
144 | 131 | ||
145 | /** | 132 | /** |
@@ -185,10 +172,12 @@ struct GNUNET_DHTU_PluginFunctions | |||
185 | * Request creation of a session with a peer at the given @a address. | 172 | * Request creation of a session with a peer at the given @a address. |
186 | * | 173 | * |
187 | * @param cls closure (internal context for the plugin) | 174 | * @param cls closure (internal context for the plugin) |
188 | * @param address target address to connect to | 175 | * @param pid target identity of the peer to connect to |
176 | * @param address target address URI to connect to | ||
189 | */ | 177 | */ |
190 | void | 178 | void |
191 | (*try_connect) (void *cls, | 179 | (*try_connect) (void *cls, |
180 | struct GNUNET_PeerIdentity *pid, | ||
192 | const char *address); | 181 | const char *address); |
193 | 182 | ||
194 | 183 | ||
diff --git a/src/include/gnunet_hello_uri_lib.h b/src/include/gnunet_hello_uri_lib.h new file mode 100644 index 000000000..0f61384d1 --- /dev/null +++ b/src/include/gnunet_hello_uri_lib.h | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2022 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 | * @file | ||
24 | * Helper library for handling HELLO URIs | ||
25 | * | ||
26 | * @defgroup hello_uri Hello_Uri library | ||
27 | * Helper library for handling HELLO URIs | ||
28 | * | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | #ifndef GNUNET_HELLO_URI_LIB_H | ||
33 | #define GNUNET_HELLO_URI_LIB_H | ||
34 | |||
35 | #ifdef __cplusplus | ||
36 | extern "C" { | ||
37 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
38 | } | ||
39 | #endif | ||
40 | #endif | ||
41 | |||
42 | #include "gnunet_util_lib.h" | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Context for building (or parsing) HELLO URIs. | ||
47 | */ | ||
48 | struct GNUNET_HELLO_Builder; | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Allocate builder. | ||
53 | * | ||
54 | * @param pid peer the builder is for | ||
55 | * @return new builder | ||
56 | */ | ||
57 | struct GNUNET_HELLO_Builder * | ||
58 | GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid); | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Release resources of a @a builder. | ||
63 | * | ||
64 | * @param[in] builder to free | ||
65 | */ | ||
66 | void | ||
67 | GNUNET_HELLO_builder_free (struct GNUNET_HELLO_Builder *builder); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Parse @a msg into builder. | ||
72 | * | ||
73 | * @param msg message to parse | ||
74 | * @return builder, NULL on failure | ||
75 | */ | ||
76 | struct GNUNET_HELLO_Builder * | ||
77 | GNUNET_HELLO_builder_from_msg (const struct GNUNET_MessageHeader *msg); | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Parse GNUnet HELLO @a url into builder. | ||
82 | * | ||
83 | * @param url URL to parse | ||
84 | * @return builder, NULL on failure | ||
85 | */ | ||
86 | struct GNUNET_HELLO_Builder * | ||
87 | GNUNET_HELLO_builder_from_url (const char *url); | ||
88 | |||
89 | |||
90 | /** | ||
91 | * Generate HELLO message from a @a builder | ||
92 | * | ||
93 | * @param builder builder to serialize | ||
94 | * @return HELLO message matching @a builder | ||
95 | */ | ||
96 | struct GNUNET_MQ_Envelope * | ||
97 | GNUNET_HELLO_builder_to_env (struct GNUNET_HELLO_Builder *builder); | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Generate GNUnet HELLO URI from a @a builder | ||
102 | * | ||
103 | * @param builder builder to serialize | ||
104 | * @return hello URI | ||
105 | */ | ||
106 | char * | ||
107 | GNUNET_HELLO_builder_to_url (struct GNUNET_HELLO_Builder *builder); | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Add individual @a address to the @a builder | ||
112 | * | ||
113 | * @param[in,out] builder to update | ||
114 | * @param address address URI to add | ||
115 | */ | ||
116 | enum GNUNET_GenericReturnValue | ||
117 | GNUNET_HELLO_builder_add_address (struct GNUNET_HELLO_Builder *builder, | ||
118 | const char *address); | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Remove individual @a address from the @a builder | ||
123 | * | ||
124 | * @param[in,out] builder to update | ||
125 | * @param address address URI to remove | ||
126 | */ | ||
127 | enum GNUNET_GenericReturnValue | ||
128 | GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder, | ||
129 | const char *address); | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Callback function used to extract URIs from a builder. | ||
134 | * | ||
135 | * @param cls closure | ||
136 | * @param uri one of the URIs | ||
137 | */ | ||
138 | typedef void | ||
139 | (*GNUNET_HELLO_UriCallback) (void *cls, | ||
140 | const char *uri); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Iterate over URIs in a builder. | ||
145 | * | ||
146 | * @param builder builder to iterate over | ||
147 | * @param[out] pid set to the peer the @a builder is for | ||
148 | * @param uc callback invoked for each URI, can be NULL | ||
149 | * @param uc_cls closure for @a addrgen | ||
150 | */ | ||
151 | void | ||
152 | GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, | ||
153 | struct GNUNET_PeerIdentity *pid, | ||
154 | GNUNET_HELLO_UriCallback uc, | ||
155 | void *uc_cls); | ||
156 | |||
157 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
158 | { | ||
159 | #endif | ||
160 | #ifdef __cplusplus | ||
161 | } | ||
162 | #endif | ||
163 | |||
164 | /* ifndef GNUNET_HELLO_URI_LIB_H */ | ||
165 | #endif | ||
166 | |||
167 | /** @} */ /* end of group */ | ||
168 | |||
169 | /* end of gnunet_hello_uri_lib.h */ | ||