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