2 This file is part of GNUnet.
3 (C) 2011 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.c
23 * @brief GNUnet DHT tracking of requests for routing replies
24 * @author Supriti Singh
27 #include "gnunet-service-xdht_neighbours.h"
28 #include "gnunet-service-xdht_routing.h"
29 #include "gnunet-service-xdht.h"
32 * 1. We need field to understand which routing table is for which peer.
33 * 2. Better function names and variable names.
34 * 3. Use destination peer id as key for routing table.
35 * 4. What does GDS stands for?
41 * Number of requests we track at most (for routing replies).
43 #define DHT_MAX_RECENT (1024 * 16)
47 * Routing table entry .
54 struct GNUNET_PeerIdentity *source;
59 struct GNUNET_PeerIdentity *destination;
62 * The peer this request was received from.
64 struct GNUNET_PeerIdentity *previous_hop;
67 * The peer to which this request should be passed to.
69 struct GNUNET_PeerIdentity *next_hop;
75 * Routing table of the peer
77 static struct GNUNET_CONTAINER_MultiPeerMap *routing_table;
80 /**FIXME: Old function added just to remove error for time being.
81 * Add a new entry to our routing table.
83 * @param sender peer that originated the request
84 * @param type type of the block
85 * @param options options for processing
86 * @param key key for the content
87 * @param xquery extended query
88 * @param xquery_size number of bytes in @a xquery
89 * @param reply_bf bloomfilter to filter duplicates
90 * @param reply_bf_mutator mutator for @a reply_bf
93 GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
94 enum GNUNET_BLOCK_Type type,
95 enum GNUNET_DHT_RouteOption options,
96 const struct GNUNET_HashCode * key, const void *xquery,
98 const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
99 uint32_t reply_bf_mutator)
106 * Find the next hop to send packet to .
107 * @return next hop peer id
109 struct GNUNET_PeerIdentity *
110 GDS_Routing_search(struct GNUNET_PeerIdentity *source_peer,
111 struct GNUNET_PeerIdentity *destination_peer,
112 struct GNUNET_PeerIdentity *prev_hop)
114 struct RoutingTrail *trail;
115 trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer));
120 return trail->next_hop;
124 /**FIXME: Old implementation just to remove error
125 * Handle a reply (route to origin). Only forwards the reply back to
126 * other peers waiting for it. Does not do local caching or
127 * forwarding to local clients. Essentially calls
128 * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching
131 * @param type type of the block
132 * @param expiration_time when does the content expire
133 * @param key key for the content
134 * @param put_path_length number of entries in put_path
135 * @param put_path peers the original PUT traversed (if tracked)
136 * @param get_path_length number of entries in get_path
137 * @param get_path peers this reply has traversed so far (if tracked)
138 * @param data payload of the reply
139 * @param data_size number of bytes in data
142 GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
143 struct GNUNET_TIME_Absolute expiration_time,
144 const struct GNUNET_HashCode * key, unsigned int put_path_length,
145 const struct GNUNET_PeerIdentity *put_path,
146 unsigned int get_path_length,
147 const struct GNUNET_PeerIdentity *get_path,
148 const void *data, size_t data_size)
154 * Initialize routing subsystem.
159 routing_table = GNUNET_CONTAINER_multipeermap_create (DHT_MAX_RECENT * 4 / 3, GNUNET_NO);
164 * Shutdown routing subsystem.
169 GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (routing_table));
170 GNUNET_CONTAINER_multipeermap_destroy (routing_table);
173 /* end of gnunet-service-xdht_routing.c */