aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gnsrecord/gnsrecord_misc.c27
-rw-r--r--src/include/gnunet_gnsrecord_lib.h57
-rw-r--r--src/include/gnunet_namestore_service.h112
-rw-r--r--src/namestore/gnunet-service-namestore.c144
-rw-r--r--src/namestore/namestore.h28
-rw-r--r--src/namestore/namestore_api.c83
-rw-r--r--src/namestore/namestore_api_monitor.c76
-rw-r--r--src/zonemaster/gnunet-service-zonemaster-monitor.c50
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c51
9 files changed, 416 insertions, 212 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 5e3bbdb8c..880fc68c6 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -421,7 +421,7 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
421 rd_public, 421 rd_public,
422 unsigned int *rd_count_public, 422 unsigned int *rd_count_public,
423 struct GNUNET_TIME_Absolute *expiry, 423 struct GNUNET_TIME_Absolute *expiry,
424 int include_private, 424 enum GNUNET_GNSRECORD_Filter filter,
425 char **emsg) 425 char **emsg)
426{ 426{
427 struct GNUNET_TIME_Absolute now; 427 struct GNUNET_TIME_Absolute now;
@@ -539,7 +539,7 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
539 539
540 /* Ignore private records for public record set */ 540 /* Ignore private records for public record set */
541 541
542 if ((GNUNET_NO == include_private) && 542 if ((0 != (filter & GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE)) &&
543 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))) 543 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)))
544 continue; 544 continue;
545 /* Skip expired records */ 545 /* Skip expired records */
@@ -561,27 +561,4 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
561} 561}
562 562
563 563
564enum GNUNET_GenericReturnValue
565GNUNET_GNSRECORD_convert_records_for_export (const char *label,
566 const struct
567 GNUNET_GNSRECORD_Data *rd,
568 unsigned int rd_count,
569 struct GNUNET_GNSRECORD_Data *
570 rd_public,
571 unsigned int *rd_count_public,
572 struct GNUNET_TIME_Absolute *expiry,
573 char **emsg)
574{
575 return GNUNET_GNSRECORD_normalize_record_set (label,
576 rd,
577 rd_count,
578 rd_public,
579 rd_count_public,
580 expiry,
581 GNUNET_NO,
582 emsg);
583
584}
585
586
587/* end of gnsrecord_misc.c */ 564/* end of gnsrecord_misc.c */
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 1ff348b71..21fb610f3 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -124,6 +124,35 @@ enum GNUNET_GNSRECORD_Flags
124#define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) 124#define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
125}; 125};
126 126
127/**
128 * Filter for GNUNET_GNSRECORD_normalize_record_set().
129 */
130enum GNUNET_GNSRECORD_Filter
131{
132 /**
133 * No filter flags set.
134 * Private and public records are returned,
135 * maintenance records (TOMBSTONE etc) are not.
136 */
137 GNUNET_GNSRECORD_FILTER_NONE = 0,
138
139 /**
140 * Include maintenance records (TOMBSTONE etc).
141 */
142 GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE = 1,
143
144 /**
145 * Filter private records
146 */
147 GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE = 2,
148
149 /**
150 * Filter public records.
151 * FIXME: Not implemented
152 */
153 //GNUNET_NAMESTORE_FILTER_OMIT_PUBLIC = 4,
154};
155
127 156
128/** 157/**
129 * A GNS record. 158 * A GNS record.
@@ -725,7 +754,7 @@ GNUNET_GNSRECORD_is_critical (uint32_t type);
725 * @param rd_public where to write the converted records 754 * @param rd_public where to write the converted records
726 * @param rd_public_count number of records written to @a rd_public 755 * @param rd_public_count number of records written to @a rd_public
727 * @param min_expiry the minimum expiration of this set 756 * @param min_expiry the minimum expiration of this set
728 * @param include_private GNUNET_YES if private records should be included. 757 * @param filter the record set filter, see GNUNET_GNSRECORD_Filter.
729 * @param emsg the error message if something went wrong 758 * @param emsg the error message if something went wrong
730 * @return GNUNET_OK if set could be normalized and is consistent 759 * @return GNUNET_OK if set could be normalized and is consistent
731 */ 760 */
@@ -736,35 +765,11 @@ GNUNET_GNSRECORD_normalize_record_set (const char *label,
736 struct GNUNET_GNSRECORD_Data *rd_public, 765 struct GNUNET_GNSRECORD_Data *rd_public,
737 unsigned int *rd_count_public, 766 unsigned int *rd_count_public,
738 struct GNUNET_TIME_Absolute *min_expiry, 767 struct GNUNET_TIME_Absolute *min_expiry,
739 int include_private, 768 enum GNUNET_GNSRECORD_Filter filter,
740 char **emsg); 769 char **emsg);
741 770
742 771
743/** 772/**
744 * Convert namestore records from the internal format to that
745 * suitable for publication (removes private records).
746 *
747 * @param label the label under which this set is (supposed to be) published.
748 * @param rd input records
749 * @param rd_count size of the @a rd and @a rd_public arrays
750 * @param rd_public where to write the converted records
751 * @param rd_public_count number of records written to @a rd_public
752 * @param expiry the expiration of the block
753 * @param emsg the error message if something went wrong
754 * @return GNUNET_OK if set is consistent and can be exported
755 */
756enum GNUNET_GenericReturnValue
757GNUNET_GNSRECORD_convert_records_for_export (const char *label,
758 const struct
759 GNUNET_GNSRECORD_Data *rd,
760 unsigned int rd_count,
761 struct GNUNET_GNSRECORD_Data *
762 rd_public,
763 unsigned int *rd_count_public,
764 struct GNUNET_TIME_Absolute *expiry,
765 char **emsg);
766
767/**
768 * Check label for invalid characters. 773 * Check label for invalid characters.
769 * 774 *
770 * @param label the label to check 775 * @param label the label to check
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index 0788bc8b4..dc6aeaa69 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -198,6 +198,27 @@ typedef void
198 unsigned int rd_count, 198 unsigned int rd_count,
199 const struct GNUNET_GNSRECORD_Data *rd); 199 const struct GNUNET_GNSRECORD_Data *rd);
200 200
201/**
202 * Process a record set that was stored in the namestore.
203 * The record set expiration value takes existing TOMBSTONE records
204 * into account even if those are not returned.
205 *
206 * @param cls closure
207 * @param zone private key of the zone
208 * @param label label of the records
209 * @param rd_count number of entries in @a rd array, 0 if label was deleted
210 * @param rd array of records with data to store
211 * @param expiry the expiration of this record set.
212 */
213typedef void
214(*GNUNET_NAMESTORE_RecordSetMonitor) (void *cls,
215 const struct
216 GNUNET_IDENTITY_PrivateKey *zone,
217 const char *label,
218 unsigned int rd_count,
219 const struct GNUNET_GNSRECORD_Data *rd,
220 struct GNUNET_TIME_Absolute expiry);
221
201 222
202/** 223/**
203 * Lookup an item in the namestore. 224 * Lookup an item in the namestore.
@@ -265,6 +286,9 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe);
265 286
266 287
267/** 288/**
289 * @deprecated since 0.16.7 will be replaced in 0.18
290 * @see GNUNET_NAMESTORE_zone_iteration_start2()
291 *
268 * Starts a new zone iteration (used to periodically PUT all of our 292 * Starts a new zone iteration (used to periodically PUT all of our
269 * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle` 293 * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle`
270 * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and 294 * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and
@@ -300,6 +324,44 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
300 GNUNET_SCHEDULER_TaskCallback finish_cb, 324 GNUNET_SCHEDULER_TaskCallback finish_cb,
301 void *finish_cb_cls); 325 void *finish_cb_cls);
302 326
327/**
328 * Starts a new zone iteration (used to periodically PUT all of our
329 * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle`
330 * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and
331 * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once
332 * immediately, and then again after
333 * #GNUNET_NAMESTORE_zone_iterator_next() is invoked.
334 *
335 * On error (disconnect), @a error_cb will be invoked.
336 * On normal completion, @a finish_cb proc will be
337 * invoked.
338 *
339 * @param h handle to the namestore
340 * @param zone zone to access, NULL for all zones
341 * @param error_cb function to call on error (i.e. disconnect),
342 * the handle is afterwards invalid
343 * @param error_cb_cls closure for @a error_cb
344 * @param proc function to call on each name from the zone; it
345 * will be called repeatedly with a value (if available)
346 * @param proc_cls closure for @a proc
347 * @param finish_cb function to call on completion
348 * the handle is afterwards invalid
349 * @param finish_cb_cls closure for @a finish_cb
350 * @return an iterator handle to use for iteration
351 */
352struct GNUNET_NAMESTORE_ZoneIterator *
353GNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h,
354 const struct
355 GNUNET_IDENTITY_PrivateKey *zone,
356 GNUNET_SCHEDULER_TaskCallback error_cb,
357 void *error_cb_cls,
358 GNUNET_NAMESTORE_RecordSetMonitor proc,
359 void *proc_cls,
360 GNUNET_SCHEDULER_TaskCallback finish_cb,
361 void *finish_cb_cls,
362 enum GNUNET_GNSRECORD_Filter filter);
363
364
303 365
304/** 366/**
305 * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start 367 * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start
@@ -332,6 +394,9 @@ struct GNUNET_NAMESTORE_ZoneMonitor;
332 394
333 395
334/** 396/**
397 * @deprecated since 0.16.7 will be replaced in 0.18
398 * @see GNUNET_NAMESTORE_zone_monitor_start2()
399 *
335 * Begin monitoring a zone for changes. Will first call the @a 400 * Begin monitoring a zone for changes. Will first call the @a
336 * monitor function on all existing records in the selected zone(s) if 401 * monitor function on all existing records in the selected zone(s) if
337 * @a iterate_first is #GNUNET_YES. In any case, we will then call @a 402 * @a iterate_first is #GNUNET_YES. In any case, we will then call @a
@@ -370,6 +435,47 @@ GNUNET_NAMESTORE_zone_monitor_start (
370 GNUNET_SCHEDULER_TaskCallback sync_cb, 435 GNUNET_SCHEDULER_TaskCallback sync_cb,
371 void *sync_cb_cls); 436 void *sync_cb_cls);
372 437
438/**
439 * Begin monitoring a zone for changes. Will first call the @a
440 * monitor function on all existing records in the selected zone(s) if
441 * @a iterate_first is #GNUNET_YES. In any case, we will then call @a
442 * sync_cb, and then afterwards call the @a monitor whenever a record
443 * changes. If the namestore disconnects, the @a error_cb function is
444 * called with a disconnect event. Once the connection is
445 * re-established, the process begins from the start (depending on @a
446 * iterate_first, we will again first do all existing records, then @a
447 * sync, then updates).
448 *
449 * @param cfg configuration to use to connect to namestore
450 * @param zone zone to monitor, NULL for all zones
451 * @param iterate_first #GNUNET_YES to first iterate over all existing records,
452 * #GNUNET_NO to only return changes that happen from now on
453 * @param error_cb function to call on error (i.e. disconnect); note that
454 * unlike the other error callbacks in this API, a call to this
455 * function does NOT destroy the monitor handle, it merely signals
456 * that monitoring is down. You need to still explicitly call
457 * #GNUNET_NAMESTORE_zone_monitor_stop().
458 * @param error_cb_cls closure for @a error_cb
459 * @param monitor function to call on zone changes, with an initial limit of 1
460 * @param monitor_cls closure for @a monitor
461 * @param sync_cb function called when we're in sync with the namestore
462 * @param sync_cb_cls closure for @a sync_cb
463 * @param filter the record set filter to use
464 * @return handle to stop monitoring
465 */
466struct GNUNET_NAMESTORE_ZoneMonitor *
467GNUNET_NAMESTORE_zone_monitor_start2 (
468 const struct GNUNET_CONFIGURATION_Handle *cfg,
469 const struct GNUNET_IDENTITY_PrivateKey *zone,
470 int iterate_first,
471 GNUNET_SCHEDULER_TaskCallback error_cb,
472 void *error_cb_cls,
473 GNUNET_NAMESTORE_RecordSetMonitor monitor,
474 void *monitor_cls,
475 GNUNET_SCHEDULER_TaskCallback sync_cb,
476 void *sync_cb_cls,
477 enum GNUNET_GNSRECORD_Filter filter);
478
373 479
374/** 480/**
375 * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start 481 * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start
@@ -435,9 +541,9 @@ GNUNET_NAMESTORE_transaction_begin (struct GNUNET_NAMESTORE_Handle *h,
435 */ 541 */
436struct GNUNET_NAMESTORE_QueueEntry * 542struct GNUNET_NAMESTORE_QueueEntry *
437GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h, 543GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h,
438 GNUNET_NAMESTORE_ContinuationWithStatus 544 GNUNET_NAMESTORE_ContinuationWithStatus
439 cont, 545 cont,
440 void *cont_cls); 546 void *cont_cls);
441/** 547/**
442 * Commit a namestore transaction. 548 * Commit a namestore transaction.
443 * Saves all actions performed since #GNUNET_NAMESTORE_transaction_begin 549 * Saves all actions performed since #GNUNET_NAMESTORE_transaction_begin
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 1bfcec76b..0a3dfea25 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -85,6 +85,11 @@ struct ZoneIteration
85 struct GNUNET_IDENTITY_PrivateKey zone; 85 struct GNUNET_IDENTITY_PrivateKey zone;
86 86
87 /** 87 /**
88 * The record set filter
89 */
90 enum GNUNET_GNSRECORD_Filter filter;
91
92 /**
88 * Last sequence number in the zone iteration used to address next 93 * Last sequence number in the zone iteration used to address next
89 * result of the zone iteration in the store 94 * result of the zone iteration in the store
90 * 95 *
@@ -181,6 +186,11 @@ struct ZoneMonitor
181 struct GNUNET_IDENTITY_PrivateKey zone; 186 struct GNUNET_IDENTITY_PrivateKey zone;
182 187
183 /** 188 /**
189 * The record set filter
190 */
191 enum GNUNET_GNSRECORD_Filter filter;
192
193 /**
184 * Task active during initial iteration. 194 * Task active during initial iteration.
185 */ 195 */
186 struct GNUNET_SCHEDULER_Task *task; 196 struct GNUNET_SCHEDULER_Task *task;
@@ -717,38 +727,63 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd,
717 * @param name name 727 * @param name name
718 * @param rd_count number of records in @a rd 728 * @param rd_count number of records in @a rd
719 * @param rd array of records 729 * @param rd array of records
730 * @param filter record set filter
720 */ 731 */
721static void 732static void
722send_lookup_response (struct NamestoreClient *nc, 733send_lookup_response_with_filter (struct NamestoreClient *nc,
723 uint32_t request_id, 734 uint32_t request_id,
724 const struct GNUNET_IDENTITY_PrivateKey *zone_key, 735 const struct
725 const char *name, 736 GNUNET_IDENTITY_PrivateKey *zone_key,
726 unsigned int rd_count, 737 const char *name,
727 const struct GNUNET_GNSRECORD_Data *rd) 738 unsigned int rd_count,
739 const struct GNUNET_GNSRECORD_Data *rd,
740 enum GNUNET_GNSRECORD_Filter filter)
728{ 741{
729 struct GNUNET_MQ_Envelope *env; 742 struct GNUNET_MQ_Envelope *env;
730 struct RecordResultMessage *zir_msg; 743 struct RecordResultMessage *zir_msg;
731 struct GNUNET_GNSRECORD_Data *nick; 744 struct GNUNET_GNSRECORD_Data *nick;
732 struct GNUNET_GNSRECORD_Data *res; 745 struct GNUNET_GNSRECORD_Data *res;
746 struct GNUNET_GNSRECORD_Data rd_nf[rd_count];
747 struct GNUNET_TIME_Absolute block_exp = GNUNET_TIME_UNIT_ZERO_ABS;;
733 unsigned int res_count; 748 unsigned int res_count;
749 unsigned int rd_nf_count;
734 size_t name_len; 750 size_t name_len;
735 ssize_t rd_ser_len; 751 ssize_t rd_ser_len;
736 char *name_tmp; 752 char *name_tmp;
737 char *rd_ser; 753 char *rd_ser;
754 char *emsg;
738 755
739 nick = get_nick_record (nc, zone_key); 756 nick = get_nick_record (nc, zone_key);
740 GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (rd_count, rd)); 757 GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (rd_count, rd));
741 758
759 if (GNUNET_OK != GNUNET_GNSRECORD_normalize_record_set (name,
760 rd,
761 rd_count,
762 rd_nf,
763 &rd_nf_count,
764 &block_exp,
765 filter,
766 &emsg))
767 {
768 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
769 GNUNET_free (emsg);
770 GNUNET_assert (0);
771 }
772
773 /**
774 * FIXME if we ever support GNUNET_NAMESTORE_OMIT_PUBLIC,
775 * we need to omit adding this public record here
776 */
742 if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT))) 777 if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT)))
743 { 778 {
744 nick->flags = 779 nick->flags =
745 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 780 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
746 merge_with_nick_records (nick, rd_count, rd, &res_count, &res); 781 merge_with_nick_records (nick, rd_nf_count, rd_nf, &res_count, &res);
747 } 782 }
748 else 783 else
749 { 784 {
750 res_count = rd_count; 785 res_count = rd_nf_count;
751 res = (struct GNUNET_GNSRECORD_Data *) rd; 786 res = (struct GNUNET_GNSRECORD_Data *) rd_nf;
752 } 787 }
753 if (NULL != nick) 788 if (NULL != nick)
754 GNUNET_free (nick); 789 GNUNET_free (nick);
@@ -782,6 +817,7 @@ send_lookup_response (struct NamestoreClient *nc,
782 zir_msg->rd_count = htons (res_count); 817 zir_msg->rd_count = htons (res_count);
783 zir_msg->rd_len = htons ((uint16_t) rd_ser_len); 818 zir_msg->rd_len = htons ((uint16_t) rd_ser_len);
784 zir_msg->private_key = *zone_key; 819 zir_msg->private_key = *zone_key;
820 zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp);
785 name_tmp = (char *) &zir_msg[1]; 821 name_tmp = (char *) &zir_msg[1];
786 GNUNET_memcpy (name_tmp, name, name_len); 822 GNUNET_memcpy (name_tmp, name, name_len);
787 rd_ser = &name_tmp[name_len]; 823 rd_ser = &name_tmp[name_len];
@@ -796,10 +832,33 @@ send_lookup_response (struct NamestoreClient *nc,
796 1, 832 1,
797 GNUNET_NO); 833 GNUNET_NO);
798 GNUNET_MQ_send (nc->mq, env); 834 GNUNET_MQ_send (nc->mq, env);
799 if (rd != res) 835 if (rd_nf != res)
800 GNUNET_free (res); 836 GNUNET_free (res);
801} 837}
802 838
839/**
840 * Generate a `struct LookupNameResponseMessage` and send it to the
841 * given client using the given notification context.
842 *
843 * @param nc client to unicast to
844 * @param request_id request ID to use
845 * @param zone_key zone key of the zone
846 * @param name name
847 * @param rd_count number of records in @a rd
848 * @param rd array of records
849 */
850static void
851send_lookup_response (struct NamestoreClient *nc,
852 uint32_t request_id,
853 const struct
854 GNUNET_IDENTITY_PrivateKey *zone_key,
855 const char *name,
856 unsigned int rd_count,
857 const struct GNUNET_GNSRECORD_Data *rd)
858{
859 send_lookup_response_with_filter (nc, request_id, zone_key, name,
860 rd_count, rd, GNUNET_GNSRECORD_FILTER_NONE);
861}
803 862
804/** 863/**
805 * Send response to the store request to the client. 864 * Send response to the store request to the client.
@@ -995,7 +1054,7 @@ refresh_block (struct NamestoreClient *nc,
995 cop->nc = nc; 1054 cop->nc = nc;
996 cop->zi = zi; 1055 cop->zi = zi;
997 if (NULL != zi) 1056 if (NULL != zi)
998 zi->cache_ops ++; 1057 zi->cache_ops++;
999 cop->rid = rid; 1058 cop->rid = rid;
1000 GNUNET_CONTAINER_DLL_insert (cop_head, cop_tail, cop); 1059 GNUNET_CONTAINER_DLL_insert (cop_head, cop_tail, cop);
1001 cop->qe = GNUNET_NAMECACHE_block_cache (namecache, 1060 cop->qe = GNUNET_NAMECACHE_block_cache (namecache,
@@ -1081,12 +1140,13 @@ continue_store_activity (struct StoreActivity *sa)
1081 "Notifying monitor about changes under label `%s'\n", 1140 "Notifying monitor about changes under label `%s'\n",
1082 sa->conv_name); 1141 sa->conv_name);
1083 zm->limit--; 1142 zm->limit--;
1084 send_lookup_response (zm->nc, 1143 send_lookup_response_with_filter (zm->nc,
1085 0, 1144 0,
1086 &rp_msg->private_key, 1145 &rp_msg->private_key,
1087 sa->conv_name, 1146 sa->conv_name,
1088 rd_count, 1147 rd_count,
1089 rd); 1148 rd,
1149 zm->filter);
1090 sa->zm_pos = zm->next; 1150 sa->zm_pos = zm->next;
1091 } 1151 }
1092 /* great, done with the monitors, unpack (again) for refresh_block operation */ 1152 /* great, done with the monitors, unpack (again) for refresh_block operation */
@@ -1454,7 +1514,7 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1454 if (GNUNET_YES == rlc.found) 1514 if (GNUNET_YES == rlc.found)
1455 llr_msg->found = htons (GNUNET_YES); 1515 llr_msg->found = htons (GNUNET_YES);
1456 else if (GNUNET_SYSERR == res) 1516 else if (GNUNET_SYSERR == res)
1457 llr_msg->found = htons (GNUNET_SYSERR); 1517 llr_msg->found = htons (GNUNET_SYSERR);
1458 else 1518 else
1459 llr_msg->found = htons (GNUNET_NO); 1519 llr_msg->found = htons (GNUNET_NO);
1460 GNUNET_memcpy (&llr_msg[1], conv_name, name_len); 1520 GNUNET_memcpy (&llr_msg[1], conv_name, name_len);
@@ -1531,13 +1591,15 @@ get_block_exp_existing (void *cls,
1531 unsigned int rd_pub_count; 1591 unsigned int rd_pub_count;
1532 char *emsg; 1592 char *emsg;
1533 1593
1534 if (GNUNET_OK != GNUNET_GNSRECORD_convert_records_for_export (label, 1594 if (GNUNET_OK !=
1535 rd, 1595 GNUNET_GNSRECORD_normalize_record_set (label,
1536 rd_count, 1596 rd,
1537 rd_pub, 1597 rd_count,
1538 &rd_pub_count, 1598 rd_pub,
1539 exp, 1599 &rd_pub_count,
1540 &emsg)) 1600 exp,
1601 GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE,
1602 &emsg))
1541 { 1603 {
1542 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1604 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1543 "%s\n", emsg); 1605 "%s\n", emsg);
@@ -1673,14 +1735,15 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1673 have_nick = GNUNET_YES; 1735 have_nick = GNUNET_YES;
1674 } 1736 }
1675 } 1737 }
1676 if (GNUNET_OK != GNUNET_GNSRECORD_normalize_record_set (conv_name, 1738 if (GNUNET_OK !=
1677 rd_clean, 1739 GNUNET_GNSRECORD_normalize_record_set (conv_name,
1678 rd_clean_off, 1740 rd_clean,
1679 rd_nf, 1741 rd_clean_off,
1680 &rd_nf_count, 1742 rd_nf,
1681 &new_block_exp, 1743 &rd_nf_count,
1682 GNUNET_YES, 1744 &new_block_exp,
1683 &emsg)) 1745 GNUNET_GNSRECORD_FILTER_NONE,
1746 &emsg))
1684 { 1747 {
1685 send_store_response (nc, GNUNET_SYSERR, emsg, rid); 1748 send_store_response (nc, GNUNET_SYSERR, emsg, rid);
1686 GNUNET_free (emsg); 1749 GNUNET_free (emsg);
@@ -1991,12 +2054,13 @@ zone_iterate_proc (void *cls,
1991 } 2054 }
1992 proc->limit--; 2055 proc->limit--;
1993 proc->zi->seq = seq; 2056 proc->zi->seq = seq;
1994 send_lookup_response (proc->zi->nc, 2057 send_lookup_response_with_filter (proc->zi->nc,
1995 proc->zi->request_id, 2058 proc->zi->request_id,
1996 zone_key, 2059 zone_key,
1997 name, 2060 name,
1998 rd_count, 2061 rd_count,
1999 rd); 2062 rd,
2063 proc->zi->filter);
2000 2064
2001 2065
2002 do_refresh_block = GNUNET_NO; 2066 do_refresh_block = GNUNET_NO;
@@ -2077,6 +2141,7 @@ handle_iteration_start (void *cls,
2077 "Received ZONE_ITERATION_START message\n"); 2141 "Received ZONE_ITERATION_START message\n");
2078 zi = GNUNET_new (struct ZoneIteration); 2142 zi = GNUNET_new (struct ZoneIteration);
2079 zi->request_id = ntohl (zis_msg->gns_header.r_id); 2143 zi->request_id = ntohl (zis_msg->gns_header.r_id);
2144 zi->filter = ntohs (zis_msg->filter);
2080 zi->offset = 0; 2145 zi->offset = 0;
2081 zi->nc = nc; 2146 zi->nc = nc;
2082 zi->zone = zis_msg->zone; 2147 zi->zone = zis_msg->zone;
@@ -2281,6 +2346,7 @@ handle_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg)
2281 zm->nc = nc; 2346 zm->nc = nc;
2282 zm->zone = zis_msg->zone; 2347 zm->zone = zis_msg->zone;
2283 zm->limit = 1; 2348 zm->limit = 1;
2349 zm->filter = ntohs (zis_msg->filter);
2284 zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first)); 2350 zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first));
2285 GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, zm); 2351 GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, zm);
2286 GNUNET_SERVICE_client_mark_monitor (nc->client); 2352 GNUNET_SERVICE_client_mark_monitor (nc->client);
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index 8aaba180f..ad02ffb48 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -280,6 +280,12 @@ struct RecordResultMessage
280 struct GNUNET_NAMESTORE_Header gns_header; 280 struct GNUNET_NAMESTORE_Header gns_header;
281 281
282 /** 282 /**
283 * Expiration time if the record result (if any).
284 * Takes TOMBSTONEs into account.
285 */
286 struct GNUNET_TIME_AbsoluteNBO expire;
287
288 /**
283 * Name length 289 * Name length
284 */ 290 */
285 uint16_t name_len GNUNET_PACKED; 291 uint16_t name_len GNUNET_PACKED;
@@ -376,6 +382,17 @@ struct ZoneMonitorStartMessage
376 uint32_t iterate_first GNUNET_PACKED; 382 uint32_t iterate_first GNUNET_PACKED;
377 383
378 /** 384 /**
385 * Record set filter control flags.
386 * See GNUNET_NAMESTORE_Filter enum.
387 */
388 uint16_t filter;
389
390 /**
391 * Reserved for alignment
392 */
393 uint16_t reserved;
394
395 /**
379 * Zone key. 396 * Zone key.
380 */ 397 */
381 struct GNUNET_IDENTITY_PrivateKey zone; 398 struct GNUNET_IDENTITY_PrivateKey zone;
@@ -420,6 +437,17 @@ struct ZoneIterationStartMessage
420 * Zone key. All zeros for "all zones". 437 * Zone key. All zeros for "all zones".
421 */ 438 */
422 struct GNUNET_IDENTITY_PrivateKey zone; 439 struct GNUNET_IDENTITY_PrivateKey zone;
440
441 /**
442 * Record set filter control flags.
443 * See GNUNET_NAMESTORE_Filter enum.
444 */
445 uint16_t filter;
446
447 /**
448 * Reserved for alignment
449 */
450 uint16_t reserved;
423}; 451};
424 452
425 453
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 71d969022..51ee25acf 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -83,6 +83,11 @@ struct GNUNET_NAMESTORE_QueueEntry
83 GNUNET_NAMESTORE_RecordMonitor proc; 83 GNUNET_NAMESTORE_RecordMonitor proc;
84 84
85 /** 85 /**
86 * Function to call with the records we get back; or NULL.
87 */
88 GNUNET_NAMESTORE_RecordSetMonitor proc2;
89
90 /**
86 * Closure for @e proc. 91 * Closure for @e proc.
87 */ 92 */
88 void *proc_cls; 93 void *proc_cls;
@@ -151,6 +156,11 @@ struct GNUNET_NAMESTORE_ZoneIterator
151 GNUNET_NAMESTORE_RecordMonitor proc; 156 GNUNET_NAMESTORE_RecordMonitor proc;
152 157
153 /** 158 /**
159 * The continuation to call with the results
160 */
161 GNUNET_NAMESTORE_RecordSetMonitor proc2;
162
163 /**
154 * Closure for @e proc. 164 * Closure for @e proc.
155 */ 165 */
156 void *proc_cls; 166 void *proc_cls;
@@ -630,6 +640,9 @@ handle_record_result (void *cls, const struct RecordResultMessage *msg)
630 { 640 {
631 if (NULL != ze->proc) 641 if (NULL != ze->proc)
632 ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd); 642 ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd);
643 if (NULL != ze->proc2)
644 ze->proc2 (ze->proc_cls, &msg->private_key, name,
645 rd_count, rd, GNUNET_TIME_absolute_ntoh (msg->expire));
633 return; 646 return;
634 } 647 }
635 } 648 }
@@ -1272,25 +1285,6 @@ GNUNET_NAMESTORE_zone_to_name (
1272} 1285}
1273 1286
1274 1287
1275/**
1276 * Starts a new zone iteration (used to periodically PUT all of our
1277 * records into our DHT). This MUST lock the struct GNUNET_NAMESTORE_Handle
1278 * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next and
1279 * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once
1280 * immediately, and then again after
1281 * #GNUNET_NAMESTORE_zone_iterator_next is invoked.
1282 *
1283 * @param h handle to the namestore
1284 * @param zone zone to access, NULL for all zones
1285 * @param error_cb function to call on error (i.e. disconnect)
1286 * @param error_cb_cls closure for @a error_cb
1287 * @param proc function to call on each name from the zone; it
1288 * will be called repeatedly with a value (if available)
1289 * @param proc_cls closure for @a proc
1290 * @param finish_cb function to call on completion
1291 * @param finish_cb_cls closure for @a finish_cb
1292 * @return an iterator handle to use for iteration
1293 */
1294struct GNUNET_NAMESTORE_ZoneIterator * 1288struct GNUNET_NAMESTORE_ZoneIterator *
1295GNUNET_NAMESTORE_zone_iteration_start ( 1289GNUNET_NAMESTORE_zone_iteration_start (
1296 struct GNUNET_NAMESTORE_Handle *h, 1290 struct GNUNET_NAMESTORE_Handle *h,
@@ -1332,15 +1326,50 @@ GNUNET_NAMESTORE_zone_iteration_start (
1332 return it; 1326 return it;
1333} 1327}
1334 1328
1329struct GNUNET_NAMESTORE_ZoneIterator *
1330GNUNET_NAMESTORE_zone_iteration_start2 (
1331 struct GNUNET_NAMESTORE_Handle *h,
1332 const struct GNUNET_IDENTITY_PrivateKey *zone,
1333 GNUNET_SCHEDULER_TaskCallback error_cb,
1334 void *error_cb_cls,
1335 GNUNET_NAMESTORE_RecordSetMonitor proc,
1336 void *proc_cls,
1337 GNUNET_SCHEDULER_TaskCallback finish_cb,
1338 void *finish_cb_cls,
1339 enum GNUNET_GNSRECORD_Filter filter)
1340{
1341 struct GNUNET_NAMESTORE_ZoneIterator *it;
1342 struct GNUNET_MQ_Envelope *env;
1343 struct ZoneIterationStartMessage *msg;
1344 uint32_t rid;
1345
1346 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1347 rid = get_op_id (h);
1348 it = GNUNET_new (struct GNUNET_NAMESTORE_ZoneIterator);
1349 it->h = h;
1350 it->error_cb = error_cb;
1351 it->error_cb_cls = error_cb_cls;
1352 it->finish_cb = finish_cb;
1353 it->finish_cb_cls = finish_cb_cls;
1354 it->proc2 = proc;
1355 it->proc_cls = proc_cls;
1356 it->op_id = rid;
1357 if (NULL != zone)
1358 it->zone = *zone;
1359 GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it);
1360 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1361 msg->gns_header.r_id = htonl (rid);
1362 msg->filter = htons ((uint16_t) filter);
1363 if (NULL != zone)
1364 msg->zone = *zone;
1365 if (NULL == h->mq)
1366 it->env = env;
1367 else
1368 GNUNET_MQ_send (h->mq, env);
1369 return it;
1370}
1371
1335 1372
1336/**
1337 * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start
1338 * for the next record.
1339 *
1340 * @param it the iterator
1341 * @param limit number of records to return to the iterator in one shot
1342 * (before #GNUNET_NAMESTORE_zone_iterator_next is to be called again)
1343 */
1344void 1373void
1345GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it, 1374GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it,
1346 uint64_t limit) 1375 uint64_t limit)
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c
index 6670e54ce..968d7ed58 100644
--- a/src/namestore/namestore_api_monitor.c
+++ b/src/namestore/namestore_api_monitor.c
@@ -65,6 +65,16 @@ struct GNUNET_NAMESTORE_ZoneMonitor
65 GNUNET_NAMESTORE_RecordMonitor monitor; 65 GNUNET_NAMESTORE_RecordMonitor monitor;
66 66
67 /** 67 /**
68 * Function to call on events.
69 */
70 GNUNET_NAMESTORE_RecordSetMonitor monitor2;
71
72 /**
73 * Record set filter for this monitor
74 */
75 enum GNUNET_GNSRECORD_Filter filter;
76
77 /**
68 * Closure for @e monitor. 78 * Closure for @e monitor.
69 */ 79 */
70 void *monitor_cls; 80 void *monitor_cls;
@@ -213,7 +223,11 @@ handle_result (void *cls, const struct RecordResultMessage *lrm)
213 GNUNET_assert ( 223 GNUNET_assert (
214 GNUNET_OK == 224 GNUNET_OK ==
215 GNUNET_GNSRECORD_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd)); 225 GNUNET_GNSRECORD_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd));
216 zm->monitor (zm->monitor_cls, &lrm->private_key, name_tmp, rd_count, rd); 226 if (NULL != zm->monitor2)
227 zm->monitor2 (zm->monitor_cls, &lrm->private_key, name_tmp,
228 rd_count, rd, GNUNET_TIME_absolute_ntoh (lrm->expire));
229 else
230 zm->monitor (zm->monitor_cls, &lrm->private_key, name_tmp, rd_count, rd);
217 } 231 }
218} 232}
219 233
@@ -272,33 +286,11 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm)
272 env = GNUNET_MQ_msg (sm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START); 286 env = GNUNET_MQ_msg (sm, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START);
273 sm->iterate_first = htonl (zm->iterate_first); 287 sm->iterate_first = htonl (zm->iterate_first);
274 sm->zone = zm->zone; 288 sm->zone = zm->zone;
289 sm->filter = htons ((uint16_t) zm->filter);
275 GNUNET_MQ_send (zm->mq, env); 290 GNUNET_MQ_send (zm->mq, env);
276} 291}
277 292
278 293
279/**
280 * Begin monitoring a zone for changes. If @a iterate_first is set,
281 * we Will first call the @a monitor function on all existing records
282 * in the selected zone(s). In any case, we will call @a sync and
283 * afterwards call @a monitor whenever a record changes.
284 *
285 * @param cfg configuration to use to connect to namestore
286 * @param zone zone to monitor
287 * @param iterate_first #GNUNET_YES to first iterate over all existing records,
288 * #GNUNET_NO to only return changes that happen from now
289 * on
290 * @param error_cb function to call on error (i.e. disconnect); note that
291 * unlike the other error callbacks in this API, a call to this
292 * function does NOT destroy the monitor handle, it merely signals
293 * that monitoring is down. You need to still explicitly call
294 * #GNUNET_NAMESTORE_zone_monitor_stop().
295 * @param error_cb_cls closure for @a error_cb
296 * @param monitor function to call on zone changes
297 * @param monitor_cls closure for @a monitor
298 * @param sync_cb function called when we're in sync with the namestore
299 * @param cls closure for @a sync_cb
300 * @return handle to stop monitoring
301 */
302struct GNUNET_NAMESTORE_ZoneMonitor * 294struct GNUNET_NAMESTORE_ZoneMonitor *
303GNUNET_NAMESTORE_zone_monitor_start ( 295GNUNET_NAMESTORE_zone_monitor_start (
304 const struct GNUNET_CONFIGURATION_Handle *cfg, 296 const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -333,6 +325,42 @@ GNUNET_NAMESTORE_zone_monitor_start (
333 return zm; 325 return zm;
334} 326}
335 327
328struct GNUNET_NAMESTORE_ZoneMonitor *
329GNUNET_NAMESTORE_zone_monitor_start2 (
330 const struct GNUNET_CONFIGURATION_Handle *cfg,
331 const struct GNUNET_IDENTITY_PrivateKey *zone,
332 int iterate_first,
333 GNUNET_SCHEDULER_TaskCallback error_cb,
334 void *error_cb_cls,
335 GNUNET_NAMESTORE_RecordSetMonitor monitor,
336 void *monitor_cls,
337 GNUNET_SCHEDULER_TaskCallback sync_cb,
338 void *sync_cb_cls,
339 enum GNUNET_GNSRECORD_Filter filter)
340{
341 struct GNUNET_NAMESTORE_ZoneMonitor *zm;
342
343 zm = GNUNET_new (struct GNUNET_NAMESTORE_ZoneMonitor);
344 if (NULL != zone)
345 zm->zone = *zone;
346 zm->iterate_first = iterate_first;
347 zm->error_cb = error_cb;
348 zm->error_cb_cls = error_cb_cls;
349 zm->monitor2 = monitor;
350 zm->monitor_cls = monitor_cls;
351 zm->sync_cb = sync_cb;
352 zm->sync_cb_cls = sync_cb_cls;
353 zm->cfg = cfg;
354 zm->filter = filter;
355 reconnect (zm);
356 if (NULL == zm->mq)
357 {
358 GNUNET_free (zm);
359 return NULL;
360 }
361 return zm;
362}
363
336 364
337/** 365/**
338 * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start 366 * Calls the monitor processor specified in #GNUNET_NAMESTORE_zone_monitor_start
diff --git a/src/zonemaster/gnunet-service-zonemaster-monitor.c b/src/zonemaster/gnunet-service-zonemaster-monitor.c
index 748a0f342..08749bede 100644
--- a/src/zonemaster/gnunet-service-zonemaster-monitor.c
+++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c
@@ -273,19 +273,17 @@ perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key,
273 * @param label label of the records; NULL on disconnect 273 * @param label label of the records; NULL on disconnect
274 * @param rd_count number of entries in @a rd array, 0 if label was deleted 274 * @param rd_count number of entries in @a rd array, 0 if label was deleted
275 * @param rd array of records with data to store 275 * @param rd array of records with data to store
276 * @param expire expiration of this record set
276 */ 277 */
277static void 278static void
278handle_monitor_event (void *cls, 279handle_monitor_event (void *cls,
279 const struct GNUNET_IDENTITY_PrivateKey *zone, 280 const struct GNUNET_IDENTITY_PrivateKey *zone,
280 const char *label, 281 const char *label,
281 unsigned int rd_count, 282 unsigned int rd_count,
282 const struct GNUNET_GNSRECORD_Data *rd) 283 const struct GNUNET_GNSRECORD_Data *rd,
284 struct GNUNET_TIME_Absolute expire)
283{ 285{
284 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
285 unsigned int rd_public_count;
286 struct DhtPutActivity *ma; 286 struct DhtPutActivity *ma;
287 struct GNUNET_TIME_Absolute expire;
288 char *emsg;
289 287
290 (void) cls; 288 (void) cls;
291 GNUNET_STATISTICS_update (statistics, 289 GNUNET_STATISTICS_update (statistics,
@@ -296,24 +294,7 @@ handle_monitor_event (void *cls,
296 "Received %u records for label `%s' via namestore monitor\n", 294 "Received %u records for label `%s' via namestore monitor\n",
297 rd_count, 295 rd_count,
298 label); 296 label);
299 /* filter out records that are not public, and convert to 297 if (0 == rd_count)
300 absolute expiration time. */
301 if (GNUNET_OK != GNUNET_GNSRECORD_convert_records_for_export (label,
302 rd,
303 rd_count,
304 rd_public,
305 &rd_public_count,
306 &expire,
307 &emsg))
308 {
309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
310 "Zonemaster-monitor failed: %s\n", emsg);
311 GNUNET_free (emsg);
312 GNUNET_NAMESTORE_zone_monitor_next (zmon,
313 1);
314 return; /* nothing to do */
315 }
316 if (0 == rd_public_count)
317 { 298 {
318 GNUNET_NAMESTORE_zone_monitor_next (zmon, 299 GNUNET_NAMESTORE_zone_monitor_next (zmon,
319 1); 300 1);
@@ -323,8 +304,8 @@ handle_monitor_event (void *cls,
323 ma->start_date = GNUNET_TIME_absolute_get (); 304 ma->start_date = GNUNET_TIME_absolute_get ();
324 ma->ph = perform_dht_put (zone, 305 ma->ph = perform_dht_put (zone,
325 label, 306 label,
326 rd_public, 307 rd,
327 rd_public_count, 308 rd_count,
328 expire, 309 expire,
329 ma); 310 ma);
330 if (NULL == ma->ph) 311 if (NULL == ma->ph)
@@ -427,15 +408,16 @@ run (void *cls,
427 /* Schedule periodic put for our records. */ 408 /* Schedule periodic put for our records. */
428 statistics = GNUNET_STATISTICS_create ("zonemaster-mon", 409 statistics = GNUNET_STATISTICS_create ("zonemaster-mon",
429 c); 410 c);
430 zmon = GNUNET_NAMESTORE_zone_monitor_start (c, 411 zmon = GNUNET_NAMESTORE_zone_monitor_start2 (c,
431 NULL, 412 NULL,
432 GNUNET_NO, 413 GNUNET_NO,
433 &handle_monitor_error, 414 &handle_monitor_error,
434 NULL, 415 NULL,
435 &handle_monitor_event, 416 &handle_monitor_event,
436 NULL, 417 NULL,
437 NULL /* sync_cb */, 418 NULL /* sync_cb */,
438 NULL); 419 NULL,
420 GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE);
439 GNUNET_NAMESTORE_zone_monitor_next (zmon, 421 GNUNET_NAMESTORE_zone_monitor_next (zmon,
440 NAMESTORE_QUEUE_LIMIT - 1); 422 NAMESTORE_QUEUE_LIMIT - 1);
441 GNUNET_break (NULL != zmon); 423 GNUNET_break (NULL != zmon);
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index c6b86bf71..dba1b24ce 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -683,46 +683,28 @@ put_gns_record (void *cls,
683 const struct GNUNET_IDENTITY_PrivateKey *key, 683 const struct GNUNET_IDENTITY_PrivateKey *key,
684 const char *label, 684 const char *label,
685 unsigned int rd_count, 685 unsigned int rd_count,
686 const struct GNUNET_GNSRECORD_Data *rd) 686 const struct GNUNET_GNSRECORD_Data *rd,
687 struct GNUNET_TIME_Absolute expire)
687{ 688{
688 struct GNUNET_GNSRECORD_Data rd_public[rd_count];
689 unsigned int rd_public_count;
690 struct DhtPutActivity *ma; 689 struct DhtPutActivity *ma;
691 struct GNUNET_TIME_Absolute expire;
692 char *emsg;
693 690
694 (void) cls; 691 (void) cls;
695 ns_iteration_left--; 692 ns_iteration_left--;
696 if (GNUNET_OK != GNUNET_GNSRECORD_convert_records_for_export (label, 693 if (0 == rd_count)
697 rd,
698 rd_count,
699 rd_public,
700 &rd_public_count,
701 &expire,
702 &emsg))
703 {
704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
705 "Record set inconsistent, moving to next record set: %s\n",
706 emsg);
707 GNUNET_free (emsg);
708 check_zone_namestore_next ();
709 return;
710 }
711 if (0 == rd_public_count)
712 { 694 {
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
714 "Record set empty, moving to next record set\n"); 696 "Record set empty, moving to next record set\n");
715 check_zone_namestore_next (); 697 check_zone_namestore_next ();
716 return; 698 return;
717 } 699 }
718 for (unsigned int i = 0; i < rd_public_count; i++) 700 for (unsigned int i = 0; i < rd_count; i++)
719 { 701 {
720 if (0 != (rd_public[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 702 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
721 { 703 {
722 /* GNUNET_GNSRECORD_block_create will convert to absolute time; 704 /* GNUNET_GNSRECORD_block_create will convert to absolute time;
723 we just need to adjust our iteration frequency */ 705 we just need to adjust our iteration frequency */
724 min_relative_record_time.rel_value_us = 706 min_relative_record_time.rel_value_us =
725 GNUNET_MIN (rd_public[i].expiration_time, 707 GNUNET_MIN (rd[i].expiration_time,
726 min_relative_record_time.rel_value_us); 708 min_relative_record_time.rel_value_us);
727 } 709 }
728 } 710 }
@@ -736,8 +718,8 @@ put_gns_record (void *cls,
736 ma->start_date = GNUNET_TIME_absolute_get (); 718 ma->start_date = GNUNET_TIME_absolute_get ();
737 ma->ph = perform_dht_put (key, 719 ma->ph = perform_dht_put (key,
738 label, 720 label,
739 rd_public, 721 rd,
740 rd_public_count, 722 rd_count,
741 expire, 723 expire,
742 ma); 724 ma);
743 put_cnt++; 725 put_cnt++;
@@ -793,14 +775,15 @@ publish_zone_dht_start (void *cls)
793 GNUNET_assert (NULL == namestore_iter); 775 GNUNET_assert (NULL == namestore_iter);
794 ns_iteration_left = 1; 776 ns_iteration_left = 1;
795 namestore_iter 777 namestore_iter
796 = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, 778 = GNUNET_NAMESTORE_zone_iteration_start2 (namestore_handle,
797 NULL, /* All zones */ 779 NULL, /* All zones */
798 &zone_iteration_error, 780 &zone_iteration_error,
799 NULL, 781 NULL,
800 &put_gns_record, 782 &put_gns_record,
801 NULL, 783 NULL,
802 &zone_iteration_finished, 784 &zone_iteration_finished,
803 NULL); 785 NULL,
786 GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE);
804 GNUNET_assert (NULL != namestore_iter); 787 GNUNET_assert (NULL != namestore_iter);
805} 788}
806 789