aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_namestore_service.h
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-09-28 14:05:01 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-09-28 14:05:01 +0900
commit3ec2b451f938398eb4d2f92603f0659c26f6675c (patch)
tree03f34b6819b1422ad8da2e566908748e87cf9975 /src/include/gnunet_namestore_service.h
parent64480e6f4e07743a5fd20389eef92e0e9eadc563 (diff)
downloadgnunet-3ec2b451f938398eb4d2f92603f0659c26f6675c.tar.gz
gnunet-3ec2b451f938398eb4d2f92603f0659c26f6675c.zip
NAMESTORE: Allow service-side record set filtering. Fixes #7193
This commit enables zone iteration APIs which allow you to set a record set filter to determine which records should be returned or not. In particular filtering of private records and maintenance records (TOMBSTONE) for zonemaster.
Diffstat (limited to 'src/include/gnunet_namestore_service.h')
-rw-r--r--src/include/gnunet_namestore_service.h112
1 files changed, 109 insertions, 3 deletions
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