diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_clients.c')
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 245130dbc..a1c3024de 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -644,8 +644,8 @@ handle_dht_local_get (void *cls, | |||
644 | cqr->type, | 644 | cqr->type, |
645 | 0, /* hop count */ | 645 | 0, /* hop count */ |
646 | cqr->replication, | 646 | cqr->replication, |
647 | 1, /* path length */ | 647 | 0, /* path length */ |
648 | GDS_NEIGHBOURS_get_id (), | 648 | NULL, |
649 | &get->key); | 649 | &get->key); |
650 | /* start remote requests */ | 650 | /* start remote requests */ |
651 | if (NULL != retry_task) | 651 | if (NULL != retry_task) |
@@ -867,7 +867,7 @@ struct ForwardReplyContext | |||
867 | /** | 867 | /** |
868 | * GET path taken. | 868 | * GET path taken. |
869 | */ | 869 | */ |
870 | const struct GNUNET_PeerIdentity *get_path; | 870 | const struct GNUNET_DHT_PathElement *get_path; |
871 | 871 | ||
872 | /** | 872 | /** |
873 | * Number of entries in @e get_path. | 873 | * Number of entries in @e get_path. |
@@ -900,7 +900,7 @@ forward_reply (void *cls, | |||
900 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; | 900 | enum GNUNET_BLOCK_ReplyEvaluationResult eval; |
901 | bool do_free; | 901 | bool do_free; |
902 | struct GNUNET_HashCode ch; | 902 | struct GNUNET_HashCode ch; |
903 | struct GNUNET_PeerIdentity *paths; | 903 | struct GNUNET_DHT_PathElement *paths; |
904 | 904 | ||
905 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, | 905 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, |
906 | "CLIENT-RESULT %s\n", | 906 | "CLIENT-RESULT %s\n", |
@@ -989,7 +989,7 @@ forward_reply (void *cls, | |||
989 | env = GNUNET_MQ_msg_extra (reply, | 989 | env = GNUNET_MQ_msg_extra (reply, |
990 | frc->bd->data_size | 990 | frc->bd->data_size |
991 | + (frc->get_path_length + frc->bd->put_path_length) | 991 | + (frc->get_path_length + frc->bd->put_path_length) |
992 | * sizeof(struct GNUNET_PeerIdentity), | 992 | * sizeof(struct GNUNET_DHT_PathElement), |
993 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT); | 993 | GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT); |
994 | reply->type = htonl (frc->bd->type); | 994 | reply->type = htonl (frc->bd->type); |
995 | reply->get_path_length = htonl (frc->get_path_length); | 995 | reply->get_path_length = htonl (frc->get_path_length); |
@@ -997,13 +997,14 @@ forward_reply (void *cls, | |||
997 | reply->unique_id = record->unique_id; | 997 | reply->unique_id = record->unique_id; |
998 | reply->expiration = GNUNET_TIME_absolute_hton (frc->bd->expiration_time); | 998 | reply->expiration = GNUNET_TIME_absolute_hton (frc->bd->expiration_time); |
999 | reply->key = frc->bd->key; | 999 | reply->key = frc->bd->key; |
1000 | paths = (struct GNUNET_PeerIdentity *) &reply[1]; | 1000 | paths = (struct GNUNET_DHT_PathElement *) &reply[1]; |
1001 | GNUNET_memcpy (paths, | 1001 | GNUNET_memcpy (paths, |
1002 | frc->bd->put_path, | 1002 | frc->bd->put_path, |
1003 | sizeof(struct GNUNET_PeerIdentity) * frc->bd->put_path_length); | 1003 | sizeof(struct GNUNET_DHT_PathElement) |
1004 | * frc->bd->put_path_length); | ||
1004 | GNUNET_memcpy (&paths[frc->bd->put_path_length], | 1005 | GNUNET_memcpy (&paths[frc->bd->put_path_length], |
1005 | frc->get_path, | 1006 | frc->get_path, |
1006 | sizeof(struct GNUNET_PeerIdentity) * frc->get_path_length); | 1007 | sizeof(struct GNUNET_DHT_PathElement) * frc->get_path_length); |
1007 | GNUNET_memcpy (&paths[frc->get_path_length + frc->bd->put_path_length], | 1008 | GNUNET_memcpy (&paths[frc->get_path_length + frc->bd->put_path_length], |
1008 | frc->bd->data, | 1009 | frc->bd->data, |
1009 | frc->bd->data_size); | 1010 | frc->bd->data_size); |
@@ -1023,13 +1024,13 @@ void | |||
1023 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, | 1024 | GDS_CLIENTS_handle_reply (const struct GDS_DATACACHE_BlockData *bd, |
1024 | const struct GNUNET_HashCode *query_hash, | 1025 | const struct GNUNET_HashCode *query_hash, |
1025 | unsigned int get_path_length, | 1026 | unsigned int get_path_length, |
1026 | const struct GNUNET_PeerIdentity *get_path) | 1027 | const struct GNUNET_DHT_PathElement *get_path) |
1027 | { | 1028 | { |
1028 | struct ForwardReplyContext frc; | 1029 | struct ForwardReplyContext frc; |
1029 | size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage) | 1030 | size_t msize = sizeof (struct GNUNET_DHT_ClientResultMessage) |
1030 | + bd->data_size | 1031 | + bd->data_size |
1031 | + (get_path_length + bd->put_path_length) | 1032 | + (get_path_length + bd->put_path_length) |
1032 | * sizeof(struct GNUNET_PeerIdentity); | 1033 | * sizeof(struct GNUNET_DHT_PathElement); |
1033 | 1034 | ||
1034 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) | 1035 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) |
1035 | { | 1036 | { |
@@ -1203,7 +1204,7 @@ struct GetActionContext | |||
1203 | uint32_t hop_count; | 1204 | uint32_t hop_count; |
1204 | uint32_t desired_replication_level; | 1205 | uint32_t desired_replication_level; |
1205 | unsigned int get_path_length; | 1206 | unsigned int get_path_length; |
1206 | const struct GNUNET_PeerIdentity *get_path; | 1207 | const struct GNUNET_DHT_PathElement *get_path; |
1207 | const struct GNUNET_HashCode *key; | 1208 | const struct GNUNET_HashCode *key; |
1208 | }; | 1209 | }; |
1209 | 1210 | ||
@@ -1222,10 +1223,10 @@ get_action (void *cls, | |||
1222 | struct GetActionContext *gac = cls; | 1223 | struct GetActionContext *gac = cls; |
1223 | struct GNUNET_MQ_Envelope *env; | 1224 | struct GNUNET_MQ_Envelope *env; |
1224 | struct GNUNET_DHT_MonitorGetMessage *mmsg; | 1225 | struct GNUNET_DHT_MonitorGetMessage *mmsg; |
1225 | struct GNUNET_PeerIdentity *msg_path; | 1226 | struct GNUNET_DHT_PathElement *msg_path; |
1226 | size_t msize; | 1227 | size_t msize; |
1227 | 1228 | ||
1228 | msize = gac->get_path_length * sizeof(struct GNUNET_PeerIdentity); | 1229 | msize = gac->get_path_length * sizeof(struct GNUNET_DHT_PathElement); |
1229 | env = GNUNET_MQ_msg_extra (mmsg, | 1230 | env = GNUNET_MQ_msg_extra (mmsg, |
1230 | msize, | 1231 | msize, |
1231 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET); | 1232 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET); |
@@ -1235,10 +1236,10 @@ get_action (void *cls, | |||
1235 | mmsg->desired_replication_level = htonl (gac->desired_replication_level); | 1236 | mmsg->desired_replication_level = htonl (gac->desired_replication_level); |
1236 | mmsg->get_path_length = htonl (gac->get_path_length); | 1237 | mmsg->get_path_length = htonl (gac->get_path_length); |
1237 | mmsg->key = *gac->key; | 1238 | mmsg->key = *gac->key; |
1238 | msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1239 | msg_path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1239 | GNUNET_memcpy (msg_path, | 1240 | GNUNET_memcpy (msg_path, |
1240 | gac->get_path, | 1241 | gac->get_path, |
1241 | gac->get_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1242 | gac->get_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1242 | GNUNET_MQ_send (m->ch->mq, | 1243 | GNUNET_MQ_send (m->ch->mq, |
1243 | env); | 1244 | env); |
1244 | } | 1245 | } |
@@ -1262,7 +1263,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
1262 | uint32_t hop_count, | 1263 | uint32_t hop_count, |
1263 | uint32_t desired_replication_level, | 1264 | uint32_t desired_replication_level, |
1264 | unsigned int path_length, | 1265 | unsigned int path_length, |
1265 | const struct GNUNET_PeerIdentity *path, | 1266 | const struct GNUNET_DHT_PathElement *path, |
1266 | const struct GNUNET_HashCode *key) | 1267 | const struct GNUNET_HashCode *key) |
1267 | { | 1268 | { |
1268 | struct GetActionContext gac = { | 1269 | struct GetActionContext gac = { |
@@ -1288,7 +1289,7 @@ GDS_CLIENTS_process_get (enum GNUNET_DHT_RouteOption options, | |||
1288 | struct ResponseActionContext | 1289 | struct ResponseActionContext |
1289 | { | 1290 | { |
1290 | const struct GDS_DATACACHE_BlockData *bd; | 1291 | const struct GDS_DATACACHE_BlockData *bd; |
1291 | const struct GNUNET_PeerIdentity *get_path; | 1292 | const struct GNUNET_DHT_PathElement *get_path; |
1292 | unsigned int get_path_length; | 1293 | unsigned int get_path_length; |
1293 | }; | 1294 | }; |
1294 | 1295 | ||
@@ -1309,12 +1310,12 @@ response_action (void *cls, | |||
1309 | 1310 | ||
1310 | struct GNUNET_MQ_Envelope *env; | 1311 | struct GNUNET_MQ_Envelope *env; |
1311 | struct GNUNET_DHT_MonitorGetRespMessage *mmsg; | 1312 | struct GNUNET_DHT_MonitorGetRespMessage *mmsg; |
1312 | struct GNUNET_PeerIdentity *path; | 1313 | struct GNUNET_DHT_PathElement *path; |
1313 | size_t msize; | 1314 | size_t msize; |
1314 | 1315 | ||
1315 | msize = bd->data_size; | 1316 | msize = bd->data_size; |
1316 | msize += (resp_ctx->get_path_length + bd->put_path_length) | 1317 | msize += (resp_ctx->get_path_length + bd->put_path_length) |
1317 | * sizeof(struct GNUNET_PeerIdentity); | 1318 | * sizeof(struct GNUNET_DHT_PathElement); |
1318 | env = GNUNET_MQ_msg_extra (mmsg, | 1319 | env = GNUNET_MQ_msg_extra (mmsg, |
1319 | msize, | 1320 | msize, |
1320 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP); | 1321 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP); |
@@ -1323,14 +1324,14 @@ response_action (void *cls, | |||
1323 | mmsg->get_path_length = htonl (resp_ctx->get_path_length); | 1324 | mmsg->get_path_length = htonl (resp_ctx->get_path_length); |
1324 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); | 1325 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); |
1325 | mmsg->key = bd->key; | 1326 | mmsg->key = bd->key; |
1326 | path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1327 | path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1327 | GNUNET_memcpy (path, | 1328 | GNUNET_memcpy (path, |
1328 | bd->put_path, | 1329 | bd->put_path, |
1329 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1330 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1330 | GNUNET_memcpy (path, | 1331 | GNUNET_memcpy (path, |
1331 | resp_ctx->get_path, | 1332 | resp_ctx->get_path, |
1332 | resp_ctx->get_path_length * sizeof(struct | 1333 | resp_ctx->get_path_length * sizeof(struct |
1333 | GNUNET_PeerIdentity)); | 1334 | GNUNET_DHT_PathElement)); |
1334 | GNUNET_memcpy (&path[resp_ctx->get_path_length], | 1335 | GNUNET_memcpy (&path[resp_ctx->get_path_length], |
1335 | bd->data, | 1336 | bd->data, |
1336 | bd->data_size); | 1337 | bd->data_size); |
@@ -1341,7 +1342,7 @@ response_action (void *cls, | |||
1341 | 1342 | ||
1342 | void | 1343 | void |
1343 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, | 1344 | GDS_CLIENTS_process_get_resp (const struct GDS_DATACACHE_BlockData *bd, |
1344 | const struct GNUNET_PeerIdentity *get_path, | 1345 | const struct GNUNET_DHT_PathElement *get_path, |
1345 | unsigned int get_path_length) | 1346 | unsigned int get_path_length) |
1346 | { | 1347 | { |
1347 | struct ResponseActionContext rac = { | 1348 | struct ResponseActionContext rac = { |
@@ -1384,12 +1385,12 @@ put_action (void *cls, | |||
1384 | const struct GDS_DATACACHE_BlockData *bd = put_ctx->bd; | 1385 | const struct GDS_DATACACHE_BlockData *bd = put_ctx->bd; |
1385 | struct GNUNET_MQ_Envelope *env; | 1386 | struct GNUNET_MQ_Envelope *env; |
1386 | struct GNUNET_DHT_MonitorPutMessage *mmsg; | 1387 | struct GNUNET_DHT_MonitorPutMessage *mmsg; |
1387 | struct GNUNET_PeerIdentity *msg_path; | 1388 | struct GNUNET_DHT_PathElement *msg_path; |
1388 | size_t msize; | 1389 | size_t msize; |
1389 | 1390 | ||
1390 | msize = bd->data_size | 1391 | msize = bd->data_size |
1391 | + bd->put_path_length | 1392 | + bd->put_path_length |
1392 | * sizeof(struct GNUNET_PeerIdentity); | 1393 | * sizeof(struct GNUNET_DHT_PathElement); |
1393 | env = GNUNET_MQ_msg_extra (mmsg, | 1394 | env = GNUNET_MQ_msg_extra (mmsg, |
1394 | msize, | 1395 | msize, |
1395 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT); | 1396 | GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT); |
@@ -1400,10 +1401,10 @@ put_action (void *cls, | |||
1400 | mmsg->put_path_length = htonl (bd->put_path_length); | 1401 | mmsg->put_path_length = htonl (bd->put_path_length); |
1401 | mmsg->key = bd->key; | 1402 | mmsg->key = bd->key; |
1402 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); | 1403 | mmsg->expiration_time = GNUNET_TIME_absolute_hton (bd->expiration_time); |
1403 | msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; | 1404 | msg_path = (struct GNUNET_DHT_PathElement *) &mmsg[1]; |
1404 | GNUNET_memcpy (msg_path, | 1405 | GNUNET_memcpy (msg_path, |
1405 | bd->put_path, | 1406 | bd->put_path, |
1406 | bd->put_path_length * sizeof(struct GNUNET_PeerIdentity)); | 1407 | bd->put_path_length * sizeof(struct GNUNET_DHT_PathElement)); |
1407 | GNUNET_memcpy (&msg_path[bd->put_path_length], | 1408 | GNUNET_memcpy (&msg_path[bd->put_path_length], |
1408 | bd->data, | 1409 | bd->data, |
1409 | bd->data_size); | 1410 | bd->data_size); |