json_t *ret;
buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk,
- &buf);
+ (void**) &buf);
ret = GNUNET_JSON_from_data (buf,
buf_len);
GNUNET_free (buf);
json_t *ret;
buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig,
- &buf);
+ (void**) &buf);
ret = GNUNET_JSON_from_data (buf,
buf_len);
GNUNET_free (buf);
const struct GNUNET_GNSRECORD_Data *rd,
unsigned int rd_count)
{
- struct GNUNET_TIME_Absolute expiration_time;
+ struct GNUNET_TIME_Absolute abs_exp;
+ struct GNUNET_TIME_Relative rel_exp;
const char *expiration_time_str;
const char *record_type_str;
char *value_str;
value_str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
rd[i].data,
rd[i].data_size);
- expiration_time = GNUNET_GNSRECORD_record_get_expiration_time (1, &rd[i]);
- expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (
- expiration_time);
+ if (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd[i].flags)
+ {
+ rel_exp.rel_value_us = rd[i].expiration_time;
+ expiration_time_str = GNUNET_STRINGS_relative_time_to_string (rel_exp,
+ GNUNET_NO);
+ } else {
+ abs_exp.abs_value_us = rd[i].expiration_time;
+ expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (abs_exp);
+ }
record_type_str = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Packing %s %s %s %d\n",
value_str, record_type_str, expiration_time_str, rd[i].flags);
- record = json_pack ("{s:s,s:s,s:s,s:i}",
+ record = json_pack ("{s:s,s:s,s:s,s:b,s:b,s:b,s:b}",
"value",
value_str,
"record_type",
record_type_str,
"expiration_time",
expiration_time_str,
- "flag",
- rd[i].flags);
+ "private",
+ rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE,
+ "relative_expiration",
+ rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION,
+ "supplemental",
+ rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL,
+ "shadow",
+ rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD);
GNUNET_free (value_str);
if (NULL == record)
{
#define GNUNET_JSON_GNSRECORD_RECORD_DATA "data"
#define GNUNET_JSON_GNSRECORD_TYPE "record_type"
#define GNUNET_JSON_GNSRECORD_EXPIRATION_TIME "expiration_time"
-#define GNUNET_JSON_GNSRECORD_FLAG "flag"
+#define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE "private"
+#define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL "supplemental"
+#define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE "relative_expiration"
+#define GNUNET_JSON_GNSRECORD_FLAG_SHADOW "shadow"
#define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name"
#define GNUNET_JSON_GNSRECORD_NEVER "never"
const char *value;
const char *record_type;
const char *expiration_time;
- int flag;
+ int private;
+ int supplemental;
+ int rel_exp;
+ int shadow;
int unpack_state = 0;
// interpret single gns record
unpack_state = json_unpack (data,
- "{s:s, s:s, s:s, s?:i!}",
+ "{s:s, s:s, s:s, s:b, s:b, s:b, s:b}",
GNUNET_JSON_GNSRECORD_VALUE,
&value,
GNUNET_JSON_GNSRECORD_TYPE,
&record_type,
GNUNET_JSON_GNSRECORD_EXPIRATION_TIME,
&expiration_time,
- GNUNET_JSON_GNSRECORD_FLAG,
- &flag);
+ GNUNET_JSON_GNSRECORD_FLAG_PRIVATE,
+ &private,
+ GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL,
+ &supplemental,
+ GNUNET_JSON_GNSRECORD_FLAG_RELATIVE,
+ &rel_exp,
+ GNUNET_JSON_GNSRECORD_FLAG_SHADOW,
+ &shadow);
if (0 != unpack_state)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
{
rd->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
}
- else if (GNUNET_OK ==
+ else if ((1 != rel_exp) &&
+ (GNUNET_OK ==
GNUNET_STRINGS_fancy_time_to_absolute (expiration_time,
- &abs_expiration_time))
+ &abs_expiration_time)))
{
rd->expiration_time = abs_expiration_time.abs_value_us;
}
GNUNET_STRINGS_fancy_time_to_relative (expiration_time,
&rel_expiration_time))
{
+ rd->flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
rd->expiration_time = rel_expiration_time.rel_value_us;
}
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expiration time invalid\n");
return GNUNET_SYSERR;
}
- rd->flags = (enum GNUNET_GNSRECORD_Flags) flag;
+ if (1 == private)
+ rd->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+ if (1 == supplemental)
+ rd->flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
+ if (1 == shadow)
+ rd->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
return GNUNET_OK;
}