33#define LOG(level, ...) GNUNET_log_from (level, "cadet-pat", __VA_ARGS__)
147 "Adding %s to path %s at offset %u\n",
175 "Removing connection %s to path %s at offset %u\n",
209 if (NULL != entry->
cc)
248 "Owner releases path %s\n",
302 entry->
score = INT_MIN;
354 "check_match mismatch because path %s is too long (%u vs. %u vs. %u)\n",
361 for (
unsigned int i = 0; i < off; i++)
362 if (cm_ctx->
cpath[i] !=
367 "check_match path %s mismatches at offset %u\n",
373 "check_match found match with path %s\n",
375 cm_ctx->
match = path;
408 entry->
peer = peers_ext[i];
453 "Extended path %s\n",
472 unsigned int get_path_length,
474 unsigned int put_path_length)
476 struct CadetPeer *cpath[get_path_length + put_path_length];
480 unsigned int total_len;
487 total_len = get_path_length + put_path_length;
488 for (
unsigned int off = 0; off < total_len; off++)
492 pid = (off < get_path_length)
493 ? &get_path[get_path_length - off - 1].pred
494 : &put_path[get_path_length + put_path_length - off - 1].pred;
505 for (
unsigned int i = 0; i < off - skip; i++)
507 if (cpath[i] == cpath[off - skip])
514 if (skip >= total_len)
517 "Path discovered from DHT is one big cycle?\n");
525 cm_ctx.
cpath = cpath;
527 for (
int i = total_len - 1; i >= 0; i--)
533 if (NULL != cm_ctx.
match)
535 if (i == total_len - 1)
539 "Path discovered from DHT is already known\n");
546 "Trying to extend existing path %s by additional links discovered from DHT\n",
567 entry->
peer = cpath[i];
585 "Path discovered from DHT is not interesting to us\n");
592 "Created new path %s based on information from DHT\n",
607 for (
unsigned int off = 0; off < path_length; off++)
608 cpath[off] =
GCP_get (&pids[path_length - 1 - off],
613 cm_ctx.
cpath = cpath;
616 for (
int i = path_length - 1; i >= 0; i--)
622 if (NULL != cm_ctx.
match)
624 if (i == path_length - 1)
628 "Returning existing path %s as inverse for incoming connection\n",
636 "Extending existing path %s to create inverse for incoming connection\n",
656 for (
int i = path_length - 1; i >= 0; i--)
661 entry->
peer = cpath[i];
664 for (
int i = path_length - 1; i >= 0; i--)
674 "Created new path %s to create inverse for incoming connection\n",
709 for (
unsigned int off = 0;
737 static char buf[2048];
739 const unsigned int max_plen = (
sizeof(buf) - 16) / 5 - 2;
742 for (
unsigned int i = 0;
752 (i > max_plen / 2) &&
753 (i < path->entries_length - max_plen / 2))
static int end
Set if we are to shutdown all services (including ARM).
static struct GNUNET_PeerIdentity my_full_id
Peer identity.
static int result
Global testing status.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and kn...
static int check_match(void *cls, struct CadetPeerPath *path, unsigned int off)
Check if the given path is identical on all of the hops until off, and not longer than off.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
void GCPP_try_path_from_dht(const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length)
Create a peer path based on the result of a DHT lookup.
static void GCPP_update_score(struct CadetPeerPath *path, unsigned int off, int delta)
Updates the score for an entry on the path based on our experiences with using path.
unsigned int GCPP_get_length(struct CadetPeerPath *path)
Return the length of the path.
static void attach_path(struct CadetPeerPath *path, unsigned int stop_at)
Tries to attach path to a peer, working backwards from the end and stopping at stop_at.
static void recalculate_path_desirability(struct CadetPeerPath *path)
Calculate the path's desirability score.
struct CadetConnection * GCPP_get_connection(struct CadetPeerPath *path, struct CadetPeer *destination, unsigned int off)
Return connection to destination using path, or return NULL if no such connection exists.
GNUNET_CONTAINER_HeapCostType GCPP_get_desirability(const struct CadetPeerPath *path)
Return how much we like keeping the path.
void GCPP_del_connection(struct CadetPeerPath *path, unsigned int off, struct CadetConnection *cc)
Notify path that it is no longer used for connection cc which ended at the path's offset off.
void GCPP_release(struct CadetPeerPath *path)
The owning peer of this path is no longer interested in maintaining it, so the path should be discard...
static void extend_path(struct CadetPeerPath *path, struct CadetPeer **peers_ext, unsigned int num_peers, int force)
Extend path path by the num_peers from the peers array, assuming the owners past the current owner wa...
void GCPP_add_connection(struct CadetPeerPath *path, unsigned int off, struct CadetConnection *cc)
Notify path that it is used for connection cc which ends at the path's offset off.
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
struct CadetPeerPath * GCPP_get_path_from_route(unsigned int path_length, const struct GNUNET_PeerIdentity *pids)
We got an incoming connection, obtain the corresponding path.
unsigned int GCPP_find_peer(struct CadetPeerPath *path, struct CadetPeer *cp)
Find peer's offset on path.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
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 no...
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.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer structure associated with the peer.
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.
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.
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.
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.
Information we track per peer.
Information we track per tunnel.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static unsigned int num_peers
Number of peers.
uint64_t GNUNET_CONTAINER_HeapCostType
Cost by which elements in a heap can be ordered.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TIME_Relative delta
Low-level connection to a destination.
struct CadetPeerPath * path
Path we are using to our destination.
unsigned int off
Offset of our destination in path.
struct CadetPeer * destination
To which peer does this connection go?
int score
Path's historic score up to this point.
struct CadetPeer * peer
The peer at this offset of the path.
struct CadetConnection * cc
Connection using this path, or NULL for none.
struct CadetPeerPath * path
Path this entry belongs to.
Information regarding a possible path to reach a peer.
unsigned int entries_length
Length of the entries array.
struct CadetPeerPathEntry ** entries
Array of all the peers on the path.
GNUNET_CONTAINER_HeapCostType desirability
Desirability of the path.
struct GNUNET_CONTAINER_HeapNode * hn
Node of this path in the owner's heap.
Struct containing all information regarding a given peer.
Closure for #find_peer_at() and check_match().
struct CadetPeerPath * match
Set to a matching path, if any.
unsigned int cpath_length
How long is the cpath array?
struct CadetPeer ** cpath
Array the combined paths.
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
The identity of the host (wraps the signing key of the peer).