Adding the handle_dht_p2p_trail_destroy function.
authorArthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr>
Thu, 30 Apr 2015 12:29:58 +0000 (12:29 +0000)
committerArthur Dewarumez <arthur.dewarumez@etudiant.univ-lille1.fr>
Thu, 30 Apr 2015 12:29:58 +0000 (12:29 +0000)
src/dht/gnunet-service-wdht_neighbours.c

index 66e0e8fc304ec222157348f60ef2487fb4b6b5a5..ba2d4eb631145c2811fca4a766f11cd6800c75d2 100644 (file)
@@ -1156,17 +1156,19 @@ handle_dht_p2p_trail_destroy (void *cls,
                              const struct GNUNET_MessageHeader *message)
 {
   const struct TrailDestroyMessage *tdm;
+  struct Trail *trail;
 
   tdm = (const struct TrailDestroyMessage *) message;
 
-  /*
-   * Steps :
-   *  1 check if message comme from a trail (that we still remember...)
-   *  1.a.1 if true: send the destroy message to the rest trail
-   *  1.a.2 clean the trail structure
-   *  1.a.3 did i have to remove the trail and ID from the db structure?
-   *  1.b if false: do nothing
-   */
+  /* Retreive the trail from the trail_map */
+  trail = GNUNET_CONTAINER_multihashmap_get(trail_map, tdm->trail_id);
+
+  if(peer == trail->pred_id){
+    delete(trail, GNUNET_NO, GNUNET_YES);
+  }
+  else{
+    delete(trail, GNUNET_YES, GNUNET_NO);
+  }
 
   return GNUNET_OK;
 }
@@ -1227,15 +1229,22 @@ handle_dht_p2p_trail_route (void *cls,
                             const struct GNUNET_MessageHeader *message)
 {
   const struct TrailRouteMessage *trm;
+  const void *payload;
+  size_t msize;
+  unsigned int start_payload;
+
+  /* msize = ntohs (message->size); */
+  /* if (msize < sizeof (struct TrailRouteMessage)) */
+  /* { */
+  /*   GNUNET_break_op (0); */
+  /*   return GNUNET_YES; */
+  /* } */
+
+  /* trm = (const struct TrailRouteMessage *) message; */
+  /* /\* Retreive payload *\/ */
+  /* start_payload = sizeof (struct PeerGetResultMessage); */
+  /* payload = message[start_payload]; */
 
-  trm = (const struct TrailRouteMessage *) message;
-
-  /*
-   * Steps :
-   *  1 check if message comme from a trail
-   *  1.a.1 if trail not finished with us, continue to forward
-   *  1.a.2 otherwise handle body message embedded in trail
-   */
   return GNUNET_OK;
 }