diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_neighbours.h')
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.h | 226 |
1 files changed, 0 insertions, 226 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h deleted file mode 100644 index 96db21b9b..000000000 --- a/src/dht/gnunet-service-dht_neighbours.h +++ /dev/null | |||
@@ -1,226 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009, 2010, 2011, 2022 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 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file dht/gnunet-service-dht_neighbours.h | ||
23 | * @brief GNUnet DHT routing code | ||
24 | * @author Christian Grothoff | ||
25 | * @author Nathan Evans | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_DHT_NEIGHBOURS_H | ||
28 | #define GNUNET_SERVICE_DHT_NEIGHBOURS_H | ||
29 | |||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_block_lib.h" | ||
32 | #include "gnunet_dht_service.h" | ||
33 | #include "gnunet_dhtu_plugin.h" | ||
34 | #include "gnunet-service-dht_datacache.h" | ||
35 | |||
36 | |||
37 | struct PeerInfo; | ||
38 | |||
39 | /** | ||
40 | * Lookup peer by peer's identity. | ||
41 | * | ||
42 | * @param target peer to look up | ||
43 | * @return NULL if we are not connected to @a target | ||
44 | */ | ||
45 | struct PeerInfo * | ||
46 | GDS_NEIGHBOURS_lookup_peer (const struct GNUNET_PeerIdentity *target); | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Perform a PUT operation. Forwards the given request to other | ||
51 | * peers. Does not store the data locally. Does not give the | ||
52 | * data to local clients. May do nothing if this is the only | ||
53 | * peer in the network (or if we are the closest peer in the | ||
54 | * network). | ||
55 | * | ||
56 | * @param bd data about the block | ||
57 | * @param desired_replication_level desired replication level | ||
58 | * @param hop_count how many hops has this message traversed so far | ||
59 | * @param bf Bloom filter of peers this PUT has already traversed | ||
60 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not | ||
61 | */ | ||
62 | enum GNUNET_GenericReturnValue | ||
63 | GDS_NEIGHBOURS_handle_put (const struct GNUNET_DATACACHE_Block *bd, | ||
64 | uint16_t desired_replication_level, | ||
65 | uint16_t hop_count, | ||
66 | struct GNUNET_CONTAINER_BloomFilter *bf); | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Perform a GET operation. Forwards the given request to other | ||
71 | * peers. Does not lookup the key locally. May do nothing if this is | ||
72 | * the only peer in the network (or if we are the closest peer in the | ||
73 | * network). | ||
74 | * | ||
75 | * @param type type of the block | ||
76 | * @param options routing options | ||
77 | * @param desired_replication_level desired replication count | ||
78 | * @param hop_count how many hops did this request traverse so far? | ||
79 | * @param key key for the content | ||
80 | * @param xquery extended query | ||
81 | * @param xquery_size number of bytes in @a xquery | ||
82 | * @param bg block group to filter replies | ||
83 | * @param peer_bf filter for peers not to select (again, updated) | ||
84 | * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not | ||
85 | */ | ||
86 | enum GNUNET_GenericReturnValue | ||
87 | GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type, | ||
88 | enum GNUNET_DHT_RouteOption options, | ||
89 | uint16_t desired_replication_level, | ||
90 | uint16_t hop_count, | ||
91 | const struct GNUNET_HashCode *key, | ||
92 | const void *xquery, | ||
93 | size_t xquery_size, | ||
94 | struct GNUNET_BLOCK_Group *bg, | ||
95 | struct GNUNET_CONTAINER_BloomFilter *peer_bf); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Handle a reply (route to origin). Only forwards the reply back to | ||
100 | * other peers waiting for it. Does not do local caching or | ||
101 | * forwarding to local clients. | ||
102 | * | ||
103 | * @param pi neighbour that should receive the block | ||
104 | * @param type type of the block | ||
105 | * @param bd details about the reply | ||
106 | * @param query_hash query that was used for the request | ||
107 | * @param get_path_length number of entries in put_path | ||
108 | * @param get_path peers this reply has traversed so far (if tracked) | ||
109 | * @return true on success | ||
110 | */ | ||
111 | bool | ||
112 | GDS_NEIGHBOURS_handle_reply (struct PeerInfo *pi, | ||
113 | const struct GNUNET_DATACACHE_Block *bd, | ||
114 | const struct GNUNET_HashCode *query_hash, | ||
115 | unsigned int get_path_length, | ||
116 | const struct GNUNET_DHT_PathElement *get_path); | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Check whether my identity is closer than any known peers. If a | ||
121 | * non-null bloomfilter is given, check if this is the closest peer | ||
122 | * that hasn't already been routed to. | ||
123 | * | ||
124 | * @param key hash code to check closeness to | ||
125 | * @param bloom bloomfilter, exclude these entries from the decision | ||
126 | * @return #GNUNET_YES if node location is closest, | ||
127 | * #GNUNET_NO otherwise. | ||
128 | */ | ||
129 | enum GNUNET_GenericReturnValue | ||
130 | GDS_am_closest_peer (const struct GNUNET_HashCode *key, | ||
131 | const struct GNUNET_CONTAINER_BloomFilter *bloom); | ||
132 | |||
133 | |||
134 | /** | ||
135 | * Callback function used to extract URIs from a builder. | ||
136 | * Called when we should consider connecting to a peer. | ||
137 | * | ||
138 | * @param cls closure pointing to a `struct GNUNET_PeerIdentity *` | ||
139 | * @param uri one of the URIs | ||
140 | */ | ||
141 | void | ||
142 | GDS_try_connect (void *cls, | ||
143 | const char *uri); | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Function to call when we connect to a peer and can henceforth transmit to | ||
148 | * that peer. | ||
149 | * | ||
150 | * @param cls the closure, must be a `struct GDS_Underlay` | ||
151 | * @param target handle to the target, | ||
152 | * pointer will remain valid until @e disconnect_cb is called | ||
153 | * @para pid peer identity, | ||
154 | * pointer will remain valid until @e disconnect_cb is called | ||
155 | * @param[out] ctx storage space for DHT to use in association with this target | ||
156 | */ | ||
157 | void | ||
158 | GDS_u_connect (void *cls, | ||
159 | struct GNUNET_DHTU_Target *target, | ||
160 | const struct GNUNET_PeerIdentity *pid, | ||
161 | void **ctx); | ||
162 | |||
163 | |||
164 | /** | ||
165 | * Function to call when we disconnected from a peer and can henceforth | ||
166 | * cannot transmit to that peer anymore. | ||
167 | * | ||
168 | * @param[in] ctx storage space used by the DHT in association with this target | ||
169 | */ | ||
170 | void | ||
171 | GDS_u_disconnect (void *ctx); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Function to call when we receive a message. | ||
176 | * | ||
177 | * @param cls the closure | ||
178 | * @param origin where the message originated from | ||
179 | * @param[in,out] tctx ctx of target address where we received the message from | ||
180 | * @param[in,out] sctx ctx of our own source address at which we received the message | ||
181 | * @param message the message we received @param message_size number of | ||
182 | * bytes in @a message | ||
183 | */ | ||
184 | void | ||
185 | GDS_u_receive (void *cls, | ||
186 | void **tctx, | ||
187 | void **sctx, | ||
188 | const void *message, | ||
189 | size_t message_size); | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Send @a msg to all peers in our buckets. | ||
194 | * | ||
195 | * @param msg message to broadcast | ||
196 | */ | ||
197 | void | ||
198 | GDS_NEIGHBOURS_broadcast (const struct GNUNET_MessageHeader *msg); | ||
199 | |||
200 | |||
201 | /** | ||
202 | * Initialize neighbours subsystem. | ||
203 | * | ||
204 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
205 | */ | ||
206 | enum GNUNET_GenericReturnValue | ||
207 | GDS_NEIGHBOURS_init (void); | ||
208 | |||
209 | |||
210 | /** | ||
211 | * Shutdown neighbours subsystem. | ||
212 | */ | ||
213 | void | ||
214 | GDS_NEIGHBOURS_done (void); | ||
215 | |||
216 | |||
217 | /** | ||
218 | * Get the ID of the local node. | ||
219 | * | ||
220 | * @return identity of the local node | ||
221 | */ | ||
222 | struct GNUNET_PeerIdentity * | ||
223 | GDS_NEIGHBOURS_get_id (void); | ||
224 | |||
225 | |||
226 | #endif | ||