/*
This file is part of GNUnet.
- (C) 2009-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @return converted result
*/
char *
-GNUNET_NAMESTORE_normalize_string (const char *src)
+GNUNET_GNSRECORD_string_to_lowercase (const char *src)
{
- GNUNET_assert (NULL != src);
- char *res = strdup (src);
- /* normalize */
- GNUNET_STRINGS_utf8_tolower(src, &res);
+ char *res;
+
+ res = GNUNET_strdup (src);
+ GNUNET_STRINGS_utf8_tolower (src, res);
return res;
}
* NOT reentrant!
*
* @param z the zone key
- * @return string form; will be overwritten by next call to #GNUNET_NAMESTORE_z2s
+ * @return string form; will be overwritten by next call to #GNUNET_GNSRECORD_z2s
*/
const char *
-GNUNET_NAMESTORE_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z)
+GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z)
{
static char buf[sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) * 8];
char *end;
* @return #GNUNET_YES if the records are equal or #GNUNET_NO if they are not
*/
int
-GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
- const struct GNUNET_NAMESTORE_RecordData *b)
+GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
+ const struct GNUNET_GNSRECORD_Data *b)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Comparing records\n");
b->expiration_time);
return GNUNET_NO;
}
- if ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS)
- != (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS))
+ if ((a->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS)
+ != (b->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Flags %lu (%lu) != %lu (%lu)\n", a->flags,
- a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS, b->flags,
- b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS);
+ a->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS, b->flags,
+ b->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS);
return GNUNET_NO;
}
if (a->data_size != b->data_size)
* @return absolute expiration time
*/
struct GNUNET_TIME_Absolute
-GNUNET_NAMESTORE_record_get_expiration_time (unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd)
{
unsigned int c;
+ unsigned int c2;
struct GNUNET_TIME_Absolute expire;
struct GNUNET_TIME_Absolute at;
struct GNUNET_TIME_Relative rt;
+ struct GNUNET_TIME_Absolute at_shadow;
+ struct GNUNET_TIME_Relative rt_shadow;
if (NULL == rd)
return GNUNET_TIME_UNIT_ZERO_ABS;
expire = GNUNET_TIME_UNIT_FOREVER_ABS;
for (c = 0; c < rd_count; c++)
{
- if (0 != (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
+ if (0 != (rd[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
{
rt.rel_value_us = rd[c].expiration_time;
at = GNUNET_TIME_relative_to_absolute (rt);
{
at.abs_value_us = rd[c].expiration_time;
}
+
+ for (c2 = 0; c2 < rd_count; c2++)
+ {
+ /* Check for shadow record */
+ if ((c == c2) ||
+ (rd[c].record_type != rd[c2].record_type) ||
+ (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)))
+ continue;
+ /* We have a shadow record */
+ if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
+ {
+ rt_shadow.rel_value_us = rd[2].expiration_time;
+ at_shadow = GNUNET_TIME_relative_to_absolute (rt_shadow);
+ }
+ else
+ {
+ at_shadow.abs_value_us = rd[c2].expiration_time;
+ }
+ at = GNUNET_TIME_absolute_max (at, at_shadow);
+ }
expire = GNUNET_TIME_absolute_min (at, expire);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
* #GNUNET_NO if not
*/
int
-GNUNET_NAMESTORE_is_expired (const struct GNUNET_NAMESTORE_RecordData *rd)
+GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd)
{
struct GNUNET_TIME_Absolute at;
- if (0 != (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
+ if (0 != (rd->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
return GNUNET_NO;
at.abs_value_us = rd->expiration_time;
return (0 == GNUNET_TIME_absolute_get_remaining (at).rel_value_us) ? GNUNET_YES : GNUNET_NO;
* key in an encoding suitable for DNS labels.
*/
const char *
-GNUNET_NAMESTORE_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
+GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
{
static char ret[128];
char *pkeys;
* @return #GNUNET_SYSERR if @a zkey has the wrong syntax
*/
int
-GNUNET_NAMESTORE_zkey_to_pkey (const char *zkey,
+GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
{
char *cpy;