-more coding towards working new GNS service
[oweals/gnunet.git] / src / gns / gnunet-service-gns_resolver.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009-2013 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file gns/gnunet-service-gns_resolver.h
22  * @brief GNUnet GNS service
23  * @author Martin Schanzenbach
24  */
25 #ifndef GNS_RESOLVER_H
26 #define GNS_RESOLVER_H
27 #include "gns.h"
28 #include "gnunet_dht_service.h"
29
30
31 /**
32  * Initialize the resolver subsystem.
33  * MUST be called before #GNS_resolver_lookup.
34  *
35  * @param nh handle to the namestore
36  * @param dht handle to the dht
37  * @param c configuration handle
38  * @param max_bg_queries maximum amount of background queries
39  * @param ignore_pending ignore records that still require user confirmation
40  *        on lookup
41  * @returns GNUNET_OK on success
42  */
43 int
44 GNS_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
45                    struct GNUNET_DHT_Handle *dht,
46                    const struct GNUNET_CONFIGURATION_Handle *c,
47                    unsigned long long max_bg_queries,
48                    int ignore_pending);
49
50
51 /**
52  * Cleanup resolver: Terminate pending lookups
53  */
54 void
55 GNS_resolver_done (void);
56
57
58 /**
59  * Handle for an active request.
60  */
61 struct GNS_ResolverHandle;
62
63
64 /**
65  * Function called with results for a GNS resolution.
66  *
67  * @param cls closure
68  * @param rd_count number of records in @a rd
69  * @param rd records returned for the lookup
70  */
71 typedef void (*GNS_ResultProcessor)(void *cls,
72                                     uint32_t rd_count,
73                                     const struct GNUNET_NAMESTORE_RecordData *rd);
74
75
76 /**
77  * Lookup of a record in a specific zone
78  * calls RecordLookupProcessor on result or timeout
79  *
80  * @param zone the zone to perform the lookup in
81  * @param record_type the record type to look up
82  * @param name the name to look up
83  * @param shorten_key optional private key for authority caching, can be NULL
84  * @param only_cached GNUNET_NO to only check locally not DHT for performance
85  * @param proc the processor to call
86  * @param proc_cls the closure to pass to @a proc
87  */
88 struct GNS_ResolverHandle *
89 GNS_resolver_lookup (const struct GNUNET_CRYPTO_EccPublicKey *zone,
90                      uint32_t record_type,
91                      const char *name,
92                      const struct GNUNET_CRYPTO_EccPrivateKey *shorten_key,
93                      int only_cached,
94                      GNS_ResultProcessor proc,
95                      void *proc_cls);
96
97
98 /**
99  * Cancel active resolution (i.e. client disconnected).
100  *
101  * @param h resolution to abort
102  */
103 void
104 GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *h);
105
106
107
108
109
110 /**
111  * Generic function to check for TLDs.  Checks if "name" ends in ".tld"
112  *
113  * @param name the name to check
114  * @param tld the tld to check
115  * @return #GNUNET_YES or #GNUNET_NO
116  */
117 int
118 is_tld (const char *name, 
119         const char *tld);
120
121
122
123 /**
124  * Checks for gnu/zkey
125  */
126 #define is_gads_tld(name) is_tld(name, GNUNET_GNS_TLD)
127 #define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY)
128
129
130 #endif