r.flags = htonl (GNUNET_NAMESTORE_RF_AUTHORITY);
request->qe = GNUNET_NAMESTORE_record_create (ns,
fcfs_zone_pkey,
+ GNUNET_TIME_absolute_get_forever(),
request->domain_name,
&r,
&put_continuation,
struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_RsaPrivateKey *key,
+ const struct GNUNET_TIME_Absolute expire,
const char *name,
const struct GNUNET_NAMESTORE_RecordData *rd,
GNUNET_NAMESTORE_ContinuationWithStatus cont,
GNUNET_NAMESTORE_record_create (namestore_handle,
alice_key,
+ GNUNET_TIME_absolute_get_forever(),
TEST_AUTHORITY_NAME,
&rd,
&put_dht,
GNUNET_NAMESTORE_record_create (namestore_handle,
alice_key,
+ GNUNET_TIME_absolute_get_forever(),
TEST_AUTHORITY_NAME,
&rd,
NULL,
GNUNET_NAMESTORE_record_create (namestore_handle,
alice_key,
+ GNUNET_TIME_absolute_get_forever(),
TEST_RECORD_NAME,
&rd,
&finish_testing,
GNUNET_NAMESTORE_record_create (namestore_handle,
alice_key,
+ GNUNET_TIME_absolute_get_forever(),
"bob",
&rd,
NULL,
rd.data = &alice_pkey;
GNUNET_NAMESTORE_record_create (namestore_handle,
bob_key,
+ GNUNET_TIME_absolute_get_forever(),
"alice",
&rd,
NULL,
GNUNET_NAMESTORE_record_create (namestore_handle,
bob_key,
+ GNUNET_TIME_absolute_get_forever(),
"www",
&rd,
NULL,
*
* @param h handle to the namestore
* @param pkey private key of the zone
+ * @param expire block expiration time
* @param name name that is being mapped (at most 255 characters long)
* @param rd record data to store
* @param cont continuation to call when done
*/
struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
- const char *name,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- GNUNET_NAMESTORE_ContinuationWithStatus cont,
- void *cont_cls);
+ const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
+ const struct GNUNET_TIME_Absolute expire,
+ const char *name,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ GNUNET_NAMESTORE_ContinuationWithStatus cont,
+ void *cont_cls);
/**
* Desired expiration time.
*/
static char *expirationstring;
-
+
+/**
+ * Desired block expiration time.
+ */
+static char *blockexpirationstring;
/**
* Task run on shutdown. Cleans up everything.
void *data = NULL;
size_t data_size = 0;
struct GNUNET_TIME_Relative etime;
+ struct GNUNET_TIME_Relative btime;
struct GNUNET_NAMESTORE_RecordData rd;
if (NULL == keyfile)
GNUNET_SCHEDULER_shutdown ();
return;
}
+ if (NULL != blockexpirationstring)
+ {
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_fancy_time_to_relative (blockexpirationstring,
+ &btime))
+ {
+ fprintf (stderr,
+ _("Invalid time format `%s'\n"),
+ blockexpirationstring);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ } else if (add | del)
+ {
+ fprintf (stderr,
+ _("Missing option `%s' for operation `%s'\n"),
+ "-b", _("add/del"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
if (add)
{
if (NULL == name)
rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always...
add_qe = GNUNET_NAMESTORE_record_create (ns,
zone_pkey,
+ GNUNET_TIME_relative_to_absolute (btime),
name,
&rd,
&add_continuation,
rd.record_type = type;
rd.expiration = GNUNET_TIME_relative_to_absolute (etime);
rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; // FIXME: not always...
- del_qe = GNUNET_NAMESTORE_record_create (ns,
+ del_qe = GNUNET_NAMESTORE_record_remove (ns,
zone_pkey,
name,
&rd,
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'a', "add", NULL,
gettext_noop ("add record"), 0,
- &GNUNET_GETOPT_set_one, &add},
+ &GNUNET_GETOPT_set_one, &add},
+ {'b', "name-expiration", "TIME",
+ gettext_noop ("expiration time for name to use (for adding only)"), 1,
+ &GNUNET_GETOPT_set_string, &blockexpirationstring},
{'d', "delete", NULL,
gettext_noop ("delete record"), 0,
&GNUNET_GETOPT_set_one, &del},
gettext_noop ("display records"), 0,
&GNUNET_GETOPT_set_one, &list},
{'e', "expiration", "TIME",
- gettext_noop ("expiration time to use (for adding only)"), 1,
+ gettext_noop ("expiration time for record to use (for adding only)"), 1,
&GNUNET_GETOPT_set_string, &expirationstring},
{'n', "name", "NAME",
gettext_noop ("name of the record to add/delete/display"), 1,
GNUNET_free (no);
}
+
GNUNET_SERVER_client_drop(nc->client);
GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
GNUNET_free (nc);
struct CreateRecordContext * crc = cls;
struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
struct GNUNET_NAMESTORE_RecordData *rd_new = NULL;
+ struct GNUNET_TIME_Absolute block_expiration;
int res;
int exist = GNUNET_SYSERR;
int update = GNUNET_NO;
}
}
+ block_expiration = GNUNET_TIME_absolute_max(crc->expire, expire);
+ if (block_expiration.abs_value != expire.abs_value)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updated block expiration time\n");
+
+
/* Database operation */
GNUNET_assert ((rd_new != NULL) && (rd_count_new > 0));
res = GSN_database->put_records(GSN_database->cls,
(const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) crc->pubkey,
- crc->expire,
+ block_expiration,
crc->name,
rd_count_new, rd_new,
signature_new);
}
struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+
res = GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_ser, rd_count, rd);
if ((res != GNUNET_OK) || (rd_count != 1))
{
GNUNET_CRYPTO_rsa_key_get_public(pkey, &pub);
GNUNET_CRYPTO_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+ crc.expire = GNUNET_TIME_absolute_ntoh(rp_msg->expire);
+ crc.res = GNUNET_SYSERR;
crc.pkey = pkey;
crc.pubkey = &pub;
crc.rd = rd;
GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
-
res = GSN_database->iterate_records (GSN_database->cls, zone_tmp , NULL, zi->offset , &zone_iteration_proc, zi);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
*
* @param h handle to the namestore
* @param pkey private key of the zone
+ * @param expire block expiration time
* @param name name that is being mapped (at most 255 characters long)
* @param rd record data to store
* @param cont continuation to call when done
struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_RsaPrivateKey *pkey,
+ const struct GNUNET_TIME_Absolute expire,
const char *name,
const struct GNUNET_NAMESTORE_RecordData *rd,
GNUNET_NAMESTORE_ContinuationWithStatus cont,
msg->rd_count = htons (1);
msg->rd_len = htons (rd_ser_len);
msg->pkey_len = htons (key_len);
+ msg->expire = GNUNET_TIME_absolute_hton(expire);
memcpy (pkey_tmp, pkey_enc, key_len);
memcpy (name_tmp, name, name_len);
memcpy (rd_tmp, rd_ser, rd_ser_len);
UNIXPATH = /tmp/gnunet-p1-service-arm.sock
[namestore]
-#PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --leak-check=full --track-origins=yes
AUTOSTART = YES
UNIXPATH = /tmp/gnunet-service-namestore.sock
UNIX_MATCH_UID = YES
s_second_record->data_size = TEST_CREATE_RECORD_DATALEN;
memset ((char *) s_second_record->data, TEST_CREATE_RECORD_DATA, TEST_CREATE_RECORD_DATALEN);
- GNUNET_NAMESTORE_record_create (nsh, privkey, name, s_second_record, &create_second_cont, name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), name, s_second_record, &create_second_cont, name);
}
else
GNUNET_break (s_name != NULL);
/* create initial record */
- GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name, s_first_record, &create_first_cont, s_name);
}
static int
s_second_record->data_size = TEST_CREATE_RECORD_DATALEN;
memset ((char *) s_second_record->data, TEST_CREATE_RECORD_DATA, TEST_CREATE_RECORD_DATALEN);
- GNUNET_NAMESTORE_record_create (nsh, privkey, name, s_second_record, &create_second_cont, name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), name, s_second_record, &create_second_cont, name);
}
else
{
res = 0;
s_first_record->expiration = GNUNET_TIME_absolute_get ();
- GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_updated_cont, s_name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name, s_first_record, &create_updated_cont, s_name);
}
else
{
{
res = 0;
/* check if record was created correct */
- GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_identical_cont, s_name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name, s_first_record, &create_identical_cont, s_name);
}
else
{
GNUNET_break (s_name != NULL);
/* create initial record */
- GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name);
+ GNUNET_NAMESTORE_record_create (nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name, s_first_record, &create_first_cont, s_name);
}
static int
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name_1, s_rd_1, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
s_rd_2 = create_record(1);
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name_2, s_rd_2, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
/* name in different zone */
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name_1, s_rd_1, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
s_rd_2 = create_record(1);
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name_2, s_rd_2, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
/* name in different zone */
#define VERBOSE GNUNET_NO
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
static struct GNUNET_NAMESTORE_Handle * nsh;
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey, GNUNET_TIME_absolute_get_forever(), s_name_1, s_rd_1, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
s_rd_2 = create_record(1);
sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
- GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
+ GNUNET_NAMESTORE_record_create(nsh, privkey,GNUNET_TIME_absolute_get_forever(), s_name_2, s_rd_2, &put_cont, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
/* name in different zone */