GNUnet  0.10.x
Typedefs | Functions
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. More...
 

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. More...
 
void GNS_resolver_done (void)
 Cleanup resolver: Terminate pending lookups. More...
 
struct GNS_ResolverHandleGNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t record_type, const char *name, enum GNUNET_GNS_LocalOptions options, GNS_ResultProcessor proc, void *proc_cls)
 Lookup of a record in a specific zone calls RecordLookupProcessor on result or timeout. More...
 
void GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh)
 Cancel active resolution (i.e. More...
 

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 69 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 2878 of file gnunet-service-gns_resolver.c.

References dht, disable_cache, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_VPN_connect(), GNUNET_YES, max_allowed_background_queries, and nc.

Referenced by run().

2882 {
2883  cfg = c;
2884  namecache_handle = nc;
2885  dht_handle = dht;
2886  dht_lookup_heap =
2888  max_allowed_background_queries = max_bg_queries;
2890  "namecache",
2891  "DISABLE");
2892  if (GNUNET_YES == disable_cache)
2894  "Namecache disabled\n");
2896 }
static struct GNUNET_VPN_Handle * vpn_handle
Our handle to the vpn service.
static struct GNUNET_NAMECACHE_Handle * namecache_handle
Our handle to the namecache service.
static struct GNUNET_CONTAINER_Heap * dht_lookup_heap
Heap for limiting parallel DHT lookups.
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 int disable_cache
Use namecache.
static struct GNUNET_DHT_Handle * dht_handle
Resolver handle to the dht.
Heap with the minimum cost at the root.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
struct GNUNET_VPN_Handle * GNUNET_VPN_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the VPN service.
Definition: vpn_api.c:504
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
int 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".
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
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 2903 of file gnunet-service-gns_resolver.c.

References GNS_resolver_lookup_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_destroy(), GNUNET_free, GNUNET_NAMECACHE_cancel(), GNUNET_VPN_disconnect(), CacheOps::namecache_qe_cache, GNS_ResolverHandle::proc, GNS_ResolverHandle::proc_cls, and Gns2DnsPending::rh.

Referenced by shutdown_task().

2904 {
2905  struct GNS_ResolverHandle *rh;
2906  struct CacheOps *co;
2907 
2908  /* abort active resolutions */
2909  while (NULL != (rh = rlh_head))
2910  {
2911  rh->proc (rh->proc_cls,
2912  0,
2913  NULL);
2915  }
2916  while (NULL != (co = co_head))
2917  {
2919  co_tail,
2920  co);
2922  GNUNET_free (co);
2923  }
2925  dht_lookup_heap = NULL;
2927  vpn_handle = NULL;
2928  dht_handle = NULL;
2929  namecache_handle = NULL;
2930 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_VPN_Handle * vpn_handle
Our handle to the vpn service.
static struct GNUNET_NAMECACHE_Handle * namecache_handle
Our handle to the namecache service.
static struct GNUNET_CONTAINER_Heap * dht_lookup_heap
Heap for limiting parallel DHT lookups.
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
struct GNUNET_NAMECACHE_QueueEntry * namecache_qe_cache
Pending Namestore caching task.
GNS_ResultProcessor proc
called when resolution phase finishes
Handle to a currenty pending resolution.
void * proc_cls
closure passed to proc
Active namestore caching operations.
void GNUNET_VPN_disconnect(struct GNUNET_VPN_Handle *vh)
Disconnect from the VPN service.
Definition: vpn_api.c:526
static struct GNUNET_DHT_Handle * dht_handle
Resolver handle to the dht.
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
static struct GNS_ResolverHandle * rlh_head
Head of resolver lookup list.
static struct CacheOps * co_tail
Organized in a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
static struct CacheOps * co_head
Organized in a DLL.
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_EcdsaPublicKey zone,
uint32_t  record_type,
const char *  name,
enum GNUNET_GNS_LocalOptions  options,
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
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
procthe processor to call on result
proc_clsthe closure to pass to proc
Returns
handle to cancel operation

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

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::name, GNS_ResolverHandle::name_resolution_pos, options, GNS_ResolverHandle::options, GNS_ResolverHandle::proc, GNS_ResolverHandle::proc_cls, GNS_ResolverHandle::record_type, Gns2DnsPending::rh, start_resolver_lookup(), GNS_ResolverHandle::task_id, and zone.

