Information we track per peer. More...
#include "platform.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_connection.h"
#include "gnunet-service-cadet_dht.h"
#include "gnunet-service-cadet_paths.h"
#include "gnunet-service-cadet_tunnels.h"
Go to the source code of this file.
Data Structures | |
struct | GCP_MessageQueueManager |
Data structure used to track whom we have to notify about changes to our message queue. More... | |
struct | CadetPeer |
Struct containing all information regarding a given peer. More... | |
Macros | |
#define | LOG(level, ...) GNUNET_log_from (level, "cadet-per", __VA_ARGS__) |
#define | IDLE_PEER_TIMEOUT |
How long do we wait until tearing down an idle peer? More... | |
#define | IDLE_PATH_TIMEOUT |
How long do we keep paths around if we no longer care about the peer? More... | |
#define | MAX_OOO_QUEUE_SIZE 100 |
Queue size when we start dropping OOO messages. More... | |
Functions | |
const char * | GCP_2s (const struct CadetPeer *cp) |
Get the static string for a peer ID. More... | |
double | GCP_get_desirability_of_path (struct CadetPeer *cp, unsigned int off) |
Calculate how desirable a path is for cp if cp is at offset off in the path. More... | |
static void | destroy_peer (void *cls) |
This peer is no longer be needed, clean it up now. More... | |
static void | consider_peer_activate (struct CadetPeer *cp) |
This peer is now on more "active" duty, activate processes related to it. More... | |
static void | consider_peer_destroy (struct CadetPeer *cp) |
This peer may no longer be needed, consider cleaning it up. More... | |
static void | drop_paths (void *cls) |
We really no longere care about a peer, stop hogging memory with paths to it. More... | |
void | GCP_set_mq (struct CadetPeer *cp, struct GNUNET_MQ_Handle *mq) |
Set the message queue to mq for peer cp and notify watchers. More... | |
static int | should_I_drop (void) |
Debug function should NEVER return true in production code, useful to simulate losses for testcases. More... | |
static void | mqm_send_done (void *cls) |
Function called when CORE took one of the messages from a message queue manager and transmitted it. More... | |
static void | mqm_execute (struct GCP_MessageQueueManager *mqm) |
Transmit current envelope from this mqm. More... | |
static void | send_next_ready (struct CadetPeer *cp) |
Find the next ready message in the queue (starting the search from the cp->mqm_ready_ptr ) and if possible execute the transmission. More... | |
void | GCP_send (struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env) |
Send the message in env to cp. More... | |
static int | destroy_iterator_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) |
Function called to destroy a peer now. More... | |
void | GCP_destroy_all_peers () |
Clean up all entries about all peers. More... | |
void | GCP_drop_owned_paths (struct CadetPeer *cp) |
Drop all paths owned by this peer, and do not allow new ones to be added: We are shutting down. More... | |
void | GCP_path_entry_add (struct CadetPeer *cp, struct CadetPeerPathEntry *entry, unsigned int off) |
Add an entry to the DLL of all of the paths that this peer is on. More... | |
void | GCP_path_entry_remove (struct CadetPeer *cp, struct CadetPeerPathEntry *entry, unsigned int off) |
Remove an entry from the DLL of all of the paths that this peer is on. More... | |
static void | path_heap_cleanup (void *cls) |
Prune down the number of paths to this peer, we seem to have way too many. More... | |
struct GNUNET_CONTAINER_HeapNode * | GCP_attach_path (struct CadetPeer *cp, struct CadetPeerPath *path, unsigned int off, int force) |
Try adding a path to this cp. More... | |
void | GCP_detach_path (struct CadetPeer *cp, struct CadetPeerPath *path, struct GNUNET_CONTAINER_HeapNode *hn) |
This peer can no longer own path as the path has been extended and a peer further down the line is now the new owner. More... | |
void | GCP_add_connection (struct CadetPeer *cp, struct CadetConnection *cc) |
Add a connection to this cp. More... | |
void | GCP_remove_connection (struct CadetPeer *cp, struct CadetConnection *cc) |
Remove a connection that went via this cp. More... | |
struct CadetPeer * | GCP_get (const struct GNUNET_PeerIdentity *peer_id, int create) |
Retrieve the CadetPeer structure associated with the peer. More... | |
const struct GNUNET_PeerIdentity * | GCP_get_id (struct CadetPeer *cp) |
Obtain the peer identity for a struct CadetPeer . More... | |
void | GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls) |
Iterate over all known peers. More... | |
unsigned int | GCP_count_paths (const struct CadetPeer *cp) |
Count the number of known paths toward the peer. More... | |
unsigned int | GCP_iterate_paths (struct CadetPeer *cp, GCP_PathIterator callback, void *callback_cls) |
Iterate over the paths to a peer. More... | |
unsigned int | GCP_iterate_indirect_paths (struct CadetPeer *cp, GCP_PathIterator callback, void *callback_cls) |
Iterate over the paths to a peer without direct link. More... | |
unsigned int | GCP_iterate_paths_at (struct CadetPeer *cp, unsigned int dist, GCP_PathIterator callback, void *callback_cls) |
Iterate over the paths to peer where peer is at distance dist from us. More... | |
struct CadetTunnel * | GCP_get_tunnel (struct CadetPeer *cp, int create) |
Get the tunnel towards a peer. More... | |
void | GCP_set_hello (struct CadetPeer *cp, const struct GNUNET_MessageHeader *hello) |
We got a HELLO for a cp, remember it, and possibly trigger adequate actions (like trying to connect). More... | |
void | GCP_drop_tunnel (struct CadetPeer *cp, struct CadetTunnel *t) |
The tunnel to the given peer no longer exists, remove it from our data structures, and possibly clean up the peer itself. More... | |
int | GCP_has_core_connection (struct CadetPeer *cp) |
Test if cp has a core-level connection. More... | |
struct GCP_MessageQueueManager * | GCP_request_mq (struct CadetPeer *cp, GCP_MessageQueueNotificationCallback cb, void *cb_cls) |
Start message queue change notifications. More... | |
void | GCP_request_mq_cancel (struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env) |
Stops message queue change notifications. More... | |
void | GCP_send_ooo (struct CadetPeer *cp, struct GNUNET_MQ_Envelope *env) |
Send the message in env to cp, overriding queueing logic. More... | |
int | GCP_check_and_update_monotime (struct CadetPeer *peer, struct GNUNET_TIME_AbsoluteNBO monotime) |
Checking if a monotime value is newer than the last monotime value received from a peer. More... | |
int | GCP_check_monotime_sig (struct CadetPeer *peer, const struct GNUNET_CADET_ConnectionCreateMessage *msg) |
Checking the signature for a monotime of a GNUNET_CADET_ConnectionCreateMessage. More... | |
Information we track per peer.
TODO:
Definition in file gnunet-service-cadet_peer.c.
#define LOG | ( | level, | |
... | |||
) | GNUNET_log_from (level, "cadet-per", __VA_ARGS__) |
Definition at line 49 of file gnunet-service-cadet_peer.c.
#define IDLE_PEER_TIMEOUT |
How long do we wait until tearing down an idle peer?
Definition at line 55 of file gnunet-service-cadet_peer.c.
#define IDLE_PATH_TIMEOUT |
How long do we keep paths around if we no longer care about the peer?
Definition at line 61 of file gnunet-service-cadet_peer.c.
#define MAX_OOO_QUEUE_SIZE 100 |
Queue size when we start dropping OOO messages.
Definition at line 67 of file gnunet-service-cadet_peer.c.
const char * GCP_2s | ( | const struct CadetPeer * | peer | ) |
Get the static string for a peer ID.
peer | Peer. |
Definition at line 234 of file gnunet-service-cadet_peer.c.
References GNUNET_CRYPTO_eddsa_public_key_to_string(), GNUNET_free, GNUNET_is_zero, GNUNET_strlcpy(), GNUNET_YES, CadetPeer::pid, GNUNET_PeerIdentity::public_key, and ret.
Referenced by consider_path_cb(), consider_peer_activate(), destroy_peer(), dht_get_id_handler(), GCC_debug(), GCCH_channel_incoming_new(), GCCH_channel_local_new(), GCP_add_connection(), GCP_attach_path(), GCP_detach_path(), GCP_drop_owned_paths(), GCP_drop_tunnel(), GCP_get(), GCP_iterate_indirect_paths(), GCP_iterate_paths(), GCP_path_entry_add(), GCP_path_entry_remove(), GCP_remove_connection(), GCP_request_mq(), GCP_request_mq_cancel(), GCP_send(), GCP_send_ooo(), GCP_set_hello(), GCP_set_mq(), GSC_bind(), handle_connection_create(), mqm_execute(), mqm_send_done(), route_message(), send_broken(), and timeout_closed_cb().
double GCP_get_desirability_of_path | ( | struct CadetPeer * | cp, |
unsigned int | off | ||
) |
Calculate how desirable a path is for cp if cp is at offset off in the path.
The 'desirability_table.c' program can be used to compute a list of sample outputs for different scenarios. Basically, we score paths lower if there are many alternatives, and higher if they are shorter than average, and very high if they are much shorter than average and without many alternatives.
cp | a peer reachable via a path |
off | offset of cp in a path |
Definition at line 256 of file gnunet-service-cadet_peer.c.
References GNUNET_assert, CadetPeerPathEntry::next, CadetPeer::num_paths, CadetPeer::off_sum, CadetPeer::path_dll_length, and CadetPeer::path_heads.
Referenced by recalculate_path_desirability().
|
static |
This peer is no longer be needed, clean it up now.
cls | peer to clean up |
Definition at line 307 of file gnunet-service-cadet_peer.c.
References CadetPeer::ash, CadetPeer::connections, CadetPeer::core_mq, CadetPeer::destroy_task, GCD_search_stop(), GCP_2s(), GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_YES, CadetPeer::heap_cleanup_task, CadetPeer::hello, LOG, CadetPeer::mqm_head, CadetPeer::mqm_ready_ptr, CadetPeer::num_paths, CadetPeer::path_dll_length, CadetPeer::path_heads, CadetPeer::path_heap, CadetPeer::path_tails, peers, CadetPeer::pid, CadetPeer::search_h, and CadetPeer::t.
Referenced by consider_peer_destroy(), and destroy_iterator_cb().
|
static |
This peer is now on more "active" duty, activate processes related to it.
cp | the more-active peer |
Definition at line 369 of file gnunet-service-cadet_peer.c.
References CadetPeer::ash, CadetPeer::connections, CadetPeer::core_mq, DESIRED_CONNECTIONS_PER_TUNNEL, CadetPeer::destroy_task, GCD_search(), GCD_search_stop(), GCP_2s(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), LOG, CadetPeer::num_paths, CadetPeer::pid, CadetPeer::search_h, CadetPeer::t, transport, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by GCP_get_tunnel(), and GCP_set_mq().
|
static |
This peer may no longer be needed, consider cleaning it up.
cp | peer to clean up |
Definition at line 464 of file gnunet-service-cadet_peer.c.
References CadetPeer::connections, CadetPeer::core_mq, destroy_peer(), CadetPeer::destroy_task, drop_paths(), GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get_remaining(), CadetPeer::hello, IDLE_PATH_TIMEOUT, IDLE_PEER_TIMEOUT, CadetPeer::num_paths, CadetPeer::path_heap, and CadetPeer::t.
Referenced by drop_paths(), GCP_drop_tunnel(), GCP_path_entry_add(), GCP_path_entry_remove(), GCP_remove_connection(), GCP_set_hello(), and GCP_set_mq().
|
static |
We really no longere care about a peer, stop hogging memory with paths to it.
Afterwards, see if there is more to be cleaned up about this peer.
cls | a struct CadetPeer . |
Definition at line 446 of file gnunet-service-cadet_peer.c.
References consider_peer_destroy(), CadetPeer::destroy_task, GCPP_release(), GNUNET_CONTAINER_heap_remove_root(), and CadetPeer::path_heap.
Referenced by consider_peer_destroy().
void GCP_set_mq | ( | struct CadetPeer * | cp, |
struct GNUNET_MQ_Handle * | mq | ||
) |
Set the message queue to mq for peer cp and notify watchers.
cp | peer to modify |
mq | message queue to set (can be NULL) |
Definition at line 512 of file gnunet-service-cadet_peer.c.
References consider_peer_activate(), consider_peer_destroy(), CadetPeer::core_mq, GCP_2s(), GCPP_get_path_from_route(), GCT_consider_path(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_discard(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, LOG, mq, CadetPeer::mqm_head, CadetPeer::pid, and CadetPeer::t.
Referenced by core_connect_cb(), and core_disconnect_cb().
|
static |
Debug function should NEVER return true in production code, useful to simulate losses for testcases.
Definition at line 576 of file gnunet-service-cadet_peer.c.
References drop_percent, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_NO, and GNUNET_YES.
Referenced by mqm_execute().
|
static |
Function called when CORE took one of the messages from a message queue manager and transmitted it.
cls | the struct CadetPeeer where we made progress |
Definition at line 699 of file gnunet-service-cadet_peer.c.
References GCP_2s(), GNUNET_ERROR_TYPE_DEBUG, LOG, and send_next_ready().
Referenced by GCP_request_mq_cancel(), GCP_send(), GCP_send_ooo(), and mqm_execute().
|
static |
Transmit current envelope from this mqm.
mqm | mqm to transmit message for now |
Definition at line 603 of file gnunet-service-cadet_peer.c.
References GCP_MessageQueueManager::cb, GCP_MessageQueueManager::cb_cls, CadetPeer::core_mq, GCP_MessageQueueManager::cp, GCP_MessageQueueManager::env, GCP_2s(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_e2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX, GNUNET_MQ_discard(), GNUNET_MQ_env_get_msg(), GNUNET_MQ_send(), GNUNET_sh2s(), GNUNET_YES, LOG, mh, CadetPeer::mqm_head, CadetPeer::mqm_ready_counter, CadetPeer::mqm_ready_ptr, mqm_send_done(), CadetPeer::mqm_tail, msg, GCP_MessageQueueManager::next, and should_I_drop().
Referenced by send_next_ready().
|
static |
Find the next ready message in the queue (starting the search from the cp->mqm_ready_ptr
) and if possible execute the transmission.
cp | peer to try to send the next ready message to |
Definition at line 677 of file gnunet-service-cadet_peer.c.
References GCP_MessageQueueManager::cp, GCP_MessageQueueManager::env, mqm_execute(), CadetPeer::mqm_ready_counter, CadetPeer::mqm_ready_ptr, and GCP_MessageQueueManager::next.
Referenced by GCP_send(), and mqm_send_done().
void GCP_send | ( | struct GCP_MessageQueueManager * | mqm, |
struct GNUNET_MQ_Envelope * | env | ||
) |
Send the message in env to cp.
Send the message in env via a mqm.
mqm | the message queue manager to use for transmission |
env | envelope with the message to send; must NOT yet have a GNUNET_MQ_notify_sent() callback attached to it |
Definition at line 718 of file gnunet-service-cadet_peer.c.
References CadetPeer::core_mq, GCP_MessageQueueManager::cp, env, GCP_MessageQueueManager::env, GCP_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_get_length(), GNUNET_MQ_notify_sent(), LOG, CadetPeer::mqm_head, CadetPeer::mqm_ready_counter, CadetPeer::mqm_ready_ptr, mqm_send_done(), and send_next_ready().
Referenced by dir_ready_cb(), GCC_transmit(), route_message(), send_create(), and send_create_ack().
|
static |
Function called to destroy a peer now.
cls | NULL |
pid | identity of the peer (unused) |
value | the struct CadetPeer to clean up |
Definition at line 754 of file gnunet-service-cadet_peer.c.
References destroy_peer(), CadetPeer::destroy_task, GNUNET_OK, GNUNET_SCHEDULER_cancel(), and value.
Referenced by GCP_destroy_all_peers().
void GCP_destroy_all_peers | ( | void | ) |
Clean up all entries about all peers.
Must only be called after all tunnels, CORE-connections and connections are down.
Definition at line 776 of file gnunet-service-cadet_peer.c.
References destroy_iterator_cb(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, LOG, and peers.
Referenced by shutdown_rest().
void GCP_drop_owned_paths | ( | struct CadetPeer * | cp | ) |
Drop all paths owned by this peer, and do not allow new ones to be added: We are shutting down.
cp | peer to drop paths to |
Definition at line 793 of file gnunet-service-cadet_peer.c.
References GCP_2s(), GCPP_release(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_ERROR_TYPE_DEBUG, LOG, and CadetPeer::path_heap.
Referenced by destroy_paths_now().
void GCP_path_entry_add | ( | struct CadetPeer * | cp, |
struct CadetPeerPathEntry * | entry, | ||
unsigned int | off | ||
) |
Add an entry to the DLL of all of the paths that this peer is on.
cp | peer to modify |
entry | an entry on a path |
off | offset of this peer on the path |
Definition at line 816 of file gnunet-service-cadet_peer.c.
References consider_peer_destroy(), CadetPeer::destroy_task, GCD_search_stop(), GCP_2s(), GCPP_2s(), GCPP_get_peer_at_offset(), GCT_consider_path(), GNUNET_array_grow, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, LOG, CadetPeer::num_paths, CadetPeer::off_sum, CadetPeerPathEntry::path, CadetPeer::path_dll_length, CadetPeer::path_heads, CadetPeer::path_tails, CadetPeer::search_h, and CadetPeer::t.
Referenced by extend_path(), GCPP_get_path_from_route(), and GCPP_try_path_from_dht().
void GCP_path_entry_remove | ( | struct CadetPeer * | cp, |
struct CadetPeerPathEntry * | entry, | ||
unsigned int | off | ||
) |
Remove an entry from the DLL of all of the paths that this peer is on.
cp | peer to modify |
entry | an entry on a path |
off | offset of this peer on the path |
Definition at line 876 of file gnunet-service-cadet_peer.c.
References consider_peer_destroy(), CadetPeer::core_mq, DESIRED_CONNECTIONS_PER_TUNNEL, CadetPeer::destroy_task, GCD_search(), GCP_2s(), GCPP_2s(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, LOG, CadetPeer::num_paths, CadetPeer::off_sum, CadetPeerPathEntry::path, CadetPeer::path_heads, CadetPeer::path_tails, CadetPeer::pid, CadetPeer::search_h, and CadetPeer::t.
Referenced by attach_path(), and GCPP_release().
|
static |
Prune down the number of paths to this peer, we seem to have way too many.
cls | the struct CadetPeer to maintain the path heap for |
Definition at line 912 of file gnunet-service-cadet_peer.c.
References DESIRED_CONNECTIONS_PER_TUNNEL, GCPP_get_connection(), GCPP_get_length(), GCPP_release(), GNUNET_assert, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_heap_remove_root(), CadetPeer::heap_cleanup_task, and CadetPeer::path_heap.
Referenced by GCP_attach_path().
struct GNUNET_CONTAINER_HeapNode * GCP_attach_path | ( | struct CadetPeer * | cp, |
struct CadetPeerPath * | path, | ||
unsigned int | off, | ||
int | force | ||
) |
Try adding a path to this cp.
If the peer already has plenty of paths, return NULL.
cp | peer to which the path leads to |
path | a path looking for an owner; may not be fully initialized yet! |
off | offset of cp in path |
force | force attaching the path |
Definition at line 942 of file gnunet-service-cadet_peer.c.
References DESIRED_CONNECTIONS_PER_TUNNEL, GCP_2s(), GCPP_2s(), GCPP_get_desirability(), GCPP_get_length(), GCPP_get_peer_at_offset(), GNUNET_assert, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_peek2(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_now(), CadetPeer::heap_cleanup_task, LOG, CadetPeer::num_paths, CadetPeer::path_heap, and path_heap_cleanup().
Referenced by attach_path(), extend_path(), and GCPP_get_path_from_route().
void GCP_detach_path | ( | struct CadetPeer * | cp, |
struct CadetPeerPath * | path, | ||
struct GNUNET_CONTAINER_HeapNode * | hn | ||
) |
This peer can no longer own path as the path has been extended and a peer further down the line is now the new owner.
cp | old owner of the path |
path | path where the ownership is lost |
hn | note in cp's path heap that must be deleted |
Definition at line 1016 of file gnunet-service-cadet_peer.c.
References GCP_2s(), GCPP_2s(), GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_ERROR_TYPE_DEBUG, and LOG.
Referenced by extend_path().
void GCP_add_connection | ( | struct CadetPeer * | cp, |
struct CadetConnection * | cc | ||
) |
Add a connection to this cp.
cp | peer via which the connection goes |
cc | the connection to add |
Definition at line 1036 of file gnunet-service-cadet_peer.c.
References CadetPeer::connections, CadetPeer::destroy_task, GCC_2s(), GCC_get_id(), GCP_2s(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, GNUNET_SCHEDULER_cancel(), and LOG.
Referenced by connection_create().
void GCP_remove_connection | ( | struct CadetPeer * | cp, |
struct CadetConnection * | cc | ||
) |
Remove a connection that went via this cp.
cp | peer via which the connection went |
cc | the connection to remove |
Definition at line 1065 of file gnunet-service-cadet_peer.c.
References CadetPeer::connections, consider_peer_destroy(), GCC_2s(), GCC_get_id(), GCP_2s(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, and LOG.
Referenced by GCC_destroy().
struct CadetPeer * GCP_get | ( | const struct GNUNET_PeerIdentity * | peer_id, |
int | create | ||
) |
Retrieve the CadetPeer structure associated with the peer.
Optionally create one and insert it in the appropriate structures if the peer is not known yet.
peer_id | Full identity of the peer. |
create | GNUNET_YES if a new peer should be created if unknown. GNUNET_NO to return NULL if peer is unknown. |
Definition at line 1094 of file gnunet-service-cadet_peer.c.
References CadetPeer::connections, create, GCP_2s(), GNUNET_assert, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_YES, LOG, CadetPeer::path_heap, peer_id, peers, and CadetPeer::pid.
Referenced by core_connect_cb(), dht_get_id_handler(), GCCH_bind(), GCPP_get_path_from_route(), GCPP_try_path_from_dht(), got_hello(), handle_channel_create(), handle_connection_create(), and handle_show_path().
const struct GNUNET_PeerIdentity * GCP_get_id | ( | struct CadetPeer * | cp | ) |
Obtain the peer identity for a struct CadetPeer
.
cp | our peer handle |
Definition at line 1130 of file gnunet-service-cadet_peer.c.
References CadetPeer::pid.
Referenced by destroy_route(), dir_ready_cb(), GCCH_2s(), GCCH_channel_local_new(), GCPP_2s(), GCT_2s(), GCT_handle_kx(), GCT_handle_kx_auth(), get_next_free_ctn(), GSC_bind(), path_info_iterator(), route_message(), send_create(), and send_kx().
void GCP_iterate_all | ( | GNUNET_CONTAINER_PeerMapIterator | iter, |
void * | cls | ||
) |
Iterate over all known peers.
iter | Iterator. |
cls | Closure for iter . |
Definition at line 1143 of file gnunet-service-cadet_peer.c.
References GNUNET_CONTAINER_multipeermap_iterate(), and peers.
Referenced by handle_get_peers(), handle_info_tunnels(), and shutdown_rest().
unsigned int GCP_count_paths | ( | const struct CadetPeer * | cp | ) |
Count the number of known paths toward the peer.
cp | Peer to get path info. |
Definition at line 1159 of file gnunet-service-cadet_peer.c.
References CadetPeer::num_paths.
Referenced by get_all_peers_iterator().
unsigned int GCP_iterate_paths | ( | struct CadetPeer * | cp, |
GCP_PathIterator | callback, | ||
void * | callback_cls | ||
) |
Iterate over the paths to a peer.
cp | Peer to get path info. |
callback | Function to call for every path. |
callback_cls | Closure for callback. |
Definition at line 1174 of file gnunet-service-cadet_peer.c.
References CadetPeer::core_mq, GCP_2s(), GCPP_get_path_from_route(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, LOG, CadetPeerPathEntry::next, CadetPeer::path_dll_length, CadetPeer::path_heads, CadetPeer::pid, and ret.
Referenced by maintain_connections_cb().
unsigned int GCP_iterate_indirect_paths | ( | struct CadetPeer * | cp, |
GCP_PathIterator | callback, | ||
void * | callback_cls | ||
) |
Iterate over the paths to a peer without direct link.
cp | Peer to get path info. |
callback | Function to call for every path. |
callback_cls | Closure for callback. |
Definition at line 1226 of file gnunet-service-cadet_peer.c.
References GCP_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, LOG, CadetPeerPathEntry::next, CadetPeer::path_dll_length, CadetPeer::path_heads, and ret.
Referenced by handle_show_path().
unsigned int GCP_iterate_paths_at | ( | struct CadetPeer * | cp, |
unsigned int | dist, | ||
GCP_PathIterator | callback, | ||
void * | callback_cls | ||
) |
Iterate over the paths to peer where peer is at distance dist from us.
cp | Peer to get path info. |
dist | desired distance of peer to us on the path |
callback | Function to call for every path. |
callback_cls | Closure for callback. |
Definition at line 1254 of file gnunet-service-cadet_peer.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, LOG, CadetPeerPathEntry::next, CadetPeer::path_dll_length, CadetPeer::path_heads, and ret.
Referenced by GCPP_get_path_from_route(), and GCPP_try_path_from_dht().
struct CadetTunnel * GCP_get_tunnel | ( | struct CadetPeer * | cp, |
int | create | ||
) |
Get the tunnel towards a peer.
cp | Peer to get from. |
create | GNUNET_YES to create a tunnel if we do not have one |
Definition at line 1292 of file gnunet-service-cadet_peer.c.
References consider_peer_activate(), create, GCT_create_tunnel(), GNUNET_NO, and CadetPeer::t.
Referenced by destroy_tunnels_now(), GCCH_channel_local_new(), get_all_peers_iterator(), get_all_tunnels_iterator(), handle_connection_create(), and send_create().
void GCP_set_hello | ( | struct CadetPeer * | cp, |
const struct GNUNET_MessageHeader * | hello | ||
) |
We got a HELLO for a cp, remember it, and possibly trigger adequate actions (like trying to connect).
cp | the peer we got a HELLO for |
hello | the HELLO to remember |
Definition at line 1307 of file gnunet-service-cadet_peer.c.
References CadetPeer::ash, consider_peer_destroy(), GCP_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_malloc, GNUNET_memcpy, GNUNET_memdup, GNUNET_MQ_PRIO_BEST_EFFORT, GNUNET_TIME_absolute_cmp, GNUNET_TIME_absolute_get(), GNUNET_TRANSPORT_application_suggest(), GNUNET_TRANSPORT_application_suggest_cancel(), CadetPeer::hello, LOG, CadetPeer::pid, GNUNET_MessageHeader::size, size, transport, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by dht_get_id_handler(), and got_hello().
void GCP_drop_tunnel | ( | struct CadetPeer * | cp, |
struct CadetTunnel * | t | ||
) |
The tunnel to the given peer no longer exists, remove it from our data structures, and possibly clean up the peer itself.
cp | the peer affected |
t | the dead tunnel |
Definition at line 1364 of file gnunet-service-cadet_peer.c.
References consider_peer_destroy(), GCP_2s(), GCT_2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, LOG, t, and CadetPeer::t.
Referenced by destroy_tunnel().
int GCP_has_core_connection | ( | struct CadetPeer * | cp | ) |
Test if cp has a core-level connection.
cp | peer to test |
Definition at line 1384 of file gnunet-service-cadet_peer.c.
References CadetPeer::core_mq, GNUNET_NO, and GNUNET_YES.
Referenced by handle_connection_create().
struct GCP_MessageQueueManager * GCP_request_mq | ( | struct CadetPeer * | cp, |
GCP_MessageQueueNotificationCallback | cb, | ||
void * | cb_cls | ||
) |
Start message queue change notifications.
cp | peer to notify for |
cb | function to call if mq becomes available or unavailable |
cb_cls | closure for cb |
Definition at line 1399 of file gnunet-service-cadet_peer.c.
References GCP_MessageQueueManager::cb, GCP_MessageQueueManager::cb_cls, CadetPeer::core_mq, GCP_MessageQueueManager::cp, GCP_2s(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_YES, LOG, CadetPeer::mqm_head, and CadetPeer::mqm_tail.
Referenced by connection_create(), and dir_init().
void GCP_request_mq_cancel | ( | struct GCP_MessageQueueManager * | mqm, |
struct GNUNET_MQ_Envelope * | last_env | ||
) |
Stops message queue change notifications.
Stops message queue change notifications and sends a last message.
mqm | handle matching request to cancel |
last_env | final message to transmit, or NULL |
Definition at line 1430 of file gnunet-service-cadet_peer.c.
References CadetPeer::core_mq, GCP_MessageQueueManager::cp, GCP_MessageQueueManager::env, GCP_2s(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_discard(), GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), LOG, CadetPeer::mqm_head, CadetPeer::mqm_ready_ptr, mqm_send_done(), CadetPeer::mqm_tail, and GCP_MessageQueueManager::next.
Referenced by destroy_direction(), GCC_destroy(), GCC_destroy_without_tunnel(), and send_broken().
void GCP_send_ooo | ( | struct CadetPeer * | cp, |
struct GNUNET_MQ_Envelope * | env | ||
) |
Send the message in env to cp, overriding queueing logic.
This function should only be used to send error messages outside of flow and congestion control, similar to ICMP. Note that the envelope may be silently discarded as well.
cp | peer to send the message to |
env | envelope with the message to send |
Definition at line 1476 of file gnunet-service-cadet_peer.c.
References CadetPeer::core_mq, env, GCP_2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_discard(), GNUNET_MQ_get_length(), GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), LOG, MAX_OOO_QUEUE_SIZE, and mqm_send_done().
Referenced by route_message(), and send_broken_without_mqm().
int GCP_check_and_update_monotime | ( | struct CadetPeer * | peer, |
struct GNUNET_TIME_AbsoluteNBO | monotime | ||
) |
Checking if a monotime value is newer than the last monotime value received from a peer.
If the time value is newer it will be stored at the peer.
peer | The peer we received a new time value from. |
monotime | Time value we check against the last time value we received from a peer. |
Definition at line 1508 of file gnunet-service-cadet_peer.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_NO, GNUNET_TIME_absolute_ntoh(), GNUNET_YES, and CadetPeer::last_connection_create.
Referenced by handle_connection_create().
int GCP_check_monotime_sig | ( | struct CadetPeer * | peer, |
const struct GNUNET_CADET_ConnectionCreateMessage * | msg | ||
) |
Checking the signature for a monotime of a GNUNET_CADET_ConnectionCreateMessage.
peer | The peer that signed the monotime value. |
msg | The GNUNET_CADET_ConnectionCreateMessage with the monotime value. |
Definition at line 1531 of file gnunet-service-cadet_peer.c.
References GNUNET_break_op, GNUNET_CRYPTO_eddsa_verify, GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR, GNUNET_SYSERR, msg, CadetPeer::pid, GNUNET_PeerIdentity::public_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, and CadetConnectionCreatePS::purpose.
Referenced by handle_connection_create().