diff options
Diffstat (limited to 'src/abd/gnunet-service-abd.c')
-rw-r--r-- | src/abd/gnunet-service-abd.c | 170 |
1 files changed, 97 insertions, 73 deletions
diff --git a/src/abd/gnunet-service-abd.c b/src/abd/gnunet-service-abd.c index 84222b290..36b0009ef 100644 --- a/src/abd/gnunet-service-abd.c +++ b/src/abd/gnunet-service-abd.c | |||
@@ -360,6 +360,7 @@ print_deleset (struct DelegationSetQueueEntry *dsentry, char *text) | |||
360 | dsentry->delegation_chain_entry->subject_attribute); | 360 | dsentry->delegation_chain_entry->subject_attribute); |
361 | } | 361 | } |
362 | 362 | ||
363 | |||
363 | static void | 364 | static void |
364 | cleanup_dsq_entry (struct DelegationSetQueueEntry *ds_entry) | 365 | cleanup_dsq_entry (struct DelegationSetQueueEntry *ds_entry) |
365 | { | 366 | { |
@@ -385,18 +386,19 @@ cleanup_dsq_entry (struct DelegationSetQueueEntry *ds_entry) | |||
385 | GNUNET_free (ds_entry->delegation_chain_entry); | 386 | GNUNET_free (ds_entry->delegation_chain_entry); |
386 | } | 387 | } |
387 | // Free DQ entries | 388 | // Free DQ entries |
388 | for(struct DelegationQueueEntry *dq_entry = ds_entry->queue_entries_head; | 389 | for (struct DelegationQueueEntry *dq_entry = ds_entry->queue_entries_head; |
389 | NULL != ds_entry->queue_entries_head; | 390 | NULL != ds_entry->queue_entries_head; |
390 | dq_entry = ds_entry->queue_entries_head) | 391 | dq_entry = ds_entry->queue_entries_head) |
391 | { | 392 | { |
392 | GNUNET_CONTAINER_DLL_remove (ds_entry->queue_entries_head, | 393 | GNUNET_CONTAINER_DLL_remove (ds_entry->queue_entries_head, |
393 | ds_entry->queue_entries_tail, | 394 | ds_entry->queue_entries_tail, |
394 | dq_entry); | 395 | dq_entry); |
395 | GNUNET_free (dq_entry); | 396 | GNUNET_free (dq_entry); |
396 | } | 397 | } |
397 | GNUNET_free (ds_entry); | 398 | GNUNET_free (ds_entry); |
398 | } | 399 | } |
399 | 400 | ||
401 | |||
400 | static void | 402 | static void |
401 | cleanup_handle (struct VerifyRequestHandle *vrh) | 403 | cleanup_handle (struct VerifyRequestHandle *vrh) |
402 | { | 404 | { |
@@ -405,21 +407,22 @@ cleanup_handle (struct VerifyRequestHandle *vrh) | |||
405 | 407 | ||
406 | if (NULL != vrh->dsq_head) | 408 | if (NULL != vrh->dsq_head) |
407 | { | 409 | { |
408 | for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL != vrh->dsq_head; | 410 | for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL != |
409 | ds_entry = vrh->dsq_head) | 411 | vrh->dsq_head; |
412 | ds_entry = vrh->dsq_head) | ||
410 | { | 413 | { |
411 | GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry); | 414 | GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry); |
412 | cleanup_dsq_entry(ds_entry); | 415 | cleanup_dsq_entry (ds_entry); |
413 | } | 416 | } |
414 | } | 417 | } |
415 | if (NULL != vrh->del_chain_head) | 418 | if (NULL != vrh->del_chain_head) |
416 | { | 419 | { |
417 | for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; | 420 | for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head; |
418 | del_entry = vrh->del_chain_head) | 421 | del_entry = vrh->del_chain_head) |
419 | { | 422 | { |
420 | GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, | 423 | GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head, |
421 | vrh->del_chain_tail, | 424 | vrh->del_chain_tail, |
422 | del_entry); | 425 | del_entry); |
423 | GNUNET_free_non_null (del_entry->delegate); | 426 | GNUNET_free_non_null (del_entry->delegate); |
424 | GNUNET_free (del_entry); | 427 | GNUNET_free (del_entry); |
425 | } | 428 | } |
@@ -428,6 +431,7 @@ cleanup_handle (struct VerifyRequestHandle *vrh) | |||
428 | GNUNET_free (vrh); | 431 | GNUNET_free (vrh); |
429 | } | 432 | } |
430 | 433 | ||
434 | |||
431 | static void | 435 | static void |
432 | shutdown_task (void *cls) | 436 | shutdown_task (void *cls) |
433 | { | 437 | { |
@@ -459,15 +463,18 @@ shutdown_task (void *cls) | |||
459 | } | 463 | } |
460 | } | 464 | } |
461 | 465 | ||
466 | |||
462 | static void | 467 | static void |
463 | send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationChainEntry *ch_entry, bool is_bw){ | 468 | send_intermediate_response (struct VerifyRequestHandle *vrh, struct |
469 | DelegationChainEntry *ch_entry, bool is_bw) | ||
470 | { | ||
464 | struct DelegationChainIntermediateMessage *rmsg; | 471 | struct DelegationChainIntermediateMessage *rmsg; |
465 | struct GNUNET_MQ_Envelope *env; | 472 | struct GNUNET_MQ_Envelope *env; |
466 | struct GNUNET_ABD_Delegation *dd; | 473 | struct GNUNET_ABD_Delegation *dd; |
467 | size_t size; | 474 | size_t size; |
468 | 475 | ||
469 | // Don't report immediate results during collect | 476 | // Don't report immediate results during collect |
470 | if(vrh->is_collect) | 477 | if (vrh->is_collect) |
471 | return; | 478 | return; |
472 | 479 | ||
473 | dd = GNUNET_new (struct GNUNET_ABD_Delegation); | 480 | dd = GNUNET_new (struct GNUNET_ABD_Delegation); |
@@ -482,31 +489,32 @@ send_intermediate_response(struct VerifyRequestHandle *vrh, struct DelegationCha | |||
482 | dd->subject_attribute = ch_entry->subject_attribute; | 489 | dd->subject_attribute = ch_entry->subject_attribute; |
483 | dd->subject_attribute_len = strlen (ch_entry->subject_attribute) + 1; | 490 | dd->subject_attribute_len = strlen (ch_entry->subject_attribute) + 1; |
484 | } | 491 | } |
485 | 492 | ||
486 | 493 | ||
487 | size = GNUNET_ABD_delegation_chain_get_size (1, | 494 | size = GNUNET_ABD_delegation_chain_get_size (1, |
488 | dd, | 495 | dd, |
489 | 0, | 496 | 0, |
490 | NULL); | 497 | NULL); |
491 | 498 | ||
492 | env = GNUNET_MQ_msg_extra (rmsg, | 499 | env = GNUNET_MQ_msg_extra (rmsg, |
493 | size, | 500 | size, |
494 | GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT); | 501 | GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT); |
495 | // Assign id so that client can find associated request | 502 | // Assign id so that client can find associated request |
496 | rmsg->id = vrh->request_id; | 503 | rmsg->id = vrh->request_id; |
497 | rmsg->is_bw = htons(is_bw); | 504 | rmsg->is_bw = htons (is_bw); |
498 | rmsg->size = htonl(size); | 505 | rmsg->size = htonl (size); |
499 | 506 | ||
500 | GNUNET_assert ( | 507 | GNUNET_assert ( |
501 | -1 != GNUNET_ABD_delegation_chain_serialize (1, | 508 | -1 != GNUNET_ABD_delegation_chain_serialize (1, |
502 | dd, | 509 | dd, |
503 | 0, | 510 | 0, |
504 | NULL, | 511 | NULL, |
505 | size, | 512 | size, |
506 | (char *) &rmsg[1])); | 513 | (char *) &rmsg[1])); |
507 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); | 514 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); |
508 | } | 515 | } |
509 | 516 | ||
517 | |||
510 | static void | 518 | static void |
511 | send_lookup_response (struct VerifyRequestHandle *vrh) | 519 | send_lookup_response (struct VerifyRequestHandle *vrh) |
512 | { | 520 | { |
@@ -570,9 +578,9 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
570 | } | 578 | } |
571 | size = | 579 | size = |
572 | GNUNET_ABD_delegation_chain_get_size (vrh->delegation_chain_size, | 580 | GNUNET_ABD_delegation_chain_get_size (vrh->delegation_chain_size, |
573 | dd, | 581 | dd, |
574 | vrh->del_chain_size, | 582 | vrh->del_chain_size, |
575 | dele); | 583 | dele); |
576 | env = GNUNET_MQ_msg_extra (rmsg, | 584 | env = GNUNET_MQ_msg_extra (rmsg, |
577 | size, | 585 | size, |
578 | GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT); | 586 | GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT); |
@@ -589,11 +597,11 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
589 | GNUNET_assert ( | 597 | GNUNET_assert ( |
590 | -1 != | 598 | -1 != |
591 | GNUNET_ABD_delegation_chain_serialize (vrh->delegation_chain_size, | 599 | GNUNET_ABD_delegation_chain_serialize (vrh->delegation_chain_size, |
592 | dd, | 600 | dd, |
593 | vrh->del_chain_size, | 601 | vrh->del_chain_size, |
594 | dele, | 602 | dele, |
595 | size, | 603 | size, |
596 | (char *) &rmsg[1])); | 604 | (char *) &rmsg[1])); |
597 | 605 | ||
598 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); | 606 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); |
599 | GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); | 607 | GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); |
@@ -604,6 +612,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
604 | GNUNET_NO); | 612 | GNUNET_NO); |
605 | } | 613 | } |
606 | 614 | ||
615 | |||
607 | static char * | 616 | static char * |
608 | partial_match (char *tmp_trail, | 617 | partial_match (char *tmp_trail, |
609 | char *tmp_subattr, | 618 | char *tmp_subattr, |
@@ -660,6 +669,7 @@ partial_match (char *tmp_trail, | |||
660 | return attr_trailer; | 669 | return attr_trailer; |
661 | } | 670 | } |
662 | 671 | ||
672 | |||
663 | static int | 673 | static int |
664 | handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, | 674 | handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, |
665 | struct DelegationSetQueueEntry *match_entry, | 675 | struct DelegationSetQueueEntry *match_entry, |
@@ -679,7 +689,7 @@ handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, | |||
679 | fw_entry = old_fw_parent; | 689 | fw_entry = old_fw_parent; |
680 | } | 690 | } |
681 | // set last entry of chain as actual_entry | 691 | // set last entry of chain as actual_entry |
682 | //actual_entry = last_entry; | 692 | // actual_entry = last_entry; |
683 | // set refcount, loop all delegations | 693 | // set refcount, loop all delegations |
684 | for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; | 694 | for (struct DelegateRecordEntry *del_entry = vrh->del_chain_head; |
685 | del_entry != NULL; | 695 | del_entry != NULL; |
@@ -724,6 +734,7 @@ handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry, | |||
724 | return GNUNET_YES; | 734 | return GNUNET_YES; |
725 | } | 735 | } |
726 | 736 | ||
737 | |||
727 | static void | 738 | static void |
728 | forward_resolution (void *cls, | 739 | forward_resolution (void *cls, |
729 | uint32_t rd_count, | 740 | uint32_t rd_count, |
@@ -846,9 +857,9 @@ forward_resolution (void *cls, | |||
846 | ds_entry->delegation_chain_entry->issuer_key = del->issuer_key; | 857 | ds_entry->delegation_chain_entry->issuer_key = del->issuer_key; |
847 | ds_entry->delegation_chain_entry->issuer_attribute = | 858 | ds_entry->delegation_chain_entry->issuer_attribute = |
848 | GNUNET_strdup (del->issuer_attribute); | 859 | GNUNET_strdup (del->issuer_attribute); |
849 | 860 | ||
850 | // Found new entry, repoting intermediate result | 861 | // Found new entry, repoting intermediate result |
851 | send_intermediate_response(vrh, ds_entry->delegation_chain_entry, false); | 862 | send_intermediate_response (vrh, ds_entry->delegation_chain_entry, false); |
852 | 863 | ||
853 | // current delegation as parent | 864 | // current delegation as parent |
854 | ds_entry->parent_queue_entry = dq_entry; | 865 | ds_entry->parent_queue_entry = dq_entry; |
@@ -929,7 +940,7 @@ forward_resolution (void *cls, | |||
929 | if (GNUNET_NO == | 940 | if (GNUNET_NO == |
930 | handle_bidirectional_match (ds_entry, del_entry, vrh)) | 941 | handle_bidirectional_match (ds_entry, del_entry, vrh)) |
931 | return; | 942 | return; |
932 | 943 | ||
933 | send_lookup_response (vrh); | 944 | send_lookup_response (vrh); |
934 | return; | 945 | return; |
935 | } | 946 | } |
@@ -948,12 +959,12 @@ forward_resolution (void *cls, | |||
948 | 959 | ||
949 | ds_entry->lookup_request = | 960 | ds_entry->lookup_request = |
950 | GNUNET_GNS_lookup (gns, | 961 | GNUNET_GNS_lookup (gns, |
951 | GNUNET_GNS_EMPTY_LABEL_AT, | 962 | GNUNET_GNS_EMPTY_LABEL_AT, |
952 | &del->issuer_key, | 963 | &del->issuer_key, |
953 | GNUNET_GNSRECORD_TYPE_DELEGATE, | 964 | GNUNET_GNSRECORD_TYPE_DELEGATE, |
954 | GNUNET_GNS_LO_DEFAULT, | 965 | GNUNET_GNS_LO_DEFAULT, |
955 | &forward_resolution, | 966 | &forward_resolution, |
956 | ds_entry); | 967 | ds_entry); |
957 | } | 968 | } |
958 | 969 | ||
959 | if (0 == vrh->pending_lookups) | 970 | if (0 == vrh->pending_lookups) |
@@ -964,6 +975,7 @@ forward_resolution (void *cls, | |||
964 | } | 975 | } |
965 | } | 976 | } |
966 | 977 | ||
978 | |||
967 | static void | 979 | static void |
968 | backward_resolution (void *cls, | 980 | backward_resolution (void *cls, |
969 | uint32_t rd_count, | 981 | uint32_t rd_count, |
@@ -998,10 +1010,10 @@ backward_resolution (void *cls, | |||
998 | 1010 | ||
999 | if (GNUNET_OK != | 1011 | if (GNUNET_OK != |
1000 | GNUNET_ABD_delegation_set_deserialize (GNUNET_ntohll ( | 1012 | GNUNET_ABD_delegation_set_deserialize (GNUNET_ntohll ( |
1001 | sets->data_size), | 1013 | sets->data_size), |
1002 | (const char *) &sets[1], | 1014 | (const char *) &sets[1], |
1003 | ntohl (sets->set_count), | 1015 | ntohl (sets->set_count), |
1004 | set)) | 1016 | set)) |
1005 | { | 1017 | { |
1006 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n"); | 1018 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to deserialize!\n"); |
1007 | continue; | 1019 | continue; |
@@ -1064,7 +1076,7 @@ backward_resolution (void *cls, | |||
1064 | GNUNET_strdup (current_set->lookup_attribute); | 1076 | GNUNET_strdup (current_set->lookup_attribute); |
1065 | 1077 | ||
1066 | // Found new entry, repoting intermediate result | 1078 | // Found new entry, repoting intermediate result |
1067 | send_intermediate_response(vrh, ds_entry->delegation_chain_entry, true); | 1079 | send_intermediate_response (vrh, ds_entry->delegation_chain_entry, true); |
1068 | 1080 | ||
1069 | ds_entry->parent_queue_entry = dq_entry; // current_delegation; | 1081 | ds_entry->parent_queue_entry = dq_entry; // current_delegation; |
1070 | 1082 | ||
@@ -1127,8 +1139,8 @@ backward_resolution (void *cls, | |||
1127 | ds_entry->unresolved_attribute_delegation); | 1139 | ds_entry->unresolved_attribute_delegation); |
1128 | // Continue with next/new backward resolution | 1140 | // Continue with next/new backward resolution |
1129 | char issuer_attribute_name[strlen ( | 1141 | char issuer_attribute_name[strlen ( |
1130 | ds_entry->unresolved_attribute_delegation) + | 1142 | ds_entry->unresolved_attribute_delegation) |
1131 | 1]; | 1143 | + 1]; |
1132 | strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation); | 1144 | strcpy (issuer_attribute_name, ds_entry->unresolved_attribute_delegation); |
1133 | char *next_attr = strtok (issuer_attribute_name, "."); | 1145 | char *next_attr = strtok (issuer_attribute_name, "."); |
1134 | if (NULL == next_attr) | 1146 | if (NULL == next_attr) |
@@ -1156,7 +1168,7 @@ backward_resolution (void *cls, | |||
1156 | del_entry = del_entry->next) | 1168 | del_entry = del_entry->next) |
1157 | { | 1169 | { |
1158 | // only check entries added by forward algorithm | 1170 | // only check entries added by forward algorithm |
1159 | if (!del_entry->from_bw) | 1171 | if (! del_entry->from_bw) |
1160 | { | 1172 | { |
1161 | // key of list entry matches actual key | 1173 | // key of list entry matches actual key |
1162 | if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key, | 1174 | if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key, |
@@ -1174,8 +1186,8 @@ backward_resolution (void *cls, | |||
1174 | // if one node on the path still needs solutions: return | 1186 | // if one node on the path still needs solutions: return |
1175 | if (GNUNET_NO == | 1187 | if (GNUNET_NO == |
1176 | handle_bidirectional_match (del_entry, ds_entry, vrh)) | 1188 | handle_bidirectional_match (del_entry, ds_entry, vrh)) |
1177 | break; | 1189 | break; |
1178 | 1190 | ||
1179 | // Send lookup response | 1191 | // Send lookup response |
1180 | send_lookup_response (vrh); | 1192 | send_lookup_response (vrh); |
1181 | return; | 1193 | return; |
@@ -1197,12 +1209,12 @@ backward_resolution (void *cls, | |||
1197 | ds_entry->handle = vrh; | 1209 | ds_entry->handle = vrh; |
1198 | ds_entry->lookup_request = | 1210 | ds_entry->lookup_request = |
1199 | GNUNET_GNS_lookup (gns, | 1211 | GNUNET_GNS_lookup (gns, |
1200 | lookup_attribute, | 1212 | lookup_attribute, |
1201 | ds_entry->issuer_key, // issuer_key, | 1213 | ds_entry->issuer_key, // issuer_key, |
1202 | GNUNET_GNSRECORD_TYPE_ATTRIBUTE, | 1214 | GNUNET_GNSRECORD_TYPE_ATTRIBUTE, |
1203 | GNUNET_GNS_LO_DEFAULT, | 1215 | GNUNET_GNS_LO_DEFAULT, |
1204 | &backward_resolution, | 1216 | &backward_resolution, |
1205 | ds_entry); | 1217 | ds_entry); |
1206 | 1218 | ||
1207 | GNUNET_free (lookup_attribute); | 1219 | GNUNET_free (lookup_attribute); |
1208 | } | 1220 | } |
@@ -1262,8 +1274,8 @@ delegation_chain_bw_resolution_start (void *cls) | |||
1262 | } | 1274 | } |
1263 | 1275 | ||
1264 | 1276 | ||
1265 | //Check for attributes from the issuer and follow the chain | 1277 | // Check for attributes from the issuer and follow the chain |
1266 | //till you get the required subject's attributes | 1278 | // till you get the required subject's attributes |
1267 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; | 1279 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + 1]; |
1268 | strcpy (issuer_attribute_name, vrh->issuer_attribute); | 1280 | strcpy (issuer_attribute_name, vrh->issuer_attribute); |
1269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1301,6 +1313,7 @@ delegation_chain_bw_resolution_start (void *cls) | |||
1301 | return 0; | 1313 | return 0; |
1302 | } | 1314 | } |
1303 | 1315 | ||
1316 | |||
1304 | static int | 1317 | static int |
1305 | delegation_chain_fw_resolution_start (void *cls) | 1318 | delegation_chain_fw_resolution_start (void *cls) |
1306 | { | 1319 | { |
@@ -1364,11 +1377,13 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1364 | GNUNET_memcpy (ds_entry->issuer_key, | 1377 | GNUNET_memcpy (ds_entry->issuer_key, |
1365 | &del_entry->delegate->subject_key, | 1378 | &del_entry->delegate->subject_key, |
1366 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 1379 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
1367 | 1380 | ||
1368 | ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry); | 1381 | ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry); |
1369 | ds_entry->delegation_chain_entry->subject_key = del_entry->delegate->subject_key; | 1382 | ds_entry->delegation_chain_entry->subject_key = |
1383 | del_entry->delegate->subject_key; | ||
1370 | ds_entry->delegation_chain_entry->subject_attribute = NULL; | 1384 | ds_entry->delegation_chain_entry->subject_attribute = NULL; |
1371 | ds_entry->delegation_chain_entry->issuer_key = del_entry->delegate->issuer_key; | 1385 | ds_entry->delegation_chain_entry->issuer_key = |
1386 | del_entry->delegate->issuer_key; | ||
1372 | ds_entry->delegation_chain_entry->issuer_attribute = | 1387 | ds_entry->delegation_chain_entry->issuer_attribute = |
1373 | GNUNET_strdup (del_entry->delegate->issuer_attribute); | 1388 | GNUNET_strdup (del_entry->delegate->issuer_attribute); |
1374 | 1389 | ||
@@ -1392,6 +1407,7 @@ delegation_chain_fw_resolution_start (void *cls) | |||
1392 | return 0; | 1407 | return 0; |
1393 | } | 1408 | } |
1394 | 1409 | ||
1410 | |||
1395 | static int | 1411 | static int |
1396 | check_verify (void *cls, const struct VerifyMessage *v_msg) | 1412 | check_verify (void *cls, const struct VerifyMessage *v_msg) |
1397 | { | 1413 | { |
@@ -1419,6 +1435,7 @@ check_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1419 | return GNUNET_OK; | 1435 | return GNUNET_OK; |
1420 | } | 1436 | } |
1421 | 1437 | ||
1438 | |||
1422 | static void | 1439 | static void |
1423 | handle_verify (void *cls, const struct VerifyMessage *v_msg) | 1440 | handle_verify (void *cls, const struct VerifyMessage *v_msg) |
1424 | { | 1441 | { |
@@ -1465,18 +1482,18 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1465 | 1482 | ||
1466 | // Parse delegates from verifaction message | 1483 | // Parse delegates from verifaction message |
1467 | delegate_count = ntohl (v_msg->d_count); | 1484 | delegate_count = ntohl (v_msg->d_count); |
1468 | delegate_data_size = ntohs (v_msg->header.size) - | 1485 | delegate_data_size = ntohs (v_msg->header.size) |
1469 | sizeof (struct VerifyMessage) - | 1486 | - sizeof (struct VerifyMessage) |
1470 | ntohs (v_msg->issuer_attribute_len) - 1; | 1487 | - ntohs (v_msg->issuer_attribute_len) - 1; |
1471 | struct GNUNET_ABD_Delegate delegates[delegate_count]; | 1488 | struct GNUNET_ABD_Delegate delegates[delegate_count]; |
1472 | memset (delegates, | 1489 | memset (delegates, |
1473 | 0, | 1490 | 0, |
1474 | sizeof (struct GNUNET_ABD_Delegate) * delegate_count); | 1491 | sizeof (struct GNUNET_ABD_Delegate) * delegate_count); |
1475 | delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1; | 1492 | delegate_data = (char *) &v_msg[1] + ntohs (v_msg->issuer_attribute_len) + 1; |
1476 | if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size, | 1493 | if (GNUNET_OK != GNUNET_ABD_delegates_deserialize (delegate_data_size, |
1477 | delegate_data, | 1494 | delegate_data, |
1478 | delegate_count, | 1495 | delegate_count, |
1479 | delegates)) | 1496 | delegates)) |
1480 | { | 1497 | { |
1481 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n"); | 1498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot deserialize delegates!\n"); |
1482 | send_lookup_response (vrh); | 1499 | send_lookup_response (vrh); |
@@ -1488,8 +1505,8 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1488 | { | 1505 | { |
1489 | del_entry = GNUNET_new (struct DelegateRecordEntry); | 1506 | del_entry = GNUNET_new (struct DelegateRecordEntry); |
1490 | del_entry->delegate = | 1507 | del_entry->delegate = |
1491 | GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + | 1508 | GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) |
1492 | delegates[i].issuer_attribute_len + 1); | 1509 | + delegates[i].issuer_attribute_len + 1); |
1493 | GNUNET_memcpy (del_entry->delegate, | 1510 | GNUNET_memcpy (del_entry->delegate, |
1494 | &delegates[i], | 1511 | &delegates[i], |
1495 | sizeof (struct GNUNET_ABD_Delegate)); | 1512 | sizeof (struct GNUNET_ABD_Delegate)); |
@@ -1509,7 +1526,7 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1509 | if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo && | 1526 | if (GNUNET_ABD_FLAG_BACKWARD & vrh->resolution_algo && |
1510 | GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo) | 1527 | GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo) |
1511 | { | 1528 | { |
1512 | if(1 == delegation_chain_fw_resolution_start (vrh)) | 1529 | if (1 == delegation_chain_fw_resolution_start (vrh)) |
1513 | return; | 1530 | return; |
1514 | delegation_chain_bw_resolution_start (vrh); | 1531 | delegation_chain_bw_resolution_start (vrh); |
1515 | } | 1532 | } |
@@ -1523,6 +1540,7 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg) | |||
1523 | } | 1540 | } |
1524 | } | 1541 | } |
1525 | 1542 | ||
1543 | |||
1526 | static void | 1544 | static void |
1527 | handle_delegate_collection_error_cb (void *cls) | 1545 | handle_delegate_collection_error_cb (void *cls) |
1528 | { | 1546 | { |
@@ -1533,6 +1551,7 @@ handle_delegate_collection_error_cb (void *cls) | |||
1533 | send_lookup_response (vrh); | 1551 | send_lookup_response (vrh); |
1534 | } | 1552 | } |
1535 | 1553 | ||
1554 | |||
1536 | static void | 1555 | static void |
1537 | delegate_collection_finished (void *cls) | 1556 | delegate_collection_finished (void *cls) |
1538 | { | 1557 | { |
@@ -1544,7 +1563,7 @@ delegate_collection_finished (void *cls) | |||
1544 | GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo) | 1563 | GNUNET_ABD_FLAG_FORWARD & vrh->resolution_algo) |
1545 | { | 1564 | { |
1546 | // if premature match found don't start bw resultion | 1565 | // if premature match found don't start bw resultion |
1547 | if(1 == delegation_chain_fw_resolution_start (vrh)) | 1566 | if (1 == delegation_chain_fw_resolution_start (vrh)) |
1548 | return; | 1567 | return; |
1549 | delegation_chain_bw_resolution_start (vrh); | 1568 | delegation_chain_bw_resolution_start (vrh); |
1550 | } | 1569 | } |
@@ -1558,6 +1577,7 @@ delegate_collection_finished (void *cls) | |||
1558 | } | 1577 | } |
1559 | } | 1578 | } |
1560 | 1579 | ||
1580 | |||
1561 | static void | 1581 | static void |
1562 | handle_delegate_collection_cb (void *cls, | 1582 | handle_delegate_collection_cb (void *cls, |
1563 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 1583 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
@@ -1599,6 +1619,7 @@ handle_delegate_collection_cb (void *cls, | |||
1599 | delegate_collection_finished (vrh); | 1619 | delegate_collection_finished (vrh); |
1600 | } | 1620 | } |
1601 | 1621 | ||
1622 | |||
1602 | static void | 1623 | static void |
1603 | handle_collect (void *cls, const struct CollectMessage *c_msg) | 1624 | handle_collect (void *cls, const struct CollectMessage *c_msg) |
1604 | { | 1625 | { |
@@ -1682,6 +1703,7 @@ check_collect (void *cls, const struct CollectMessage *c_msg) | |||
1682 | return GNUNET_OK; | 1703 | return GNUNET_OK; |
1683 | } | 1704 | } |
1684 | 1705 | ||
1706 | |||
1685 | static void | 1707 | static void |
1686 | client_disconnect_cb (void *cls, | 1708 | client_disconnect_cb (void *cls, |
1687 | struct GNUNET_SERVICE_Client *client, | 1709 | struct GNUNET_SERVICE_Client *client, |
@@ -1690,6 +1712,7 @@ client_disconnect_cb (void *cls, | |||
1690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); | 1712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1691 | } | 1713 | } |
1692 | 1714 | ||
1715 | |||
1693 | static void * | 1716 | static void * |
1694 | client_connect_cb (void *cls, | 1717 | client_connect_cb (void *cls, |
1695 | struct GNUNET_SERVICE_Client *client, | 1718 | struct GNUNET_SERVICE_Client *client, |
@@ -1699,6 +1722,7 @@ client_connect_cb (void *cls, | |||
1699 | return client; | 1722 | return client; |
1700 | } | 1723 | } |
1701 | 1724 | ||
1725 | |||
1702 | /** | 1726 | /** |
1703 | * Process Credential requests. | 1727 | * Process Credential requests. |
1704 | * | 1728 | * |