2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
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.
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.
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file ats/gnunet-service-ats_addresses.h
23 * @brief ats service address management
24 * @author Matthias Wachs
25 * @author Christian Grothoff
27 #ifndef GNUNET_SERVICE_ATS_ADDRESSES_H
28 #define GNUNET_SERVICE_ATS_ADDRESSES_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_ats_service.h"
32 #include "gnunet_statistics_service.h"
35 #define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
38 * Address with additional information
45 struct ATS_Address *next;
48 * Previous element in DLL
50 struct ATS_Address *prev;
55 struct GNUNET_PeerIdentity peer;
58 * Session ID, 0 if no session is given
78 * MLP specific information
79 * TODO remove or rename
81 void *mlp_information;
86 //struct GNUNET_ATS_Information *ats;
89 * Number of ATS information
94 struct GNUNET_TIME_Relative atsp_latency;
97 struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_in;
100 struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_out;
104 uint32_t atsp_distance;
107 uint32_t atsp_cost_wan;
110 uint32_t atsp_cost_lan;
113 uint32_t atsp_cost_wlan;
116 uint32_t atsp_network_type;
119 * Inbound bandwidth assigned by solver in NBO
121 struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_in;
124 * Outbound bandwidth assigned by solver in NBO
126 struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out;
131 struct GNUNET_TIME_Relative block_interval;
134 * Time when address can be suggested again
136 struct GNUNET_TIME_Absolute blocked_until;
139 * Is this the active address for this peer?
144 * Is this the address for this peer in use?
151 * Init the simplistic problem solving component
154 * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
155 * out_quota[i] contains outbound quota for network type i
156 * in_quota[i] contains inbound quota for network type i
159 * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
160 * network[2] == GNUNET_ATS_NET_LAN
161 * out_quota[2] == 65353
162 * in_quota[2] == 65353
164 * @param cfg configuration handle
165 * @param stats the GNUNET_STATISTICS handle
166 * @param network array of GNUNET_ATS_NetworkType with length dest_length
167 * @param out_quota array of outbound quotas
168 * param in_quota array of outbound quota
169 * @return handle for the solver on success, NULL on fail
172 (*GAS_solver_init) (const struct GNUNET_CONFIGURATION_Handle *cfg,
173 const struct GNUNET_STATISTICS_Handle *stats,
175 unsigned long long *out_quota,
176 unsigned long long *in_quota,
180 (*GAS_solver_address_change_preference) (void *solver,
181 const struct GNUNET_PeerIdentity *peer,
182 enum GNUNET_ATS_PreferenceKind kind,
186 (*GAS_solver_address_delete) (void *solver,
187 struct GNUNET_CONTAINER_MultiHashMap *addresses,
188 struct ATS_Address *address);
191 (*GAS_solver_address_update) (void *solver,
192 struct GNUNET_CONTAINER_MultiHashMap *addresses,
193 struct ATS_Address *address);
196 typedef const struct ATS_Address *
197 (*GAS_solver_get_preferred_address) (void *solver,
198 struct GNUNET_CONTAINER_MultiHashMap *addresses,
199 const struct GNUNET_PeerIdentity *peer);
203 (*GAS_solver_done) (void *solver);
207 * Initialize address subsystem.
209 * @param cfg configuration to use
210 * @param stats the statistics handle to use
212 struct GAS_Addresses_Handle *
213 GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
214 const struct GNUNET_STATISTICS_Handle *stats);
217 * Shutdown address subsystem.
220 GAS_addresses_done (struct GAS_Addresses_Handle *handle);
223 GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer);
226 * This address is now used or not used anymore
229 GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
230 const char *plugin_name, const void *plugin_addr,
231 size_t plugin_addr_len, uint32_t session_id, int in_use);
234 GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
235 const char *plugin_name, const void *plugin_addr,
236 size_t plugin_addr_len, uint32_t session_id,
237 const struct GNUNET_ATS_Information *atsi,
238 uint32_t atsi_count);
242 GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
243 const char *plugin_name, const void *plugin_addr,
244 size_t plugin_addr_len, uint32_t session_id);
248 GAS_addresses_destroy_all (void);
252 * Cancel address suggestions for a peer
254 * @param peer the respective peer
257 GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer);
260 GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer);
263 GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
264 enum GNUNET_ATS_PreferenceKind kind,
268 GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
269 const char *plugin_name, const void *plugin_addr,
270 size_t plugin_addr_len, uint32_t session_id,
271 const struct GNUNET_ATS_Information *atsi,
272 uint32_t atsi_count);
275 typedef void (*GNUNET_ATS_Peer_Iterator) (void *p_it_cls,
276 const struct GNUNET_PeerIdentity *id);
279 * Return all peers currently known to ATS
281 * @param p_it the iterator to call for every peer
282 * @param p_it_cls the closure for the iterator
285 GAS_addresses_iterate_peers (GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls);
287 typedef void (*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls,
288 const struct GNUNET_PeerIdentity *id,
289 const char *plugin_name,
290 const void *plugin_addr, size_t plugin_addr_len,
291 const int address_active,
292 const struct GNUNET_ATS_Information *atsi,
294 struct GNUNET_BANDWIDTH_Value32NBO
296 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
299 * Return information all peers currently known to ATS
301 * @param peer the respective peer
302 * @param pi_it the iterator to call for every peer
303 * @param pi_it_cls the closure for the iterator
306 GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls);
310 /* end of gnunet-service-ats_addresses.h */