From 5d0de68e3f7785eba7693f5d4dd3c83a7a94a684 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 1 Mar 2012 10:08:51 +0000 Subject: [PATCH] -new api --- src/include/block_gns.h | 11 ++++---- src/include/gnunet_namestore_service.h | 35 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/include/block_gns.h b/src/include/block_gns.h index 4514acf6b..04dcac3bc 100644 --- a/src/include/block_gns.h +++ b/src/include/block_gns.h @@ -64,6 +64,11 @@ struct GNSRecordBlock struct GNSNameRecordBlock { + /** + * The public key of the authority + */ + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; + /** * GNUNET_RSA_Signature using RSA-key generated from the records. */ @@ -74,11 +79,6 @@ struct GNSNameRecordBlock */ struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; - /** - * The public key of the authority - */ - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; - /* number of records that follow */ uint32_t rd_count GNUNET_PACKED; @@ -86,7 +86,6 @@ struct GNSNameRecordBlock /* variable-size GNSRecordBlocks follows here */ - }; GNUNET_NETWORK_STRUCT_END diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 130264418..5616225df 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h @@ -357,6 +357,41 @@ void GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe); + +/* convenience APIs for serializing / deserializing GNS records */ + +/** + * Calculate how many bytes we will need to serialize the given + * records. + */ +size_t +GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd); + +/** + * Serialize the given records to the given destination buffer. + */ +ssize_t +GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, + const struct GNUNET_NAMESTORE_RecordData *rd, + size_t dest_size, + char *dest); + + +/** + * @param rd_count expected number of records in 'src' + * @param dest array of 'rd_count' entries for storing record data; + * 'data' values in 'dest' will point into 'src' and will thus + * become invalid if 'src' is modified + * @return GNUNET_OK on success, GNUNET_SYSERR on error + */ +int +GNUNET_NAMESTORE_records_deserialize (size_t len, + const char *src, + unsigned int rd_count, + struct GNUNET_NAMESTORE_RecordData *dest); + + #if 0 /* keep Emacsens' auto-indent happy */ { #endif -- 2.25.1