GNUnet  0.11.x
gnunet_dhtu_plugin.h
Go to the documentation of this file.
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 
27 #ifndef PLUGIN_DHTU_H
28 #define PLUGIN_DHTU_H
29 
30 #include "gnunet_util_lib.h"
31 
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0 /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40 
41 
46 struct GNUNET_DHTU_Source;
47 
52 struct GNUNET_DHTU_Target;
53 
59 
64 
70 {
74  uint16_t size;
75 
76  /* followed by size-2 bytes of the actual public key */
77 };
78 
79 
84 {
85 
89  struct GNUNET_HashCode hc;
90 };
91 
92 
99 {
104 
108  void *cls;
109 
122  void
123  (*address_add_cb)(void *cls,
124  const struct GNUNET_DHTU_Hash *my_id,
125  const struct GNUNET_DHTU_PrivateKey *pk,
126  const char *address,
127  struct GNUNET_DHTU_Source *source,
128  void **ctx);
129 
135  void
136  (*address_del_cb)(void *ctx);
137 
146  void
147  (*network_size_cb)(void *cls,
148  struct GNUNET_TIME_Absolute timestamp,
149  double logestimate,
150  double std_dev);
151 
165  void
166  (*connect_cb)(void *cls,
167  const struct GNUNET_DHTU_PublicKey *pk,
168  const struct GNUNET_DHTU_Hash *peer_id,
169  struct GNUNET_DHTU_Target *target,
170  void **ctx);
171 
178  void
179  (*disconnect_cb)(void *ctx);
180 
191  void
192  (*receive_cb)(void *cls,
193  void **tctx,
194  void **sctx,
195  const void *message,
196  size_t message_size);
197 
198 };
199 
200 
205 {
209  void *cls;
210 
220  ssize_t
221  (*sign)(void *cls,
222  const struct GNUNET_DHTU_PrivateKey *pk,
224  void **sig);
225 
239  (*verify)(void *cls,
240  const struct GNUNET_DHTU_PublicKey *pk,
242  const void *sig,
243  size_t sig_size);
244 
245 
252  void
253  (*try_connect) (void *cls,
254  const char *address);
255 
265  (*hold)(void *cls,
266  struct GNUNET_DHTU_Target *target);
267 
274  void
276 
292  void
293  (*send) (void *cls,
294  struct GNUNET_DHTU_Target *target,
295  const void *msg,
296  size_t msg_size,
297  GNUNET_SCHEDULER_TaskCallback finished_cb,
298  void *finished_cb_cls);
299 
300 };
301 
302 
303 #if 0 /* keep Emacsens' auto-indent happy */
304 {
305 #endif
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #endif
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static char * address
GNS address for this phone.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Hash used by the DHT for keys and peers.
struct GNUNET_HashCode hc
For now, use a 512 bit hash.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
void * cls
Closure to use for callbacks.
void(* connect_cb)(void *cls, const struct GNUNET_DHTU_PublicKey *pk, const struct GNUNET_DHTU_Hash *peer_id, struct GNUNET_DHTU_Target *target, void **ctx)
Function to call when we connect to a peer and can henceforth transmit to that peer.
void(* address_add_cb)(void *cls, const struct GNUNET_DHTU_Hash *my_id, const struct GNUNET_DHTU_PrivateKey *pk, const char *address, struct GNUNET_DHTU_Source *source, void **ctx)
Function to call with new addresses of this peer.
void(* address_del_cb)(void *ctx)
Function to call with expired addresses of this peer.
void(* disconnect_cb)(void *ctx)
Function to call when we disconnected from a peer and can henceforth cannot transmit to that peer any...
void(* network_size_cb)(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
We have a new estimate on the size of the underlay.
void(* receive_cb)(void *cls, void **tctx, void **sctx, const void *message, size_t message_size)
Function to call when we receive a message.
struct returned by the initialization function of the plugin
void(* try_connect)(void *cls, const char *address)
Request creation of a session with a peer at the given address.
enum GNUNET_GenericReturnValue(* verify)(void *cls, const struct GNUNET_DHTU_PublicKey *pk, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const void *sig, size_t sig_size)
Verify signature in sig over purpose.
void * cls
Closure to pass to all plugin functions.
ssize_t(* sign)(void *cls, const struct GNUNET_DHTU_PrivateKey *pk, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, void **sig)
Use our private key to sign a message.
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no long request underlay to keep the connection alive.
void(* send)(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.
Opaque handle expressing a preference of the DHT to keep a particular target connected.
Handle for a private key used by this underlay.
Handle for a public key used by another peer.
uint16_t size
How long is the public key, in network byte order.
Opaque handle that the underlay offers for our address to be used when sending messages to another pe...
Opaque handle that the underlay offers for the target peer when sending messages to another peer.
A 512-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.