plain IP based DHT network underlay More...
#include "platform.h"
#include "gnunet_dhtu_plugin.h"
#include "gnunet_core_service.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_nse_service.h"
#include "plugin_dhtu_gnunet.h"
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 | Plugin |
Handle for a plugin. More... | |
Functions | |
static void | gnunet_try_connect (void *cls, const struct GNUNET_PeerIdentity *pid, const char *address) |
Request creation of a session with a peer at the given address. More... | |
static struct GNUNET_DHTU_PreferenceHandle * | gnunet_hold (void *cls, struct GNUNET_DHTU_Target *target) |
Request underlay to keep the connection to target alive if possible. More... | |
static void | gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph) |
Do no long request underlay to keep the connection alive. More... | |
static void | gnunet_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... | |
static void * | core_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
Method called whenever a given peer connects. More... | |
static void | core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls) |
Method called whenever a peer disconnects. More... | |
static void | add_addr (void *cls, const struct GNUNET_PeerIdentity *pid, const char *addr) |
static void | peerinfo_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Find the hello for our identity and then pass it to the DHT as a URL. More... | |
static void | error_cb (void *cls) |
static void | sync_cb (void *cls) |
static void | core_init_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
Function called after GNUNET_CORE_connect has succeeded (or failed for good). More... | |
static int | check_core_message (void *cls, const struct GNUNET_MessageHeader *msg) |
Anything goes, always return GNUNET_OK. More... | |
static void | handle_core_message (void *cls, const struct GNUNET_MessageHeader *msg) |
Handle message from CORE for the DHT. More... | |
static void | nse_cb (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) |
Callback to call when network size estimate is updated. More... | |
void * | DHTU_gnunet_done (struct GNUNET_DHTU_PluginFunctions *api) |
Exit point from the plugin. More... | |
struct GNUNET_DHTU_PluginFunctions * | DHTU_gnunet_init (struct GNUNET_DHTU_PluginEnvironment *env) |
Entry point for the plugin. More... | |
plain IP based DHT network underlay
Definition in file plugin_dhtu_gnunet.c.
|
static |
Request creation of a session with a peer at the given address.
cls | closure (internal context for the plugin) |
pid | target identity of the peer to connect to |
address | target address to connect to |
Definition at line 191 of file plugin_dhtu_gnunet.c.
References address, GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_TRANSPORT_application_validate(), nt, pid, and plugin.
Referenced by DHTU_gnunet_init().
|
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.
cls | closure |
target | connection to keep alive |
Definition at line 232 of file plugin_dhtu_gnunet.c.
References GNUNET_DHTU_Target::ash, GNUNET_BANDWIDTH_ZERO, GNUNET_CONTAINER_DLL_insert, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_new, GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, GNUNET_DHTU_Target::pid, plugin, and GNUNET_DHTU_PreferenceHandle::target.
Referenced by DHTU_gnunet_init().
|
static |
Do no long request underlay to keep the connection alive.
cls | closure |
target | connection to keep alive |
Definition at line 262 of file plugin_dhtu_gnunet.c.
References GNUNET_DHTU_Target::ash, GNUNET_BANDWIDTH_ZERO, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, GNUNET_DHTU_Target::pid, plugin, GNUNET_DHTU_Target::plugin, and GNUNET_DHTU_PreferenceHandle::target.
Referenced by DHTU_gnunet_init().
|
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.
cls | closure (internal context for the plugin) |
target | receiver identification |
msg | message |
msg_size | number of bytes in msg |
finished_cb | function called once transmission is done (not called if target disconnects, then only the disconnect_cb is called). |
finished_cb_cls | closure for finished_cb |
Definition at line 301 of file plugin_dhtu_gnunet.c.
References env, finished_cb(), GNUNET_MESSAGE_TYPE_DHT_CORE, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_DHTU_Target::mq, and msg.
Referenced by DHTU_gnunet_init().
|
static |
Method called whenever a given peer connects.
cls | closure |
peer | peer identity this notification is about |
Definition at line 334 of file plugin_dhtu_gnunet.c.
References GNUNET_DHTU_Target::app_ctx, GNUNET_TESTING_PluginFunctions::cls, GNUNET_new, mq, GNUNET_DHTU_Target::mq, GNUNET_DHTU_Target::pid, plugin, and GNUNET_DHTU_Target::plugin.
Referenced by DHTU_gnunet_init().
|
static |
Method called whenever a peer disconnects.
cls | closure |
peer | peer identity this notification is about |
peer_cls | closure associated with peer. given in GNUNET_CORE_ConnectEventHandler |
Definition at line 362 of file plugin_dhtu_gnunet.c.
References GNUNET_DHTU_Target::app_ctx, GNUNET_DHTU_Target::ash, GNUNET_free, GNUNET_TRANSPORT_application_suggest_cancel(), and plugin.
Referenced by DHTU_gnunet_init().
|
static |
Definition at line 377 of file plugin_dhtu_gnunet.c.
References GNUNET_TESTING_PluginFunctions::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and plugin.
Referenced by peerinfo_cb().
|
static |
Find the hello for our identity and then pass it to the DHT as a URL.
Note that we only add addresses, never remove them, due to limitations of the current peerinfo/core/transport APIs. This will change with TNG.
cls | a struct Plugin |
peer | id of the peer, NULL for last call |
hello | hello message for the peer (can be NULL) |
err_msg | message |
Definition at line 406 of file plugin_dhtu_gnunet.c.
References add_addr(), GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_msg(), GNUNET_HELLO_parser_iterate(), GNUNET_memcmp, GNUNET_PEERSTORE_monitor_next(), consensus-simulation::parser, plugin, and record().
Referenced by core_init_cb().
|
static |
Definition at line 434 of file plugin_dhtu_gnunet.c.
References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.
Referenced by core_init_cb().
|
static |
Definition at line 442 of file plugin_dhtu_gnunet.c.
References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.
Referenced by core_init_cb().
|
static |
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
Note that the private key of the peer is intentionally not exposed here; if you need it, your process should try to read the private key file directly (which should work if you are authorized...). Implementations of this function must not call GNUNET_CORE_disconnect (other than by scheduling a new task to do this later).
cls | closure |
my_identity | ID of this peer, NULL if we failed |
Definition at line 462 of file plugin_dhtu_gnunet.c.
References error_cb(), GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_monitor_start(), GNUNET_YES, my_identity, peerinfo_cb(), plugin, and sync_cb().
Referenced by DHTU_gnunet_init().
|
static |
Anything goes, always return GNUNET_OK.
cls | unused |
msg | message to check |
Definition at line 490 of file plugin_dhtu_gnunet.c.
|
static |
Handle message from CORE for the DHT.
Passes it to the DHT logic.
cls | a struct GNUNET_DHTU_Target of the sender |
msg | the message we received |
Definition at line 507 of file plugin_dhtu_gnunet.c.
References GNUNET_TESTING_PluginFunctions::cls, msg, origin, plugin, and GNUNET_MessageHeader::size.
|
static |
Callback to call when network size estimate is updated.
cls | closure |
timestamp | time when the estimate was received from the server (or created by the server) |
logestimate | the log(Base 2) value of the current network size estimate |
std_dev | standard deviation for the estimate |
Definition at line 530 of file plugin_dhtu_gnunet.c.
References GNUNET_TESTING_PluginFunctions::cls, plugin, and timestamp().
Referenced by DHTU_gnunet_init().
void * DHTU_gnunet_done | ( | struct GNUNET_DHTU_PluginFunctions * | api | ) |
Exit point from the plugin.
cls | closure (our struct Plugin ) |
Definition at line 551 of file plugin_dhtu_gnunet.c.
References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_TESTING_PluginFunctions::cls, GNUNET_CORE_disconnect(), GNUNET_free, GNUNET_NSE_disconnect(), GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_monitor_stop(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TRANSPORT_application_done(), and plugin.
Referenced by DHTU_gnunet_init(), and shutdown_task().
struct GNUNET_DHTU_PluginFunctions * DHTU_gnunet_init | ( | struct GNUNET_DHTU_PluginEnvironment * | env | ) |
Entry point for the plugin.
cls | closure (the struct GNUNET_DHTU_PluginEnvironment ) |
Definition at line 584 of file plugin_dhtu_gnunet.c.
References GNUNET_DHTU_PluginFunctions::cls, core_connect_cb(), core_disconnect_cb(), core_init_cb(), DHTU_gnunet_done(), GNUNET_DHTU_PluginFunctions::drop, env, GNUNET_break, GNUNET_CORE_connect(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), gnunet_drop(), gnunet_hold(), GNUNET_MESSAGE_TYPE_DHT_CORE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NSE_connect(), GNUNET_PEERSTORE_connect(), gnunet_send(), GNUNET_TRANSPORT_application_init(), gnunet_try_connect(), handlers, GNUNET_DHTU_PluginFunctions::hold, nse_cb(), plugin, GNUNET_DHTU_PluginFunctions::send, and GNUNET_DHTU_PluginFunctions::try_connect.
Referenced by load_underlay().