Referenced by handle_dns_request(), and handle_lookup().

2733 {
2734  struct GNS_ResolverHandle *rh;
2735 
2737  "Starting lookup for `%s'\n",
2738  name);
2739  rh = GNUNET_new (struct GNS_ResolverHandle);
2741  rlh_tail,
2742  rh);
2743  rh->authority_zone = *zone;
2744  rh->proc = proc;
2745  rh->proc_cls = proc_cls;
2746  rh->options = options;
2747  rh->record_type = record_type;
2748  rh->name = GNUNET_strdup (name);
2749  rh->name_resolution_pos = strlen (name);
2751  rh);
2752  return rh;
2753 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
GNS_ResultProcessor proc
called when resolution phase finishes
#define GNUNET_new(type)
Allocate a struct or union of the given type.
char * name
The name to resolve.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle to a currenty pending resolution.
void * proc_cls
closure passed to proc
static void start_resolver_lookup(void *cls)
Begin the resolution process from 'name', starting with the identification of the zone specified by '...
static char * zone
Name of the zone we manage.
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:1273
int record_type
Desired type for the resolution.
struct GNUNET_SCHEDULER_Task * task_id
ID of a task associated with the resolution process.
size_t name_resolution_pos
Current offset in 'name' where we are resolving.
const char * name
struct GNUNET_CRYPTO_EcdsaPublicKey authority_zone
The top-level GNS authoritative zone to query.
#define GNUNET_log(kind,...)
static struct GNS_ResolverHandle * rlh_head
Head of resolver lookup list.
static struct GNS_ResolverHandle * rlh_tail
Tail of resolver lookup list.
enum GNUNET_GNS_LocalOptions options
Use only cache.
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 2762 of file gnunet-service-gns_resolver.c.

References Gns2DnsPending::ac, GNS_ResolverHandle::ac_head, GNS_ResolverHandle::ac_tail, AuthorityChain::authority_info, GNS_ResolverHandle::dht_heap_node, AuthorityChain::dns_authority, 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_free_non_null, GNUNET_log, GNUNET_NAMECACHE_cancel(), GNUNET_NO, GNUNET_RESOLVER_request_cancel(), GNUNET_REVOCATION_query_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_VPN_cancel_request(), AuthorityChain::label, GNS_ResolverHandle::leho, GNS_ResolverHandle::name, GNS_ResolverHandle::namecache_qe, VpnContext::rd_data, GNS_ResolverHandle::rev_check, Gns2DnsPending::rh, GNS_ResolverHandle::std_resolve, GNS_ResolverHandle::task_id, GNS_ResolverHandle::vpn_ctx, and VpnContext::vpn_request.

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

