- mark old API calls used for previous VPN implementation as deprecated
[oweals/gnunet.git] / src / include / gnunet_gns_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2012 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 /**
22  * @file include/gnunet_gns_service.h
23  * @brief API to the GNS service
24  * @author Martin Schanzenbach
25  *
26  * TODO:
27  * - decide what goes into storage API and what into GNS-service API
28  * - decide where to pass/expose/check keys / signatures
29  * - are GNS private keys per peer or per user?
30  */
31
32
33 #ifndef GNUNET_GNS_SERVICE_H
34 #define GNUNET_GNS_SERVICE_H
35
36 #include "gnunet_util_lib.h"
37 #include "gnunet_dnsparser_lib.h"
38 #include "gnunet_namestore_service.h"
39
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #if 0                           /* keep Emacsens' auto-indent happy */
44 }
45 #endif
46 #endif
47
48
49 /**
50  * Connection to the GNS service.
51  */
52 struct GNUNET_GNS_Handle;
53
54 /**
55  * Handle to control a get operation.
56  */
57 struct GNUNET_GNS_LookupHandle;
58
59 /**
60  * Handle to control a shorten operation
61  */
62
63 /**
64  * Record types
65  * Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
66  */
67 enum GNUNET_GNS_RecordType
68 {
69   /* Standard DNS */
70   /* struct in_addr */
71   GNUNET_GNS_RECORD_A          = GNUNET_DNSPARSER_TYPE_A,
72
73   /* char */
74   GNUNET_GNS_RECORD_NS         = GNUNET_DNSPARSER_TYPE_NS,
75
76   /* char */
77   GNUNET_GNS_RECORD_CNAME      = GNUNET_DNSPARSER_TYPE_CNAME,
78
79   /* struct soa_data */
80   GNUNET_GNS_RECORD_SOA        = GNUNET_DNSPARSER_TYPE_SOA,
81
82   /* struct srv_data */
83   GNUNET_GNS_RECORD_SRV        = GNUNET_DNSPARSER_TYPE_SRV,
84
85   /* char */
86   GNUNET_GNS_RECORD_PTR        = GNUNET_DNSPARSER_TYPE_PTR,
87
88   /* uint16_t, char */
89   GNUNET_GNS_RECORD_MX         = GNUNET_DNSPARSER_TYPE_MX,
90
91   /* char */
92   GNUNET_GNS_RECORD_TXT        = GNUNET_DNSPARSER_TYPE_TXT,
93
94   /* struct in6_addr */
95   GNUNET_GNS_RECORD_AAAA       = GNUNET_DNSPARSER_TYPE_AAAA,
96
97   /* GNS specific */
98   /* struct GNUNET_CRYPTO_ShortHashCode */
99   GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
100
101   /* char */
102   GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
103   GNUNET_GNS_RECORD_ANY  = GNUNET_NAMESTORE_TYPE_ANY,
104
105   /* char */
106   GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
107
108   /* struct vpn_data */
109   GNUNET_GNS_RECORD_VPN  = GNUNET_NAMESTORE_TYPE_VPN,
110   GNUNET_GNS_RECORD_REV  = GNUNET_NAMESTORE_TYPE_REV
111 };
112
113 /**
114  * Initialize the connection with the GNS service.
115  *
116  * @param cfg configuration to use
117  *
118  * @return handle to the GNS service, or NULL on error
119  */
120 struct GNUNET_GNS_Handle *
121 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
122
123
124 /**
125  * Shutdown connection with the GNS service.
126  *
127  * @param handle connection to shut down
128  */
129 void
130 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
131
132
133 /* *************** Standard API: lookup ******************* */
134
135 /**
136  * Iterator called on obtained result for a GNS
137  * lookup
138  *
139  * @param cls closure
140  * @param name "name" of the original lookup
141  * @param rd_count number of records
142  * @param rd the records in reply
143  */
144 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
145                                  uint32_t rd_count,
146                                  const struct GNUNET_NAMESTORE_RecordData *rd);
147
148
149
150 /**
151  * Perform an asynchronous lookup operation on the GNS
152  * in the default zone.
153  *
154  * @param handle handle to the GNS service
155  * @param name the name to look up
156  * @param type the GNUNET_GNS_RecordType to look for
157  * @param only_cached GNUNET_NO to only check locally not DHT for performance
158  * @param shorten_key the private key of the shorten zone (can be NULL)
159  * @param proc function to call on result
160  * @param proc_cls closure for processor
161  *
162  * @return handle to the queued request
163  */
164 struct GNUNET_GNS_QueueEntry *
165 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
166                          const char * name,
167                          enum GNUNET_GNS_RecordType type,
168                          int only_cached,
169                          struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
170                          GNUNET_GNS_LookupResultProcessor proc,
171                          void *proc_cls);
172
173 /**
174  * Perform an asynchronous lookup operation on the GNS
175  * in the zone specified by 'zone'.
176  *
177  * @param handle handle to the GNS service
178  * @param name the name to look up
179  * @param zone the zone to start the resolution in
180  * @param type the GNUNET_GNS_RecordType to look for
181  * @param only_cached GNUNET_YES to only check locally not DHT for performance
182  * @param shorten_key the private key of the shorten zone (can be NULL)
183  * @param proc function to call on result
184  * @param proc_cls closure for processor
185  *
186  * @return handle to the queued request
187  */
188 struct GNUNET_GNS_QueueEntry *
189 GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
190                          const char * name,
191                          struct GNUNET_CRYPTO_ShortHashCode *zone,
192                          enum GNUNET_GNS_RecordType type,
193                          int only_cached,
194                          struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
195                          GNUNET_GNS_LookupResultProcessor proc,
196                          void *proc_cls);
197
198 /* *************** Standard API: shorten ******************* */
199
200
201 /**
202  * Processor called on for a name shortening result
203  * called only once
204  *
205  * @param cls closure
206  * @param short_name the shortened name or NULL if no result
207  */
208 typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
209                                         const char* short_name);
210
211
212 /**
213  * Perform a name shortening operation on the GNS.
214  *
215  * @param handle handle to the GNS service
216  * @param name the name to look up
217  * @param private_zone the public zone of the private zone
218  * @param shorten_zone the public zone of the shorten zone
219  * @param proc function to call on result
220  * @param proc_cls closure for processor
221  * @return handle to the operation
222  */
223 struct GNUNET_GNS_QueueEntry *
224 GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
225                     const char * name,
226                     struct GNUNET_CRYPTO_ShortHashCode *private_zone,
227                     struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
228                     GNUNET_GNS_ShortenResultProcessor proc,
229                     void *proc_cls);
230
231
232 /**
233  * Perform a name shortening operation on the GNS.
234  *
235  * @param handle handle to the GNS service
236  * @param name the name to look up
237  * @param private_zone the public zone of the private zone
238  * @param shorten_zone the public zone of the shorten zone
239  * @param zone the zone to start the resolution in
240  * @param proc function to call on result
241  * @param proc_cls closure for processor
242  * @return handle to the operation
243  */
244 struct GNUNET_GNS_QueueEntry *
245 GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
246                          const char * name,
247                          struct GNUNET_CRYPTO_ShortHashCode *private_zone,
248                          struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
249                          struct GNUNET_CRYPTO_ShortHashCode *zone,
250                          GNUNET_GNS_ShortenResultProcessor proc,
251                          void *proc_cls);
252
253 /* *************** Standard API: get authority ******************* */
254
255
256 /**
257  * Processor called on for a name shortening result
258  * called only once
259  *
260  * @param cls closure
261  * @param auth_name the name of the auhtority or NULL
262  */
263 typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
264                                         const char* short_name);
265
266
267 /**
268  * Perform an authority lookup for a given name.
269  *
270  * @param handle handle to the GNS service
271  * @param name the name to look up authority for
272  * @param proc function to call on result
273  * @param proc_cls closure for processor
274  * @return handle to the operation
275  */
276 struct GNUNET_GNS_QueueEntry *
277 GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
278                     const char * name,
279                     GNUNET_GNS_GetAuthResultProcessor proc,
280                     void *proc_cls);
281
282 #if 0                           /* keep Emacsens' auto-indent happy */
283 {
284 #endif
285 #ifdef __cplusplus
286 }
287 #endif
288
289
290 #endif
291 /* gnunet_gns_service.h */