|
@@ -1,6 +1,6 @@
|
|
|
/*
|
|
|
This file is part of GNUnet.
|
|
|
- Copyright (C) 2009-2013, 2016, 2018 GNUnet e.V.
|
|
|
+ Copyright (C) 2009-2020 GNUnet e.V.
|
|
|
|
|
|
GNUnet is free software: you can redistribute it and/or modify it
|
|
|
under the terms of the GNU Affero General Public License as published
|
|
@@ -36,6 +36,12 @@
|
|
|
|
|
|
#define LOG(kind, ...) GNUNET_log_from (kind, "gns-api", __VA_ARGS__)
|
|
|
|
|
|
+/**
|
|
|
+ * Default recursion depth limit to apply if
|
|
|
+ * the application does not specify any.
|
|
|
+ */
|
|
|
+#define DEFAULT_LIMIT 128
|
|
|
+
|
|
|
/**
|
|
|
* Handle to a lookup request
|
|
|
*/
|
|
@@ -325,21 +331,24 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr)
|
|
|
*
|
|
|
* @param handle handle to the GNS service
|
|
|
* @param name the name to look up (in UTF-8 encoding)
|
|
|
- * @param zone the zone to start the resolution in
|
|
|
- * @param type the record type to look up
|
|
|
+ * @param zone zone to look in
|
|
|
+ * @param type the GNS record type to look for
|
|
|
* @param options local options for the lookup
|
|
|
- * @param proc processor to call on result
|
|
|
+ * @param recursion_depth_limit maximum number of zones
|
|
|
+ * that the lookup may (still) traverse
|
|
|
+ * @param proc function to call on result
|
|
|
* @param proc_cls closure for @a proc
|
|
|
- * @return handle to the get request
|
|
|
+ * @return handle to the queued request
|
|
|
*/
|
|
|
-struct GNUNET_GNS_LookupRequest*
|
|
|
-GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
|
|
|
- const char *name,
|
|
|
- const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
|
|
|
- uint32_t type,
|
|
|
- enum GNUNET_GNS_LocalOptions options,
|
|
|
- GNUNET_GNS_LookupResultProcessor proc,
|
|
|
- void *proc_cls)
|
|
|
+struct GNUNET_GNS_LookupRequest *
|
|
|
+GNUNET_GNS_lookup_limited (struct GNUNET_GNS_Handle *handle,
|
|
|
+ const char *name,
|
|
|
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
|
|
|
+ uint32_t type,
|
|
|
+ enum GNUNET_GNS_LocalOptions options,
|
|
|
+ uint16_t recursion_depth_limit,
|
|
|
+ GNUNET_GNS_LookupResultProcessor proc,
|
|
|
+ void *proc_cls)
|
|
|
{
|
|
|
/* IPC to shorten gns names, return shorten_handle */
|
|
|
struct LookupMessage *lookup_msg;
|
|
@@ -370,6 +379,8 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
|
|
|
GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
|
|
|
lookup_msg->id = htonl (lr->r_id);
|
|
|
lookup_msg->options = htons ((uint16_t) options);
|
|
|
+ lookup_msg->recursion_depth_limit
|
|
|
+ = htons (recursion_depth_limit);
|
|
|
lookup_msg->zone = *zone;
|
|
|
lookup_msg->type = htonl (type);
|
|
|
GNUNET_memcpy (&lookup_msg[1],
|
|
@@ -385,4 +396,35 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
|
|
|
}
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * Perform an asynchronous lookup operation on the GNS.
|
|
|
+ *
|
|
|
+ * @param handle handle to the GNS service
|
|
|
+ * @param name the name to look up (in UTF-8 encoding)
|
|
|
+ * @param zone the zone to start the resolution in
|
|
|
+ * @param type the record type to look up
|
|
|
+ * @param options local options for the lookup
|
|
|
+ * @param proc processor to call on result
|
|
|
+ * @param proc_cls closure for @a proc
|
|
|
+ * @return handle to the get request
|
|
|
+ */
|
|
|
+struct GNUNET_GNS_LookupRequest*
|
|
|
+GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
|
|
|
+ const char *name,
|
|
|
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
|
|
|
+ uint32_t type,
|
|
|
+ enum GNUNET_GNS_LocalOptions options,
|
|
|
+ GNUNET_GNS_LookupResultProcessor proc,
|
|
|
+ void *proc_cls)
|
|
|
+{
|
|
|
+ return GNUNET_GNS_lookup_limited (handle,
|
|
|
+ name,
|
|
|
+ zone,
|
|
|
+ type,
|
|
|
+ options,
|
|
|
+ DEFAULT_LIMIT,
|
|
|
+ proc,
|
|
|
+ proc_cls);
|
|
|
+}
|
|
|
+
|
|
|
/* end of gns_api.c */
|