aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gns_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gns_api.c')
-rw-r--r--src/gns/gns_api.c68
1 files changed, 55 insertions, 13 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 4a4003b2a..0d99d822e 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016, 2018 GNUnet e.V. 3 Copyright (C) 2009-2020 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -37,6 +37,12 @@
37#define LOG(kind, ...) GNUNET_log_from (kind, "gns-api", __VA_ARGS__) 37#define LOG(kind, ...) GNUNET_log_from (kind, "gns-api", __VA_ARGS__)
38 38
39/** 39/**
40 * Default recursion depth limit to apply if
41 * the application does not specify any.
42 */
43#define DEFAULT_LIMIT 128
44
45/**
40 * Handle to a lookup request 46 * Handle to a lookup request
41 */ 47 */
42struct GNUNET_GNS_LookupRequest 48struct GNUNET_GNS_LookupRequest
@@ -325,21 +331,24 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr)
325 * 331 *
326 * @param handle handle to the GNS service 332 * @param handle handle to the GNS service
327 * @param name the name to look up (in UTF-8 encoding) 333 * @param name the name to look up (in UTF-8 encoding)
328 * @param zone the zone to start the resolution in 334 * @param zone zone to look in
329 * @param type the record type to look up 335 * @param type the GNS record type to look for
330 * @param options local options for the lookup 336 * @param options local options for the lookup
331 * @param proc processor to call on result 337 * @param recursion_depth_limit maximum number of zones
338 * that the lookup may (still) traverse
339 * @param proc function to call on result
332 * @param proc_cls closure for @a proc 340 * @param proc_cls closure for @a proc
333 * @return handle to the get request 341 * @return handle to the queued request
334 */ 342 */
335struct GNUNET_GNS_LookupRequest* 343struct GNUNET_GNS_LookupRequest *
336GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, 344GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle,
337 const char *name, 345 const char *name,
338 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, 346 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
339 uint32_t type, 347 uint32_t type,
340 enum GNUNET_GNS_LocalOptions options, 348 enum GNUNET_GNS_LocalOptions options,
341 GNUNET_GNS_LookupResultProcessor proc, 349 uint16_t recursion_depth_limit,
342 void *proc_cls) 350 GNUNET_GNS_LookupResultProcessor proc,
351 void *proc_cls)
343{ 352{
344 /* IPC to shorten gns names, return shorten_handle */ 353 /* IPC to shorten gns names, return shorten_handle */
345 struct LookupMessage *lookup_msg; 354 struct LookupMessage *lookup_msg;
@@ -370,6 +379,8 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
370 GNUNET_MESSAGE_TYPE_GNS_LOOKUP); 379 GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
371 lookup_msg->id = htonl (lr->r_id); 380 lookup_msg->id = htonl (lr->r_id);
372 lookup_msg->options = htons ((uint16_t) options); 381 lookup_msg->options = htons ((uint16_t) options);
382 lookup_msg->recursion_depth_limit
383 = htons (recursion_depth_limit);
373 lookup_msg->zone = *zone; 384 lookup_msg->zone = *zone;
374 lookup_msg->type = htonl (type); 385 lookup_msg->type = htonl (type);
375 GNUNET_memcpy (&lookup_msg[1], 386 GNUNET_memcpy (&lookup_msg[1],
@@ -385,4 +396,35 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
385} 396}
386 397
387 398
399/**
400 * Perform an asynchronous lookup operation on the GNS.
401 *
402 * @param handle handle to the GNS service
403 * @param name the name to look up (in UTF-8 encoding)
404 * @param zone the zone to start the resolution in
405 * @param type the record type to look up
406 * @param options local options for the lookup
407 * @param proc processor to call on result
408 * @param proc_cls closure for @a proc
409 * @return handle to the get request
410 */
411struct GNUNET_GNS_LookupRequest*
412GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
413 const char *name,
414 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
415 uint32_t type,
416 enum GNUNET_GNS_LocalOptions options,
417 GNUNET_GNS_LookupResultProcessor proc,
418 void *proc_cls)
419{
420 return GNUNET_GNS_lookup_limited (handle,
421 name,
422 zone,
423 type,
424 options,
425 DEFAULT_LIMIT,
426 proc,
427 proc_cls);
428}
429
388/* end of gns_api.c */ 430/* end of gns_api.c */