X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fgnsrecord%2Fgnsrecord_misc.c;h=15da4ea84795ea249de72f3af6a57fdc622956d4;hb=dd1927b960c7cea13733e061a11142274652ba27;hp=aee1f9fd2323fe7cb60d5e7c8f52df82786cba67;hpb=accfd6bd85274da2f19e7230c8da6b273cfb2ece;p=oweals%2Fgnunet.git diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index aee1f9fd2..15da4ea84 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009-2013 Christian Grothoff (and other contributing authors) + Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ 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. */ /** @@ -45,10 +45,10 @@ char * 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; } @@ -153,9 +153,12 @@ 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; @@ -171,6 +174,26 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count, { 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,