diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-04 16:26:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-04 16:26:39 +0000 |
commit | 90d532b2a3770ba8e34135484d303c6f53dbb820 (patch) | |
tree | 7b9307cf1dda471be4185df4bf00e7bc47a5b399 /src/gnsrecord/gnsrecord_crypto.c | |
parent | da13e727041d9f0552095c2e3d56f2c79136ad3d (diff) | |
download | gnunet-90d532b2a3770ba8e34135484d303c6f53dbb820.tar.gz gnunet-90d532b2a3770ba8e34135484d303c6f53dbb820.zip |
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
Diffstat (limited to 'src/gnsrecord/gnsrecord_crypto.c')
-rw-r--r-- | src/gnsrecord/gnsrecord_crypto.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c index bc3f07c1e..a83a1c0cd 100644 --- a/src/gnsrecord/gnsrecord_crypto.c +++ b/src/gnsrecord/gnsrecord_crypto.c | |||
@@ -223,6 +223,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
223 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 223 | struct GNUNET_GNSRECORD_Data rd[rd_count]; |
224 | unsigned int i; | 224 | unsigned int i; |
225 | unsigned int j; | 225 | unsigned int j; |
226 | unsigned int k; | ||
226 | struct GNUNET_TIME_Absolute now; | 227 | struct GNUNET_TIME_Absolute now; |
227 | 228 | ||
228 | if (GNUNET_OK != | 229 | if (GNUNET_OK != |
@@ -245,8 +246,32 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
245 | GNUNET_break_op (0); | 246 | GNUNET_break_op (0); |
246 | continue; | 247 | continue; |
247 | } | 248 | } |
248 | if (rd[i].expiration_time >= now.abs_value_us) | 249 | |
250 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) | ||
251 | { | ||
252 | int include_record = GNUNET_YES; | ||
253 | /* Shadow record, figure out if we have a not expired active record */ | ||
254 | for (k=0;k<rd_count;k++) | ||
255 | { | ||
256 | if (k == i) | ||
257 | continue; | ||
258 | if ((rd[k].record_type == rd[i].record_type) && | ||
259 | (rd[k].expiration_time >= now.abs_value_us) && | ||
260 | (rd[i].expiration_time >= now.abs_value_us) && | ||
261 | (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) | ||
262 | include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */ | ||
263 | } | ||
264 | if (GNUNET_YES == include_record) | ||
265 | { | ||
266 | rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW_RECORD; /* Remove Flag */ | ||
267 | if (j != i) | ||
268 | rd[j] = rd[i]; | ||
269 | j++; | ||
270 | } | ||
271 | } | ||
272 | else if (rd[i].expiration_time >= now.abs_value_us) | ||
249 | { | 273 | { |
274 | /* Include this record */ | ||
250 | if (j != i) | 275 | if (j != i) |
251 | rd[j] = rd[i]; | 276 | rd[j] = rd[i]; |
252 | j++; | 277 | j++; |