aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_routing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-xdht_routing.h')
-rw-r--r--src/dht/gnunet-service-xdht_routing.h104
1 files changed, 49 insertions, 55 deletions
diff --git a/src/dht/gnunet-service-xdht_routing.h b/src/dht/gnunet-service-xdht_routing.h
index 2475741c4..f186f5f8c 100644
--- a/src/dht/gnunet-service-xdht_routing.h
+++ b/src/dht/gnunet-service-xdht_routing.h
@@ -30,81 +30,77 @@
30#include "gnunet_block_lib.h" 30#include "gnunet_block_lib.h"
31#include "gnunet_dht_service.h" 31#include "gnunet_dht_service.h"
32 32
33
34/** 33/**
35 * Add a new entry to our routing table. 34 * To understand the direction in which trial should be read.
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.
39 * @return GNUNET_YES
40 * GNUNET_SYSERR If the number of routing entries crossed thershold.
41 */ 35 */
42int 36enum GDS_ROUTING_trail_direction
43GDS_ROUTING_add (const struct GNUNET_PeerIdentity *source, 37{
44 const struct GNUNET_PeerIdentity *dest, 38 GDS_ROUTING_SRC_TO_DEST,
45 const struct GNUNET_PeerIdentity *next_hop, 39 GDS_ROUTING_DEST_TO_SRC
46 const struct GNUNET_PeerIdentity *prev_hop); 40};
47 41
48 42
49/** 43/**
50 * Iterate over routing table and remove entries for which peer is a part. 44 * Update the prev. hop of the trail. Call made by trail teardown where
51 * @param peer 45 * if you are the first friend now in the trail then you need to update
52 * @return 46 * your prev. hop.
47 * @param trail_id
48 * @return #GNUNET_OK success
49 * #GNUNET_SYSERR in case no matching entry found in routing table.
53 */ 50 */
54void 51int
55GDS_ROUTING_remove_entry (const struct GNUNET_PeerIdentity *peer); 52GDS_ROUTING_update_trail_prev_hop (struct GNUNET_HashCode trail_id,
56 53 struct GNUNET_PeerIdentity prev_hop);
57 54
58/** 55/**
59 * Search the next hop to send the packet to in routing table. 56 * Get the next hop for trail corresponding to trail_id
60 * @return next hop peer id 57 * @param trail_id Trail id to be searched.
58 * @return Next_hop if found
59 * NULL If next hop not found.
61 */ 60 */
62struct GNUNET_PeerIdentity * 61struct GNUNET_PeerIdentity *
63GDS_ROUTING_search(struct GNUNET_PeerIdentity *source_peer, 62GDS_ROUTING_get_next_hop (struct GNUNET_HashCode trail_id,
64 struct GNUNET_PeerIdentity *destination_peer, 63 enum GDS_ROUTING_trail_direction trail_direction);
65 const struct GNUNET_PeerIdentity *prev_hop); 64
66 65
67/** 66/**
68 * FIXME: How to ensure that with only 3 fields also we have a unique trail. 67 * Remove every trail where peer is either next_hop or prev_hop
69 * in case of redundant routes we can have different next hop. 68 * @param peer Peer to be searched.
70 * in that case we have to call this function on each entry of routing table 69 */
71 * and from multiple next hop we return one. Here also we are going to return one. 70void
72 * URGENT. 71GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer);
73 * Assumption - there can be only on one trail with all these fields. But if 72/**
74 * we consider only 3 fields then it is possible that next hop is differet. 73 * Remove trail with trail_id
75 * Update prev_hop field to source_peer. Trail from source peer to destination 74 * @param trail_id Trail id to be removed
76 * peer is compressed such that I am the first friend in the trail. 75 * @return #GNUNET_YES success
77 * @param source_peer Source of the trail. 76 * #GNUNET_NO if entry not found.
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.
82 */ 77 */
83int 78int
84GDS_ROUTING_trail_update (struct GNUNET_PeerIdentity *source_peer, 79GDS_ROUTING_remove_trail (struct GNUNET_HashCode remove_trail_id);
85 struct GNUNET_PeerIdentity *destination_peer,
86 const struct GNUNET_PeerIdentity *prev_hop);
87 80
88 81
89/** 82/**
90 * Remove the trail as result of trail tear down message. 83 * Add a new entry in routing table
91 * @param source_peer Source of the trail. 84 * @param new_trail_id
92 * @param destination_peer Destination of the trail. 85 * @param prev_hop
93 * @param next_hop Next hop 86 * @param next_hop
94 * @param prev_hop Previous hop. 87 * @return #GNUNET_OK success
95 * @return #GNUNET_YES if successful 88 * #GNUNET_SYSERR in case new_trail_id already exists in the network
96 * #GNUNET_NO if not successful. 89 * but with different prev_hop/next_hop
97 */ 90 */
98int 91int
99GDS_ROUTING_remove_trail (struct GNUNET_PeerIdentity *source_peer, 92GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
100 struct GNUNET_PeerIdentity *destination_peer, 93 struct GNUNET_PeerIdentity *prev_hop,
101 const struct GNUNET_PeerIdentity *prev_hop); 94 const struct GNUNET_PeerIdentity *next_hop);
102 95
103/** 96/**
104 * Check if size of routing table is greater than threshold or not. 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
105 */ 100 */
106int 101int
107GDS_ROUTING_check_threshold (void); 102GDS_ROUTING_threshold_reached (void);
103
108 104
109/** 105/**
110 * Initialize routing subsystem. 106 * Initialize routing subsystem.
@@ -112,11 +108,9 @@ GDS_ROUTING_check_threshold (void);
112void 108void
113GDS_ROUTING_init (void); 109GDS_ROUTING_init (void);
114 110
115
116/** 111/**
117 * Shutdown routing subsystem. 112 * Shutdown routing subsystem.
118 */ 113 */
119void 114void
120GDS_ROUTING_done (void); 115GDS_ROUTING_done (void);
121 116#endif \ No newline at end of file
122#endif