/* FIXME
* 1. We need field to understand which routing table is for which peer.
* 2. Better function names and variable names.
+ * 3. Use destination peer id as key for routing table.
+ * 4. What does GDS stands for?
+ *
*/
+
+
/**
* Number of requests we track at most (for routing replies).
*/
*/
struct RoutingTrail
{
- /**
- * Source peer .
- */
- struct GNUNET_PeerIdentity endpoint1;
-
- /**
- * Destination peer.
- */
- struct GNUNET_PeerIdentity endppoint2;
-
- /**
- * The peer this request was received from.
- */
- struct GNUNET_PeerIdentity previous_hop;
-
- /**
- * The peer to which this request should be passed to.
- */
- struct GNUNET_PeerIdentity next_hop;
+ /**
+ * Source peer .
+ */
+ struct GNUNET_PeerIdentity *source;
+
+ /**
+ * Destination peer.
+ */
+ struct GNUNET_PeerIdentity *destination;
+
+ /**
+ * The peer this request was received from.
+ */
+ struct GNUNET_PeerIdentity *previous_hop;
+
+ /**
+ * The peer to which this request should be passed to.
+ */
+ struct GNUNET_PeerIdentity *next_hop;
+
};
/**
- * Find the next hop to pass the message to .
- * @return
+ * FIXME: Change the name of variable.
+ * Ensure that everywhere in this file you are using destination as the key.
+ * Add a new entry to our routing table.
+ * @param source peer
+ * @param destintation
+ * @param prev_hop
+ * @param next_hop
*/
-//static struct GNUNET_PeerIdentity *
-//find_next_hop()
-//{
+void
+GDS_ROUTING_add (struct GNUNET_PeerIdentity *source,
+ struct GNUNET_PeerIdentity *dest,
+ struct GNUNET_PeerIdentity *prev_hop,
+ struct GNUNET_PeerIdentity *next_hop)
+{
+ struct RoutingTrail *new_routing_entry;
-//}
-
+ new_routing_entry = GNUNET_malloc (sizeof (struct RoutingTrail));
+ new_routing_entry->source = source;
+ new_routing_entry->previous_hop = prev_hop;
+ new_routing_entry->next_hop = next_hop;
+ new_routing_entry->destination = dest;
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multipeermap_put (routing_table,
+ dest, new_routing_entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+}
/**
- * Add a new entry to our routing table.
- *
- * @param sender peer that originated the request
- * @param type type of the block
- * @param options options for processing
- * @param key key for the content
- * @param xquery extended query
- * @param xquery_size number of bytes in @a xquery
- * @param reply_bf bloomfilter to filter duplicates
- * @param reply_bf_mutator mutator for @a reply_bf
+ * Find the next hop to send packet to .
+ * @return next hop peer id
*/
-void
-GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
- enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- const struct GNUNET_HashCode * key, const void *xquery,
- size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator)
+struct GNUNET_PeerIdentity *
+GDS_Routing_search(struct GNUNET_PeerIdentity *source_peer,
+ struct GNUNET_PeerIdentity *destination_peer,
+ struct GNUNET_PeerIdentity *prev_hop)
{
-
+ struct RoutingTrail *trail;
+ trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer));
+
+ if(trail == NULL)
+ return NULL;
+
+ return trail->next_hop;
}
-/* search in routing table for next hop to pass the message to .
- * struct GNUNET_PeerIdentity *
-GDS_Routing_search()
-{
-}*/
/**FIXME: Old implementation just to remove error
* Handle a reply (route to origin). Only forwards the reply back to
const void *data, size_t data_size)
{
}
+
+
/**
* Initialize routing subsystem.
*/