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)
215 if (NULL != path->
hn)
248 "Owner releases path %s\n",
263 if (NULL == path->
hn)
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;
402 old_len + num_peers);
403 for (i = num_peers - 1; i >= 0; i--)
407 path->
entries[old_len + i] = entry;
408 entry->
peer = peers[i];
411 for (i = num_peers - 1; i >= 0; i--)
440 if (NULL == path->
hn)
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]
494 : &put_path[get_path_length + put_path_length - off - 1];
502 cpath[off - skip] =
GCP_get (pid,
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];
581 if (NULL == path->
hn)
585 "Path discovered from DHT is not interesting to us\n");
592 "Created new path %s based on information from DHT\n",
614 for (
unsigned int off = 0; off < path_length; off++)
615 cpath[off] =
GCP_get (&pids[path_length - 1 - off],
620 cm_ctx.
cpath = cpath;
623 for (
int i = path_length - 1; i >= 0; i--)
629 if (NULL != cm_ctx.
match)
631 if (i == path_length - 1)
635 "Returning existing path %s as inverse for incoming connection\n",
643 "Extending existing path %s to create inverse for incoming connection\n",
663 for (
int i = path_length - 1; i >= 0; i--)
668 entry->
peer = cpath[i];
671 for (
int i = path_length - 1; i >= 0; i--)
681 "Created new path %s to create inverse for incoming connection\n",
716 for (
unsigned int off = 0;
751 static char buf[2048];
753 const unsigned int max_plen = (
sizeof(
buf) - 16) / 5 - 2;
756 for (
unsigned int i = 0;
766 (i > max_plen / 2) &&
struct GNUNET_CONTAINER_HeapNode * hn
Node of this path in the owner's heap.
Low-level connection to a destination.
static struct GNUNET_TIME_Relative delta
static void recalculate_path_desirability(struct CadetPeerPath *path)
Calculate the path's desirability score.
static int end
Set if we are to shutdown all services (including ARM).
struct CadetPeer * peer
The peer at this offset of the path.
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and kn...
struct CadetConnection * cc
Connection using this path, or NULL for none.
const char * GCC_2s(const struct CadetConnection *cc)
Get a (static) string for a connection.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void extend_path(struct CadetPeerPath *path, struct CadetPeer **peers, 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...
struct CadetPeerPath * path
Path we are using to our destination.
struct CadetPeer * destination
To which peer does this connection go?
struct CadetPeer ** cpath
Array the combined paths.
struct GNUNET_CONTAINER_HeapNode * GCP_attach_path(struct CadetPeer *cp, struct CadetPeerPath *path, unsigned int off, int force)
Try adding a path to this peer.
Information we track per tunnel.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GCPP_try_path_from_dht(const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length)
Create a peer path based on the result of a DHT lookup.
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct CadetPeerPath * match
Set to a matching path, if any.
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.
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.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Information we track per peer.
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.
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.
struct CadetPeerPath * path
Path this entry belongs to.
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...
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static int result
Global testing status.
int score
Path's historic score up to this point.
GNUNET_CONTAINER_HeapCostType desirability
Desirability of the path.
unsigned int cpath_length
How long is the cpath array?
uint64_t GNUNET_CONTAINER_HeapCostType
Cost by which elements in a heap can be ordered.
GNUNET_CONTAINER_HeapCostType GCPP_get_desirability(const struct CadetPeerPath *path)
Return how much we like keeping the path.
static unsigned int num_peers
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
unsigned int GCP_iterate_paths_at(struct CadetPeer *cp, unsigned int dist, GCP_PathIterator callback, void *callback_cls)
Iterate over the paths to cp where cp is at distance dist from us.
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.
unsigned int GCPP_find_peer(struct CadetPeerPath *path, struct CadetPeer *cp)
Find peer's offset on path.
The identity of the host (wraps the signing key of the peer).
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
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...
static struct CadetPeer * peers
Operation to get peer ids.
struct CadetPeerPathEntry ** entries
Array of all the peers on the path.
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...
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.
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...
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
unsigned int entries_length
Length of the entries array.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Closure for #find_peer_at() and check_match().
Information regarding a possible path to reach a peer.
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.
unsigned int GCPP_get_length(struct CadetPeerPath *path)
Return the length of the path.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
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...
unsigned int off
Offset of our destination in path.