GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
gnunet-service-gns_resolver.h File Reference

GNUnet GNS service. More...

#include "gns.h"
#include "gnunet_dht_service.h"
#include "gnunet_gns_service.h"
#include "gnunet_namecache_service.h"
Include dependency graph for gnunet-service-gns_resolver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GNS_ResultProcessor) (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Function called with results for a GNS resolution.
 

Functions

void GNS_resolver_init (struct GNUNET_NAMECACHE_Handle *nc, struct GNUNET_DHT_Handle *dht, const struct GNUNET_CONFIGURATION_Handle *c, unsigned long long max_bg_queries)
 Initialize the resolver subsystem.
 
void GNS_resolver_done (void)
 Cleanup resolver: Terminate pending lookups.
 
struct GNS_ResolverHandleGNS_resolver_lookup (const struct GNUNET_CRYPTO_BlindablePublicKey *zone, uint32_t record_type, const char *name, enum GNUNET_GNS_LocalOptions options, uint16_t recursion_depth_limit, GNS_ResultProcessor proc, void *proc_cls)
 Lookup of a record in a specific zone calls RecordLookupProcessor on result or timeout.
 
void GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh)
 Cancel active resolution (i.e.
 

Detailed Description

GNUnet GNS service.

Author
Martin Schanzenbach

Definition in file gnunet-service-gns_resolver.h.

Typedef Documentation

◆ GNS_ResultProcessor

typedef void(* GNS_ResultProcessor) (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)

Function called with results for a GNS resolution.

Parameters
clsclosure
rd_countnumber of records in rd
rdrecords returned for the lookup

Definition at line 68 of file gnunet-service-gns_resolver.h.

Function Documentation

◆ GNS_resolver_init()

void GNS_resolver_init ( struct GNUNET_NAMECACHE_Handle nc,
struct GNUNET_DHT_Handle dht,
const struct GNUNET_CONFIGURATION_Handle c,
unsigned long long  max_bg_queries 
)

Initialize the resolver subsystem.

MUST be called before GNS_resolver_lookup.

Parameters
ncthe namecache handle
dhthandle to the dht
cconfiguration handle
max_bg_queriesmaximum amount of background queries

Initialize the resolver subsystem.

Parameters
ncthe namecache handle
dhtthe dht handle
cconfiguration handle
max_bg_queriesmaximum number of parallel background queries in dht

Definition at line 3392 of file gnunet-service-gns_resolver.c.

3396{
3397 cfg = c;
3399 dht_handle = dht;
3402 max_allowed_background_queries = max_bg_queries;
3404 "namecache",
3405 "DISABLE");
3408 "Namecache disabled\n");
3409}
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
static struct GNUNET_NotificationContext * nc
Notification context for broadcasting to monitors.
static int disable_cache
Use namecache.
static unsigned long long max_allowed_background_queries
Maximum amount of parallel queries to the DHT.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Global configuration.
static struct GNUNET_DHT_Handle * dht_handle
Resolver handle to the dht.
static struct GNUNET_CONTAINER_Heap * dht_lookup_heap
Heap for limiting parallel DHT lookups.
static struct GNUNET_NAMECACHE_Handle * namecache_handle
Our handle to the namecache service.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
#define GNUNET_log(kind,...)
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_WARNING

References cfg, dht, dht_handle, dht_lookup_heap, disable_cache, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_YES, max_allowed_background_queries, namecache_handle, and nc.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNS_resolver_done()

void GNS_resolver_done ( void  )

Cleanup resolver: Terminate pending lookups.

Cleanup resolver: Terminate pending lookups.

Definition at line 3416 of file gnunet-service-gns_resolver.c.

3417{
3418 struct GNS_ResolverHandle *rh;
3419 struct CacheOps *co;
3420
3421 /* abort active resolutions */
3422 while (NULL != (rh = rlh_head))
3423 {
3424 rh->proc (rh->proc_cls,
3425 0,
3426 NULL);
3428 }
3429 while (NULL != ro_head)
3431 while (NULL != (co = co_head))
3432 {
3434 co_tail,
3435 co);
3437 GNUNET_free (co);
3438 }
3440 dht_lookup_heap = NULL;
3441 dht_handle = NULL;
3442 namecache_handle = NULL;
3443}
static struct RefreshOps * ro_head
Organized in a DLL.
static struct GNS_ResolverHandle * rlh_head
Head of resolver lookup list.
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
static void refresh_stop(struct RefreshOps *ro)
End a background refresh.
static struct CacheOps * co_head
Organized in a DLL.
static struct CacheOps * co_tail
Organized in a DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
Active namestore caching operations.
struct GNUNET_NAMECACHE_QueueEntry * namecache_qe_cache
Pending Namestore caching task.
Handle to a currently pending resolution.
void * proc_cls
closure passed to proc
GNS_ResultProcessor proc
called when resolution phase finishes

