diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 57 | ||||
-rw-r--r-- | src/include/gnunet_namestore_service.h | 112 |
2 files changed, 140 insertions, 29 deletions
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 | */ | ||
130 | enum 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 | */ | ||
756 | enum GNUNET_GenericReturnValue | ||
757 | GNUNET_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 | */ | ||
213 | typedef 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 | */ | ||
352 | struct GNUNET_NAMESTORE_ZoneIterator * | ||
353 | GNUNET_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 | */ | ||
466 | struct GNUNET_NAMESTORE_ZoneMonitor * | ||
467 | GNUNET_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 | */ |
436 | struct GNUNET_NAMESTORE_QueueEntry * | 542 | struct GNUNET_NAMESTORE_QueueEntry * |
437 | GNUNET_NAMESTORE_transaction_rollback (struct GNUNET_NAMESTORE_Handle *h, | 543 | GNUNET_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 |