2 This file is part of GNUnet.
3 (C) 2011 - 2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file dht/gnunet-service-xdht_routing.h
23 * @brief GNUnet DHT tracking of requests for routing replies
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_XDHT_ROUTING_H
27 #define GNUNET_SERVICE_XDHT_ROUTING_H
29 #include "gnunet_util_lib.h"
30 #include "gnunet_block_lib.h"
31 #include "gnunet_dht_service.h"
35 * Add a new entry to our routing table.
36 * @param source peer Source of the trail.
37 * @param destintation Destination of the trail.
38 * @param next_hop Next peer to forward the message to reach the destination.
40 * GNUNET_SYSERR If the number of routing entries crossed thershold.
43 GDS_ROUTING_add (const struct GNUNET_PeerIdentity *source,
44 const struct GNUNET_PeerIdentity *dest,
45 const struct GNUNET_PeerIdentity *next_hop,
46 const struct GNUNET_PeerIdentity *prev_hop);
50 * Iterate over routing table and remove entries for which peer is a part.
55 GDS_ROUTING_remove_entry (const struct GNUNET_PeerIdentity *peer);
59 * Search the next hop to send the packet to in routing table.
60 * @return next hop peer id
62 struct GNUNET_PeerIdentity *
63 GDS_ROUTING_search(struct GNUNET_PeerIdentity *source_peer,
64 struct GNUNET_PeerIdentity *destination_peer,
65 const struct GNUNET_PeerIdentity *prev_hop);
68 * FIXME: How to ensure that with only 3 fields also we have a unique trail.
69 * in case of redundant routes we can have different next hop.
70 * in that case we have to call this function on each entry of routing table
71 * and from multiple next hop we return one. Here also we are going to return one.
73 * Assumption - there can be only on one trail with all these fields. But if
74 * we consider only 3 fields then it is possible that next hop is differet.
75 * Update prev_hop field to source_peer. Trail from source peer to destination
76 * peer is compressed such that I am the first friend in the trail.
77 * @param source_peer Source of the trail.
78 * @param destination_peer Destination of the trail.
79 * @param prev_hop Peer before me in the trail.
80 * @return #GNUNET_YES trail is updated.
81 * #GNUNET_NO, trail not found.
84 GDS_ROUTING_trail_update (struct GNUNET_PeerIdentity *source_peer,
85 struct GNUNET_PeerIdentity *destination_peer,
86 const struct GNUNET_PeerIdentity *prev_hop);
90 * Remove the trail as result of trail tear down message.
91 * @param source_peer Source of the trail.
92 * @param destination_peer Destination of the trail.
93 * @param next_hop Next hop
94 * @param prev_hop Previous hop.
95 * @return #GNUNET_YES if successful
96 * #GNUNET_NO if not successful.
99 GDS_ROUTING_remove_trail (struct GNUNET_PeerIdentity *source_peer,
100 struct GNUNET_PeerIdentity *destination_peer,
101 const struct GNUNET_PeerIdentity *prev_hop);
107 GDS_ROUTING_print (void);
110 * Check if size of routing table is greater than threshold or not.
113 GDS_ROUTING_check_threshold (void);
116 * Initialize routing subsystem.
119 GDS_ROUTING_init (void);
123 * Shutdown routing subsystem.
126 GDS_ROUTING_done (void);