1.Modified struct PeerTrailSetupMessage and PeerTrailSetupResultMessage.
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_routing.c
index 0a0b1ac61db3e9ffec29ab7a1d90a108c9f6f38f..13f0d3e77a758df2f07e801b5b8d04c54ab3b73a 100644 (file)
@@ -77,28 +77,40 @@ struct RoutingTrail
 static struct GNUNET_CONTAINER_MultiPeerMap *routing_table;
 
 
-/**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.
+ * Do we need prev field in routing table?
  * 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 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 *next_hop)
 {
-
+  struct RoutingTrail *new_routing_entry;
+    
+  new_routing_entry = GNUNET_malloc (sizeof (struct RoutingTrail));
+  new_routing_entry->source = source;
+  new_routing_entry->next_hop = next_hop;
+  new_routing_entry->destination = dest;
+    
+  /* If dest is already present in the routing table, then exit.*/
+  if (GNUNET_YES ==
+    GNUNET_CONTAINER_multipeermap_contains (routing_table,
+                                              dest))
+  {
+    GNUNET_break (0);
+    return;
+  }
+
+  GNUNET_assert (GNUNET_OK ==
+    GNUNET_CONTAINER_multipeermap_put (routing_table,
+                                           dest, new_routing_entry,
+                                           GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
 }
 
 
@@ -107,17 +119,16 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
  * @return next hop peer id
  */
 struct GNUNET_PeerIdentity *
-GDS_Routing_search(struct GNUNET_PeerIdentity *source_peer,
-                   struct GNUNET_PeerIdentity *destination_peer,
-                   struct GNUNET_PeerIdentity *prev_hop)
+GDS_ROUTING_search(struct GNUNET_PeerIdentity *source_peer,
+                   struct GNUNET_PeerIdentity *destination_peer)
 {
-    struct RoutingTrail *trail;
-    trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer));
+  struct RoutingTrail *trail;
+  trail = (struct RoutingTrail *)(GNUNET_CONTAINER_multipeermap_get(routing_table,destination_peer));
     
-    if(trail == NULL)
-        return NULL;
+  if(trail == NULL)
+      return NULL;
     
-    return trail->next_hop;
+  return trail->next_hop;
 }
 
 
@@ -147,6 +158,7 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
                      const struct GNUNET_PeerIdentity *get_path,
                      const void *data, size_t data_size)
 {
+
 }
 
 
@@ -155,7 +167,7 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
  */
 void
 GDS_ROUTING_init ()
-{
+{ 
   routing_table = GNUNET_CONTAINER_multipeermap_create (DHT_MAX_RECENT * 4 / 3, GNUNET_NO);
 }