summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-07-08 22:36:00 +0000
committerChristian Grothoff <christian@grothoff.org>2013-07-08 22:36:00 +0000
commitc8b184df65f4ce954ab571a2a174db3ea0d5c1d6 (patch)
tree351fcb9c770ad65c9990b043c4e4bf529784e78e /src
parent8f31d00ecb420926db5363a2882b5302d8635246 (diff)
downloadgnunet-c8b184df65f4ce954ab571a2a174db3ea0d5c1d6.tar.gz
gnunet-c8b184df65f4ce954ab571a2a174db3ea0d5c1d6.zip
-get rid of iteration response, use lookup response instead, message formats were identical to begin with
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_namestore_service.h8
-rw-r--r--src/include/gnunet_protocols.h10
-rw-r--r--src/namestore/gnunet-service-namestore.c14
-rw-r--r--src/namestore/namestore.h52
-rw-r--r--src/namestore/namestore_api.c11
5 files changed, 25 insertions, 70 deletions
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index a1c5d6437..3966c3db2 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -458,13 +458,12 @@ struct GNUNET_NAMESTORE_ZoneMonitor;
458 * Function called whenever the records for a given name changed. 458 * Function called whenever the records for a given name changed.
459 * 459 *
460 * @param cls closure 460 * @param cls closure
461 * @param was_removed GNUNET_NO if the record was added, GNUNET_YES if it was removed, 461 * @param zone_key NULL if the communication with the namestore broke down
462 * GNUNET_SYSERR if the communication with the namestore broke down
463 * (and thus all entries should be 'cleared' until the communication 462 * (and thus all entries should be 'cleared' until the communication
464 * can be re-established, at which point the monitor will 463 * can be re-established, at which point the monitor will
465 * re-add all records that are (still) in the namestore after 464 * re-add all records that are (still) in the namestore after
466 * the reconnect); if this value is SYSERR, all other arguments 465 * the reconnect); if this value is NULL, all other arguments
467 * will be 0/NULL. 466 * will also be 0/NULL.
468 * @param freshness when does the corresponding block in the DHT expire (until 467 * @param freshness when does the corresponding block in the DHT expire (until
469 * when should we never do a DHT lookup for the same name again)?; 468 * when should we never do a DHT lookup for the same name again)?;
470 * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, 469 * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore,
@@ -476,7 +475,6 @@ struct GNUNET_NAMESTORE_ZoneMonitor;
476 * @param signature signature of the record block 475 * @param signature signature of the record block
477 */ 476 */
478typedef void (*GNUNET_NAMESTORE_RecordMonitor)(void *cls, 477typedef void (*GNUNET_NAMESTORE_RecordMonitor)(void *cls,
479 int was_removed,
480 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 478 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key,
481 struct GNUNET_TIME_Absolute freshness, 479 struct GNUNET_TIME_Absolute freshness,
482 const char *name, 480 const char *name,
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 1bd1714c9..9238924ee 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1402,14 +1402,16 @@ extern "C"
1402#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440 1402#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
1403 1403
1404/** 1404/**
1405 * Client to service: please start iteration 1405 * Client to service: start monitoring (yields sequence of
1406 * "ZONE_ITERATION_RESPONSES" --- forever).
1406 */ 1407 */
1407#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445 1408#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START 441
1408 1409
1409/** 1410/**
1410 * Service to client: current record in iteration (or end of list). 1411 * Client to service: please start iteration; receives
1412 * "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return.
1411 */ 1413 */
1412#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446 1414#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
1413 1415
1414/** 1416/**
1415 * Client to service: next record in iteration please. 1417 * Client to service: next record in iteration please.
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index b71893d5d..cde74a11a 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1364,7 +1364,7 @@ zone_iteraterate_proc (void *cls,
1364 struct GNUNET_NAMESTORE_CryptoContainer *cc; 1364 struct GNUNET_NAMESTORE_CryptoContainer *cc;
1365 struct GNUNET_HashCode long_hash; 1365 struct GNUNET_HashCode long_hash;
1366 struct GNUNET_CRYPTO_ShortHashCode zone_hash; 1366 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
1367 struct ZoneIterationResponseMessage *zir_msg; 1367 struct LookupNameResponseMessage *zir_msg;
1368 struct GNUNET_TIME_Relative rt; 1368 struct GNUNET_TIME_Relative rt;
1369 unsigned int rd_count_filtered; 1369 unsigned int rd_count_filtered;
1370 unsigned int c; 1370 unsigned int c;
@@ -1484,14 +1484,14 @@ zone_iteraterate_proc (void *cls,
1484 name); 1484 name);
1485 name_len = strlen (name) + 1; 1485 name_len = strlen (name) + 1;
1486 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count_filtered, rd_filtered); 1486 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count_filtered, rd_filtered);
1487 msg_size = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_ser_len; 1487 msg_size = sizeof (struct LookupNameResponseMessage) + name_len + rd_ser_len;
1488 1488
1489 zir_msg = GNUNET_malloc (msg_size); 1489 zir_msg = GNUNET_malloc (msg_size);
1490 zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); 1490 zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE);
1491 zir_msg->gns_header.header.size = htons (msg_size); 1491 zir_msg->gns_header.header.size = htons (msg_size);
1492 zir_msg->gns_header.r_id = htonl (proc->zi->request_id); 1492 zir_msg->gns_header.r_id = htonl (proc->zi->request_id);
1493 zir_msg->expire = GNUNET_TIME_absolute_hton (expire); 1493 zir_msg->expire = GNUNET_TIME_absolute_hton (expire);
1494 zir_msg->reserved = htons (0); 1494 zir_msg->contains_sig = htons ((NULL == signature) ? GNUNET_NO : GNUNET_YES);
1495 zir_msg->name_len = htons (name_len); 1495 zir_msg->name_len = htons (name_len);
1496 zir_msg->rd_count = htons (rd_count_filtered); 1496 zir_msg->rd_count = htons (rd_count_filtered);
1497 zir_msg->rd_len = htons (rd_ser_len); 1497 zir_msg->rd_len = htons (rd_ser_len);
@@ -1524,7 +1524,7 @@ static void
1524run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi) 1524run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi)
1525{ 1525{
1526 struct ZoneIterationProcResult proc; 1526 struct ZoneIterationProcResult proc;
1527 struct ZoneIterationResponseMessage zir_end; 1527 struct LookupNameResponseMessage zir_end;
1528 struct GNUNET_CRYPTO_ShortHashCode *zone; 1528 struct GNUNET_CRYPTO_ShortHashCode *zone;
1529 1529
1530 memset (&proc, 0, sizeof (proc)); 1530 memset (&proc, 0, sizeof (proc));
@@ -1560,8 +1560,8 @@ run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi)
1560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1561 "No more results for all zones\n"); 1561 "No more results for all zones\n");
1562 memset (&zir_end, 0, sizeof (zir_end)); 1562 memset (&zir_end, 0, sizeof (zir_end));
1563 zir_end.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); 1563 zir_end.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE);
1564 zir_end.gns_header.header.size = htons (sizeof (struct ZoneIterationResponseMessage)); 1564 zir_end.gns_header.header.size = htons (sizeof (struct LookupNameResponseMessage));
1565 zir_end.gns_header.r_id = htonl(zi->request_id); 1565 zir_end.gns_header.r_id = htonl(zi->request_id);
1566 GNUNET_SERVER_notification_context_unicast (snc, 1566 GNUNET_SERVER_notification_context_unicast (snc,
1567 zi->client->client, 1567 zi->client->client,
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index 3fb7a558c..8e2625c10 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -137,7 +137,6 @@ struct LookupNameResponseMessage
137 */ 137 */
138 struct GNUNET_TIME_AbsoluteNBO expire; 138 struct GNUNET_TIME_AbsoluteNBO expire;
139 139
140
141 /** 140 /**
142 * Name length 141 * Name length
143 */ 142 */
@@ -352,7 +351,10 @@ struct ZoneToNameResponseMessage
352 */ 351 */
353 uint16_t rd_count; 352 uint16_t rd_count;
354 353
355 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */ 354 /**
355 * result in NBO: GNUNET_OK on success, GNUNET_NO if there were no
356 * results, GNUNET_SYSERR on error
357 */
356 int16_t res; 358 int16_t res;
357 359
358 /** 360 /**
@@ -443,52 +445,6 @@ struct ZoneIterationStopMessage
443}; 445};
444 446
445 447
446/**
447 * Next result of zone iteration for the given operation
448 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
449 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
450 */
451struct ZoneIterationResponseMessage
452{
453 /**
454 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
455 */
456 struct GNUNET_NAMESTORE_Header gns_header;
457
458 struct GNUNET_TIME_AbsoluteNBO expire;
459
460 uint16_t name_len;
461
462 /**
463 * Record data length
464 */
465 uint16_t rd_len;
466
467 /**
468 * Number of records contained
469 */
470 uint16_t rd_count;
471
472 /**
473 * always zero (for alignment)
474 */
475 uint16_t reserved;
476
477 /**
478 * All zeros if 'contains_sig' is GNUNET_NO.
479 */
480 struct GNUNET_CRYPTO_EccSignature signature;
481
482 /**
483 * The public key
484 */
485 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key;
486
487};
488
489
490
491
492GNUNET_NETWORK_STRUCT_END 448GNUNET_NETWORK_STRUCT_END
493 449
494 450
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 97d34aa24..54cc8ec66 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -514,7 +514,7 @@ manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe,
514 */ 514 */
515static int 515static int
516handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, 516handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
517 const struct ZoneIterationResponseMessage *msg, 517 const struct LookupNameResponseMessage *msg,
518 size_t size) 518 size_t size)
519{ 519{
520 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubdummy; 520 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubdummy;
@@ -534,13 +534,12 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
534 rd_count = ntohs (msg->rd_count); 534 rd_count = ntohs (msg->rd_count);
535 name_len = ntohs (msg->name_len); 535 name_len = ntohs (msg->name_len);
536 expire = GNUNET_TIME_absolute_ntoh (msg->expire); 536 expire = GNUNET_TIME_absolute_ntoh (msg->expire);
537 exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len; 537 exp_msg_len = sizeof (struct LookupNameResponseMessage) + name_len + rd_len;
538 if (msg_len != exp_msg_len) 538 if (msg_len != exp_msg_len)
539 { 539 {
540 GNUNET_break (0); 540 GNUNET_break (0);
541 return GNUNET_SYSERR; 541 return GNUNET_SYSERR;
542 } 542 }
543 GNUNET_break (0 == ntohs (msg->reserved));
544 memset (&pubdummy, '\0', sizeof (pubdummy)); 543 memset (&pubdummy, '\0', sizeof (pubdummy));
545 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy))))) 544 if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy)))))
546 { 545 {
@@ -589,13 +588,13 @@ manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze,
589 /* handle different message type */ 588 /* handle different message type */
590 switch (type) 589 switch (type)
591 { 590 {
592 case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE: 591 case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE:
593 if (size < sizeof (struct ZoneIterationResponseMessage)) 592 if (size < sizeof (struct LookupNameResponseMessage))
594 { 593 {
595 GNUNET_break (0); 594 GNUNET_break (0);
596 return GNUNET_SYSERR; 595 return GNUNET_SYSERR;
597 } 596 }
598 return handle_zone_iteration_response (ze, (const struct ZoneIterationResponseMessage *) msg, size); 597 return handle_zone_iteration_response (ze, (const struct LookupNameResponseMessage *) msg, size);
599 default: 598 default:
600 GNUNET_break (0); 599 GNUNET_break (0);
601 return GNUNET_SYSERR; 600 return GNUNET_SYSERR;