2763 {
2764  struct DnsResult *dr;
2765  struct AuthorityChain *ac;
2766  struct VpnContext *vpn_ctx;
2767 
2769  rlh_tail,
2770  rh);
2771  if (NULL != rh->dns_request)
2772  {
2774  rh->dns_request = NULL;
2775  }
2776  while (NULL != (ac = rh->ac_head))
2777  {
2779  rh->ac_tail,
2780  ac);
2781  if (GNUNET_NO == ac->gns_authority)
2782  {
2783  struct Gns2DnsPending *gp;
2784 
2785  while (NULL != (gp = ac->authority_info.dns_authority.gp_head))
2786  {
2788  ac->authority_info.dns_authority.gp_tail,
2789  gp);
2790  if (NULL != gp->rh)
2791  {
2792  /* rh->g2dc->rh is NOT in the DLL yet, so to enable us
2793  using GNS_resolver_lookup_cancel here, we need to
2794  add it first... */
2796  rlh_tail,
2797  gp->rh);
2798  GNUNET_assert (NULL == gp->rh->task_id);
2800  gp->rh);
2801  gp->rh = NULL;
2802  }
2803  if (NULL != gp->dns_rh)
2804  {
2806  gp->dns_rh = NULL;
2807  }
2808  GNUNET_free (gp);
2809  }
2811  }
2812  GNUNET_free (ac->label);
2813  GNUNET_free (ac);
2814  }
2815  if (NULL != rh->task_id)
2816  {
2818  rh->task_id = NULL;
2819  }
2820  if (NULL != rh->get_handle)
2821  {
2823  rh->get_handle = NULL;
2824  }
2825  if (NULL != rh->dht_heap_node)
2826  {
2828  rh->dht_heap_node = NULL;
2829  }
2830  if (NULL != (vpn_ctx = rh->vpn_ctx))
2831  {
2833  GNUNET_free (vpn_ctx->rd_data);
2834  GNUNET_free (vpn_ctx);
2835  }
2836  if (NULL != rh->namecache_qe)
2837  {
2839  rh->namecache_qe = NULL;
2840  }
2841  if (NULL != rh->rev_check)
2842  {
2844  rh->rev_check = NULL;
2845  }
2846  if (NULL != rh->std_resolve)
2847  {
2849  "Canceling standard DNS resolution\n");
2851  rh->std_resolve = NULL;
2852  }
2853  while (NULL != (dr = rh->dns_result_head))
2854  {
2856  rh->dns_result_tail,
2857  dr);
2858  GNUNET_free (dr);
2859  }
2860  GNUNET_free_non_null (rh->leho);
2861  GNUNET_free (rh->name);
2862  GNUNET_free (rh);
2863 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNS_ResolverHandle * rh
Handle for the resolution of the IP part of the GNS2DNS record.
void GNUNET_REVOCATION_query_cancel(struct GNUNET_REVOCATION_Query *q)
Cancel key revocation check.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_DHT_GetHandle * get_handle
Handle for DHT lookups.
static void GNS_resolver_lookup_cancel_(void *cls)
Wrapper around GNS_resolver_lookup_cancel() as a task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition: dnsstub.c:731
char * label
label/name corresponding to the authority
struct GNUNET_VPN_RedirectionRequest * vpn_request
Handle to the VPN request that we were performing.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * name
The name to resolve.
int gns_authority
GNUNET_YES if the authority was a GNS authority, GNUNET_NO if the authority was a DNS authority...
struct AuthorityChain * ac_head
DLL to store the authority chain.
struct GNUNET_RESOLVER_RequestHandle * std_resolve
Handle for standard DNS resolution, NULL if none is active.
struct AuthorityChain * ac_tail
DLL to store the authority chain.
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:1273
struct GNUNET_NAMECACHE_QueueEntry * namecache_qe
Pending Namecache lookup task.
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
DLL to hold the authority chain we had to pass in the resolution process.
struct GNUNET_SCHEDULER_Task * task_id
ID of a task associated with the resolution process.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
void GNUNET_VPN_cancel_request(struct GNUNET_VPN_RedirectionRequest *rr)
Cancel redirection request with the service.
Definition: vpn_api.c:369
A result we got from DNS.
struct GNUNET_CONTAINER_HeapNode * dht_heap_node
Heap node associated with this lookup.
Element of a resolution process for looking up the responsible DNS server hostname in a GNS2DNS recur...
struct VpnContext * vpn_ctx
Handle to a VPN request, NULL if none is active.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
char * rd_data
Serialized records.
struct GNUNET_DNSSTUB_RequestSocket * dns_request
Socket for a DNS request, NULL if none is active.
struct GNUNET_RESOLVER_RequestHandle * dns_rh
Handle for DNS resolution of the DNS nameserver.
Closure for vpn_allocation_cb.
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition: dnsstub.c:571
#define GNUNET_log(kind,...)
static struct GNS_ResolverHandle * rlh_head
Head of resolver lookup list.
static struct GNS_ResolverHandle * rlh_tail
Tail of resolver lookup list.
struct GNUNET_REVOCATION_Query * rev_check
Pending revocation check.
struct DnsResult * dns_result_tail
DLL of results we got from DNS.
char * leho
Legacy Hostname to use if we encountered GNS2DNS record and thus can deduct the LEHO from that transi...
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
union AuthorityChain::@22 authority_info
Information about the resolver authority for this label.
struct DnsResult * dns_result_head
DLL of results we got from DNS.
#define GNUNET_free(ptr)
Wrapper around free.
struct AuthorityChain::@22::@23 dns_authority
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function: