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_peer.h
24 * @brief Information we track per peer.
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
28 #ifndef GNUNET_SERVICE_CADET_PEER_H
29 #define GNUNET_SERVICE_CADET_PEER_H
31 #include "gnunet-service-cadet-new.h"
32 #include "gnunet_hello_lib.h"
36 * Get the static string for a peer ID.
40 * @return Static string for it's ID.
43 GCP_2s (const struct CadetPeer *peer);
47 * Retrieve the CadetPeer stucture associated with the
48 * peer. Optionally create one and insert it in the appropriate
49 * structures if the peer is not known yet.
51 * @param peer_id Full identity of the peer.
52 * @param create #GNUNET_YES if a new peer should be created if unknown.
53 * #GNUNET_NO to return NULL if peer is unknown.
54 * @return Existing or newly created peer structure.
55 * NULL if unknown and not requested @a create
58 GCP_get (const struct GNUNET_PeerIdentity *peer_id,
63 * Obtain the peer identity for a `struct CadetPeer`.
65 * @param cp our peer handle
66 * @param[out] peer_id where to write the peer identity
69 GCP_id (struct CadetPeer *cp,
70 struct GNUNET_PeerIdentity *peer_id);
74 * Iterate over all known peers.
76 * @param iter Iterator.
77 * @param cls Closure for @c iter.
80 GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter,
85 * Count the number of known paths toward the peer.
87 * @param peer Peer to get path info.
88 * @return Number of known paths.
91 GCP_count_paths (const struct CadetPeer *peer);
98 * @param peer Peer this path is towards.
99 * @param path Path itself
100 * @return #GNUNET_YES if should keep iterating.
101 * #GNUNET_NO otherwise.
103 * FIXME: path argument should be redundant; remove!
106 (*GCP_PathIterator) (void *cls,
107 struct CadetPeer *peer,
108 struct CadetPeerPath *path);
112 * Iterate over the paths to a peer.
114 * @param peer Peer to get path info.
115 * @param callback Function to call for every path.
116 * @param callback_cls Closure for @a callback.
117 * @return Number of iterated paths.
120 GCP_iterate_paths (struct CadetPeer *peer,
121 GCP_PathIterator callback,
126 * Get the tunnel towards a peer.
128 * @param peer Peer to get from.
129 * @param create #GNUNET_YES to create a tunnel if we do not have one
130 * @return Tunnel towards peer.
133 GCP_get_tunnel (struct CadetPeer *peer,
138 * The tunnel to the given peer no longer exists, remove it from our
139 * data structures, and possibly clean up the peer itself.
141 * @param peer the peer affected
142 * @param t the dead tunnel
145 GCP_drop_tunnel (struct CadetPeer *peer,
146 struct CadetTunnel *t);
150 * We got a HELLO for a @a peer, remember it, and possibly
151 * trigger adequate actions (like trying to connect).
153 * @param peer the peer we got a HELLO for
154 * @param hello the HELLO to remember
157 GCP_set_hello (struct CadetPeer *peer,
158 const struct GNUNET_HELLO_Message *hello);
162 * Clean up all entries about all peers.
163 * Must only be called after all tunnels, CORE-connections and
164 * connections are down.
167 GCP_destroy_all_peers (void);