diff options
Diffstat (limited to 'src/include/gnunet_dhtu_plugin.h')
-rw-r--r-- | src/include/gnunet_dhtu_plugin.h | 134 |
1 files changed, 20 insertions, 114 deletions
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h index df9729a23..0503dda1c 100644 --- a/src/include/gnunet_dhtu_plugin.h +++ b/src/include/gnunet_dhtu_plugin.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef PLUGIN_DHTU_H | 27 | #ifndef PLUGIN_DHTU_H |
28 | #define PLUGIN_DHTU_H | 28 | #define PLUGIN_DHTU_H |
29 | 29 | ||
30 | |||
30 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
31 | 32 | ||
32 | 33 | ||
@@ -57,62 +58,6 @@ struct GNUNET_DHTU_Target; | |||
57 | */ | 58 | */ |
58 | struct GNUNET_DHTU_PreferenceHandle; | 59 | struct GNUNET_DHTU_PreferenceHandle; |
59 | 60 | ||
60 | /** | ||
61 | * Opaque handle for a private key used by this underlay. | ||
62 | */ | ||
63 | struct GNUNET_DHTU_PrivateKey; | ||
64 | |||
65 | /** | ||
66 | * Handle for a public key used by another peer. Note that | ||
67 | * the underlay used must be communicated separately. | ||
68 | */ | ||
69 | struct GNUNET_DHTU_PublicKey | ||
70 | { | ||
71 | /** | ||
72 | * How long is the public key, in network byte order. | ||
73 | */ | ||
74 | uint16_t size; | ||
75 | |||
76 | /* followed by size-2 bytes of the actual public key */ | ||
77 | }; | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Hash used by the DHT for keys and peers. | ||
82 | */ | ||
83 | struct GNUNET_DHTU_Hash | ||
84 | { | ||
85 | |||
86 | /** | ||
87 | * For now, use a 512 bit hash. (To be discussed). | ||
88 | */ | ||
89 | struct GNUNET_HashCode hc; | ||
90 | }; | ||
91 | |||
92 | |||
93 | /** | ||
94 | * @brief header of what an DHTU signature signs | ||
95 | * this must be followed by "size - 8" bytes of | ||
96 | * the actual signed data | ||
97 | */ | ||
98 | struct GNUNET_DHTU_SignaturePurpose | ||
99 | { | ||
100 | /** | ||
101 | * How many bytes does this signature sign? | ||
102 | * (including this purpose header); in network | ||
103 | * byte order (!). | ||
104 | */ | ||
105 | uint32_t size GNUNET_PACKED; | ||
106 | |||
107 | /** | ||
108 | * What does this signature vouch for? This | ||
109 | * must contain a GNUNET_SIGNATURE_PURPOSE_XXX | ||
110 | * constant (from gnunet_signatures.h). In | ||
111 | * network byte order! | ||
112 | */ | ||
113 | uint32_t purpose GNUNET_PACKED; | ||
114 | }; | ||
115 | |||
116 | 61 | ||
117 | /** | 62 | /** |
118 | * The datastore service will pass a pointer to a struct | 63 | * The datastore service will pass a pointer to a struct |
@@ -131,13 +76,10 @@ struct GNUNET_DHTU_PluginEnvironment | |||
131 | */ | 76 | */ |
132 | void *cls; | 77 | void *cls; |
133 | 78 | ||
134 | /** | 79 | /** |
135 | * Function to call with new addresses of this peer. | 80 | * Function to call with new addresses of this peer. |
136 | * | 81 | * |
137 | * @param cls the closure | 82 | * @param cls the closure |
138 | * @param my_id hash position of this address in the DHT | ||
139 | * @param pk private key of this peer used at @a address, | ||
140 | * pointer will remain valid until @e address_del_cb is called | ||
141 | * @param address address under which we are likely reachable, | 83 | * @param address address under which we are likely reachable, |
142 | * pointer will remain valid until @e address_del_cb is called; to be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/" | 84 | * pointer will remain valid until @e address_del_cb is called; to be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/" |
143 | * @param source handle for sending from this address, NULL if we can only receive | 85 | * @param source handle for sending from this address, NULL if we can only receive |
@@ -145,13 +87,11 @@ struct GNUNET_DHTU_PluginEnvironment | |||
145 | */ | 87 | */ |
146 | void | 88 | void |
147 | (*address_add_cb)(void *cls, | 89 | (*address_add_cb)(void *cls, |
148 | const struct GNUNET_DHTU_Hash *my_id, | ||
149 | const struct GNUNET_DHTU_PrivateKey *pk, | ||
150 | const char *address, | 90 | const char *address, |
151 | struct GNUNET_DHTU_Source *source, | 91 | struct GNUNET_DHTU_Source *source, |
152 | void **ctx); | 92 | void **ctx); |
153 | 93 | ||
154 | /** | 94 | /** |
155 | * Function to call with expired addresses of this peer. | 95 | * Function to call with expired addresses of this peer. |
156 | * | 96 | * |
157 | * @param[in] ctx storage space used by the DHT in association with this address | 97 | * @param[in] ctx storage space used by the DHT in association with this address |
@@ -160,7 +100,7 @@ struct GNUNET_DHTU_PluginEnvironment | |||
160 | (*address_del_cb)(void *ctx); | 100 | (*address_del_cb)(void *ctx); |
161 | 101 | ||
162 | /** | 102 | /** |
163 | * We have a new estimate on the size of the underlay. | 103 | * We have a new estimate on the size of the underlay. |
164 | * | 104 | * |
165 | * @param cls closure | 105 | * @param cls closure |
166 | * @param timestamp time when the estimate was received from the server (or created by the server) | 106 | * @param timestamp time when the estimate was received from the server (or created by the server) |
@@ -172,27 +112,25 @@ struct GNUNET_DHTU_PluginEnvironment | |||
172 | struct GNUNET_TIME_Absolute timestamp, | 112 | struct GNUNET_TIME_Absolute timestamp, |
173 | double logestimate, | 113 | double logestimate, |
174 | double std_dev); | 114 | double std_dev); |
175 | 115 | ||
176 | /** | 116 | /** |
177 | * Function to call when we connect to a peer and can henceforth transmit to | 117 | * Function to call when we connect to a peer and can henceforth transmit to |
178 | * that peer. | 118 | * that peer. |
179 | * | 119 | * |
180 | * @param cls the closure | 120 | * @param cls the closure |
181 | * @param pk public key of the target, | ||
182 | * pointer will remain valid until @e disconnect_cb is called | ||
183 | * @para peer_id hash position of the peer, | ||
184 | * pointer will remain valid until @e disconnect_cb is called | ||
185 | * @param target handle to the target, | 121 | * @param target handle to the target, |
186 | * pointer will remain valid until @e disconnect_cb is called | 122 | * pointer will remain valid until @e disconnect_cb is called |
123 | * @param pid peer identity, | ||
124 | * pointer will remain valid until @e disconnect_cb is called | ||
187 | * @param[out] ctx storage space for DHT to use in association with this target | 125 | * @param[out] ctx storage space for DHT to use in association with this target |
188 | */ | 126 | */ |
189 | void | 127 | void |
190 | (*connect_cb)(void *cls, | 128 | (*connect_cb)(void *cls, |
191 | const struct GNUNET_DHTU_PublicKey *pk, | ||
192 | const struct GNUNET_DHTU_Hash *peer_id, | ||
193 | struct GNUNET_DHTU_Target *target, | 129 | struct GNUNET_DHTU_Target *target, |
130 | const struct GNUNET_PeerIdentity *pid, | ||
194 | void **ctx); | 131 | void **ctx); |
195 | 132 | ||
133 | |||
196 | /** | 134 | /** |
197 | * Function to call when we disconnected from a peer and can henceforth | 135 | * Function to call when we disconnected from a peer and can henceforth |
198 | * cannot transmit to that peer anymore. | 136 | * cannot transmit to that peer anymore. |
@@ -208,7 +146,7 @@ struct GNUNET_DHTU_PluginEnvironment | |||
208 | * @param cls the closure | 146 | * @param cls the closure |
209 | * @param origin where the message originated from | 147 | * @param origin where the message originated from |
210 | * @param[in,out] tctx ctx of target address where we received the message from | 148 | * @param[in,out] tctx ctx of target address where we received the message from |
211 | * @param[in,out] sctx ctx of our own source address at which we received the message | 149 | * @param[in,out] sctx ctx of our own source address at which we received the message |
212 | * @param message the message we received @param message_size number of | 150 | * @param message the message we received @param message_size number of |
213 | * bytes in @a message | 151 | * bytes in @a message |
214 | */ | 152 | */ |
@@ -233,55 +171,23 @@ struct GNUNET_DHTU_PluginFunctions | |||
233 | void *cls; | 171 | void *cls; |
234 | 172 | ||
235 | /** | 173 | /** |
236 | * Use our private key to sign a message. | ||
237 | * | ||
238 | * @param cls closure | ||
239 | * @param pk our private key to sign with | ||
240 | * @param purpose what to sign | ||
241 | * @param[out] signature, allocated on heap and returned | ||
242 | * @return -1 on error, otherwise number of bytes in @a sig | ||
243 | */ | ||
244 | ssize_t | ||
245 | (*sign)(void *cls, | ||
246 | const struct GNUNET_DHTU_PrivateKey *pk, | ||
247 | const struct GNUNET_DHTU_SignaturePurpose *purpose, | ||
248 | void **sig); | ||
249 | |||
250 | /** | ||
251 | * Verify signature in @a sig over @a purpose. | ||
252 | * | ||
253 | * @param cls closure | ||
254 | * @param pk public key to verify signature of | ||
255 | * @param purpose what was being signed | ||
256 | * @param sig signature data | ||
257 | * @param sig_size number of bytes in @a sig | ||
258 | * @return #GNUNET_OK if signature is valid | ||
259 | * #GNUNET_NO if signatures are not supported | ||
260 | * #GNUNET_SYSERR if signature is invalid | ||
261 | */ | ||
262 | enum GNUNET_GenericReturnValue | ||
263 | (*verify)(void *cls, | ||
264 | const struct GNUNET_DHTU_PublicKey *pk, | ||
265 | const struct GNUNET_DHTU_SignaturePurpose *purpose, | ||
266 | const void *sig, | ||
267 | size_t sig_size); | ||
268 | |||
269 | |||
270 | /** | ||
271 | * Request creation of a session with a peer at the given @a address. | 174 | * Request creation of a session with a peer at the given @a address. |
272 | * | 175 | * |
273 | * @param cls closure (internal context for the plugin) | 176 | * @param cls closure (internal context for the plugin) |
274 | * @param address target address to connect to | 177 | * @param pid target identity of the peer to connect to |
178 | * @param address target address URI to connect to | ||
275 | */ | 179 | */ |
276 | void | 180 | void |
277 | (*try_connect) (void *cls, | 181 | (*try_connect) (void *cls, |
182 | const struct GNUNET_PeerIdentity *pid, | ||
278 | const char *address); | 183 | const char *address); |
279 | 184 | ||
185 | |||
280 | /** | 186 | /** |
281 | * Request underlay to keep the connection to @a target alive if possible. | 187 | * Request underlay to keep the connection to @a target alive if possible. |
282 | * Hold may be called multiple times to express a strong preference to | 188 | * Hold may be called multiple times to express a strong preference to |
283 | * keep a connection, say because a @a target is in multiple tables. | 189 | * keep a connection, say because a @a target is in multiple tables. |
284 | * | 190 | * |
285 | * @param cls closure | 191 | * @param cls closure |
286 | * @param target connection to keep alive | 192 | * @param target connection to keep alive |
287 | */ | 193 | */ |
@@ -290,14 +196,14 @@ struct GNUNET_DHTU_PluginFunctions | |||
290 | struct GNUNET_DHTU_Target *target); | 196 | struct GNUNET_DHTU_Target *target); |
291 | 197 | ||
292 | /** | 198 | /** |
293 | * Do no long request underlay to keep the connection alive. | 199 | * Do no longer request underlay to keep the connection alive. |
294 | * | 200 | * |
295 | * @param cls closure | 201 | * @param cls closure |
296 | * @param target connection to keep alive | 202 | * @param target connection to keep alive |
297 | */ | 203 | */ |
298 | void | 204 | void |
299 | (*drop)(struct GNUNET_DHTU_PreferenceHandle *ph); | 205 | (*drop)(struct GNUNET_DHTU_PreferenceHandle *ph); |
300 | 206 | ||
301 | /** | 207 | /** |
302 | * Send message to some other participant over the network. Note that | 208 | * Send message to some other participant over the network. Note that |
303 | * sending is not guaranteeing that the other peer actually received the | 209 | * sending is not guaranteeing that the other peer actually received the |
@@ -310,7 +216,7 @@ struct GNUNET_DHTU_PluginFunctions | |||
310 | * @param msg_size number of bytes in @a msg | 216 | * @param msg_size number of bytes in @a msg |
311 | * @param finished_cb function called once transmission is done | 217 | * @param finished_cb function called once transmission is done |
312 | * (not called if @a target disconnects, then only the | 218 | * (not called if @a target disconnects, then only the |
313 | * disconnect_cb is called). | 219 | * disconnect_cb is called). |
314 | * @param finished_cb_cls closure for @a finished_cb | 220 | * @param finished_cb_cls closure for @a finished_cb |
315 | */ | 221 | */ |
316 | void | 222 | void |
@@ -320,7 +226,7 @@ struct GNUNET_DHTU_PluginFunctions | |||
320 | size_t msg_size, | 226 | size_t msg_size, |
321 | GNUNET_SCHEDULER_TaskCallback finished_cb, | 227 | GNUNET_SCHEDULER_TaskCallback finished_cb, |
322 | void *finished_cb_cls); | 228 | void *finished_cb_cls); |
323 | 229 | ||
324 | }; | 230 | }; |
325 | 231 | ||
326 | 232 | ||