GNUnet  0.11.x
Data Structures | Functions
plugin_dhtu_gnunet.c File Reference
#include "platform.h"
Include dependency graph for plugin_dhtu_gnunet.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_DHTU_Source
 Opaque handle that the underlay offers for our address to be used when sending messages to another peer. More...
 
struct  GNUNET_DHTU_Target
 Opaque handle that the underlay offers for the target peer when sending messages to another peer. More...
 
struct  GNUNET_DHTU_PreferenceHandle
 Opaque handle expressing a preference of the DHT to keep a particular target connected. More...
 
struct  GNUNET_DHTU_PrivateKey
 Opaque handle for a private key used by this underlay. More...
 
struct  Plugin
 Handle for a plugin. More...
 

Functions

static ssize_t ip_sign (void *cls, const struct GNUNET_DHTU_PrivateKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, void **sig)
 Use our private key to sign a message. More...
 
static enum GNUNET_GenericReturnValue ip_verify (void *cls, const struct GNUNET_DHTU_PublicKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, const void *sig, size_t sig_size)
 Verify signature in sig over purpose. More...
 
static void ip_try_connect (void *cls, const char *address)
 Request creation of a session with a peer at the given address. More...
 
static struct GNUNET_DHTU_PreferenceHandleip_hold (void *cls, struct GNUNET_DHTU_Target *target)
 Request underlay to keep the connection to target alive if possible. More...
 
static void ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
 Do no long request underlay to keep the connection alive. More...
 
static void ip_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. More...
 
void * libgnunet_plugin_dhtu_ip_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_dhtu_gnunet_done (void *cls)
 Exit point from the plugin. More...
 

Function Documentation

◆ ip_sign()

static ssize_t ip_sign ( void *  cls,
const struct GNUNET_DHTU_PrivateKey pk,
const struct GNUNET_DHTU_SignaturePurpose purpose,
void **  sig 
)
static

Use our private key to sign a message.

Parameters
clsclosure
pkour private key to sign with
purposewhat to sign
[out]signature,allocatedon heap and returned
Returns
-1 on error, otherwise number of bytes in sig

Definition at line 127 of file plugin_dhtu_gnunet.c.

Referenced by libgnunet_plugin_dhtu_ip_init().

131 {
132  return 0;
133 }
Here is the caller graph for this function:

◆ ip_verify()

static enum GNUNET_GenericReturnValue ip_verify ( void *  cls,
const struct GNUNET_DHTU_PublicKey pk,
const struct GNUNET_DHTU_SignaturePurpose purpose,
const void *  sig,
size_t  sig_size 
)
static

Verify signature in sig over purpose.

Parameters
clsclosure
pkpublic key to verify signature of
purposewhat was being signed
sigsignature data
sig_sizenumber of bytes in sig
Returns
GNUNET_OK if signature is valid GNUNET_NO if signatures are not supported GNUNET_SYSERR if signature is invalid

Definition at line 149 of file plugin_dhtu_gnunet.c.

References GNUNET_NO.

Referenced by libgnunet_plugin_dhtu_ip_init().

154 {
155  return GNUNET_NO;
156 }
Here is the caller graph for this function:

◆ ip_try_connect()

static void ip_try_connect ( void *  cls,
const char *  address 
)
static

Request creation of a session with a peer at the given address.

Parameters
clsclosure (internal context for the plugin)
addresstarget address to connect to

Definition at line 166 of file plugin_dhtu_gnunet.c.

References GNUNET_break.

Referenced by libgnunet_plugin_dhtu_ip_init().

