2 This file is part of GNUnet.
3 Copyright (C) 2011 - 2014 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, 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);
57 * Update the next hop of the trail. Call made by trail compression where
58 * if you are source of the trail and now you have a new first friend, then
59 * you should update the trail.
61 * @return #GNUNET_OK success
62 * #GNUNET_SYSERR in case no matching entry found in routing table.
65 GDS_ROUTING_update_trail_next_hop (const struct GNUNET_HashCode trail_id,
66 struct GNUNET_PeerIdentity next_hop);
69 * Get the next hop for trail corresponding to trail_id
70 * @param trail_id Trail id to be searched.
71 * @return Next_hop if found
72 * NULL If next hop not found.
74 struct GNUNET_PeerIdentity *
75 GDS_ROUTING_get_next_hop (struct GNUNET_HashCode trail_id,
76 enum GDS_ROUTING_trail_direction trail_direction);
80 * Remove every trail where peer is either next_hop or prev_hop
81 * @param peer Peer to be searched.
84 GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer);
86 * Remove trail with trail_id
87 * @param trail_id Trail id to be removed
88 * @return #GNUNET_YES success
89 * #GNUNET_NO if entry not found.
92 GDS_ROUTING_remove_trail (struct GNUNET_HashCode remove_trail_id);
96 * Add a new entry in routing table
100 * @return #GNUNET_OK success
101 * #GNUNET_SYSERR in case new_trail_id already exists in the network
102 * but with different prev_hop/next_hop
105 GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
106 struct GNUNET_PeerIdentity prev_hop,
107 struct GNUNET_PeerIdentity next_hop);
111 * Check if the size of routing table has crossed threshold.
112 * @return #GNUNET_YES, if threshold crossed
113 * #GNUNET_NO, if size is within threshold
116 GDS_ROUTING_threshold_reached (void);
120 * Test function. Remove afterwards.
123 GDS_ROUTING_test_print (void);
127 * Initialize routing subsystem.
130 GDS_ROUTING_init (void);
133 * Shutdown routing subsystem.
136 GDS_ROUTING_done (void);