remove protocol violation
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_routing.h
1 /*
2      This file is part of GNUnet.
3      (C) 2011 - 2014 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20
21 /**
22  * @file dht/gnunet-service-xdht_routing.h
23  * @brief GNUnet DHT tracking of requests for routing replies
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_XDHT_ROUTING_H
27 #define GNUNET_SERVICE_XDHT_ROUTING_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_block_lib.h"
31 #include "gnunet_dht_service.h"
32
33 /**
34  * To understand the direction in which trial should be read. 
35  */
36 enum GDS_ROUTING_trail_direction 
37 {
38   GDS_ROUTING_SRC_TO_DEST,
39   GDS_ROUTING_DEST_TO_SRC
40 };
41
42
43 /**
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
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. 
50  */
51 int
52 GDS_ROUTING_update_trail_prev_hop (struct GNUNET_HashCode trail_id,
53                                    struct GNUNET_PeerIdentity prev_hop);
54
55 /**
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. 
60  */
61 struct GNUNET_PeerIdentity *
62 GDS_ROUTING_get_next_hop (struct GNUNET_HashCode trail_id,
63                           enum GDS_ROUTING_trail_direction trail_direction);
64
65
66 /**
67   * Remove every trail where peer is either next_hop or prev_hop 
68  * @param peer Peer to be searched.
69  */
70 void
71 GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer);
72 /**
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.
77  */
78 int
79 GDS_ROUTING_remove_trail (struct GNUNET_HashCode remove_trail_id);
80
81
82 /**
83  * Add a new entry in routing table
84  * @param new_trail_id
85  * @param prev_hop
86  * @param next_hop
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
90  */
91 int
92 GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id, 
93                  struct GNUNET_PeerIdentity prev_hop,
94                  struct GNUNET_PeerIdentity next_hop);
95
96
97 /**
98  * Check if the size of routing table has crossed threshold. 
99  * @return #GNUNET_YES, if threshold crossed 
100  *         #GNUNET_NO, if size is within threshold 
101  */
102 int
103 GDS_ROUTING_threshold_reached (void);
104
105
106 /**
107  * Initialize routing subsystem.
108  */
109 void
110 GDS_ROUTING_init (void);
111
112 /**
113  * Shutdown routing subsystem.
114  */
115 void
116 GDS_ROUTING_done (void);
117 #endif