References co_head, co_tail, dht_handle, dht_lookup_heap, GNS_resolver_lookup_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_destroy(), GNUNET_free, GNUNET_NAMECACHE_cancel(), namecache_handle, CacheOps::namecache_qe_cache, GNS_ResolverHandle::proc, GNS_ResolverHandle::proc_cls, refresh_stop(), rlh_head, and ro_head.

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNS_resolver_lookup()

struct GNS_ResolverHandle * GNS_resolver_lookup ( const struct GNUNET_CRYPTO_BlindablePublicKey zone,
uint32_t  record_type,
const char *  name,
enum GNUNET_GNS_LocalOptions  options,
uint16_t  recursion_depth_limit,
GNS_ResultProcessor  proc,
void *  proc_cls 
)

Lookup of a record in a specific zone calls RecordLookupProcessor on result or timeout.

Parameters
zonethe zone to perform the lookup in
record_typethe record type to look up
namethe name to look up
optionsoptions set to control local lookup
recursion_depth_limithow many zones to traverse at most
procthe processor to call
proc_clsthe closure to pass to proc
Returns
handle to cancel operation

Lookup of a record in a specific zone calls RecordLookupProcessor on result or timeout.

Parameters
zonethe zone to perform the lookup in
record_typethe record type to look up
namethe name to look up
optionslocal options to control local lookup
recursion_depth_limithow many zones to traverse at most
procthe processor to call on result
proc_clsthe closure to pass to proc
Returns
handle to cancel operation

Definition at line 3240 of file gnunet-service-gns_resolver.c.

3247{
3248 struct GNS_ResolverHandle *rh;
3249
3251 "Starting lookup for `%s'\n",
3252 name);
3253 rh = GNUNET_new (struct GNS_ResolverHandle);
3255 rlh_tail,
3256 rh);
3257 rh->authority_zone = *zone;
3258 rh->proc = proc;
3259 rh->proc_cls = proc_cls;
3260 rh->options = options;
3262 rh->name = GNUNET_strdup (name);
3263 rh->name_resolution_pos = strlen (name);
3264 rh->loop_threshold = recursion_depth_limit;
3266 rh);
3267 return rh;
3268}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
static char * name
Name (label) of the records to list.
static void start_resolver_lookup(void *cls)
Begin the resolution process from 'name', starting with the identification of the zone specified by '...
static struct GNS_ResolverHandle * rlh_tail
Tail of resolver lookup list.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1310
size_t name_resolution_pos
Current offset in name where we are resolving.
int record_type
Desired type for the resolution.
struct GNUNET_CRYPTO_BlindablePublicKey authority_zone
The top-level GNS authoritative zone to query.
unsigned int loop_threshold
Maximum value of loop_limiter allowed by client.
struct GNUNET_SCHEDULER_Task * task_id
ID of a task associated with the resolution process.
char * name
The name to resolve.
enum GNUNET_GNS_LocalOptions options
Use only cache.

References GNS_ResolverHandle::authority_zone, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_strdup, GNS_ResolverHandle::loop_threshold, name, GNS_ResolverHandle::name, GNS_ResolverHandle::name_resolution_pos, options, GNS_ResolverHandle::options, GNS_ResolverHandle::proc, GNS_ResolverHandle::proc_cls, GNS_ResolverHandle::record_type, rlh_head, rlh_tail, start_resolver_lookup(), and GNS_ResolverHandle::task_id.

Referenced by handle_dns_request(), and handle_lookup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNS_resolver_lookup_cancel()

void GNS_resolver_lookup_cancel ( struct GNS_ResolverHandle rh)

Cancel active resolution (i.e.

client disconnected).

Parameters
rhresolution to abort

Definition at line 3277 of file gnunet-service-gns_resolver.c.

