diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-08-11 22:24:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-08-11 22:24:07 +0000 |
commit | 596fe6fcff78fc66f2ed7e8bd46475feef9c6210 (patch) | |
tree | f2d48964e5d77ada7f9f5188b5f8c35483dded66 | |
parent | b309c5f5ae339faf3632f7ee3a86520981f6523a (diff) | |
download | gnunet-596fe6fcff78fc66f2ed7e8bd46475feef9c6210.tar.gz gnunet-596fe6fcff78fc66f2ed7e8bd46475feef9c6210.zip |
more work on FS URIs
-rw-r--r-- | src/datastore/datastore_api.c | 19 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 4 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 22 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 211 | ||||
-rw-r--r-- | src/fs/test_fs_getopt.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_uri.c | 10 | ||||
-rw-r--r-- | src/include/gnunet_signatures.h | 8 | ||||
-rw-r--r-- | src/include/gnunet_time_lib.h | 11 | ||||
-rw-r--r-- | src/util/pseudonym.c | 4 | ||||
-rw-r--r-- | src/util/time.c | 19 |
10 files changed, 181 insertions, 129 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 73783cfb8..929698a5b 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -494,7 +494,6 @@ with_result_response_handler (void *cls, | |||
494 | const struct | 494 | const struct |
495 | GNUNET_MessageHeader * msg) | 495 | GNUNET_MessageHeader * msg) |
496 | { | 496 | { |
497 | static struct GNUNET_TIME_Absolute zero; | ||
498 | struct GNUNET_DATASTORE_Handle *h = cls; | 497 | struct GNUNET_DATASTORE_Handle *h = cls; |
499 | GNUNET_DATASTORE_Iterator cont = h->response_proc; | 498 | GNUNET_DATASTORE_Iterator cont = h->response_proc; |
500 | const struct DataMessage *dm; | 499 | const struct DataMessage *dm; |
@@ -506,7 +505,8 @@ with_result_response_handler (void *cls, | |||
506 | GNUNET_CLIENT_disconnect (h->client); | 505 | GNUNET_CLIENT_disconnect (h->client); |
507 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); | 506 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); |
508 | cont (h->response_proc_cls, | 507 | cont (h->response_proc_cls, |
509 | NULL, 0, NULL, 0, 0, 0, zero, 0); | 508 | NULL, 0, NULL, 0, 0, 0, |
509 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
510 | return; | 510 | return; |
511 | } | 511 | } |
512 | if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) | 512 | if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) |
@@ -518,7 +518,8 @@ with_result_response_handler (void *cls, | |||
518 | "Received end of result set\n"); | 518 | "Received end of result set\n"); |
519 | #endif | 519 | #endif |
520 | cont (h->response_proc_cls, | 520 | cont (h->response_proc_cls, |
521 | NULL, 0, NULL, 0, 0, 0, zero, 0); | 521 | NULL, 0, NULL, 0, 0, 0, |
522 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
522 | return; | 523 | return; |
523 | } | 524 | } |
524 | if ( (ntohs(msg->size) < sizeof(struct DataMessage)) || | 525 | if ( (ntohs(msg->size) < sizeof(struct DataMessage)) || |
@@ -529,7 +530,8 @@ with_result_response_handler (void *cls, | |||
529 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); | 530 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); |
530 | h->response_proc = NULL; | 531 | h->response_proc = NULL; |
531 | cont (h->response_proc_cls, | 532 | cont (h->response_proc_cls, |
532 | NULL, 0, NULL, 0, 0, 0, zero, 0); | 533 | NULL, 0, NULL, 0, 0, 0, |
534 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
533 | return; | 535 | return; |
534 | } | 536 | } |
535 | dm = (const struct DataMessage*) msg; | 537 | dm = (const struct DataMessage*) msg; |
@@ -541,7 +543,8 @@ with_result_response_handler (void *cls, | |||
541 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); | 543 | h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg); |
542 | h->response_proc = NULL; | 544 | h->response_proc = NULL; |
543 | cont (h->response_proc_cls, | 545 | cont (h->response_proc_cls, |
544 | NULL, 0, NULL, 0, 0, 0, zero, 0); | 546 | NULL, 0, NULL, 0, 0, 0, |
547 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
545 | return; | 548 | return; |
546 | } | 549 | } |
547 | #if DEBUG_DATASTORE | 550 | #if DEBUG_DATASTORE |
@@ -632,7 +635,6 @@ transmit_for_result (struct GNUNET_DATASTORE_Handle *h, | |||
632 | void *cont_cls, | 635 | void *cont_cls, |
633 | struct GNUNET_TIME_Relative timeout) | 636 | struct GNUNET_TIME_Relative timeout) |
634 | { | 637 | { |
635 | static struct GNUNET_TIME_Absolute zero; | ||
636 | const struct GNUNET_MessageHeader *hdr; | 638 | const struct GNUNET_MessageHeader *hdr; |
637 | uint16_t msize; | 639 | uint16_t msize; |
638 | 640 | ||
@@ -660,7 +662,8 @@ transmit_for_result (struct GNUNET_DATASTORE_Handle *h, | |||
660 | h->response_proc = NULL; | 662 | h->response_proc = NULL; |
661 | h->message_size = 0; | 663 | h->message_size = 0; |
662 | cont (h->response_proc_cls, | 664 | cont (h->response_proc_cls, |
663 | NULL, 0, NULL, 0, 0, 0, zero, 0); | 665 | NULL, 0, NULL, 0, 0, 0, |
666 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
664 | } | 667 | } |
665 | } | 668 | } |
666 | 669 | ||
@@ -759,7 +762,7 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | |||
759 | dm->priority = htonl(0); | 762 | dm->priority = htonl(0); |
760 | dm->anonymity = htonl(0); | 763 | dm->anonymity = htonl(0); |
761 | dm->uid = GNUNET_htonll(0); | 764 | dm->uid = GNUNET_htonll(0); |
762 | dm->expiration.value = 0; | 765 | dm->expiration = GNUNET_TIME_absolute_hton(GNUNET_TIME_UNIT_ZERO_ABS); |
763 | dm->key = *key; | 766 | dm->key = *key; |
764 | memcpy (&dm[1], data, size); | 767 | memcpy (&dm[1], data, size); |
765 | transmit_for_status (h, cont, cont_cls, timeout); | 768 | transmit_for_status (h, cont, cont_cls, timeout); |
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 977f1398e..79dd7a318 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -871,7 +871,6 @@ handle_get (void *cls, | |||
871 | struct GNUNET_SERVER_Client *client, | 871 | struct GNUNET_SERVER_Client *client, |
872 | const struct GNUNET_MessageHeader *message) | 872 | const struct GNUNET_MessageHeader *message) |
873 | { | 873 | { |
874 | static struct GNUNET_TIME_Absolute zero; | ||
875 | const struct GetMessage *msg; | 874 | const struct GetMessage *msg; |
876 | uint16_t size; | 875 | uint16_t size; |
877 | 876 | ||
@@ -900,7 +899,8 @@ handle_get (void *cls, | |||
900 | "GET"); | 899 | "GET"); |
901 | #endif | 900 | #endif |
902 | transmit_item (client, | 901 | transmit_item (client, |
903 | NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 902 | NULL, NULL, 0, NULL, 0, 0, 0, |
903 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
904 | return; | 904 | return; |
905 | } | 905 | } |
906 | GNUNET_SERVER_client_keep (client); | 906 | GNUNET_SERVER_client_keep (client); |
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index e76b21cb2..0b06c45b3 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -507,7 +507,6 @@ static void | |||
507 | sqlite_next_request_cont (void *cls, | 507 | sqlite_next_request_cont (void *cls, |
508 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 508 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
509 | { | 509 | { |
510 | static struct GNUNET_TIME_Absolute zero; | ||
511 | struct NextContext * nc= cls; | 510 | struct NextContext * nc= cls; |
512 | struct Plugin *plugin; | 511 | struct Plugin *plugin; |
513 | unsigned long long rowid; | 512 | unsigned long long rowid; |
@@ -530,7 +529,7 @@ sqlite_next_request_cont (void *cls, | |||
530 | END: | 529 | END: |
531 | nc->iter (nc->iter_cls, | 530 | nc->iter (nc->iter_cls, |
532 | NULL, NULL, 0, NULL, 0, 0, 0, | 531 | NULL, NULL, 0, NULL, 0, 0, 0, |
533 | zero, 0); | 532 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
534 | nc->prep (nc->prep_cls, NULL); | 533 | nc->prep (nc->prep_cls, NULL); |
535 | GNUNET_free (nc); | 534 | GNUNET_free (nc); |
536 | return; | 535 | return; |
@@ -923,7 +922,6 @@ basic_iter (struct Plugin *plugin, | |||
923 | PluginIterator iter, | 922 | PluginIterator iter, |
924 | void *iter_cls) | 923 | void *iter_cls) |
925 | { | 924 | { |
926 | static struct GNUNET_TIME_Absolute zero; | ||
927 | struct NextContext *nc; | 925 | struct NextContext *nc; |
928 | struct IterContext *ic; | 926 | struct IterContext *ic; |
929 | sqlite3_stmt *stmt_1; | 927 | sqlite3_stmt *stmt_1; |
@@ -941,7 +939,7 @@ basic_iter (struct Plugin *plugin, | |||
941 | LOG_SQLITE (plugin, NULL, | 939 | LOG_SQLITE (plugin, NULL, |
942 | GNUNET_ERROR_TYPE_ERROR | | 940 | GNUNET_ERROR_TYPE_ERROR | |
943 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); | 941 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); |
944 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 942 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
945 | return; | 943 | return; |
946 | } | 944 | } |
947 | if (sq_prepare (plugin->dbh, stmt_str_2, &stmt_2) != SQLITE_OK) | 945 | if (sq_prepare (plugin->dbh, stmt_str_2, &stmt_2) != SQLITE_OK) |
@@ -950,7 +948,7 @@ basic_iter (struct Plugin *plugin, | |||
950 | GNUNET_ERROR_TYPE_ERROR | | 948 | GNUNET_ERROR_TYPE_ERROR | |
951 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); | 949 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); |
952 | sqlite3_finalize (stmt_1); | 950 | sqlite3_finalize (stmt_1); |
953 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 951 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
954 | return; | 952 | return; |
955 | } | 953 | } |
956 | nc = GNUNET_malloc (sizeof(struct NextContext) + | 954 | nc = GNUNET_malloc (sizeof(struct NextContext) + |
@@ -1166,7 +1164,6 @@ sqlite_plugin_iter_all_now (void *cls, | |||
1166 | PluginIterator iter, | 1164 | PluginIterator iter, |
1167 | void *iter_cls) | 1165 | void *iter_cls) |
1168 | { | 1166 | { |
1169 | static struct GNUNET_TIME_Absolute zero; | ||
1170 | struct Plugin *plugin = cls; | 1167 | struct Plugin *plugin = cls; |
1171 | struct NextContext *nc; | 1168 | struct NextContext *nc; |
1172 | sqlite3_stmt *stmt; | 1169 | sqlite3_stmt *stmt; |
@@ -1178,7 +1175,7 @@ sqlite_plugin_iter_all_now (void *cls, | |||
1178 | LOG_SQLITE (plugin, NULL, | 1175 | LOG_SQLITE (plugin, NULL, |
1179 | GNUNET_ERROR_TYPE_ERROR | | 1176 | GNUNET_ERROR_TYPE_ERROR | |
1180 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); | 1177 | GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare"); |
1181 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1178 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1182 | return; | 1179 | return; |
1183 | } | 1180 | } |
1184 | nc = GNUNET_malloc (sizeof(struct NextContext)); | 1181 | nc = GNUNET_malloc (sizeof(struct NextContext)); |
@@ -1276,7 +1273,6 @@ sqlite_plugin_get (void *cls, | |||
1276 | uint32_t type, | 1273 | uint32_t type, |
1277 | PluginIterator iter, void *iter_cls) | 1274 | PluginIterator iter, void *iter_cls) |
1278 | { | 1275 | { |
1279 | static struct GNUNET_TIME_Absolute zero; | ||
1280 | struct Plugin *plugin = cls; | 1276 | struct Plugin *plugin = cls; |
1281 | struct GetNextContext *gpc; | 1277 | struct GetNextContext *gpc; |
1282 | struct NextContext *nc; | 1278 | struct NextContext *nc; |
@@ -1301,7 +1297,7 @@ sqlite_plugin_get (void *cls, | |||
1301 | { | 1297 | { |
1302 | LOG_SQLITE (plugin, NULL, | 1298 | LOG_SQLITE (plugin, NULL, |
1303 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); | 1299 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); |
1304 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1300 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1305 | return; | 1301 | return; |
1306 | } | 1302 | } |
1307 | sqoff = 1; | 1303 | sqoff = 1; |
@@ -1321,7 +1317,7 @@ sqlite_plugin_get (void *cls, | |||
1321 | GNUNET_ERROR_TYPE_ERROR, "sqlite_bind"); | 1317 | GNUNET_ERROR_TYPE_ERROR, "sqlite_bind"); |
1322 | sqlite3_reset (stmt); | 1318 | sqlite3_reset (stmt); |
1323 | sqlite3_finalize (stmt); | 1319 | sqlite3_finalize (stmt); |
1324 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1320 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1325 | return; | 1321 | return; |
1326 | } | 1322 | } |
1327 | ret = sqlite3_step (stmt); | 1323 | ret = sqlite3_step (stmt); |
@@ -1332,7 +1328,7 @@ sqlite_plugin_get (void *cls, | |||
1332 | "sqlite_step"); | 1328 | "sqlite_step"); |
1333 | sqlite3_reset (stmt); | 1329 | sqlite3_reset (stmt); |
1334 | sqlite3_finalize (stmt); | 1330 | sqlite3_finalize (stmt); |
1335 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1331 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1336 | return; | 1332 | return; |
1337 | } | 1333 | } |
1338 | total = sqlite3_column_int (stmt, 0); | 1334 | total = sqlite3_column_int (stmt, 0); |
@@ -1340,7 +1336,7 @@ sqlite_plugin_get (void *cls, | |||
1340 | sqlite3_finalize (stmt); | 1336 | sqlite3_finalize (stmt); |
1341 | if (0 == total) | 1337 | if (0 == total) |
1342 | { | 1338 | { |
1343 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1339 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1344 | return; | 1340 | return; |
1345 | } | 1341 | } |
1346 | 1342 | ||
@@ -1357,7 +1353,7 @@ sqlite_plugin_get (void *cls, | |||
1357 | LOG_SQLITE (plugin, NULL, | 1353 | LOG_SQLITE (plugin, NULL, |
1358 | GNUNET_ERROR_TYPE_ERROR | | 1354 | GNUNET_ERROR_TYPE_ERROR | |
1359 | GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); | 1355 | GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); |
1360 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, zero, 0); | 1356 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1361 | return; | 1357 | return; |
1362 | } | 1358 | } |
1363 | nc = GNUNET_malloc (sizeof(struct NextContext) + | 1359 | nc = GNUNET_malloc (sizeof(struct NextContext) + |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 10ffe1350..cf0e8a067 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -80,6 +80,7 @@ | |||
80 | */ | 80 | */ |
81 | #include "platform.h" | 81 | #include "platform.h" |
82 | #include "gnunet_fs_service.h" | 82 | #include "gnunet_fs_service.h" |
83 | #include "gnunet_signatures.h" | ||
83 | #include "fs.h" | 84 | #include "fs.h" |
84 | 85 | ||
85 | 86 | ||
@@ -422,6 +423,91 @@ uri_chk_parse (const char *s, char **emsg) | |||
422 | 423 | ||
423 | 424 | ||
424 | /** | 425 | /** |
426 | * Convert a character back to the binary value | ||
427 | * that it represents (given base64-encoding). | ||
428 | * | ||
429 | * @param a character to convert | ||
430 | * @return offset in the "tbl" array | ||
431 | */ | ||
432 | static unsigned int | ||
433 | c2v (unsigned char a) | ||
434 | { | ||
435 | if ((a >= '0') && (a <= '9')) | ||
436 | return a - '0'; | ||
437 | if ((a >= 'A') && (a <= 'Z')) | ||
438 | return (a - 'A' + 10); | ||
439 | if ((a >= 'a') && (a <= 'z')) | ||
440 | return (a - 'a' + 36); | ||
441 | if (a == '_') | ||
442 | return 62; | ||
443 | if (a == '=') | ||
444 | return 63; | ||
445 | return -1; | ||
446 | } | ||
447 | |||
448 | |||
449 | /** | ||
450 | * Convert string back to binary data. | ||
451 | * | ||
452 | * @param input '\0'-terminated string | ||
453 | * @param data where to write binary data | ||
454 | * @param size how much data should be converted | ||
455 | * @return number of characters processed from input, | ||
456 | * -1 on error | ||
457 | */ | ||
458 | static int | ||
459 | enc2bin (const char *input, void *data, size_t size) | ||
460 | { | ||
461 | size_t len; | ||
462 | size_t pos; | ||
463 | unsigned int bits; | ||
464 | unsigned int hbits; | ||
465 | |||
466 | len = size * 8 / 6; | ||
467 | if (((size * 8) % 6) != 0) | ||
468 | len++; | ||
469 | if (strlen (input) < len) | ||
470 | return -1; /* error! */ | ||
471 | bits = 0; | ||
472 | hbits = 0; | ||
473 | len = 0; | ||
474 | pos = 0; | ||
475 | for (pos = 0; pos < size; pos++) | ||
476 | { | ||
477 | while (hbits < 8) | ||
478 | { | ||
479 | bits |= (c2v (input[len++]) << hbits); | ||
480 | hbits += 6; | ||
481 | } | ||
482 | (((unsigned char *) data)[pos]) = (unsigned char) bits; | ||
483 | bits >>= 8; | ||
484 | hbits -= 8; | ||
485 | } | ||
486 | return len; | ||
487 | } | ||
488 | |||
489 | |||
490 | /** | ||
491 | * Structure that defines how the | ||
492 | * contents of a location URI must be | ||
493 | * assembled in memory to create or | ||
494 | * verify the signature of a location | ||
495 | * URI. | ||
496 | */ | ||
497 | struct LocUriAssembly | ||
498 | { | ||
499 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | ||
500 | |||
501 | struct GNUNET_TIME_AbsoluteNBO exptime; | ||
502 | |||
503 | struct FileIdentifier fi; | ||
504 | |||
505 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer; | ||
506 | |||
507 | }; | ||
508 | |||
509 | |||
510 | /** | ||
425 | * Parse a LOC URI. | 511 | * Parse a LOC URI. |
426 | * Also verifies validity of the location URI. | 512 | * Also verifies validity of the location URI. |
427 | * | 513 | * |
@@ -432,12 +518,15 @@ uri_chk_parse (const char *s, char **emsg) | |||
432 | static struct GNUNET_FS_Uri * | 518 | static struct GNUNET_FS_Uri * |
433 | uri_loc_parse (const char *s, char **emsg) | 519 | uri_loc_parse (const char *s, char **emsg) |
434 | { | 520 | { |
435 | struct GNUNET_FS_Uri *ret; | 521 | struct GNUNET_FS_Uri *uri; |
436 | char h1[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)]; | 522 | char h1[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)]; |
437 | char h2[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)]; | 523 | char h2[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)]; |
438 | unsigned int pos; | 524 | unsigned int pos; |
439 | unsigned int npos; | 525 | unsigned int npos; |
440 | unsigned long long exptime; | 526 | unsigned long long exptime; |
527 | struct GNUNET_TIME_Absolute et; | ||
528 | struct GNUNET_CRYPTO_RsaSignature sig; | ||
529 | struct LocUriAssembly ass; | ||
441 | int ret; | 530 | int ret; |
442 | size_t slen; | 531 | size_t slen; |
443 | char *addr; | 532 | char *addr; |
@@ -462,14 +551,14 @@ uri_loc_parse (const char *s, char **emsg) | |||
462 | h2[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)-1] = '\0'; | 551 | h2[sizeof(struct GNUNET_CRYPTO_HashAsciiEncoded)-1] = '\0'; |
463 | 552 | ||
464 | if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, | 553 | if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, |
465 | &fi.chk.key)) || | 554 | &ass.fi.chk.key)) || |
466 | (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, | 555 | (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, |
467 | &fi.chk.query)) | 556 | &ass.fi.chk.query)) || |
468 | (1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], | 557 | (1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], |
469 | "%llu", | 558 | "%llu", |
470 | &fi.file_length)) ) | 559 | &ass.fi.file_length)) ) |
471 | return NULL; | 560 | return NULL; |
472 | fi.file_length = GNUNET_htonll (fi.file_length); | 561 | ass.fi.file_length = GNUNET_htonll (ass.fi.file_length); |
473 | 562 | ||
474 | npos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2; | 563 | npos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2; |
475 | while ((s[npos] != '\0') && (s[npos] != '.')) | 564 | while ((s[npos] != '\0') && (s[npos] != '.')) |
@@ -477,39 +566,42 @@ uri_loc_parse (const char *s, char **emsg) | |||
477 | if (s[npos] == '\0') | 566 | if (s[npos] == '\0') |
478 | goto ERR; | 567 | goto ERR; |
479 | ret = enc2bin (&s[npos], | 568 | ret = enc2bin (&s[npos], |
480 | &loc->peer, | 569 | &ass.peer, |
481 | sizeof (GNUNET_RSA_PublicKey)); | 570 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
482 | if (ret == -1) | 571 | if (ret == -1) |
483 | goto ERR; | 572 | goto ERR; |
484 | npos += ret; | 573 | npos += ret; |
485 | if (dup[npos++] != '.') | 574 | if (s[npos++] != '.') |
486 | goto ERR; | 575 | goto ERR; |
487 | ret = enc2bin (&s[npos], | 576 | ret = enc2bin (&s[npos], |
488 | &loc->contentSignature, | 577 | &sig, |
489 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 578 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
490 | if (ret == -1) | 579 | if (ret == -1) |
491 | goto ERR; | 580 | goto ERR; |
492 | npos += ret; | 581 | npos += ret; |
493 | if (dup[npos++] != '.') | 582 | if (s[npos++] != '.') |
494 | goto ERR; | 583 | goto ERR; |
495 | if (1 != SSCANF (&dup[npos], "%llu", &exptime)) | 584 | if (1 != SSCANF (&s[npos], "%llu", &exptime)) |
496 | goto ERR; | 585 | goto ERR; |
497 | // FIXME: do something to exptime... | 586 | ass.purpose.size = htonl(sizeof(struct LocUriAssembly)); |
498 | /* Finally: verify sigs! */ | 587 | ass.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT); |
499 | if (GNUNET_OK != GNUNET_RSA_verify (&loc->fi, | 588 | et.value = exptime; |
500 | sizeof (struct FileIdentifier) + | 589 | ass.exptime = GNUNET_TIME_absolute_hton (et); |
501 | sizeof (GNUNET_PeerIdentity) + | 590 | if (GNUNET_OK != |
502 | sizeof (GNUNET_Int32Time), | 591 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT, |
503 | &loc->contentSignature, | 592 | &ass.purpose, |
504 | &loc->peer)) | 593 | &sig, |
594 | &ass.peer)) | ||
505 | goto ERR; | 595 | goto ERR; |
506 | 596 | ||
507 | ret = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri)); | 597 | uri = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri)); |
508 | ret->type = loc; | 598 | uri->type = loc; |
509 | ret->data.loc.chk = fi; | 599 | uri->data.loc.fi = ass.fi; |
510 | ret->data.loc.xx = yy; | 600 | uri->data.loc.peer = ass.peer; |
601 | uri->data.loc.expirationTime = et; | ||
602 | uri->data.loc.contentSignature = sig; | ||
511 | 603 | ||
512 | return ret; | 604 | return uri; |
513 | ERR: | 605 | ERR: |
514 | GNUNET_free_non_null (addr); | 606 | GNUNET_free_non_null (addr); |
515 | return NULL; | 607 | return NULL; |
@@ -1251,71 +1343,6 @@ bin2enc (const void *data, size_t size) | |||
1251 | 1343 | ||
1252 | 1344 | ||
1253 | /** | 1345 | /** |
1254 | * Convert a character back to the binary value | ||
1255 | * that it represents (given base64-encoding). | ||
1256 | * | ||
1257 | * @param a character to convert | ||
1258 | * @return offset in the "tbl" array | ||
1259 | */ | ||
1260 | static unsigned int | ||
1261 | c2v (unsigned char a) | ||
1262 | { | ||
1263 | if ((a >= '0') && (a <= '9')) | ||
1264 | return a - '0'; | ||
1265 | if ((a >= 'A') && (a <= 'Z')) | ||
1266 | return (a - 'A' + 10); | ||
1267 | if ((a >= 'a') && (a <= 'z')) | ||
1268 | return (a - 'a' + 36); | ||
1269 | if (a == '_') | ||
1270 | return 62; | ||
1271 | if (a == '=') | ||
1272 | return 63; | ||
1273 | return -1; | ||
1274 | } | ||
1275 | |||
1276 | |||
1277 | /** | ||
1278 | * Convert string back to binary data. | ||
1279 | * | ||
1280 | * @param input '\0'-terminated string | ||
1281 | * @param data where to write binary data | ||
1282 | * @param size how much data should be converted | ||
1283 | * @return number of characters processed from input, | ||
1284 | * -1 on error | ||
1285 | */ | ||
1286 | static int | ||
1287 | enc2bin (const char *input, void *data, size_t size) | ||
1288 | { | ||
1289 | size_t len; | ||
1290 | size_t pos; | ||
1291 | unsigned int bits; | ||
1292 | unsigned int hbits; | ||
1293 | |||
1294 | len = size * 8 / 6; | ||
1295 | if (((size * 8) % 6) != 0) | ||
1296 | len++; | ||
1297 | if (strlen (input) < len) | ||
1298 | return -1; /* error! */ | ||
1299 | bits = 0; | ||
1300 | hbits = 0; | ||
1301 | len = 0; | ||
1302 | pos = 0; | ||
1303 | for (pos = 0; pos < size; pos++) | ||
1304 | { | ||
1305 | while (hbits < 8) | ||
1306 | { | ||
1307 | bits |= (c2v (input[len++]) << hbits); | ||
1308 | hbits += 6; | ||
1309 | } | ||
1310 | (((unsigned char *) data)[pos]) = (unsigned char) bits; | ||
1311 | bits >>= 8; | ||
1312 | hbits -= 8; | ||
1313 | } | ||
1314 | return len; | ||
1315 | } | ||
1316 | |||
1317 | |||
1318 | /** | ||
1319 | * Convert a LOC URI to a string. | 1346 | * Convert a LOC URI to a string. |
1320 | * | 1347 | * |
1321 | * @param uri loc uri to convert | 1348 | * @param uri loc uri to convert |
@@ -1337,15 +1364,15 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri) | |||
1337 | peerSig = bin2enc (&uri->data.loc.contentSignature, | 1364 | peerSig = bin2enc (&uri->data.loc.contentSignature, |
1338 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 1365 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
1339 | GNUNET_asprintf (&ret, | 1366 | GNUNET_asprintf (&ret, |
1340 | "%s%s%s.%s.%llu.%s.%s.%u", // FIXME: expirationTime 64-bit??? | 1367 | "%s%s%s.%s.%llu.%s.%s.%llu", |
1341 | GNUNET_FS_URI_PREFIX, | 1368 | GNUNET_FS_URI_PREFIX, |
1342 | GNUNET_FS_URI_LOC_INFIX, | 1369 | GNUNET_FS_URI_LOC_INFIX, |
1343 | (const char *) &keyhash, | 1370 | (const char *) &keyhash, |
1344 | (const char *) &queryhash, | 1371 | (const char *) &queryhash, |
1345 | GNUNET_ntohll (uri->data.loc.fi.file_length), | 1372 | (unsigned long long) GNUNET_ntohll (uri->data.loc.fi.file_length), |
1346 | peerId, | 1373 | peerId, |
1347 | peerSig, | 1374 | peerSig, |
1348 | uri->data.loc.expirationTime); | 1375 | (unsigned long long) uri->data.loc.expirationTime.value); |
1349 | GNUNET_free (peerSig); | 1376 | GNUNET_free (peerSig); |
1350 | GNUNET_free (peerId); | 1377 | GNUNET_free (peerId); |
1351 | return ret; | 1378 | return ret; |
diff --git a/src/fs/test_fs_getopt.c b/src/fs/test_fs_getopt.c index 2c0a0eba4..d2e424b4a 100644 --- a/src/fs/test_fs_getopt.c +++ b/src/fs/test_fs_getopt.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_fs_lib.h" | 26 | #include "gnunet_fs_service.h" |
27 | 27 | ||
28 | int | 28 | int |
29 | main (int argc, char *argv[]) | 29 | main (int argc, char *argv[]) |
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c index f24f4fe27..f07ba4179 100644 --- a/src/fs/test_fs_uri.c +++ b/src/fs/test_fs_uri.c | |||
@@ -19,15 +19,15 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file applications/fs/ecrs/uritest.c | 22 | * @file fs/test_fs_uri.c |
23 | * @brief Test for uri.c | 23 | * @brief Test for fs_uri.c |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_ecrs_lib.h" | 29 | #include "gnunet_fs_service.h" |
30 | #include "ecrs.h" | 30 | #include "fs.h" |
31 | 31 | ||
32 | #define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); return 1; } | 32 | #define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); return 1; } |
33 | 33 | ||
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index 90b04edb1..6e4b0dc42 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -59,10 +59,16 @@ extern "C" | |||
59 | */ | 59 | */ |
60 | #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 3 | 60 | #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 3 |
61 | 61 | ||
62 | |||
63 | /** | ||
64 | * Signature of content URI placed into a namespace. | ||
65 | */ | ||
66 | #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_PLACEMENT 4 | ||
67 | |||
62 | /** | 68 | /** |
63 | * | 69 | * |
64 | */ | 70 | */ |
65 | #define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 3 | 71 | #define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 5 |
66 | 72 | ||
67 | 73 | ||
68 | #if 0 /* keep Emacsens' auto-indent happy */ | 74 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index 5a339e6cb..b5da09cd8 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -61,7 +61,7 @@ struct GNUNET_TIME_Relative | |||
61 | */ | 61 | */ |
62 | struct GNUNET_TIME_RelativeNBO | 62 | struct GNUNET_TIME_RelativeNBO |
63 | { | 63 | { |
64 | uint64_t value GNUNET_PACKED; | 64 | uint64_t value__ GNUNET_PACKED; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | 67 | ||
@@ -70,13 +70,15 @@ struct GNUNET_TIME_RelativeNBO | |||
70 | */ | 70 | */ |
71 | struct GNUNET_TIME_AbsoluteNBO | 71 | struct GNUNET_TIME_AbsoluteNBO |
72 | { | 72 | { |
73 | uint64_t value GNUNET_PACKED; | 73 | uint64_t value__ GNUNET_PACKED; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | |||
76 | /** | 77 | /** |
77 | * @brief constants to specify time | 78 | * @brief constants to specify time |
78 | */ | 79 | */ |
79 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() | 80 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() |
81 | #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() | ||
80 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() | 82 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() |
81 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) | 83 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) |
82 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) | 84 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) |
@@ -104,6 +106,11 @@ struct GNUNET_TIME_AbsoluteNBO | |||
104 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero (void); | 106 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero (void); |
105 | 107 | ||
106 | /** | 108 | /** |
109 | * Return absolute time of 0ms. | ||
110 | */ | ||
111 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero (void); | ||
112 | |||
113 | /** | ||
107 | * Return relative time of 1ms. | 114 | * Return relative time of 1ms. |
108 | */ | 115 | */ |
109 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit (void); | 116 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit (void); |
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index 5bf336060..441865acc 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c | |||
@@ -496,7 +496,9 @@ GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
496 | * Insert metadata into existing MD record (passed as cls). | 496 | * Insert metadata into existing MD record (passed as cls). |
497 | */ | 497 | */ |
498 | static int | 498 | static int |
499 | merge_meta_helper (EXTRACTOR_KeywordType type, const char *data, void *cls) | 499 | merge_meta_helper (void *cls, |
500 | EXTRACTOR_KeywordType type, | ||
501 | const char *data) | ||
500 | { | 502 | { |
501 | struct GNUNET_CONTAINER_MetaData *meta = cls; | 503 | struct GNUNET_CONTAINER_MetaData *meta = cls; |
502 | GNUNET_CONTAINER_meta_data_insert (meta, type, data); | 504 | GNUNET_CONTAINER_meta_data_insert (meta, type, data); |
diff --git a/src/util/time.c b/src/util/time.c index f3d17f421..85d8d0cd6 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -55,6 +55,17 @@ GNUNET_TIME_relative_get_zero () | |||
55 | return zero; | 55 | return zero; |
56 | } | 56 | } |
57 | 57 | ||
58 | |||
59 | /** | ||
60 | * Return absolute time of 0ms. | ||
61 | */ | ||
62 | struct GNUNET_TIME_Absolute | ||
63 | GNUNET_TIME_absolute_get_zero () | ||
64 | { | ||
65 | static struct GNUNET_TIME_Absolute zero; | ||
66 | return zero; | ||
67 | } | ||
68 | |||
58 | /** | 69 | /** |
59 | * Return relative time of 1ms. | 70 | * Return relative time of 1ms. |
60 | */ | 71 | */ |
@@ -257,7 +268,7 @@ struct GNUNET_TIME_RelativeNBO | |||
257 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) | 268 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) |
258 | { | 269 | { |
259 | struct GNUNET_TIME_RelativeNBO ret; | 270 | struct GNUNET_TIME_RelativeNBO ret; |
260 | ret.value = GNUNET_htonll (a.value); | 271 | ret.value__ = GNUNET_htonll (a.value); |
261 | return ret; | 272 | return ret; |
262 | } | 273 | } |
263 | 274 | ||
@@ -268,7 +279,7 @@ struct GNUNET_TIME_Relative | |||
268 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) | 279 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) |
269 | { | 280 | { |
270 | struct GNUNET_TIME_Relative ret; | 281 | struct GNUNET_TIME_Relative ret; |
271 | ret.value = GNUNET_ntohll (a.value); | 282 | ret.value = GNUNET_ntohll (a.value__); |
272 | return ret; | 283 | return ret; |
273 | 284 | ||
274 | } | 285 | } |
@@ -280,7 +291,7 @@ struct GNUNET_TIME_AbsoluteNBO | |||
280 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) | 291 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) |
281 | { | 292 | { |
282 | struct GNUNET_TIME_AbsoluteNBO ret; | 293 | struct GNUNET_TIME_AbsoluteNBO ret; |
283 | ret.value = GNUNET_htonll (a.value); | 294 | ret.value__ = GNUNET_htonll (a.value); |
284 | return ret; | 295 | return ret; |
285 | } | 296 | } |
286 | 297 | ||
@@ -291,7 +302,7 @@ struct GNUNET_TIME_Absolute | |||
291 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) | 302 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) |
292 | { | 303 | { |
293 | struct GNUNET_TIME_Absolute ret; | 304 | struct GNUNET_TIME_Absolute ret; |
294 | ret.value = GNUNET_ntohll (a.value); | 305 | ret.value = GNUNET_ntohll (a.value__); |
295 | return ret; | 306 | return ret; |
296 | 307 | ||
297 | } | 308 | } |