aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_peerstore_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_peerstore_service.h')
-rw-r--r--src/include/gnunet_peerstore_service.h148
1 files changed, 147 insertions, 1 deletions
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
index c4000c680..c57a66b1f 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -46,6 +46,10 @@ extern "C" {
46#endif 46#endif
47#endif 47#endif
48 48
49/**
50 * Key used for storing HELLO in the peerstore
51 */
52#define GNUNET_PEERSTORE_HELLO_KEY "peerstore-peer-hello-uri"
49 53
50/** 54/**
51 * Key used for storing addresses in URL format in the peerstore 55 * Key used for storing addresses in URL format in the peerstore
@@ -118,6 +122,11 @@ struct GNUNET_PEERSTORE_Handle;
118struct GNUNET_PEERSTORE_StoreContext; 122struct GNUNET_PEERSTORE_StoreContext;
119 123
120/** 124/**
125 * Context for the info handler.
126 */
127struct GNUNET_PEERSTORE_NotifyContext;
128
129/**
121 * Single PEERSTORE record 130 * Single PEERSTORE record
122 */ 131 */
123struct GNUNET_PEERSTORE_Record 132struct GNUNET_PEERSTORE_Record
@@ -170,6 +179,73 @@ typedef void (*GNUNET_PEERSTORE_Continuation) (void *cls, int success);
170 179
171 180
172/** 181/**
182 * Context for a add hello uri request.
183 */
184struct GNUNET_PEERSTORE_StoreHelloContext
185{
186 /**
187 * Kept (also) in a DLL.
188 */
189 struct GNUNET_PEERSTORE_StoreHelloContext *prev;
190
191 /**
192 * Kept (also) in a DLL.
193 */
194 struct GNUNET_PEERSTORE_StoreHelloContext *next;
195
196 /**
197 * Peerstore handle.
198 */
199 struct GNUNET_PEERSTORE_Handle *h;
200
201 /**
202 * Function to call with information.
203 */
204 GNUNET_PEERSTORE_Continuation cont;
205
206 /**
207 * Closure for @e callback.
208 */
209 void *cont_cls;
210
211 /**
212 * Map with all store contexts started during adding hello.
213 */
214 struct GNUNET_CONTAINER_MultiPeerMap *store_context_map;
215
216 /**
217 * Active watch to be notified about conflicting hello uri add requests.
218 */
219 struct GNUNET_PEERSTORE_WatchContext *wc;
220
221 /**
222 * Hello uri which was request for storing.
223 */
224 struct GNUNET_MessageHeader *hello;
225
226 /**
227 * The peer id for the hello.
228 */
229 struct GNUNET_PeerIdentity *pid;
230
231 /**
232 * Was this request successful.
233 */
234 int success;
235};
236
237/**
238 * Closure to hold a GNUNET_PEERSTORE_StoreHelloContext.
239 */
240struct GNUNET_PEERSTORE_StoreHelloContextClosure
241{
242 /**
243 * The GNUNET_PEERSTORE_StoreHelloContext to hold.
244 */
245 struct GNUNET_PEERSTORE_StoreHelloContext *shc;
246};
247
248/**
173 * Function called by PEERSTORE for each matching record. 249 * Function called by PEERSTORE for each matching record.
174 * 250 *
175 * @param cls closure 251 * @param cls closure
@@ -181,6 +257,75 @@ typedef void (*GNUNET_PEERSTORE_Processor) (
181 const struct GNUNET_PEERSTORE_Record *record, 257 const struct GNUNET_PEERSTORE_Record *record,
182 const char *emsg); 258 const char *emsg);
183 259
260/**
261 * Function called by PEERSTORE when notifying a client about a changed hello.
262 *
263 * @param cls closure
264 * @param hello_uri Hello uri.
265 */
266typedef void (*GNUNET_PEERSTORE_hello_notify_cb) (
267 void *cls,
268 const struct GNUNET_PeerIdentity *peer,
269 const struct GNUNET_MessageHeader *hello,
270 const char *err_msg);
271
272/**
273 * Call a method whenever our known information about peers
274 * changes. Initially calls the given function for all known
275 * peers and then only signals changes.
276 *
277 * If @a include_friend_only is set to #GNUNET_YES peerinfo will include HELLO
278 * messages which are intended for friend to friend mode and which do not
279 * have to be gossiped. Otherwise these messages are skipped. //FIXME Not implemented atm!
280 *
281 * @param h Handle to the PEERSTORE service
282 * @param include_friend_only include HELLO messages for friends only (not used at the moment)
283 * @param callback the method to call for getting the hello.
284 * @param callback_cls closure for @a callback
285 * @return NULL on error
286 */
287struct GNUNET_PEERSTORE_NotifyContext *
288GNUNET_PEERSTORE_hello_changed_notify (struct GNUNET_PEERSTORE_Handle *h,
289 int include_friend_only,
290 GNUNET_PEERSTORE_hello_notify_cb callback,
291 void *callback_cls);
292
293
294/**
295 * Stop notifying about changes.
296 *
297 * @param nc context to stop notifying
298 */
299void
300GNUNET_PEERSTORE_hello_changed_notify_cancel (struct
301 GNUNET_PEERSTORE_NotifyContext *nc);
302
303
304/**
305 * Add hello to peerstore.
306 *
307 * @param h handle for peerstore.
308 * @param msg The hello to add.
309 * @param cont The continuation function to execute after storing.
310 * @param cont_cls The continuation function closure.
311 * @return The context for storing.
312 */
313struct GNUNET_PEERSTORE_StoreHelloContext *
314GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h,
315 const struct GNUNET_MessageHeader *msg,
316 GNUNET_PEERSTORE_Continuation cont,
317 void *cont_cls);
318
319
320/**
321 * Cancel the request to add a hello.
322 *
323 * @param huc The context for storing a hello.
324 */
325void
326GNUNET_PEERSTORE_hello_add_cancel (struct
327 GNUNET_PEERSTORE_StoreHelloContext *huc);
328
184 329
185/** 330/**
186 * Connect to the PEERSTORE service. 331 * Connect to the PEERSTORE service.
@@ -273,7 +418,8 @@ GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic);
273 418
274/** 419/**
275 * Request watching a given key 420 * Request watching a given key
276 * User will be notified with any new values added to key. 421 * User will be notified with any new values added to key,
422 * all existing entries are supplied beforehand.
277 * 423 *
278 * @param h handle to the PEERSTORE service 424 * @param h handle to the PEERSTORE service
279 * @param sub_system name of sub system 425 * @param sub_system name of sub system