diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-16 19:32:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-16 19:32:52 +0000 |
commit | 6308c2556c54ea8a19b33bfe16bd2f81eae65e86 (patch) | |
tree | 2017381fa55744868e3664b59a46d60cce8c2433 /src/include/gnunet_namecache_service.h | |
parent | e71d2567fc6d2634c503587ba481cc92f5f5e60e (diff) | |
download | gnunet-6308c2556c54ea8a19b33bfe16bd2f81eae65e86.tar.gz gnunet-6308c2556c54ea8a19b33bfe16bd2f81eae65e86.zip |
-copied block-related functions from namestore to namecache
Diffstat (limited to 'src/include/gnunet_namecache_service.h')
-rw-r--r-- | src/include/gnunet_namecache_service.h | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/src/include/gnunet_namecache_service.h b/src/include/gnunet_namecache_service.h new file mode 100644 index 000000000..1a71f1ebd --- /dev/null +++ b/src/include/gnunet_namecache_service.h | |||
@@ -0,0 +1,163 @@ | |||
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_namecache_service.h | ||
23 | * @brief API that can be used to store naming information on a GNUnet node; | ||
24 | * Naming information can either be records for which this peer/user | ||
25 | * is authoritative, or blocks which are cached, encrypted naming | ||
26 | * data from other peers. | ||
27 | * @author Christian Grothoff | ||
28 | */ | ||
29 | #ifndef GNUNET_NAMECACHE_SERVICE_H | ||
30 | #define GNUNET_NAMECACHE_SERVICE_H | ||
31 | |||
32 | #include "gnunet_util_lib.h" | ||
33 | #include "gnunet_block_lib.h" | ||
34 | #include "gnunet_namestore_service.h" | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Entry in the queue. | ||
47 | */ | ||
48 | struct GNUNET_NAMECACHE_QueueEntry; | ||
49 | |||
50 | /** | ||
51 | * Handle to the namecache service. | ||
52 | */ | ||
53 | struct GNUNET_NAMECACHE_Handle; | ||
54 | |||
55 | /** | ||
56 | * Maximum size of a value that can be stored in the namecache. | ||
57 | */ | ||
58 | #define GNUNET_NAMECACHE_MAX_VALUE_SIZE (63 * 1024) | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Connect to the namecache service. | ||
63 | * | ||
64 | * @param cfg configuration to use | ||
65 | * @return handle to use to access the service | ||
66 | */ | ||
67 | struct GNUNET_NAMECACHE_Handle * | ||
68 | GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Disconnect from the namecache service (and free associated | ||
73 | * resources). Must not be called from within operation callbacks of | ||
74 | * the API. | ||
75 | * | ||
76 | * @param h handle to the namecache | ||
77 | */ | ||
78 | void | ||
79 | GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h); | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Continuation called to notify client about result of the | ||
84 | * operation. | ||
85 | * | ||
86 | * @param cls closure | ||
87 | * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | ||
88 | * #GNUNET_NO if content was already there or not found | ||
89 | * #GNUNET_YES (or other positive value) on success | ||
90 | * @param emsg NULL on success, otherwise an error message | ||
91 | */ | ||
92 | typedef void (*GNUNET_NAMECACHE_ContinuationWithStatus) (void *cls, | ||
93 | int32_t success, | ||
94 | const char *emsg); | ||
95 | |||
96 | |||
97 | |||
98 | /** | ||
99 | * Store an item in the namecache. If the item is already present, | ||
100 | * it is replaced with the new record. | ||
101 | * | ||
102 | * @param h handle to the namecache | ||
103 | * @param block block to store | ||
104 | * @param cont continuation to call when done | ||
105 | * @param cont_cls closure for @a cont | ||
106 | * @return handle to abort the request | ||
107 | */ | ||
108 | struct GNUNET_NAMECACHE_QueueEntry * | ||
109 | GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h, | ||
110 | const struct GNUNET_NAMESTORE_Block *block, | ||
111 | GNUNET_NAMECACHE_ContinuationWithStatus cont, | ||
112 | void *cont_cls); | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Process a record that was stored in the namecache. | ||
117 | * | ||
118 | * @param cls closure | ||
119 | * @param block block that was stored in the namecache | ||
120 | */ | ||
121 | typedef void (*GNUNET_NAMECACHE_BlockProcessor) (void *cls, | ||
122 | const struct GNUNET_NAMESTORE_Block *block); | ||
123 | |||
124 | |||
125 | /** | ||
126 | * Get a result for a particular key from the namecache. The processor | ||
127 | * will only be called once. | ||
128 | * | ||
129 | * @param h handle to the namecache | ||
130 | * @param derived_hash hash of zone key combined with name to lookup | ||
131 | * then at the end once with NULL | ||
132 | * @param proc function to call on the matching block, or with | ||
133 | * NULL if there is no matching block | ||
134 | * @param proc_cls closure for @a proc | ||
135 | * @return a handle that can be used to cancel | ||
136 | */ | ||
137 | struct GNUNET_NAMECACHE_QueueEntry * | ||
138 | GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h, | ||
139 | const struct GNUNET_HashCode *derived_hash, | ||
140 | GNUNET_NAMECACHE_BlockProcessor proc, void *proc_cls); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Cancel a namecache operation. The final callback from the | ||
145 | * operation must not have been done yet. Must be called on any | ||
146 | * namecache operation that has not yet completed prior to calling | ||
147 | * #GNUNET_NAMECACHE_disconnect. | ||
148 | * | ||
149 | * @param qe operation to cancel | ||
150 | */ | ||
151 | void | ||
152 | GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe); | ||
153 | |||
154 | |||
155 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
156 | { | ||
157 | #endif | ||
158 | #ifdef __cplusplus | ||
159 | } | ||
160 | #endif | ||
161 | |||
162 | /* end of gnunet_namecache_service.h */ | ||
163 | #endif | ||