3 This file is part of GNUnet.
4 Copyright (C) 2001-2017 GNUnet e.V.
6 GNUnet is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
11 GNUnet is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNUnet; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 * @file cadet/gnunet-service-cadet-new_paths.h
24 * @brief Information we track per path.
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
28 #ifndef GNUNET_SERVICE_CADET_PATHS_H
29 #define GNUNET_SERVICE_CADET_PATHS_H
31 #include "gnunet_util_lib.h"
32 #include "gnunet-service-cadet-new.h"
35 * Create a peer path based on the result of a DHT lookup.
36 * If we already know this path, or one that is longer,
39 * @param get_path path of the get request
40 * @param get_path_length lenght of @a get_path
41 * @param put_path path of the put request
42 * @param put_path_length length of the @a put_path
43 * @return a path through the network
45 struct CadetPeerPath *
46 GCPP_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
47 unsigned int get_path_length,
48 const struct GNUNET_PeerIdentity *put_path,
49 unsigned int put_path_length);
53 * Destroy a path, we no longer need it.
55 * @param path path to destroy.
58 GCPP_path_destroy (struct CadetPeerPath *path);
62 * Return the length of the path. Excludes one end of the
63 * path, so the loopback path has length 0.
65 * @param path path to return the length for
66 * @return number of peers on the path
69 GCPP_get_length (struct CadetPeerPath *path);
73 * Return connection to @a destination using @a path, or return
74 * NULL if no such connection exists.
76 * @param path path to traverse
77 * @param destination destination node to get to, must be on path
78 * @param off offset of @a destination on @a path
79 * @return NULL if @a create is NO and we have no existing connection
80 * otherwise connection from us to @a destination via @a path
82 struct CadetConnection *
83 GCPP_get_connection (struct CadetPeerPath *path,
84 struct CadetPeer *destination,
89 * Notify @a path that it is used for connection @a cc
90 * which ends at the path's offset @a off.
92 * @param path the path to remember the @a cc
93 * @param off the offset where the @a cc ends
94 * @param cc the connection to remember
97 GCPP_add_connection (struct CadetPeerPath *path,
99 struct CadetConnection *cc);
103 * Notify @a path that it is no longer used for connection @a cc which
104 * ended at the path's offset @a off.
106 * @param path the path to forget the @a cc
107 * @param off the offset where the @a cc ended
108 * @param cc the connection to forget
111 GCPP_del_connection (struct CadetPeerPath *path,
113 struct CadetConnection *cc);
117 * Find peer's offset on path.
119 * @param path path to search
120 * @param cp peer to look for
121 * @return offset of @a cp on @a path, or UINT_MAX if not found
124 GCPP_find_peer (struct CadetPeerPath *path,
125 struct CadetPeer *cp);
129 * Return how much we like keeping the path. This is an aggregate
130 * score based on various factors, including the age of the path
131 * (older == better), and the value of this path to all of its ajacent
132 * peers. For example, long paths that end at a peer that we have no
133 * shorter way to reach are very desirable, while long paths that end
134 * at a peer for which we have a shorter way as well are much less
135 * desirable. Higher values indicate more valuable paths. The
136 * returned value should be used to decide which paths to remember.
138 * @param path path to return the length for
139 * @return desirability of the path, larger is more desirable
141 GNUNET_CONTAINER_HeapCostType
142 GCPP_get_desirability (const struct CadetPeerPath *path);
146 * The given peer @a cp used to own this @a path. However, it is no
147 * longer interested in maintaining it, so the path should be
148 * discarded or shortened (in case a previous peer on the path finds
149 * the path desirable).
151 * @param path the path that is being released
152 * @param node entry in the heap of @a cp where this path is anchored
153 * should be used for updates to the desirability of this path
156 GCPP_acquire (struct CadetPeerPath *path,
157 struct GNUNET_CONTAINER_HeapNode *node);
161 * The given peer @a cp used to own this @a path. However, it is no
162 * longer interested in maintaining it, so the path should be
163 * discarded or shortened (in case a previous peer on the path finds
164 * the path desirable).
166 * @param path the path that is being released
169 GCPP_release (struct CadetPeerPath *path);
173 * Obtain the peer at offset @a off in @a path.
175 * @param path peer path to inspect
176 * @param off offset to return, must be smaller than path length
177 * @return peer at offset @a off
180 GCPP_get_peer_at_offset (struct CadetPeerPath *path,