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