#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 439
-#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 439
-#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 439
-#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 439
+#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 440
+#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
/**
- * Connect to namestore service
+ * A GNS record serialized for network transmission.
+ * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
+ */
+struct GNUNET_NAMESTORE_NetworkRecord
+{
+ /**
+ * Expiration time for the DNS record.
+ */
+ struct GNUNET_TIME_AbsoluteNBO expiration;
+
+ /**
+ * Number of bytes in 'data'.
+ */
+ uint32_t data_size;
+
+ /**
+ * Type of the GNS/DNS record.
+ */
+ uint32_t record_type;
+
+ /**
+ * Flags for the record.
+ */
+ uint32_t flags;
+};
+
+
+
+/**
+ * Connect to namestore service. FIXME: UNNECESSARY.
*/
struct StartMessage
{
struct GNUNET_MessageHeader header;
};
-GNUNET_NETWORK_STRUCT_END
-
-GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Generic namestore message with op id
+ * Connect to namestore service. FIXME: UNNECESSARY.
*/
-struct GenericMessage
+struct DisconnectMessage
{
+
/**
- * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
+ * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT
*/
struct GNUNET_MessageHeader header;
/**
- * Operation ID in NBO
+ * Drop namestore?
+ * GNUNET_YES or _NO in NBO
*/
- uint32_t op_id;
+ uint32_t drop;
};
-GNUNET_NETWORK_STRUCT_END
/**
- * Connect to namestore service
+ * Generic namestore message with op id
*/
-GNUNET_NETWORK_STRUCT_BEGIN
-struct LookupNameMessage
+struct GNUNET_NAMESTORE_Header
{
/**
- * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME
+ * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
+ * header.size will be message size
*/
struct GNUNET_MessageHeader header;
/**
- * Operation ID in NBO
+ * Request ID in NBO
*/
- uint32_t op_id;
+ uint32_t r_id;
+};
+
+
+/**
+ * Connect to namestore service
+ */
+struct LookupNameMessage
+{
+ struct GNUNET_NAMESTORE_Header gns_header;
/* The zone */
GNUNET_HashCode zone;
/* Requested record type */
uint32_t name_len;
};
-GNUNET_NETWORK_STRUCT_END
/**
* Memory layout:
* [struct LookupNameResponseMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData][struct GNUNET_CRYPTO_RsaSignature]
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct LookupNameResponseMessage
{
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
struct GNUNET_TIME_AbsoluteNBO expire;
uint16_t name_len;
- uint16_t contains_sig;
+ uint16_t rd_len;
+
+ uint16_t rd_count;
+
+ int32_t contains_sig;
/* Requested record type */
- uint32_t rc_count;
};
-GNUNET_NETWORK_STRUCT_END
/**
* Memory layout:
* [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct RecordPutMessage
{
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/* name length */
uint16_t name_len;
- /* Requested record type */
- uint32_t rd_count;
+ /* Length of serialized rd data */
+ uint16_t rd_len;
+
+ /* Number of records contained */
+ uint16_t rd_count;
+
+ /* Length of pubkey */
+ uint16_t key_len;
struct GNUNET_TIME_AbsoluteNBO expire;
struct GNUNET_CRYPTO_RsaSignature signature;
};
-GNUNET_NETWORK_STRUCT_END
+
/**
* Put a record to the namestore response
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct RecordPutResponseMessage
{
/**
*/
uint16_t op_result;
};
-GNUNET_NETWORK_STRUCT_END
/**
- * Put a record to the namestore
+ * Create a record and put it to the namestore
* Memory layout:
- * [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
+ * [struct RecordCreateMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct RecordCreateMessage
{
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/* name length */
uint16_t name_len;
- struct GNUNET_CRYPTO_RsaSignature signature;
+ /* Record data length */
+ uint16_t rd_len;
+
+ /* Record count */
+ uint16_t rd_count;
+
+ /* private key length */
+ uint16_t pkey_len;
};
-GNUNET_NETWORK_STRUCT_END
/**
* Create a record to the namestore response
* Memory layout:
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct RecordCreateResponseMessage
{
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* 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;
+
+
};
-GNUNET_NETWORK_STRUCT_END
/**
* Remove a record from the namestore
* Memory layout:
* [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData]
*/
-GNUNET_NETWORK_STRUCT_BEGIN
struct RecordRemoveMessage
{
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* 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
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* 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;
};
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
};
GNUNET_NETWORK_STRUCT_END
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
};
GNUNET_NETWORK_STRUCT_END
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
*/
- struct GNUNET_MessageHeader header;
+ struct GNUNET_NAMESTORE_Header gns_header;
+
+ struct GNUNET_TIME_AbsoluteNBO expire;
+
+ uint16_t name_len;
+
+ uint16_t contains_sig;
+
+ /* Record data length */
+ uint16_t rd_len;
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
};
GNUNET_NETWORK_STRUCT_END