8dcbc19c53a0ca2137cf6272c0d70535c6a7aab1
[oweals/gnunet.git] / src / include / gnunet_dht_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2004, 2005, 2006, 2008, 2009 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 2, 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_dht_service.h
23  * @brief API to the DHT service
24  * @author Christian Grothoff
25  */
26
27 #ifndef GNUNET_DHT_SERVICE_H
28 #define GNUNET_DHT_SERVICE_H
29
30 #include "gnunet_util_lib.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40 // FIXME: document
41 struct GNUNET_DHT_GetHandle;
42
43
44 /**
45  * Perform an asynchronous GET operation on the DHT identified.
46  *
47  * @param type expected type of the response object
48  * @param key the key to look up
49  * @param iter function to call on each result
50  * @param iter_cls closure for iter
51  * @return handle to stop the async get
52  */
53 struct GNUNET_DHT_GetHandle *
54 GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h,
55                       uint32_t type,
56                       const GNUNET_HashCode * key,
57                       GNUNET_DHT_Iterator iter,
58                       void *iter_cls);
59
60
61 /**
62  * Stop async DHT-get.  Frees associated resources.
63  */
64 int GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *record);
65
66
67 // FIXME: add continuation? expiration?
68 /**
69  * Perform a PUT operation on the DHT identified by 'table' storing
70  * a binding of 'key' to 'value'.  The peer does not have to be part
71  * of the table (if so, we will attempt to locate a peer that is!)
72  *
73  * @param key the key to store under
74  */
75 int GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, 
76                     const GNUNET_HashCode * key,
77                     uint32_t type, 
78                     uint32_t size, 
79                     const char *data);
80
81
82 #if 0                           /* keep Emacsens' auto-indent happy */
83 {
84 #endif
85 #ifdef __cplusplus
86 }
87 #endif
88
89
90 #endif 
91 /* gnunet_dht_service.h */