aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-02 13:29:09 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-02 13:29:09 +0000
commit5c79d310f1b8eecdb7e6f708df17d5bf38230c7d (patch)
tree465615883783f601f1e221a272f649c3ab15a856 /src/namestore
parentbe31c5cb271233f82757b1830f07485f6293d3b4 (diff)
downloadgnunet-5c79d310f1b8eecdb7e6f708df17d5bf38230c7d.tar.gz
gnunet-5c79d310f1b8eecdb7e6f708df17d5bf38230c7d.zip
-committing relative/abs expiration time changes from a few days ago
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-service-namestore.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index a03f70d2a..99c648741 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -905,7 +905,7 @@ handle_record_put (void *cls,
905 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 905 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
906 906
907 if (GNUNET_OK != 907 if (GNUNET_OK !=
908 GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_ser, rd_count, rd)) 908 GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, rd))
909 { 909 {
910 GNUNET_break (0); 910 GNUNET_break (0);
911 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 911 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -1707,6 +1707,7 @@ zone_iteraterate_proc (void *cls,
1707 struct GNUNET_HashCode long_hash; 1707 struct GNUNET_HashCode long_hash;
1708 struct GNUNET_CRYPTO_ShortHashCode zone_hash; 1708 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
1709 struct ZoneIterationResponseMessage *zir_msg; 1709 struct ZoneIterationResponseMessage *zir_msg;
1710 struct GNUNET_TIME_Relative rt;
1710 unsigned int rd_count_filtered; 1711 unsigned int rd_count_filtered;
1711 unsigned int c; 1712 unsigned int c;
1712 size_t name_len; 1713 size_t name_len;
@@ -1714,7 +1715,6 @@ zone_iteraterate_proc (void *cls,
1714 size_t msg_size; 1715 size_t msg_size;
1715 char *name_tmp; 1716 char *name_tmp;
1716 char *rd_ser; 1717 char *rd_ser;
1717 int include;
1718 1718
1719 proc->res_iteration_finished = GNUNET_NO; 1719 proc->res_iteration_finished = GNUNET_NO;
1720 if ((NULL == zone_key) && (NULL == name)) 1720 if ((NULL == zone_key) && (NULL == name))
@@ -1736,49 +1736,49 @@ zone_iteraterate_proc (void *cls,
1736 name); 1736 name);
1737 for (c = 0; c < rd_count; c++) 1737 for (c = 0; c < rd_count; c++)
1738 { 1738 {
1739 // FIXME: new expiration flags need additional special treatment here!
1740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1741 "Record %i has flags: 0x%x must have 0x%x\n", 1740 "Record %u has flags: %x must have flags are %x, must not have flags are %x\n",
1742 c, rd[c].flags, 1741 c, rd[c].flags,
1743 proc->zi->must_have_flags); 1742 proc->zi->must_have_flags,
1744 include = GNUNET_YES; 1743 proc->zi->must_not_have_flags);
1745 /* Checking must have flags */ 1744 /* Checking must have flags, except 'relative-expiration' which is a special flag */
1746 if ((rd[c].flags & proc->zi->must_have_flags) == proc->zi->must_have_flags) 1745 if ((rd[c].flags & proc->zi->must_have_flags & (~GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
1746 != (proc->zi->must_have_flags & (~ GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)))
1747 { 1747 {
1748 /* Include */ 1748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record %u lacks 'must-have' flags: Not included\n", c);
1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record %i has flags: Include \n", c); 1749 continue;
1750 }
1751 else
1752 {
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record %i has flags: Not include \n", c);
1754 include = GNUNET_NO;
1755 } 1750 }
1756 1751 /* Checking must-not-have flags */
1757 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1758 "Record %i has flags: 0x%x must not have 0x%x\n",
1759 c, rd[c].flags, proc->zi->must_not_have_flags);
1760 if (0 != (rd[c].flags & proc->zi->must_not_have_flags)) 1752 if (0 != (rd[c].flags & proc->zi->must_not_have_flags))
1761 { 1753 {
1762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1763 "Record %i has flags: Not include \n", c); 1755 "Record %u has 'must-not-have' flags: Not included\n", c);
1764 include = GNUNET_NO; 1756 continue;
1765 } 1757 }
1766 else 1758 rd_filtered[rd_count_filtered] = rd[c];
1759 /* convert relative to absolute expiration time unless explicitly requested otherwise */
1760 if ( (0 == (proc->zi->must_have_flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)) &&
1761 (0 != (rd[c].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)) )
1767 { 1762 {
1768 /* Include */ 1763 /* should convert relative-to-absolute expiration time */
1769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record %i has flags: Include \n", c); 1764 rt.rel_value = rd[c].expiration_time;
1765 rd_filtered[c].expiration_time = GNUNET_TIME_relative_to_absolute (rt).abs_value;
1766 rd_filtered[c].flags &= ~ GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
1770 } 1767 }
1771 if (GNUNET_YES == include) 1768 /* we NEVER keep the 'authority' flag */
1772 rd_filtered[rd_count_filtered++] = rd[c]; 1769 rd_filtered[c].flags &= ~ GNUNET_NAMESTORE_RF_AUTHORITY;
1770 rd_count_filtered++;
1773 } 1771 }
1774 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1775 "Included %u of %u records\n", 1773 "Included %u of %u records\n",
1776 rd_count_filtered, rd_count); 1774 rd_count_filtered, rd_count);
1777 1775
1778 signature = NULL; 1776 signature = NULL;
1779 if (rd_count_filtered > 0) 1777 if ( (rd_count_filtered > 0) &&
1778 (0 == (proc->zi->must_have_flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)) )
1780 { 1779 {
1781 /* compute / obtain signature */ 1780 /* compute / obtain signature, but only if we (a) have records and (b) expiration times were
1781 converted to absolute expiration times */
1782 GNUNET_CRYPTO_short_hash (zone_key, 1782 GNUNET_CRYPTO_short_hash (zone_key,
1783 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1783 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1784 &zone_hash); 1784 &zone_hash);