/* 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
- */
-//static
-struct GNUNET_PeerIdentity *
-find_next_hop()
-{
- return NULL;
-}
-
-
-
-/**FIXME: Old function added just to remove error for time being.
+ * 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 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
+ * @param source peer
+ * @param destintation
+ * @param prev_hop
+ * @param next_hop
*/
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)
+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));
}
/**
- * Search the next hop to send the packet to in routing table.
+ * Find the next hop to send packet to .
* @return next hop peer id
*/
struct GNUNET_PeerIdentity *
struct GNUNET_PeerIdentity *destination_peer,
struct GNUNET_PeerIdentity *prev_hop)
{
- //struct GNUNET_PeerIdentity *next_hop;
+ struct RoutingTrail *trail;
+ trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer));
+
+ if(trail == NULL)
+ return NULL;
- /* We have got all the fields and now we should search the
- routing table by destination_peer and we should return the next_hop
- I don't see any function at the moment in container_multipeer_map. */
- return NULL;
+ return trail->next_hop;
}
const void *data, size_t data_size)
{
}
+
+
/**
* Initialize routing subsystem.
*/