aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-09-12 22:25:04 +0000
committerBart Polot <bart@net.in.tum.de>2011-09-12 22:25:04 +0000
commite1d2bd3ef857adf95e4f26a937ba8b8fdf003a30 (patch)
tree911f700ef4111c4da736c531330ff9e9ed385818 /src/dht/gnunet-service-dht.c
parentff335cda7a4bd384e988266c912a672dde39b7b9 (diff)
downloadgnunet-e1d2bd3ef857adf95e4f26a937ba8b8fdf003a30.tar.gz
gnunet-e1d2bd3ef857adf95e4f26a937ba8b8fdf003a30.zip
WiP
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index b864e39e3..0cbf8315c 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -2846,6 +2846,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2846 int ret; 2846 int ret;
2847 struct RepublishContext *put_context; 2847 struct RepublishContext *put_context;
2848 GNUNET_HashCode key; 2848 GNUNET_HashCode key;
2849 struct DHTQueryRecord *record;
2849 2850
2850 GNUNET_assert (ntohs (msg->size) >= sizeof (struct GNUNET_DHT_PutMessage)); 2851 GNUNET_assert (ntohs (msg->size) >= sizeof (struct GNUNET_DHT_PutMessage));
2851 2852
@@ -2923,6 +2924,37 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg,
2923 } 2924 }
2924#endif 2925#endif
2925 2926
2927// GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** PUT 1\n");
2928 record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, &msg_ctx->key);
2929 if (NULL != record)
2930 {
2931 struct DHTRouteSource *pos;
2932 struct GNUNET_DHT_GetMessage *gmsg;
2933 size_t gsize;
2934
2935// GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** PUT 2\n");
2936 pos = record->head;
2937 while (pos != NULL)
2938 {
2939 /* TODO: do only for local started requests? or also for remote peers? */
2940 /* TODO: include this in statistics? under what? */
2941 if (NULL == pos->client)
2942 continue;
2943
2944 gsize = data_size + sizeof(struct GNUNET_DHT_GetMessage);
2945 gmsg = GNUNET_malloc(gsize);
2946 gmsg->header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET_RESULT);
2947 gmsg->header.size = htons(gsize);
2948 gmsg->type = put_msg->type;
2949 memcpy(&gmsg[1], &put_msg[1], data_size);
2950
2951 /* TODO: duplicate and reverse order of path_history? */
2952 send_reply_to_client (pos->client, &gmsg->header, msg_ctx);
2953 GNUNET_free(gmsg);
2954 }
2955 }
2956// GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** PUT END\n");
2957
2926 if (msg_ctx->closest != GNUNET_YES) 2958 if (msg_ctx->closest != GNUNET_YES)
2927 { 2959 {
2928 route_message (msg, msg_ctx); 2960 route_message (msg, msg_ctx);
@@ -3716,6 +3748,8 @@ cache_response (struct DHT_MessageContext *msg_ctx)
3716 3748
3717 current_size = GNUNET_CONTAINER_multihashmap_size (forward_list.hashmap); 3749 current_size = GNUNET_CONTAINER_multihashmap_size (forward_list.hashmap);
3718 3750
3751 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** GET %s\n", GNUNET_h2s_full(&msg_ctx->key));
3752
3719#if DELETE_WHEN_FULL 3753#if DELETE_WHEN_FULL
3720 while (current_size >= MAX_OUTSTANDING_FORWARDS) 3754 while (current_size >= MAX_OUTSTANDING_FORWARDS)
3721 { 3755 {
@@ -4575,7 +4609,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client,
4575 msg_ctx.path_history_len = 1; 4609 msg_ctx.path_history_len = 1;
4576 } 4610 }
4577 msg_ctx.network_size = estimate_diameter (); 4611 msg_ctx.network_size = estimate_diameter ();
4578 msg_ctx.peer = &my_identity; 4612 msg_ctx.peer = &my_identity; /* FIXME NULL? Fix doxygen? */
4579 msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ 4613 msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */
4580 msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; 4614 msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT;
4581 4615