3278{
3279 struct DnsResult *dr;
3280 struct AuthorityChain *ac;
3281
3283 rlh_tail,
3284 rh);
3285 if (NULL != rh->dns_request)
3286 {
3288 rh->dns_request = NULL;
3289 }
3290 while (NULL != (ac = rh->ac_head))
3291 {
3293 rh->ac_tail,
3294 ac);
3295 if (GNUNET_NO == ac->gns_authority)
3296 {
3297 struct Gns2DnsPending *gp;
3298
3299 while (NULL != (gp = ac->authority_info.dns_authority.gp_head))
3300 {
3303 gp);
3304 if (NULL != gp->rh)
3305 {
3306 /* rh->g2dc->rh is NOT in the DLL yet, so to enable us
3307 using GNS_resolver_lookup_cancel here, we need to
3308 add it first... */
3310 rlh_tail,
3311 gp->rh);
3312 GNUNET_assert (NULL == gp->rh->task_id);
3315 gp->rh);
3316 gp->rh = NULL;
3317 }
3318 if (NULL != gp->dns_rh)
3319 {
3321 gp->dns_rh = NULL;
3322 }
3323 GNUNET_free (gp);
3324 }
3326 }
3327 GNUNET_free (ac->label);
3328 GNUNET_free (ac);
3329 }
3330 if (NULL != rh->task_id)
3331 {
3333 rh->task_id = NULL;
3334 }
3335 if (NULL != rh->get_handle)
3336 {
3338 rh->get_handle = NULL;
3339 }
3340 if (NULL != rh->dht_heap_node)
3341 {
3343 rh->dht_heap_node = NULL;
3344 }
3345 if (NULL != rh->namecache_qe)
3346 {
3348 rh->namecache_qe = NULL;
3349 }
3350 if (NULL != rh->rev_check)
3351 {
3353 rh->rev_check = NULL;
3354 }
3355 if (NULL != rh->std_resolve)
3356 {
3358 "Canceling standard DNS resolution\n");
3360 rh->std_resolve = NULL;
3361 }
3362 while (NULL != (dr = rh->dns_result_head))
3363 {
3366 dr);
3367 GNUNET_free (dr);
3368 }
3369 if (NULL != rh->prefix)
3370 {
3372 rh->prefix = NULL;
3373 }
3374 GNUNET_free (rh->leho);
3375 GNUNET_free (rh->name);
3376 GNUNET_free (rh);
3377}
static void GNS_resolver_lookup_cancel_(void *cls)
Wrapper around GNS_resolver_lookup_cancel() as a task.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition dht_api.c:1238
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition dnsstub.c:704
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition dnsstub.c:561
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
DLL to hold the authority chain we had to pass in the resolution process.
char * label
label/name corresponding to the authority
struct AuthorityChain::@63::@64 dns_authority
int gns_authority
GNUNET_YES if the authority was a GNS authority, GNUNET_NO if the authority was a DNS authority.
struct GNUNET_DNSSTUB_Context * dns_handle
Handle to perform DNS lookups with this authority (in GNS2DNS handling).
struct GNS_ResolverHandle * rh
Resolver handle this entry in the chain belongs to.
union AuthorityChain::@63 authority_info
Information about the resolver authority for this label.
struct Gns2DnsPending * gp_head
List of resolutions of the 'ip' of the name server that are still pending.
struct Gns2DnsPending * gp_tail
Tail of list of resolutions of the 'ip' of the name server that are still pending.
A result we got from DNS.
char * leho
Legacy Hostname to use if we encountered GNS2DNS record and thus can deduct the LEHO from that transi...
struct GNUNET_CONTAINER_HeapNode * dht_heap_node
Heap node associated with this lookup.
struct GNUNET_DHT_GetHandle * get_handle
Handle for DHT lookups.
struct DnsResult * dns_result_tail
DLL of results we got from DNS.
struct GNUNET_REVOCATION_Query * rev_check
Pending revocation check.
struct GNUNET_NAMECACHE_QueueEntry * namecache_qe
Pending Namecache lookup task.
struct GNUNET_RESOLVER_RequestHandle * std_resolve
Handle for standard DNS resolution, NULL if none is active.
struct DnsResult * dns_result_head
DLL of results we got from DNS.
struct AuthorityChain * ac_head
DLL to store the authority chain.
struct AuthorityChain * ac_tail
DLL to store the authority chain.
char * prefix
For SMIMEA,OPENPGPKEY... records.
struct GNUNET_DNSSTUB_RequestSocket * dns_request
Socket for a DNS request, NULL if none is active.
Element of a resolution process for looking up the responsible DNS server hostname in a GNS2DNS recur...
struct GNUNET_RESOLVER_RequestHandle * dns_rh
Handle for DNS resolution of the DNS nameserver.
struct GNS_ResolverHandle * rh
Handle for the resolution of the IP part of the GNS2DNS record.
struct AuthorityChain * ac
Context this activity belongs with.

References Gns2DnsPending::ac, GNS_ResolverHandle::ac_head, GNS_ResolverHandle::ac_tail, AuthorityChain::authority_info, GNS_ResolverHandle::dht_heap_node, AuthorityChain::dns_authority, AuthorityChain::dns_handle, GNS_ResolverHandle::dns_request, GNS_ResolverHandle::dns_result_head, GNS_ResolverHandle::dns_result_tail, Gns2DnsPending::dns_rh, GNS_ResolverHandle::get_handle, AuthorityChain::gns_authority, GNS_resolver_lookup_cancel_(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_remove_node(), GNUNET_DHT_get_stop(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_DNSSTUB_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMECACHE_cancel(), GNUNET_NO, GNUNET_RESOLVER_request_cancel(), GNUNET_REVOCATION_query_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), AuthorityChain::gp_head, AuthorityChain::gp_tail, AuthorityChain::label, GNS_ResolverHandle::leho, GNS_ResolverHandle::name, GNS_ResolverHandle::namecache_qe, GNS_ResolverHandle::prefix, GNS_ResolverHandle::rev_check, Gns2DnsPending::rh, AuthorityChain::rh, rlh_head, rlh_tail, GNS_ResolverHandle::std_resolve, and GNS_ResolverHandle::task_id.

Referenced by client_disconnect_cb(), GNS_interceptor_done(), GNS_resolver_done(), GNS_resolver_lookup_cancel_(), and transmit_lookup_dns_result().

Here is the call graph for this function:
Here is the caller graph for this function: