paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / dht / gnunet-service-dht.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009-2016 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20  * @file dht/gnunet-service-dht.h
21  * @brief GNUnet DHT globals
22  * @author Christian Grothoff
23  */
24 #ifndef GNUNET_SERVICE_DHT_H
25 #define GNUNET_SERVICE_DHT_H
26
27 #include "gnunet_util_lib.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet_transport_service.h"
30 #include "gnunet_block_lib.h"
31
32 #define DEBUG_DHT GNUNET_EXTRA_LOGGING
33
34 /**
35  * Configuration we use.
36  */
37 extern const struct GNUNET_CONFIGURATION_Handle *GDS_cfg;
38
39 /**
40  * Handle for the service.
41  */
42 extern struct GNUNET_SERVICE_Handle *GDS_service;
43
44 /**
45  * Our handle to the BLOCK library.
46  */
47 extern struct GNUNET_BLOCK_Context *GDS_block_context;
48
49 /**
50  * Handle for the statistics service.
51  */
52 extern struct GNUNET_STATISTICS_Handle *GDS_stats;
53
54 /**
55  * Our HELLO
56  */
57 extern struct GNUNET_MessageHeader *GDS_my_hello;
58
59
60
61 /**
62  * Handle a reply we've received from another peer.  If the reply
63  * matches any of our pending queries, forward it to the respective
64  * client(s).
65  *
66  * @param expiration when will the reply expire
67  * @param key the query this reply is for
68  * @param get_path_length number of peers in @a get_path
69  * @param get_path path the reply took on get
70  * @param put_path_length number of peers in @a put_path
71  * @param put_path path the reply took on put
72  * @param type type of the reply
73  * @param data_size number of bytes in @a data
74  * @param data application payload data
75  */
76 void
77 GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
78                           const struct GNUNET_HashCode *key,
79                           unsigned int get_path_length,
80                           const struct GNUNET_PeerIdentity *get_path,
81                           unsigned int put_path_length,
82                           const struct GNUNET_PeerIdentity *put_path,
83                           enum GNUNET_BLOCK_Type type,
84                           size_t data_size,
85                           const void *data);
86
87
88 /**
89  * Check if some client is monitoring GET messages and notify
90  * them in that case.
91  *
92  * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
93  * @param type The type of data in the request.
94  * @param hop_count Hop count so far.
95  * @param path_length number of entries in path (or 0 if not recorded).
96  * @param path peers on the GET path (or NULL if not recorded).
97  * @param desired_replication_level Desired replication level.
98  * @param key Key of the requested data.
99  */
100 void
101 GDS_CLIENTS_process_get (uint32_t options,
102                          enum GNUNET_BLOCK_Type type,
103                          uint32_t hop_count,
104                          uint32_t desired_replication_level,
105                          unsigned int path_length,
106                          const struct GNUNET_PeerIdentity *path,
107                          const struct GNUNET_HashCode *key);
108
109
110 /**
111  * Check if some client is monitoring GET RESP messages and notify
112  * them in that case.
113  *
114  * @param type The type of data in the result.
115  * @param get_path Peers on GET path (or NULL if not recorded).
116  * @param get_path_length number of entries in @a get_path.
117  * @param put_path peers on the PUT path (or NULL if not recorded).
118  * @param put_path_length number of entries in @a get_path.
119  * @param exp Expiration time of the data.
120  * @param key Key of the @a data.
121  * @param data Pointer to the result data.
122  * @param size Number of bytes in @a data.
123  */
124 void
125 GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
126                               const struct GNUNET_PeerIdentity *get_path,
127                               unsigned int get_path_length,
128                               const struct GNUNET_PeerIdentity *put_path,
129                               unsigned int put_path_length,
130                               struct GNUNET_TIME_Absolute exp,
131                               const struct GNUNET_HashCode * key,
132                               const void *data,
133                               size_t size);
134
135
136 /**
137  * Check if some client is monitoring PUT messages and notify
138  * them in that case.
139  *
140  * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
141  * @param type The type of data in the request.
142  * @param hop_count Hop count so far.
143  * @param path_length number of entries in path (or 0 if not recorded).
144  * @param path peers on the PUT path (or NULL if not recorded).
145  * @param desired_replication_level Desired replication level.
146  * @param exp Expiration time of the data.
147  * @param key Key under which data is to be stored.
148  * @param data Pointer to the data carried.
149  * @param size Number of bytes in data.
150  */
151 void
152 GDS_CLIENTS_process_put (uint32_t options,
153                          enum GNUNET_BLOCK_Type type,
154                          uint32_t hop_count,
155                          uint32_t desired_replication_level,
156                          unsigned int path_length,
157                          const struct GNUNET_PeerIdentity *path,
158                          struct GNUNET_TIME_Absolute exp,
159                          const struct GNUNET_HashCode *key,
160                          const void *data,
161                          size_t size);
162
163 #endif