plain IP based DHT network underlay More...
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... | |
Macros | |
#define | SCAN_FREQ GNUNET_TIME_UNIT_MINUTES |
How frequently should we re-scan our local interfaces for IPs? More... | |
#define | MAX_DESTS 256 |
Maximum number of concurrently active destinations to support. More... | |
Functions | |
static struct GNUNET_DHTU_Target * | create_target (struct Plugin *plugin, const struct GNUNET_PeerIdentity *pid, const struct sockaddr *addr, socklen_t addrlen) |
Create a target to which we may send traffic. More... | |
static struct GNUNET_DHTU_Target * | find_target (struct Plugin *plugin, const struct GNUNET_PeerIdentity *pid, const void *addr, size_t addrlen) |
Find target matching addr. More... | |
static void | ip_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 * | ip_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... | |
static struct GNUNET_DHTU_Source * | create_source (struct Plugin *plugin, const struct sockaddr *addr, socklen_t addrlen) |
Create a new source on which we may be receiving traffic. More... | |
static int | addrcmp_np (const struct sockaddr *a1, const struct sockaddr *a2, size_t alen) |
Compare two addresses excluding the ports for equality. More... | |
static int | addrcmp (const struct sockaddr *a1, const struct sockaddr *a2, size_t alen) |
Compare two addresses for equality. More... | |
static enum GNUNET_GenericReturnValue | process_ifcs (void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen) |
Callback function invoked for each interface found. More... | |
static void | scan (void *cls) |
Scan network interfaces for IP address changes. More... | |
static struct GNUNET_DHTU_Source * | find_source (struct Plugin *plugin, const void *addr, size_t addrlen) |
Find our source matching addr. More... | |
static void | read_cb (void *cls) |
UDP socket is ready to receive. More... | |
struct GNUNET_DHTU_PluginFunctions * | DHTU_ip_init (struct GNUNET_DHTU_PluginEnvironment *env) |
Entry point for the plugin. More... | |
void * | DHTU_ip_done (struct GNUNET_DHTU_PluginFunctions *api) |
Exit point from the plugin. More... | |
plain IP based DHT network underlay
Definition in file plugin_dhtu_ip.c.
#define SCAN_FREQ GNUNET_TIME_UNIT_MINUTES |
How frequently should we re-scan our local interfaces for IPs?
Definition at line 34 of file plugin_dhtu_ip.c.
#define MAX_DESTS 256 |
Maximum number of concurrently active destinations to support.
Definition at line 39 of file plugin_dhtu_ip.c.
|
static |
Create a target to which we may send traffic.
plugin | our plugin |
pid | presumed identity of the target |
addr | target address |
addrlen | number of bytes in addr |
Definition at line 247 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Target::addr, GNUNET_DHTU_Target::addrlen, GNUNET_DHTU_Target::app_ctx, GNUNET_TESTING_PluginFunctions::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_new, GNUNET_YES, key, MAX_DESTS, GNUNET_DHTU_Target::pid, pid, and plugin.
Referenced by find_target().
|
static |
Find target matching addr.
If none exists, create one!
plugin | the plugin handle |
pid | presumed identity of the target |
addr | socket address to find |
addrlen | number of bytes in addr |
Definition at line 312 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Target::addr, GNUNET_DHTU_Target::addrlen, create_target(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_YES, key, pid, and plugin.
Referenced by ip_try_connect(), and read_cb().
|
static |
Request creation of a session with a peer at the given address.
cls | closure (internal context for the plugin) |
pid | identity of the target peer |
address | target address to connect to |
Definition at line 361 of file plugin_dhtu_ip.c.
References address, AI_NUMERICSERV, find_target(), GNUNET_break, GNUNET_free, GNUNET_strdup, pid, plugin, port, and result.
Referenced by DHTU_ip_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 425 of file plugin_dhtu_ip.c.
References GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_DHTU_Target::ph_count, GNUNET_DHTU_Target::ph_head, GNUNET_DHTU_Target::ph_tail, and GNUNET_DHTU_PreferenceHandle::target.
Referenced by DHTU_ip_init().
|
static |
Do no long request underlay to keep the connection alive.
cls | closure |
target | connection to keep alive |
Definition at line 447 of file plugin_dhtu_ip.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 DHTU_ip_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 475 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Target::addr, GNUNET_DHTU_Target::addrlen, finished_cb(), GNUNET_NETWORK_socket_sendto(), msg, and plugin.
Referenced by DHTU_ip_init().
|
static |
Create a new source on which we may be receiving traffic.
plugin | our plugin |
addr | our address |
addrlen | number of bytes in addr |
Definition at line 509 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Source::addr, GNUNET_DHTU_Source::address, GNUNET_DHTU_Source::addrlen, GNUNET_DHTU_Source::app_ctx, GNUNET_TESTING_PluginFunctions::cls, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_new, plugin, and GNUNET_DHTU_Source::scan_generation.
Referenced by find_source(), and process_ifcs().
|
static |
Compare two addresses excluding the ports for equality.
Only compares IP address. Must only be called on AF_INET or AF_INET6 addresses.
a1 | address to compare |
a2 | address to compare |
alen | number of bytes in a1 and a2 |
Definition at line 579 of file plugin_dhtu_ip.c.
References GNUNET_assert, and GNUNET_memcmp.
Referenced by process_ifcs().
|
static |
Compare two addresses for equality.
Only compares IP address and port. Must only be called on AF_INET or AF_INET6 addresses.
a1 | address to compare |
a2 | address to compare |
alen | number of bytes in a1 and a2 |
Definition at line 625 of file plugin_dhtu_ip.c.
References GNUNET_assert, and GNUNET_memcmp.
Referenced by find_source().
|
static |
Callback function invoked for each interface found.
cls | closure |
name | name of the interface (can be NULL for unknown) |
isDefault | is this presumably the default interface |
addr | address of this interface (can be NULL for unknown or unassigned) |
broadcast_addr | the broadcast address (can be NULL for unknown or unassigned) |
netmask | the network mask (can be NULL for unknown or unassigned) |
addrlen | length of the address |
Definition at line 677 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Source::addr, addrcmp_np(), GNUNET_DHTU_Source::addrlen, create_source(), GNUNET_assert, GNUNET_OK, GNUNET_DHTU_Source::next, plugin, and GNUNET_DHTU_Source::scan_generation.
Referenced by scan().
|
static |
Scan network interfaces for IP address changes.
cls | a struct Plugin |
Definition at line 742 of file plugin_dhtu_ip.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OS_network_interfaces_list(), GNUNET_SCHEDULER_add_delayed(), GNUNET_DHTU_Source::next, plugin, process_ifcs(), scan(), and SCAN_FREQ.
Referenced by DHTU_ip_init(), and scan().
|
static |
Find our source matching addr.
If none exists, create one!
plugin | the plugin handle |
addr | socket address to find |
addrlen | number of bytes in addr |
Definition at line 780 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Source::addr, addrcmp(), GNUNET_DHTU_Source::addrlen, create_source(), and plugin.
Referenced by read_cb().
|
static |
UDP socket is ready to receive.
Read.
cls | our struct Plugin * |
Definition at line 807 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Source::app_ctx, GNUNET_DHTU_Target::app_ctx, GNUNET_TESTING_PluginFunctions::cls, find_source(), find_target(), GNUNET_ALIGN, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NETWORK_get_fd(), GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, mh, pid, plugin, read_cb(), ret, and GNUNET_DHTU_Source::scan_generation.
Referenced by DHTU_ip_init(), and read_cb().
struct GNUNET_DHTU_PluginFunctions * DHTU_ip_init | ( | struct GNUNET_DHTU_PluginEnvironment * | env | ) |
Entry point for the plugin.
cls | closure (the struct GNUNET_DHTU_PluginEnvironment ) |
Definition at line 951 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_PluginFunctions::cls, GNUNET_DHTU_PluginFunctions::drop, dummy, env, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_get_peer_identity(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_log_config_missing(), GNUNET_log_strerror, GNUNET_NETWORK_socket_box_native(), GNUNET_NETWORK_test_pf(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_DHTU_PluginFunctions::hold, ip_drop(), ip_hold(), ip_send(), ip_try_connect(), nse, plugin, port, read_cb(), scan(), GNUNET_DHTU_PluginFunctions::send, Plugin::sock, and GNUNET_DHTU_PluginFunctions::try_connect.
Referenced by load_underlay().
void * DHTU_ip_done | ( | struct GNUNET_DHTU_PluginFunctions * | api | ) |
Exit point from the plugin.
cls | closure (our struct Plugin ) |
Definition at line 1132 of file plugin_dhtu_ip.c.
References GNUNET_DHTU_Source::address, Plugin::api, GNUNET_DHTU_Source::app_ctx, GNUNET_DHTU_Target::app_ctx, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_TESTING_PluginFunctions::cls, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_DHTU_Target::ph_head, and plugin.
Referenced by shutdown_task().