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