diff options
author | xrs <xrs@mail36.net> | 2020-01-16 17:12:09 +0100 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2020-01-16 17:12:09 +0100 |
commit | 32b55237f2b94b4940d7031a0bc1adcf8b63824a (patch) | |
tree | 92766aa532ef2c674192dc3bd0e9b71a99829fa1 /src/reclaim/gnunet-service-reclaim.c | |
parent | ec78709681261eaddedbed6484dd95849f180f92 (diff) | |
parent | 5177efb74f9301bbffd79d63f47eb78611e6abba (diff) | |
download | gnunet-32b55237f2b94b4940d7031a0bc1adcf8b63824a.tar.gz gnunet-32b55237f2b94b4940d7031a0bc1adcf8b63824a.zip |
Merge branch 'master' of ssh://git.gnunet.org/gnunet
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 903 |
1 files changed, 876 insertions, 27 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index a83ea05a6..556006af0 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -266,6 +266,15 @@ struct AttributeDeleteHandle | |||
266 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 266 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * The attestation to delete | ||
270 | */ | ||
271 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | ||
272 | |||
273 | /** | ||
274 | * The reference to delete | ||
275 | */ | ||
276 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
277 | /** | ||
269 | * Tickets to update | 278 | * Tickets to update |
270 | */ | 279 | */ |
271 | struct TicketRecordsEntry *tickets_to_update_head; | 280 | struct TicketRecordsEntry *tickets_to_update_head; |
@@ -328,6 +337,16 @@ struct AttributeStoreHandle | |||
328 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 337 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
329 | 338 | ||
330 | /** | 339 | /** |
340 | * The attestation to store | ||
341 | */ | ||
342 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | ||
343 | |||
344 | /** | ||
345 | * The reference to store | ||
346 | */ | ||
347 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference; | ||
348 | |||
349 | /** | ||
331 | * The attribute expiration interval | 350 | * The attribute expiration interval |
332 | */ | 351 | */ |
333 | struct GNUNET_TIME_Relative exp; | 352 | struct GNUNET_TIME_Relative exp; |
@@ -459,6 +478,10 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
459 | GNUNET_free (adh->label); | 478 | GNUNET_free (adh->label); |
460 | if (NULL != adh->claim) | 479 | if (NULL != adh->claim) |
461 | GNUNET_free (adh->claim); | 480 | GNUNET_free (adh->claim); |
481 | if (NULL != adh->attest) | ||
482 | GNUNET_free (adh->attest); | ||
483 | if (NULL != adh->reference) | ||
484 | GNUNET_free (adh->reference); | ||
462 | while (NULL != (le = adh->tickets_to_update_head)) | 485 | while (NULL != (le = adh->tickets_to_update_head)) |
463 | { | 486 | { |
464 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 487 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
@@ -486,6 +509,10 @@ cleanup_as_handle (struct AttributeStoreHandle *ash) | |||
486 | GNUNET_NAMESTORE_cancel (ash->ns_qe); | 509 | GNUNET_NAMESTORE_cancel (ash->ns_qe); |
487 | if (NULL != ash->claim) | 510 | if (NULL != ash->claim) |
488 | GNUNET_free (ash->claim); | 511 | GNUNET_free (ash->claim); |
512 | if (NULL != ash->attest) | ||
513 | GNUNET_free (ash->attest); | ||
514 | if (NULL != ash->reference) | ||
515 | GNUNET_free (ash->reference); | ||
489 | GNUNET_free (ash); | 516 | GNUNET_free (ash); |
490 | } | 517 | } |
491 | 518 | ||
@@ -1023,6 +1050,478 @@ handle_attribute_store_message (void *cls, | |||
1023 | 1050 | ||
1024 | 1051 | ||
1025 | /** | 1052 | /** |
1053 | * Attestation store result handler | ||
1054 | * | ||
1055 | * @param cls our attribute store handle | ||
1056 | * @param success GNUNET_OK if successful | ||
1057 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1058 | */ | ||
1059 | static void | ||
1060 | attest_store_cont (void *cls, int32_t success, const char *emsg) | ||
1061 | { | ||
1062 | struct AttributeStoreHandle *ash = cls; | ||
1063 | struct GNUNET_MQ_Envelope *env; | ||
1064 | struct SuccessResultMessage *acr_msg; | ||
1065 | |||
1066 | ash->ns_qe = NULL; | ||
1067 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | ||
1068 | ash->client->store_op_tail, | ||
1069 | ash); | ||
1070 | |||
1071 | if (GNUNET_SYSERR == success) | ||
1072 | { | ||
1073 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1074 | "Failed to store attestation %s\n", | ||
1075 | emsg); | ||
1076 | cleanup_as_handle (ash); | ||
1077 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1078 | return; | ||
1079 | } | ||
1080 | |||
1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
1082 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
1083 | acr_msg->id = htonl (ash->r_id); | ||
1084 | acr_msg->op_result = htonl (GNUNET_OK); | ||
1085 | GNUNET_MQ_send (ash->client->mq, env); | ||
1086 | cleanup_as_handle (ash); | ||
1087 | } | ||
1088 | |||
1089 | /** | ||
1090 | * Send a reference error response | ||
1091 | * | ||
1092 | * @param ash our attribute store handle | ||
1093 | * @param success the success status | ||
1094 | */ | ||
1095 | static void | ||
1096 | send_ref_error (struct AttributeStoreHandle *ash) | ||
1097 | { | ||
1098 | struct GNUNET_MQ_Envelope *env; | ||
1099 | struct SuccessResultMessage *acr_msg; | ||
1100 | |||
1101 | ash->ns_qe = NULL; | ||
1102 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | ||
1103 | ash->client->store_op_tail, | ||
1104 | ash); | ||
1105 | |||
1106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
1107 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
1108 | acr_msg->id = htonl (ash->r_id); | ||
1109 | acr_msg->op_result = htonl (GNUNET_SYSERR); | ||
1110 | GNUNET_MQ_send (ash->client->mq, env); | ||
1111 | cleanup_as_handle (ash); | ||
1112 | } | ||
1113 | |||
1114 | /** | ||
1115 | * Error looking up potential attestation. Abort. | ||
1116 | * | ||
1117 | * @param cls our attribute store handle | ||
1118 | */ | ||
1119 | static void | ||
1120 | attest_error (void *cls) | ||
1121 | { | ||
1122 | struct AttributeStoreHandle *ash = cls; | ||
1123 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1124 | "Failed to check for existing Attestation\n"); | ||
1125 | cleanup_as_handle (ash); | ||
1126 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1127 | return; | ||
1128 | } | ||
1129 | |||
1130 | /** | ||
1131 | * Check for existing record before storing reference | ||
1132 | * | ||
1133 | * @param cls our attribute store handle | ||
1134 | * @param zone zone we are iterating | ||
1135 | * @param label label of the records | ||
1136 | * @param rd_count record count | ||
1137 | * @param rd records | ||
1138 | */ | ||
1139 | static void | ||
1140 | attest_add_cb (void *cls, | ||
1141 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1142 | const char *label, | ||
1143 | unsigned int rd_count, | ||
1144 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1145 | { | ||
1146 | struct AttributeStoreHandle *ash = cls; | ||
1147 | char *buf; | ||
1148 | size_t buf_size; | ||
1149 | buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest); | ||
1150 | buf = GNUNET_malloc (buf_size); | ||
1151 | GNUNET_RECLAIM_ATTESTATION_serialize (ash->attest, buf); | ||
1152 | if (0 == rd_count ) | ||
1153 | { | ||
1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1155 | "Storing new Attestation\n"); | ||
1156 | struct GNUNET_GNSRECORD_Data rd_new[1]; | ||
1157 | rd_new[0].data_size = buf_size; | ||
1158 | rd_new[0].data = buf; | ||
1159 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR; | ||
1160 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1161 | rd_new[0].expiration_time = ash->exp.rel_value_us; | ||
1162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1163 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1164 | &ash->identity, | ||
1165 | label, | ||
1166 | 1, | ||
1167 | rd_new, | ||
1168 | &attest_store_cont, | ||
1169 | ash); | ||
1170 | GNUNET_free (buf); | ||
1171 | return; | ||
1172 | } | ||
1173 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1174 | { | ||
1175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1176 | "Existing Attestation location is not an Attestation\n"); | ||
1177 | send_ref_error (ash); | ||
1178 | return; | ||
1179 | } | ||
1180 | struct GNUNET_GNSRECORD_Data rd_new[rd_count]; | ||
1181 | for (int i = 0; i<rd_count; i++) | ||
1182 | { | ||
1183 | rd_new[i] = rd[i]; | ||
1184 | } | ||
1185 | rd_new[0].data_size = buf_size; | ||
1186 | rd_new[0].data = buf; | ||
1187 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR; | ||
1188 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1189 | rd_new[0].expiration_time = ash->exp.rel_value_us; | ||
1190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1191 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1192 | &ash->identity, | ||
1193 | label, | ||
1194 | rd_count, | ||
1195 | rd_new, | ||
1196 | &attest_store_cont, | ||
1197 | ash); | ||
1198 | GNUNET_free (buf); | ||
1199 | } | ||
1200 | |||
1201 | /** | ||
1202 | * Add a new attestation | ||
1203 | * | ||
1204 | * @param cls the AttributeStoreHandle | ||
1205 | */ | ||
1206 | static void | ||
1207 | attest_store_task (void *cls) | ||
1208 | { | ||
1209 | struct AttributeStoreHandle *ash = cls; | ||
1210 | char *label; | ||
1211 | |||
1212 | // Give the ash a new id if unset | ||
1213 | if (0 == ash->attest->id) | ||
1214 | ash->attest->id | ||
1215 | = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | ||
1216 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->attest->id, | ||
1217 | sizeof(uint64_t)); | ||
1218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1219 | "Looking up existing data under label %s\n", label); | ||
1220 | // Test for the content of the existing ID | ||
1221 | ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
1222 | &ash->identity, | ||
1223 | label, | ||
1224 | &attest_error, | ||
1225 | ash, | ||
1226 | &attest_add_cb, | ||
1227 | ash); | ||
1228 | GNUNET_free (label); | ||
1229 | } | ||
1230 | |||
1231 | /** | ||
1232 | * Check an attestation store message | ||
1233 | * | ||
1234 | * @param cls unused | ||
1235 | * @param sam the message to check | ||
1236 | */ | ||
1237 | static int | ||
1238 | check_attestation_store_message (void *cls, | ||
1239 | const struct AttributeStoreMessage *sam) | ||
1240 | { | ||
1241 | uint16_t size; | ||
1242 | |||
1243 | size = ntohs (sam->header.size); | ||
1244 | if (size <= sizeof(struct AttributeStoreMessage)) | ||
1245 | { | ||
1246 | GNUNET_break (0); | ||
1247 | return GNUNET_SYSERR; | ||
1248 | } | ||
1249 | return GNUNET_OK; | ||
1250 | } | ||
1251 | |||
1252 | /** | ||
1253 | * Handle an attestation store message | ||
1254 | * | ||
1255 | * @param cls our client | ||
1256 | * @param sam the message to handle | ||
1257 | */ | ||
1258 | static void | ||
1259 | handle_attestation_store_message (void *cls, | ||
1260 | const struct AttributeStoreMessage *sam) | ||
1261 | { | ||
1262 | struct AttributeStoreHandle *ash; | ||
1263 | struct IdpClient *idp = cls; | ||
1264 | size_t data_len; | ||
1265 | |||
1266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_STORE message\n"); | ||
1267 | |||
1268 | data_len = ntohs (sam->attr_len); | ||
1269 | |||
1270 | ash = GNUNET_new (struct AttributeStoreHandle); | ||
1271 | ash->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &sam[1], | ||
1272 | data_len); | ||
1273 | |||
1274 | ash->r_id = ntohl (sam->id); | ||
1275 | ash->identity = sam->identity; | ||
1276 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); | ||
1277 | GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey); | ||
1278 | |||
1279 | GNUNET_SERVICE_client_continue (idp->client); | ||
1280 | ash->client = idp; | ||
1281 | GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); | ||
1282 | GNUNET_SCHEDULER_add_now (&attest_store_task, ash); | ||
1283 | } | ||
1284 | |||
1285 | /** | ||
1286 | * Error looking up potential reference value. Abort. | ||
1287 | * | ||
1288 | * @param cls our attribute store handle | ||
1289 | */ | ||
1290 | static void | ||
1291 | ref_error (void *cls) | ||
1292 | { | ||
1293 | struct AttributeStoreHandle *ash = cls; | ||
1294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1295 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1296 | cleanup_as_handle (ash); | ||
1297 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1298 | return; | ||
1299 | } | ||
1300 | |||
1301 | /** | ||
1302 | * Error looking up potential reference value. Abort. | ||
1303 | * | ||
1304 | * @param cls our attribute delete handle | ||
1305 | */ | ||
1306 | static void | ||
1307 | ref_del_error (void *cls) | ||
1308 | { | ||
1309 | struct AttributeDeleteHandle *adh = cls; | ||
1310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1311 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1312 | cleanup_adh (adh); | ||
1313 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1314 | return; | ||
1315 | } | ||
1316 | /** | ||
1317 | * Reference store result handler | ||
1318 | * | ||
1319 | * @param cls our attribute store handle | ||
1320 | * @param success GNUNET_OK if successful | ||
1321 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1322 | */ | ||
1323 | static void | ||
1324 | reference_store_cont (void *cls, int32_t success, const char *emsg) | ||
1325 | { | ||
1326 | struct AttributeStoreHandle *ash = cls; | ||
1327 | struct GNUNET_MQ_Envelope *env; | ||
1328 | struct SuccessResultMessage *acr_msg; | ||
1329 | |||
1330 | ash->ns_qe = NULL; | ||
1331 | GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, | ||
1332 | ash->client->store_op_tail, | ||
1333 | ash); | ||
1334 | |||
1335 | if (GNUNET_SYSERR == success) | ||
1336 | { | ||
1337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1338 | "Failed to store reference %s\n", | ||
1339 | emsg); | ||
1340 | cleanup_as_handle (ash); | ||
1341 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1342 | return; | ||
1343 | } | ||
1344 | |||
1345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n"); | ||
1346 | env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE); | ||
1347 | acr_msg->id = htonl (ash->r_id); | ||
1348 | acr_msg->op_result = htonl (GNUNET_OK); | ||
1349 | GNUNET_MQ_send (ash->client->mq, env); | ||
1350 | cleanup_as_handle (ash); | ||
1351 | } | ||
1352 | |||
1353 | |||
1354 | /** | ||
1355 | * Check for existing record before storing reference | ||
1356 | * | ||
1357 | * @param cls our attribute store handle | ||
1358 | * @param zone zone we are iterating | ||
1359 | * @param label label of the records | ||
1360 | * @param rd_count record count | ||
1361 | * @param rd records | ||
1362 | */ | ||
1363 | static void | ||
1364 | ref_add_cb (void *cls, | ||
1365 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1366 | const char *label, | ||
1367 | unsigned int rd_count, | ||
1368 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1369 | { | ||
1370 | struct AttributeStoreHandle *ash = cls; | ||
1371 | char *buf; | ||
1372 | size_t buf_size; | ||
1373 | buf_size = GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (ash->reference); | ||
1374 | buf = GNUNET_malloc (buf_size); | ||
1375 | GNUNET_RECLAIM_ATTESTATION_REF_serialize (ash->reference, buf); | ||
1376 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
1377 | char *data_tmp; | ||
1378 | if (0 == rd_count ) | ||
1379 | { | ||
1380 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1381 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1382 | send_ref_error (ash); | ||
1383 | return; | ||
1384 | } | ||
1385 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1386 | { | ||
1387 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1388 | "Intended Reference storage location is not an attestation\n"); | ||
1389 | send_ref_error (ash); | ||
1390 | return; | ||
1391 | } | ||
1392 | struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1]; | ||
1393 | int i; | ||
1394 | for (i = 0; i<rd_count; i++) | ||
1395 | { | ||
1396 | data_tmp = GNUNET_malloc (rd[i].data_size); | ||
1397 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
1398 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, htons ( | ||
1399 | rd[i].data_size)); | ||
1400 | rd_new[i] = rd[i]; | ||
1401 | if ((strcmp (ash->reference->name,ref->name) == 0)&& | ||
1402 | (strcmp (ash->reference->reference_value,ref->reference_value)==0) ) | ||
1403 | { | ||
1404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1405 | "Reference already stored\n"); | ||
1406 | reference_store_cont (ash,GNUNET_OK, NULL); | ||
1407 | return; | ||
1408 | } | ||
1409 | } | ||
1410 | rd_new[rd_count].data_size = buf_size; | ||
1411 | rd_new[rd_count].data = buf; | ||
1412 | rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE; | ||
1413 | rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | ||
1414 | rd_new[rd_count].expiration_time = ash->exp.rel_value_us; | ||
1415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label); | ||
1416 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1417 | &ash->identity, | ||
1418 | label, | ||
1419 | rd_count + 1, | ||
1420 | rd_new, | ||
1421 | &reference_store_cont, | ||
1422 | ash); | ||
1423 | GNUNET_free (buf); | ||
1424 | } | ||
1425 | |||
1426 | /** | ||
1427 | * Add a new reference | ||
1428 | * | ||
1429 | * @param cls the AttributeStoreHandle | ||
1430 | */ | ||
1431 | static void | ||
1432 | reference_store_task (void *cls) | ||
1433 | { | ||
1434 | struct AttributeStoreHandle *ash = cls; | ||
1435 | char *label; | ||
1436 | |||
1437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing reference\n"); | ||
1438 | |||
1439 | // Give the ash a new id if unset | ||
1440 | if (0 == ash->reference->id) | ||
1441 | { | ||
1442 | if (0 == ash->reference->id_attest) | ||
1443 | { | ||
1444 | ash->reference->id = GNUNET_CRYPTO_random_u64 ( | ||
1445 | GNUNET_CRYPTO_QUALITY_STRONG, | ||
1446 | UINT64_MAX); | ||
1447 | } | ||
1448 | else | ||
1449 | { | ||
1450 | ash->reference->id = ash->reference->id_attest; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | label = GNUNET_STRINGS_data_to_string_alloc (&ash->reference->id, | ||
1455 | sizeof(uint64_t)); | ||
1456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1457 | "Looking up existing data under label %s\n", label); | ||
1458 | // Test for the content of the existing ID | ||
1459 | |||
1460 | ash->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
1461 | &ash->identity, | ||
1462 | label, | ||
1463 | &ref_error, | ||
1464 | ash, | ||
1465 | &ref_add_cb, | ||
1466 | ash); | ||
1467 | GNUNET_free (label); | ||
1468 | } | ||
1469 | |||
1470 | /** | ||
1471 | * Check an attestation reference store message | ||
1472 | * | ||
1473 | * @param cls unused | ||
1474 | * @param sam the message to check | ||
1475 | */ | ||
1476 | static int | ||
1477 | check_reference_store_message (void *cls, | ||
1478 | const struct | ||
1479 | AttributeStoreMessage *sam) | ||
1480 | { | ||
1481 | uint16_t size; | ||
1482 | |||
1483 | size = ntohs (sam->header.size); | ||
1484 | if (size <= sizeof(struct AttributeStoreMessage)) | ||
1485 | { | ||
1486 | GNUNET_break (0); | ||
1487 | return GNUNET_SYSERR; | ||
1488 | } | ||
1489 | return GNUNET_OK; | ||
1490 | } | ||
1491 | |||
1492 | |||
1493 | /** | ||
1494 | * Handle an attestation reference store message | ||
1495 | * | ||
1496 | * @param cls our client | ||
1497 | * @param sam the message to handle | ||
1498 | */ | ||
1499 | static void | ||
1500 | handle_reference_store_message (void *cls, | ||
1501 | const struct AttributeStoreMessage *sam) | ||
1502 | { | ||
1503 | struct AttributeStoreHandle *ash; | ||
1504 | struct IdpClient *idp = cls; | ||
1505 | size_t data_len; | ||
1506 | |||
1507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_STORE message\n"); | ||
1508 | |||
1509 | data_len = ntohs (sam->attr_len); | ||
1510 | ash = GNUNET_new (struct AttributeStoreHandle); | ||
1511 | ash->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &sam[1], | ||
1512 | data_len); | ||
1513 | ash->r_id = ntohl (sam->id); | ||
1514 | ash->identity = sam->identity; | ||
1515 | ash->exp.rel_value_us = GNUNET_ntohll (sam->exp); | ||
1516 | GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey); | ||
1517 | |||
1518 | |||
1519 | GNUNET_SERVICE_client_continue (idp->client); | ||
1520 | ash->client = idp; | ||
1521 | GNUNET_CONTAINER_DLL_insert (idp->store_op_head, idp->store_op_tail, ash); | ||
1522 | GNUNET_SCHEDULER_add_now (&reference_store_task, ash); | ||
1523 | } | ||
1524 | /** | ||
1026 | * Send a deletion success response | 1525 | * Send a deletion success response |
1027 | * | 1526 | * |
1028 | * @param adh our attribute deletion handle | 1527 | * @param adh our attribute deletion handle |
@@ -1066,15 +1565,21 @@ ticket_iter (void *cls, | |||
1066 | struct AttributeDeleteHandle *adh = cls; | 1565 | struct AttributeDeleteHandle *adh = cls; |
1067 | struct TicketRecordsEntry *le; | 1566 | struct TicketRecordsEntry *le; |
1068 | int has_changed = GNUNET_NO; | 1567 | int has_changed = GNUNET_NO; |
1069 | |||
1070 | for (int i = 0; i < rd_count; i++) | 1568 | for (int i = 0; i < rd_count; i++) |
1071 | { | 1569 | { |
1072 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 1570 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
1073 | continue; | 1571 | continue; |
1074 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) | 1572 | if (adh->claim != NULL) |
1075 | continue; | 1573 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) |
1574 | continue; | ||
1575 | if (adh->attest != NULL) | ||
1576 | if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t))) | ||
1577 | continue; | ||
1578 | if (adh->reference != NULL) | ||
1579 | if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) | ||
1580 | continue; | ||
1076 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1581 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1077 | "Attribute to delete found (%s)\n", | 1582 | "Attribute or Attestation/Reference to delete found (%s)\n", |
1078 | adh->label); | 1583 | adh->label); |
1079 | has_changed = GNUNET_YES; | 1584 | has_changed = GNUNET_YES; |
1080 | break; | 1585 | break; |
@@ -1136,7 +1641,7 @@ update_tickets (void *cls) | |||
1136 | if (NULL == adh->tickets_to_update_head) | 1641 | if (NULL == adh->tickets_to_update_head) |
1137 | { | 1642 | { |
1138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1643 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1139 | "Finished updatding tickets, success\n"); | 1644 | "Finished updating tickets, success\n"); |
1140 | send_delete_response (adh, GNUNET_OK); | 1645 | send_delete_response (adh, GNUNET_OK); |
1141 | cleanup_adh (adh); | 1646 | cleanup_adh (adh); |
1142 | return; | 1647 | return; |
@@ -1164,9 +1669,18 @@ update_tickets (void *cls) | |||
1164 | int j = 0; | 1669 | int j = 0; |
1165 | for (int i = 0; i < le->rd_count; i++) | 1670 | for (int i = 0; i < le->rd_count; i++) |
1166 | { | 1671 | { |
1167 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | 1672 | if (adh->claim != NULL) |
1168 | && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) | 1673 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) |
1169 | continue; | 1674 | && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) |
1675 | continue; | ||
1676 | if (adh->attest != NULL) | ||
1677 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | ||
1678 | && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) | ||
1679 | continue; | ||
1680 | if (adh->reference != NULL) | ||
1681 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | ||
1682 | && (0 == memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))) | ||
1683 | continue; | ||
1170 | rd_new[j] = rd[i]; | 1684 | rd_new[j] = rd[i]; |
1171 | j++; | 1685 | j++; |
1172 | } | 1686 | } |
@@ -1192,7 +1706,6 @@ static void | |||
1192 | ticket_iter_fin (void *cls) | 1706 | ticket_iter_fin (void *cls) |
1193 | { | 1707 | { |
1194 | struct AttributeDeleteHandle *adh = cls; | 1708 | struct AttributeDeleteHandle *adh = cls; |
1195 | |||
1196 | adh->ns_it = NULL; | 1709 | adh->ns_it = NULL; |
1197 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | 1710 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); |
1198 | } | 1711 | } |
@@ -1309,6 +1822,8 @@ handle_attribute_delete_message (void *cls, | |||
1309 | adh = GNUNET_new (struct AttributeDeleteHandle); | 1822 | adh = GNUNET_new (struct AttributeDeleteHandle); |
1310 | adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], | 1823 | adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], |
1311 | data_len); | 1824 | data_len); |
1825 | adh->reference = NULL; | ||
1826 | adh->attest = NULL; | ||
1312 | 1827 | ||
1313 | adh->r_id = ntohl (dam->id); | 1828 | adh->r_id = ntohl (dam->id); |
1314 | adh->identity = dam->identity; | 1829 | adh->identity = dam->identity; |
@@ -1326,6 +1841,256 @@ handle_attribute_delete_message (void *cls, | |||
1326 | adh); | 1841 | adh); |
1327 | } | 1842 | } |
1328 | 1843 | ||
1844 | /** | ||
1845 | * Attestation deleted callback | ||
1846 | * | ||
1847 | * @param cls our handle | ||
1848 | * @param success success status | ||
1849 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1850 | */ | ||
1851 | static void | ||
1852 | attest_delete_cont (void *cls, int32_t success, const char *emsg) | ||
1853 | { | ||
1854 | struct AttributeDeleteHandle *adh = cls; | ||
1855 | |||
1856 | adh->ns_qe = NULL; | ||
1857 | if (GNUNET_SYSERR == success) | ||
1858 | { | ||
1859 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1860 | "Error deleting attestation %s\n", | ||
1861 | adh->label); | ||
1862 | send_delete_response (adh, GNUNET_SYSERR); | ||
1863 | cleanup_adh (adh); | ||
1864 | return; | ||
1865 | } | ||
1866 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | ||
1867 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1868 | } | ||
1869 | |||
1870 | /** | ||
1871 | * Check attestation delete message format | ||
1872 | * | ||
1873 | * @cls unused | ||
1874 | * @dam message to check | ||
1875 | */ | ||
1876 | static int | ||
1877 | check_attestation_delete_message (void *cls, | ||
1878 | const struct AttributeDeleteMessage *dam) | ||
1879 | { | ||
1880 | uint16_t size; | ||
1881 | |||
1882 | size = ntohs (dam->header.size); | ||
1883 | if (size <= sizeof(struct AttributeDeleteMessage)) | ||
1884 | { | ||
1885 | GNUNET_break (0); | ||
1886 | return GNUNET_SYSERR; | ||
1887 | } | ||
1888 | return GNUNET_OK; | ||
1889 | } | ||
1890 | |||
1891 | |||
1892 | /** | ||
1893 | * Handle attestation deletion | ||
1894 | * | ||
1895 | * @param cls our client | ||
1896 | * @param dam deletion message | ||
1897 | */ | ||
1898 | static void | ||
1899 | handle_attestation_delete_message (void *cls, | ||
1900 | const struct AttributeDeleteMessage *dam) | ||
1901 | { | ||
1902 | struct AttributeDeleteHandle *adh; | ||
1903 | struct IdpClient *idp = cls; | ||
1904 | size_t data_len; | ||
1905 | |||
1906 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_DELETE message\n"); | ||
1907 | |||
1908 | data_len = ntohs (dam->attr_len); | ||
1909 | |||
1910 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
1911 | adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1], | ||
1912 | data_len); | ||
1913 | adh->reference = NULL; | ||
1914 | adh->claim = NULL; | ||
1915 | |||
1916 | adh->r_id = ntohl (dam->id); | ||
1917 | adh->identity = dam->identity; | ||
1918 | adh->label | ||
1919 | = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, sizeof(uint64_t)); | ||
1920 | GNUNET_SERVICE_client_continue (idp->client); | ||
1921 | adh->client = idp; | ||
1922 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
1923 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1924 | &adh->identity, | ||
1925 | adh->label, | ||
1926 | 0, | ||
1927 | NULL, | ||
1928 | &attest_delete_cont, | ||
1929 | adh); | ||
1930 | } | ||
1931 | |||
1932 | |||
1933 | |||
1934 | /** | ||
1935 | * Reference deleted callback | ||
1936 | * | ||
1937 | * @param cls our handle | ||
1938 | * @param success success status | ||
1939 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1940 | */ | ||
1941 | static void | ||
1942 | reference_delete_cont (void *cls, int32_t success, const char *emsg) | ||
1943 | { | ||
1944 | struct AttributeDeleteHandle *adh = cls; | ||
1945 | |||
1946 | adh->ns_qe = NULL; | ||
1947 | if (GNUNET_SYSERR == success) | ||
1948 | { | ||
1949 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1950 | "Error deleting reference %s\n", | ||
1951 | adh->label); | ||
1952 | send_delete_response (adh, GNUNET_SYSERR); | ||
1953 | cleanup_adh (adh); | ||
1954 | return; | ||
1955 | } | ||
1956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | ||
1957 | //GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1958 | send_delete_response (adh, GNUNET_OK); | ||
1959 | cleanup_adh (adh); | ||
1960 | return; | ||
1961 | } | ||
1962 | |||
1963 | static void | ||
1964 | ref_del_cb (void *cls, | ||
1965 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
1966 | const char *label, | ||
1967 | unsigned int rd_count, | ||
1968 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1969 | { | ||
1970 | |||
1971 | struct AttributeDeleteHandle *adh = cls; | ||
1972 | char *data_tmp; | ||
1973 | struct GNUNET_GNSRECORD_Data rd_new[rd_count - 1]; | ||
1974 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *ref; | ||
1975 | size_t attr_len; | ||
1976 | |||
1977 | if (0 == rd_count ) | ||
1978 | { | ||
1979 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1980 | "Failed to find Attestation entry for Attestation reference\n"); | ||
1981 | cleanup_adh (adh); | ||
1982 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1983 | return; | ||
1984 | } | ||
1985 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
1986 | { | ||
1987 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1988 | "Intended Reference location is not an attestation\n"); | ||
1989 | cleanup_adh (adh); | ||
1990 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1991 | return; | ||
1992 | } | ||
1993 | rd_new[0] = rd[0]; | ||
1994 | int i; | ||
1995 | int j = 1; | ||
1996 | for (i = 1; i<rd_count; i++) | ||
1997 | { | ||
1998 | data_tmp = GNUNET_malloc (rd[i].data_size); | ||
1999 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2000 | attr_len = htons (rd[i].data_size); | ||
2001 | ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize (data_tmp, attr_len); | ||
2002 | if (NULL == ref ) | ||
2003 | { | ||
2004 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2005 | "Unable to parse attestation reference from %s\n", | ||
2006 | data_tmp); | ||
2007 | rd_new[j] = rd[i]; | ||
2008 | j += 1; | ||
2009 | continue; | ||
2010 | } | ||
2011 | if ((strcmp (adh->reference->name,ref->name) == 0)&& | ||
2012 | (strcmp (adh->reference->reference_value,ref->reference_value)==0) ) | ||
2013 | { | ||
2014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2015 | "Found reference to delete.\n"); | ||
2016 | } | ||
2017 | else | ||
2018 | { | ||
2019 | rd_new[j] = rd[i]; | ||
2020 | j += 1; | ||
2021 | } | ||
2022 | GNUNET_free (data_tmp); | ||
2023 | } | ||
2024 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
2025 | &adh->identity, | ||
2026 | label, | ||
2027 | j, | ||
2028 | rd_new, | ||
2029 | &reference_delete_cont, | ||
2030 | adh); | ||
2031 | } | ||
2032 | |||
2033 | /** | ||
2034 | * Check an attestation reference delete message | ||
2035 | * | ||
2036 | * @param cls unused | ||
2037 | * @param sam the message to check | ||
2038 | */ | ||
2039 | static int | ||
2040 | check_reference_delete_message (void *cls, | ||
2041 | const struct AttributeDeleteMessage *dam) | ||
2042 | { | ||
2043 | uint16_t size; | ||
2044 | |||
2045 | size = ntohs (dam->header.size); | ||
2046 | if (size <= sizeof(struct AttributeDeleteMessage)) | ||
2047 | { | ||
2048 | GNUNET_break (0); | ||
2049 | return GNUNET_SYSERR; | ||
2050 | } | ||
2051 | return GNUNET_OK; | ||
2052 | } | ||
2053 | |||
2054 | /** | ||
2055 | * Handle reference deletion | ||
2056 | * | ||
2057 | * @param cls our client | ||
2058 | * @param dam deletion message | ||
2059 | */ | ||
2060 | static void | ||
2061 | handle_reference_delete_message (void *cls, | ||
2062 | const struct AttributeDeleteMessage *dam) | ||
2063 | { | ||
2064 | struct AttributeDeleteHandle *adh; | ||
2065 | struct IdpClient *idp = cls; | ||
2066 | size_t data_len; | ||
2067 | |||
2068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REFERENCE_DELETE message\n"); | ||
2069 | data_len = ntohs (dam->attr_len); | ||
2070 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
2071 | adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1], | ||
2072 | data_len); | ||
2073 | adh->attest = NULL; | ||
2074 | adh->claim = NULL; | ||
2075 | |||
2076 | adh->r_id = ntohl (dam->id); | ||
2077 | adh->identity = dam->identity; | ||
2078 | adh->label | ||
2079 | = GNUNET_STRINGS_data_to_string_alloc (&adh->reference->id, | ||
2080 | sizeof(uint64_t)); | ||
2081 | GNUNET_SERVICE_client_continue (idp->client); | ||
2082 | adh->client = idp; | ||
2083 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
2084 | adh->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, | ||
2085 | &adh->identity, | ||
2086 | adh->label, | ||
2087 | &ref_del_error, | ||
2088 | adh, | ||
2089 | &ref_del_cb, | ||
2090 | adh); | ||
2091 | } | ||
2092 | |||
2093 | |||
1329 | 2094 | ||
1330 | /************************************************* | 2095 | /************************************************* |
1331 | * Attrubute iteration | 2096 | * Attrubute iteration |
@@ -1372,7 +2137,7 @@ attr_iter_error (void *cls) | |||
1372 | 2137 | ||
1373 | 2138 | ||
1374 | /** | 2139 | /** |
1375 | * Got record. Return if it is an attribute. | 2140 | * Got record. Return if it is an attribute or attestation/reference. |
1376 | * | 2141 | * |
1377 | * @param cls our attribute iterator | 2142 | * @param cls our attribute iterator |
1378 | * @param zone zone we are iterating | 2143 | * @param zone zone we are iterating |
@@ -1388,35 +2153,103 @@ attr_iter_cb (void *cls, | |||
1388 | const struct GNUNET_GNSRECORD_Data *rd) | 2153 | const struct GNUNET_GNSRECORD_Data *rd) |
1389 | { | 2154 | { |
1390 | struct AttributeIterator *ai = cls; | 2155 | struct AttributeIterator *ai = cls; |
1391 | struct AttributeResultMessage *arm; | ||
1392 | struct GNUNET_MQ_Envelope *env; | 2156 | struct GNUNET_MQ_Envelope *env; |
1393 | char *data_tmp; | 2157 | char *data_tmp; |
1394 | 2158 | ||
1395 | if (rd_count != 1) | 2159 | if (rd_count == 0) |
1396 | { | 2160 | { |
1397 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 2161 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); |
1398 | return; | 2162 | return; |
1399 | } | 2163 | } |
2164 | if (rd_count > 1) | ||
2165 | { | ||
2166 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[0].record_type) | ||
2167 | { | ||
2168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2169 | "Found Ticket. Ignoring.\n"); | ||
2170 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2171 | return; | ||
2172 | } | ||
2173 | else if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type) | ||
2174 | { | ||
2175 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2176 | "Non-Attestation record with multiple entries found: %u\n", | ||
2177 | rd[0].record_type); | ||
2178 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2179 | return; | ||
2180 | } | ||
2181 | } | ||
1400 | 2182 | ||
1401 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd->record_type) | 2183 | for (int i = 0; i<rd_count; i++) |
1402 | { | 2184 | { |
1403 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | 2185 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) && |
1404 | return; | 2186 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) && |
2187 | (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type)) | ||
2188 | { | ||
2189 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1); | ||
2190 | return; | ||
2191 | } | ||
2192 | |||
2193 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type ) | ||
2194 | { | ||
2195 | struct AttributeResultMessage *arm; | ||
2196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", | ||
2197 | label); | ||
2198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2199 | "Sending ATTRIBUTE_RESULT message\n"); | ||
2200 | env = GNUNET_MQ_msg_extra (arm, | ||
2201 | rd[i].data_size, | ||
2202 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | ||
2203 | arm->id = htonl (ai->request_id); | ||
2204 | arm->attr_len = htons (rd[i].data_size); | ||
2205 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | ||
2206 | data_tmp = (char *) &arm[1]; | ||
2207 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2208 | GNUNET_MQ_send (ai->client->mq, env); | ||
2209 | } | ||
2210 | else | ||
2211 | { | ||
2212 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type ) | ||
2213 | { | ||
2214 | struct AttributeResultMessage *arm; | ||
2215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", | ||
2216 | label); | ||
2217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2218 | "Sending ATTESTATION_RESULT message\n"); | ||
2219 | env = GNUNET_MQ_msg_extra (arm, | ||
2220 | rd[i].data_size, | ||
2221 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); | ||
2222 | arm->id = htonl (ai->request_id); | ||
2223 | arm->attr_len = htons (rd[i].data_size); | ||
2224 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | ||
2225 | data_tmp = (char *) &arm[1]; | ||
2226 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2227 | GNUNET_MQ_send (ai->client->mq, env); | ||
2228 | } | ||
2229 | else | ||
2230 | { | ||
2231 | struct ReferenceResultMessage *rrm; | ||
2232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n", | ||
2233 | label); | ||
2234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2235 | "Sending REFERENCE_RESULT message\n"); | ||
2236 | env = GNUNET_MQ_msg_extra (rrm, | ||
2237 | rd[i].data_size + rd[0].data_size, | ||
2238 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT); | ||
2239 | rrm->id = htonl (ai->request_id); | ||
2240 | rrm->attest_len = htons (rd[0].data_size); | ||
2241 | rrm->ref_len = htons (rd[i].data_size); | ||
2242 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &rrm->identity); | ||
2243 | data_tmp = (char *) &rrm[1]; | ||
2244 | GNUNET_memcpy (data_tmp, rd[0].data, rd[0].data_size); | ||
2245 | data_tmp += rd[0].data_size; | ||
2246 | GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size); | ||
2247 | GNUNET_MQ_send (ai->client->mq, env); | ||
2248 | } | ||
2249 | } | ||
1405 | } | 2250 | } |
1406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label); | ||
1407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); | ||
1408 | env = GNUNET_MQ_msg_extra (arm, | ||
1409 | rd->data_size, | ||
1410 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); | ||
1411 | arm->id = htonl (ai->request_id); | ||
1412 | arm->attr_len = htons (rd->data_size); | ||
1413 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); | ||
1414 | data_tmp = (char *) &arm[1]; | ||
1415 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | ||
1416 | GNUNET_MQ_send (ai->client->mq, env); | ||
1417 | } | 2251 | } |
1418 | 2252 | ||
1419 | |||
1420 | /** | 2253 | /** |
1421 | * Iterate over zone to get attributes | 2254 | * Iterate over zone to get attributes |
1422 | * | 2255 | * |
@@ -1742,10 +2575,26 @@ GNUNET_SERVICE_MAIN ( | |||
1742 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, | 2575 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, |
1743 | struct AttributeStoreMessage, | 2576 | struct AttributeStoreMessage, |
1744 | NULL), | 2577 | NULL), |
2578 | GNUNET_MQ_hd_var_size (attestation_store_message, | ||
2579 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE, | ||
2580 | struct AttributeStoreMessage, | ||
2581 | NULL), | ||
1745 | GNUNET_MQ_hd_var_size (attribute_delete_message, | 2582 | GNUNET_MQ_hd_var_size (attribute_delete_message, |
1746 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, | 2583 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, |
1747 | struct AttributeDeleteMessage, | 2584 | struct AttributeDeleteMessage, |
1748 | NULL), | 2585 | NULL), |
2586 | GNUNET_MQ_hd_var_size (attestation_delete_message, | ||
2587 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, | ||
2588 | struct AttributeDeleteMessage, | ||
2589 | NULL), | ||
2590 | GNUNET_MQ_hd_var_size (reference_store_message, | ||
2591 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE, | ||
2592 | struct AttributeStoreMessage, | ||
2593 | NULL), | ||
2594 | GNUNET_MQ_hd_var_size (reference_delete_message, | ||
2595 | GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE, | ||
2596 | struct AttributeDeleteMessage, | ||
2597 | NULL), | ||
1749 | GNUNET_MQ_hd_fixed_size ( | 2598 | GNUNET_MQ_hd_fixed_size ( |
1750 | iteration_start, | 2599 | iteration_start, |
1751 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 2600 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |