gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit c8b184df65f4ce954ab571a2a174db3ea0d5c1d6
parent 8f31d00ecb420926db5363a2882b5302d8635246
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon,  8 Jul 2013 22:36:00 +0000

-get rid of iteration response, use lookup response instead, message formats were identical to begin with

Diffstat:
Msrc/include/gnunet_namestore_service.h | 8+++-----
Msrc/include/gnunet_protocols.h | 10++++++----
Msrc/namestore/gnunet-service-namestore.c | 14+++++++-------
Msrc/namestore/namestore.h | 52++++------------------------------------------------
Msrc/namestore/namestore_api.c | 11+++++------
5 files changed, 25 insertions(+), 70 deletions(-)

diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h @@ -458,13 +458,12 @@ struct GNUNET_NAMESTORE_ZoneMonitor; * Function called whenever the records for a given name changed. * * @param cls closure - * @param was_removed GNUNET_NO if the record was added, GNUNET_YES if it was removed, - * GNUNET_SYSERR if the communication with the namestore broke down + * @param zone_key NULL if the communication with the namestore broke down * (and thus all entries should be 'cleared' until the communication * can be re-established, at which point the monitor will * re-add all records that are (still) in the namestore after - * the reconnect); if this value is SYSERR, all other arguments - * will be 0/NULL. + * the reconnect); if this value is NULL, all other arguments + * will also be 0/NULL. * @param freshness when does the corresponding block in the DHT expire (until * when should we never do a DHT lookup for the same name again)?; * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore, @@ -476,7 +475,6 @@ struct GNUNET_NAMESTORE_ZoneMonitor; * @param signature signature of the record block */ typedef void (*GNUNET_NAMESTORE_RecordMonitor)(void *cls, - int was_removed, const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, struct GNUNET_TIME_Absolute freshness, const char *name, diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h @@ -1402,14 +1402,16 @@ extern "C" #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440 /** - * Client to service: please start iteration + * Client to service: start monitoring (yields sequence of + * "ZONE_ITERATION_RESPONSES" --- forever). */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445 +#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START 441 /** - * Service to client: current record in iteration (or end of list). + * Client to service: please start iteration; receives + * "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return. */ -#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446 +#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445 /** * Client to service: next record in iteration please. diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c @@ -1364,7 +1364,7 @@ zone_iteraterate_proc (void *cls, struct GNUNET_NAMESTORE_CryptoContainer *cc; struct GNUNET_HashCode long_hash; struct GNUNET_CRYPTO_ShortHashCode zone_hash; - struct ZoneIterationResponseMessage *zir_msg; + struct LookupNameResponseMessage *zir_msg; struct GNUNET_TIME_Relative rt; unsigned int rd_count_filtered; unsigned int c; @@ -1484,14 +1484,14 @@ zone_iteraterate_proc (void *cls, name); name_len = strlen (name) + 1; rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count_filtered, rd_filtered); - msg_size = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_ser_len; + msg_size = sizeof (struct LookupNameResponseMessage) + name_len + rd_ser_len; zir_msg = GNUNET_malloc (msg_size); - zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); + zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE); zir_msg->gns_header.header.size = htons (msg_size); zir_msg->gns_header.r_id = htonl (proc->zi->request_id); zir_msg->expire = GNUNET_TIME_absolute_hton (expire); - zir_msg->reserved = htons (0); + zir_msg->contains_sig = htons ((NULL == signature) ? GNUNET_NO : GNUNET_YES); zir_msg->name_len = htons (name_len); zir_msg->rd_count = htons (rd_count_filtered); zir_msg->rd_len = htons (rd_ser_len); @@ -1524,7 +1524,7 @@ static void run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi) { struct ZoneIterationProcResult proc; - struct ZoneIterationResponseMessage zir_end; + struct LookupNameResponseMessage zir_end; struct GNUNET_CRYPTO_ShortHashCode *zone; memset (&proc, 0, sizeof (proc)); @@ -1560,8 +1560,8 @@ run_zone_iteration_round (struct GNUNET_NAMESTORE_ZoneIteration *zi) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more results for all zones\n"); memset (&zir_end, 0, sizeof (zir_end)); - zir_end.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); - zir_end.gns_header.header.size = htons (sizeof (struct ZoneIterationResponseMessage)); + zir_end.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE); + zir_end.gns_header.header.size = htons (sizeof (struct LookupNameResponseMessage)); zir_end.gns_header.r_id = htonl(zi->request_id); GNUNET_SERVER_notification_context_unicast (snc, zi->client->client, diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h @@ -137,7 +137,6 @@ struct LookupNameResponseMessage */ struct GNUNET_TIME_AbsoluteNBO expire; - /** * Name length */ @@ -352,7 +351,10 @@ struct ZoneToNameResponseMessage */ uint16_t rd_count; - /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */ + /** + * result in NBO: GNUNET_OK on success, GNUNET_NO if there were no + * results, GNUNET_SYSERR on error + */ int16_t res; /** @@ -443,52 +445,6 @@ struct ZoneIterationStopMessage }; -/** - * Next result of zone iteration for the given operation - * // FIXME: use 'struct LookupResponseMessage' instead? (identical except - * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise). - */ -struct ZoneIterationResponseMessage -{ - /** - * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE - */ - struct GNUNET_NAMESTORE_Header gns_header; - - struct GNUNET_TIME_AbsoluteNBO expire; - - uint16_t name_len; - - /** - * Record data length - */ - uint16_t rd_len; - - /** - * Number of records contained - */ - uint16_t rd_count; - - /** - * always zero (for alignment) - */ - uint16_t reserved; - - /** - * All zeros if 'contains_sig' is GNUNET_NO. - */ - struct GNUNET_CRYPTO_EccSignature signature; - - /** - * The public key - */ - struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; - -}; - - - - GNUNET_NETWORK_STRUCT_END diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c @@ -514,7 +514,7 @@ manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe, */ static int handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, - const struct ZoneIterationResponseMessage *msg, + const struct LookupNameResponseMessage *msg, size_t size) { struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubdummy; @@ -534,13 +534,12 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, rd_count = ntohs (msg->rd_count); name_len = ntohs (msg->name_len); expire = GNUNET_TIME_absolute_ntoh (msg->expire); - exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len; + exp_msg_len = sizeof (struct LookupNameResponseMessage) + name_len + rd_len; if (msg_len != exp_msg_len) { GNUNET_break (0); return GNUNET_SYSERR; } - GNUNET_break (0 == ntohs (msg->reserved)); memset (&pubdummy, '\0', sizeof (pubdummy)); if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy))))) { @@ -589,13 +588,13 @@ manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze, /* handle different message type */ switch (type) { - case GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE: - if (size < sizeof (struct ZoneIterationResponseMessage)) + case GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE: + if (size < sizeof (struct LookupNameResponseMessage)) { GNUNET_break (0); return GNUNET_SYSERR; } - return handle_zone_iteration_response (ze, (const struct ZoneIterationResponseMessage *) msg, size); + return handle_zone_iteration_response (ze, (const struct LookupNameResponseMessage *) msg, size); default: GNUNET_break (0); return GNUNET_SYSERR;