-renaming gnunet-gns to gnunet-namestore
[oweals/gnunet.git] / src / namestore / namestore.h
index ab0da612647ae777e919b5d0208eaa98e54b0490..f8aa71f0eda17dbbc2ed6ecd160347b083022532 100644 (file)
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 441
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 442
 
+#define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 443
+
+/**
+ * Sign name and records
+ *
+ * @param key the private key
+ * @param name the name
+ * @param rd record data
+ * @param rd_count number of records
+ *
+ * @return the signature
+ */
+struct GNUNET_CRYPTO_RsaSignature *
+GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count);
+
+/**
+ * Compares if two records are equal
+ *
+ * @param a record
+ * @param b record
+ *
+ * @return GNUNET_YES or GNUNET_NO
+ */
+int
+GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
+                              const struct GNUNET_NAMESTORE_RecordData *b);
 
 GNUNET_NETWORK_STRUCT_BEGIN
 /**
@@ -87,6 +113,25 @@ struct StartMessage
 
 };
 
+/**
+ * Connect to namestore service.  FIXME: UNNECESSARY.
+ */
+struct DisconnectMessage
+{
+
+  /**
+   * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Drop namestore?
+   * GNUNET_YES or _NO in NBO
+   */
+  uint32_t drop;
+};
+
+
 /**
  * Generic namestore message with op id
  */
@@ -141,6 +186,8 @@ struct LookupNameResponseMessage
 
   uint16_t rd_len;
 
+  uint16_t rd_count;
+
   int32_t contains_sig;
 
   /* Requested record type */
@@ -167,6 +214,9 @@ struct RecordPutMessage
   /* Length of serialized rd data */
   uint16_t rd_len;
 
+  /* Number of records contained */
+  uint16_t rd_count;
+
   /* Length of pubkey */
   uint16_t key_len;
 
@@ -220,6 +270,9 @@ struct RecordCreateMessage
   /* Record data length */
   uint16_t rd_len;
 
+  /* Record count */
+  uint16_t rd_count;
+
   /* private key length */
   uint16_t pkey_len;
 };
@@ -239,9 +292,9 @@ struct RecordCreateResponseMessage
   /* Contenct starts here */
 
   /**
-   *  name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
+   *  name length: GNUNET_NO already existsw, GNUNET_YES on success, GNUNET_SYSERR error
    */
-  uint16_t op_result;
+  int16_t op_result;
 
 
 };
@@ -260,10 +313,17 @@ struct RecordRemoveMessage
 
   /* Contenct starts here */
 
-  /* name length */
+  /* Name length */
   uint16_t name_len;
 
-  struct GNUNET_CRYPTO_RsaSignature signature;
+  /* Length of serialized rd data */
+  uint16_t rd_len;
+
+  /* Number of records contained */
+  uint16_t rd_count;
+
+  /* Length of pubkey */
+  uint16_t key_len;
 };
 GNUNET_NETWORK_STRUCT_END
 
@@ -282,7 +342,12 @@ struct RecordRemoveResponseMessage
   /* Contenct starts here */
 
   /**
-   *  name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
+   *  result:
+   *  0 : successful
+   *  1 : no records for entry
+   *  2 : Could not find record to remove
+   *  3 : Failed to create new signature
+   *  4 : Failed to put new set of records in database
    */
   uint16_t op_result;
 };