incomplete code for finger and friend tables
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_routing.c
1 /*
2      This file is part of GNUnet.
3      (C) 2011 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.c
23  * @brief GNUnet DHT tracking of requests for routing replies
24  * @author Supriti Singh
25  */
26 #include "platform.h"
27 #include "gnunet-service-xdht_neighbours.h"
28 #include "gnunet-service-xdht_routing.h"
29 #include "gnunet-service-xdht.h"
30
31 /* FIXME
32  * 1. We need field to understand which routing table is for which peer.
33  * 2. Better function names and variable names.
34  */
35 /**
36  * Number of requests we track at most (for routing replies).
37  */
38 #define DHT_MAX_RECENT (1024 * 16)
39
40
41 /**
42  * Routing table entry .
43  */
44 struct RoutingTrail
45 {
46     /**
47      * Source peer .
48      */
49     struct GNUNET_PeerIdentity endpoint1;
50
51     /**
52      * Destination peer.
53      */
54     struct GNUNET_PeerIdentity endppoint2;
55
56     /**
57      * The peer this request was received from.
58      */
59     struct GNUNET_PeerIdentity previous_hop;
60
61     /**
62      * The peer to which this request should be passed to.
63      */
64     struct GNUNET_PeerIdentity next_hop;
65 };
66
67
68 /**
69  * Routing table of the peer
70  */
71 static struct GNUNET_CONTAINER_MultiPeerMap *routing_table;
72
73
74 /**
75  * Find the next hop to pass the message to .
76  * @return
77  */
78 //static struct GNUNET_PeerIdentity *
79 //find_next_hop()
80 //{
81     
82 //}
83
84
85
86 /**
87  * Add a new entry to our routing table.
88  *
89  * @param sender peer that originated the request
90  * @param type type of the block
91  * @param options options for processing
92  * @param key key for the content
93  * @param xquery extended query
94  * @param xquery_size number of bytes in @a xquery
95  * @param reply_bf bloomfilter to filter duplicates
96  * @param reply_bf_mutator mutator for @a reply_bf
97  */
98 void
99 GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
100                  enum GNUNET_BLOCK_Type type,
101                  enum GNUNET_DHT_RouteOption options,
102                  const struct GNUNET_HashCode * key, const void *xquery,
103                  size_t xquery_size,
104                  const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
105                  uint32_t reply_bf_mutator)
106 {
107
108 }
109
110 /* search in routing table for next hop to pass the message to . 
111  * struct GNUNET_PeerIdentity *
112 GDS_Routing_search()
113 {
114 }*/
115
116 /**FIXME: Old implementation just to remove error
117  * Handle a reply (route to origin).  Only forwards the reply back to
118  * other peers waiting for it.  Does not do local caching or
119  * forwarding to local clients.  Essentially calls
120  * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching
121  * request recently.
122  *
123  * @param type type of the block
124  * @param expiration_time when does the content expire
125  * @param key key for the content
126  * @param put_path_length number of entries in put_path
127  * @param put_path peers the original PUT traversed (if tracked)
128  * @param get_path_length number of entries in get_path
129  * @param get_path peers this reply has traversed so far (if tracked)
130  * @param data payload of the reply
131  * @param data_size number of bytes in data
132  */
133 void
134 GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
135                      struct GNUNET_TIME_Absolute expiration_time,
136                      const struct GNUNET_HashCode * key, unsigned int put_path_length,
137                      const struct GNUNET_PeerIdentity *put_path,
138                      unsigned int get_path_length,
139                      const struct GNUNET_PeerIdentity *get_path,
140                      const void *data, size_t data_size)
141 {
142 }
143 /**
144  * Initialize routing subsystem.
145  */
146 void
147 GDS_ROUTING_init ()
148 {
149   routing_table = GNUNET_CONTAINER_multipeermap_create (DHT_MAX_RECENT * 4 / 3, GNUNET_NO);
150 }
151
152
153 /**
154  * Shutdown routing subsystem.
155  */
156 void
157 GDS_ROUTING_done ()
158 {
159   GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (routing_table));
160   GNUNET_CONTAINER_multipeermap_destroy (routing_table);
161 }
162
163 /* end of gnunet-service-xdht_routing.c */