gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30508 - gnunet/src/gnsrecord


From: gnunet
Subject: [GNUnet-SVN] r30508 - gnunet/src/gnsrecord
Date: Mon, 4 Nov 2013 17:26:39 +0100

Author: wachs
Date: 2013-11-04 17:26:39 +0100 (Mon, 04 Nov 2013)
New Revision: 30508

Modified:
   gnunet/src/gnsrecord/gnsrecord_crypto.c
Log:
implementation of shadow record functionality:
on decrypt iterate over included records
- if a shadow record is found, check if:
-- a non expired, non-shadow record for this record type exists: if yes: filter 
shadow record
-- shadow record is expired
if not:
- remove shadow flag and include record



Modified: gnunet/src/gnsrecord/gnsrecord_crypto.c
===================================================================
--- gnunet/src/gnsrecord/gnsrecord_crypto.c     2013-11-04 15:12:57 UTC (rev 
30507)
+++ gnunet/src/gnsrecord/gnsrecord_crypto.c     2013-11-04 16:26:39 UTC (rev 
30508)
@@ -223,6 +223,7 @@
       struct GNUNET_GNSRECORD_Data rd[rd_count];
       unsigned int i;
       unsigned int j;
+      unsigned int k;
       struct GNUNET_TIME_Absolute now;
 
       if (GNUNET_OK !=
@@ -245,8 +246,32 @@
           GNUNET_break_op (0);
           continue;
         }
-        if (rd[i].expiration_time >= now.abs_value_us)
+
+        if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))
         {
+          int include_record = GNUNET_YES;
+          /* Shadow record, figure out if we have a not expired active record 
*/
+          for (k=0;k<rd_count;k++)
+          {
+            if (k == i)
+              continue;
+            if ((rd[k].record_type == rd[i].record_type) &&
+                (rd[k].expiration_time >= now.abs_value_us) &&
+                (rd[i].expiration_time >= now.abs_value_us) &&
+                (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)))
+                include_record = GNUNET_NO; /* We have a non-expired, 
non-shadow record of the same type */
+          }
+          if (GNUNET_YES == include_record)
+          {
+            rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW_RECORD; /* Remove Flag */
+            if (j != i)
+              rd[j] = rd[i];
+            j++;
+          }
+        }
+        else if (rd[i].expiration_time >= now.abs_value_us)
+        {
+          /* Include this record */
           if (j != i)
             rd[j] = rd[i];
           j++;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]