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"
34 * To understand the direction in which trial should be read.
36 enum GDS_ROUTING_trail_direction
38 GDS_ROUTING_SRC_TO_DEST,
39 GDS_ROUTING_DEST_TO_SRC
44 * Update the prev. hop of the trail. Call made by trail teardown where
45 * if you are the first friend now in the trail then you need to update
48 * @return #GNUNET_OK success
49 * #GNUNET_SYSERR in case no matching entry found in routing table.
52 GDS_ROUTING_update_trail_prev_hop (struct GNUNET_HashCode trail_id,
53 struct GNUNET_PeerIdentity prev_hop);
56 * Get the next hop for trail corresponding to trail_id
57 * @param trail_id Trail id to be searched.
58 * @return Next_hop if found
59 * NULL If next hop not found.
61 struct GNUNET_PeerIdentity *
62 GDS_ROUTING_get_next_hop (struct GNUNET_HashCode trail_id,
63 enum GDS_ROUTING_trail_direction trail_direction);
67 * Remove every trail where peer is either next_hop or prev_hop
68 * @param peer Peer to be searched.
71 GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer);
73 * Remove trail with trail_id
74 * @param trail_id Trail id to be removed
75 * @return #GNUNET_YES success
76 * #GNUNET_NO if entry not found.
79 GDS_ROUTING_remove_trail (struct GNUNET_HashCode remove_trail_id);
83 * Add a new entry in routing table
87 * @return #GNUNET_OK success
88 * #GNUNET_SYSERR in case new_trail_id already exists in the network
89 * but with different prev_hop/next_hop
92 GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
93 struct GNUNET_PeerIdentity prev_hop,
94 struct GNUNET_PeerIdentity next_hop);
97 * Check if the size of routing table has crossed threshold.
98 * @return #GNUNET_YES, if threshold crossed
99 * #GNUNET_NO, if size is within threshold
102 GDS_ROUTING_threshold_reached (void);
106 * Initialize routing subsystem.
109 GDS_ROUTING_init (void);
112 * Shutdown routing subsystem.
115 GDS_ROUTING_done (void);