-new api
authorChristian Grothoff <christian@grothoff.org>
Thu, 1 Mar 2012 10:08:51 +0000 (10:08 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 1 Mar 2012 10:08:51 +0000 (10:08 +0000)
src/include/block_gns.h
src/include/gnunet_namestore_service.h

index 4514acf6b6e07e6544bd76e95bb304578c914df2..04dcac3bca4146661378583607675e4e1235e9d3 100644 (file)
@@ -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
index 1302644187f2fbe3f65d8cf9b86cac28d756dff3..5616225dfad0647a38e9aaca9a02a60e54277557 100644 (file)
@@ -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