should be uint32_t
[oweals/gnunet.git] / src / include / gnunet_gns_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2012-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 /**
22  * @file include/gnunet_gns_service.h
23  * @brief API to the GNS service
24  * @author Martin Schanzenbach
25  */
26 #ifndef GNUNET_GNS_SERVICE_H
27 #define GNUNET_GNS_SERVICE_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_dnsparser_lib.h"
31 #include "gnunet_namestore_service.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0                           /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40
41
42 /**
43  * String we use to indicate the local master zone or a
44  * root entry in the current zone.
45  */
46 #define GNUNET_GNS_MASTERZONE_STR "+"
47
48 /**
49  * Connection to the GNS service.
50  */
51 struct GNUNET_GNS_Handle;
52
53 /**
54  * Handle to control a lookup operation.
55  */
56 struct GNUNET_GNS_LookupRequest;
57
58
59 /**
60  * Initialize the connection with the GNS service.
61  *
62  * @param cfg configuration to use
63  * @return handle to the GNS service, or NULL on error
64  */
65 struct GNUNET_GNS_Handle *
66 GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
67
68
69 /**
70  * Shutdown connection with the GNS service.
71  *
72  * @param handle connection to shut down
73  */
74 void
75 GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
76
77
78 /**
79  * Iterator called on obtained result for a GNS lookup.
80  *
81  * @param cls closure
82  * @param rd_count number of records in @a rd
83  * @param rd the records in reply
84  */
85 typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
86                                                   uint32_t rd_count,
87                                                   const struct GNUNET_GNSRECORD_Data *rd);
88
89
90 /**
91  * Perform an asynchronous lookup operation on the GNS.
92  *
93  * @param handle handle to the GNS service
94  * @param name the name to look up
95  * @param zone zone to look in
96  * @param type the GNS record type to look for
97  * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
98  * @param shorten_zone_key the private key of the shorten zone (can be NULL);
99  *                    specify to enable automatic shortening (given a PSEU
100  *                    record, if a given pseudonym is not yet used in the
101  *                    shorten zone, we automatically add the respective zone
102  *                    under that name)
103  * @param proc function to call on result
104  * @param proc_cls closure for processor
105  * @return handle to the queued request
106  */
107 struct GNUNET_GNS_LookupRequest *
108 GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
109                    const char *name,
110                    const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
111                    uint32_t type,
112                    int only_cached,
113                    const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
114                    GNUNET_GNS_LookupResultProcessor proc,
115                    void *proc_cls);
116
117
118 /**
119  * Cancel pending lookup request
120  *
121  * @param lr the lookup request to cancel
122  */
123 void
124 GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
125
126
127 #if 0                           /* keep Emacsens' auto-indent happy */
128 {
129 #endif
130 #ifdef __cplusplus
131 }
132 #endif
133
134
135 #endif
136 /* gnunet_gns_service.h */