168 {
169  GNUNET_break (0);
170 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Here is the caller graph for this function:

◆ ip_hold()

static struct GNUNET_DHTU_PreferenceHandle* ip_hold ( void *  cls,
struct GNUNET_DHTU_Target target 
)
static

Request underlay to keep the connection to target alive if possible.

Hold may be called multiple times to express a strong preference to keep a connection, say because a target is in multiple tables.

Parameters
clsclosure
targetconnection to keep alive

Definition at line 182 of file plugin_dhtu_gnunet.c.

References GNUNET_CONTAINER_DLL_insert, GNUNET_new, ph, GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by libgnunet_plugin_dhtu_ip_init().

184 {
186 
188  ph->target = target;
190  target->ph_tail,
191  ph);
192  target->ph_count++;
193  return ph;
194 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Opaque handle expressing a preference of the DHT to keep a particular target connected.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
struct GNUNET_DHTU_Target * target
Target a preference was expressed for.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_DHTU_PreferenceHandle * ph_head
Head of preferences expressed for this target.
struct GNUNET_DHTU_PreferenceHandle * ph_tail
Tail of preferences expressed for this target.
unsigned int ph_count
Preference counter, length of the ph_head DLL.
Here is the caller graph for this function:

◆ ip_drop()

static void ip_drop ( struct GNUNET_DHTU_PreferenceHandle ph)
static

Do no long request underlay to keep the connection alive.

Parameters
clsclosure
targetconnection to keep alive

Definition at line 204 of file plugin_dhtu_gnunet.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by libgnunet_plugin_dhtu_ip_init().

205 {
206  struct GNUNET_DHTU_Target *target = ph->target;
207 
209  target->ph_tail,
210  ph);
211  target->ph_count--;
212  GNUNET_free (ph);
213 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_DHTU_Target * target
Target a preference was expressed for.
struct GNUNET_DHTU_PreferenceHandle * ph_head
Head of preferences expressed for this target.
struct GNUNET_DHTU_PreferenceHandle * ph_tail
Tail of preferences expressed for this target.
Opaque handle that the underlay offers for the target peer when sending messages to another peer...
unsigned int ph_count
Preference counter, length of the ph_head DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ ip_send()

static void ip_send ( void *  cls,
struct GNUNET_DHTU_Target target,
const void *  msg,
size_t  msg_size,
GNUNET_SCHEDULER_TaskCallback  finished_cb,
void *  finished_cb_cls 
)
static

Send message to some other participant over the network.

Note that sending is not guaranteeing that the other peer actually received the message. For any given target, the DHT must wait for the finished_cb to be called before calling send() again.

Parameters
clsclosure (internal context for the plugin)
targetreceiver identification
msgmessage
msg_sizenumber of bytes in msg
finished_cbfunction called once transmission is done (not called if target disconnects, then only the disconnect_cb is called).
finished_cb_clsclosure for finished_cb

Definition at line 232 of file plugin_dhtu_gnunet.c.

References GNUNET_break.

Referenced by libgnunet_plugin_dhtu_ip_init().

238 {
239  GNUNET_break (0);
240 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Here is the caller graph for this function:

◆ libgnunet_plugin_dhtu_ip_init()

void* libgnunet_plugin_dhtu_ip_init ( void *  cls)

Entry point for the plugin.

Parameters
clsclosure (the struct GNUNET_DHTU_PluginEnvironment)
Returns
the plugin's API

Definition at line 250 of file plugin_dhtu_gnunet.c.

References Plugin::api, GNUNET_DHTU_PluginEnvironment::cls, GNUNET_DHTU_PluginFunctions::cls, GNUNET_DHTU_PluginFunctions::drop, env, Plugin::env, GNUNET_new, GNUNET_DHTU_PluginFunctions::hold, ip_drop(), ip_hold(), ip_send(), ip_sign(), ip_try_connect(), ip_verify(), plugin, GNUNET_DHTU_PluginFunctions::send, GNUNET_DHTU_PluginFunctions::sign, GNUNET_DHTU_PluginFunctions::try_connect, and GNUNET_DHTU_PluginFunctions::verify.

251 {
253  struct GNUNET_DHTU_PluginFunctions *api;
254  struct Plugin *plugin;
255 
256  plugin = GNUNET_new (struct Plugin);
257  plugin->env = env;
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 }
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static void ip_drop(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no long request underlay to keep the connection alive.
static struct GNUNET_DHTU_PreferenceHandle * ip_hold(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
enum GNUNET_GenericReturnValue(* verify)(void *cls, const struct GNUNET_DHTU_PublicKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, const void *sig, size_t sig_size)
Verify signature in sig over purpose.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no long request underlay to keep the connection alive.
struct returned by the initialization function of the plugin
void * cls
Closure to use for callbacks.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void ip_try_connect(void *cls, const char *address)
Request creation of a session with a peer at the given address.
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.
Handle for a plugin.
Definition: block.c:37
static enum GNUNET_GenericReturnValue ip_verify(void *cls, const struct GNUNET_DHTU_PublicKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, const void *sig, size_t sig_size)
Verify signature in sig over purpose.
struct Plugin * plugin
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
static ssize_t ip_sign(void *cls, const struct GNUNET_DHTU_PrivateKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, void **sig)
Use our private key to sign a message.
static void ip_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.
void(* try_connect)(void *cls, const char *address)
Request creation of a session with a peer at the given address.
ssize_t(* sign)(void *cls, const struct GNUNET_DHTU_PrivateKey *pk, const struct GNUNET_DHTU_SignaturePurpose *purpose, void **sig)
Use our private key to sign a message.
void * cls
Closure to pass to all plugin functions.
Here is the call graph for this function:

◆ libgnunet_plugin_dhtu_gnunet_done()

void* libgnunet_plugin_dhtu_gnunet_done ( void *  cls)

Exit point from the plugin.

Parameters
clsclosure (our struct Plugin)
Returns
NULL

Definition at line 277 of file plugin_dhtu_gnunet.c.

References GNUNET_DHTU_PluginFunctions::cls, GNUNET_free, and plugin.

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 }
struct returned by the initialization function of the plugin
Handle for a plugin.
Definition: block.c:37
struct Plugin * plugin
void * cls
Closure to pass to all plugin functions.
#define GNUNET_free(ptr)
Wrapper around free.