From d0483d2d766ad0b78745058ce46077d267ab5f55 Mon Sep 17 00:00:00 2001 From: Arthur Dewarumez Date: Thu, 30 Apr 2015 12:29:58 +0000 Subject: [PATCH] Adding the handle_dht_p2p_trail_destroy function. --- src/dht/gnunet-service-wdht_neighbours.c | 41 +++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/dht/gnunet-service-wdht_neighbours.c b/src/dht/gnunet-service-wdht_neighbours.c index 66e0e8fc3..ba2d4eb63 100644 --- a/src/dht/gnunet-service-wdht_neighbours.c +++ b/src/dht/gnunet-service-wdht_neighbours.c @@ -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; } -- 2.25.1