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-solver_proportional.h
23 * @brief ATS proportional solver
24 * @author Matthias Wachs
25 * @author Christian Grothoff
28 #include "gnunet_statistics_service.h"
29 #include "gnunet-service-ats_addresses.h"
32 * ATS proportional solver
38 * Changes the preferences for a peer in the problem
40 * @param solver the solver handle
41 * @param addresses the address hashmap
42 * @param peer the peer to change the preference for
43 * @param kind the kind to change the preference
44 * @param pref_rel the normalized preference value for this kind over all clients
47 GAS_proportional_address_change_preference (void *solver,
48 struct GNUNET_CONTAINER_MultiHashMap *addresses,
49 const struct GNUNET_PeerIdentity *peer,
50 enum GNUNET_ATS_PreferenceKind kind,
55 * Init the proportional problem solver
58 * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
59 * out_quota[i] contains outbound quota for network type i
60 * in_quota[i] contains inbound quota for network type i
63 * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
64 * network[2] == GNUNET_ATS_NET_LAN
65 * out_quota[2] == 65353
66 * in_quota[2] == 65353
68 * @param cfg configuration handle
69 * @param stats the GNUNET_STATISTICS handle
70 * @param network array of GNUNET_ATS_NetworkType with length dest_length
71 * @param out_quota array of outbound quotas
72 * @param in_quota array of outbound quota
73 * @param dest_length array length for quota arrays
74 * @param bw_changed_cb callback for changed bandwidth amounts
75 * @param bw_changed_cb_cls cls for callback
76 * @return handle for the solver on success, NULL on fail
79 GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
80 const struct GNUNET_STATISTICS_Handle *stats,
82 unsigned long long *out_quota,
83 unsigned long long *in_quota,
85 GAS_bandwidth_changed_cb bw_changed_cb,
86 void *bw_changed_cb_cls,
87 GAS_get_preferences get_preference,
88 void *get_preference_cls);
92 * Shutdown the proportional problem solver
94 * @param solver the respective handle to shutdown
97 GAS_proportional_done (void * solver);
101 * Add a single address within a network to the solver
103 * @param solver the solver Handle
104 * @param addresses the address hashmap containing all addresses
105 * @param address the address to add
106 * @param network network type of this address
109 GAS_proportional_address_add (void *solver,
110 struct GNUNET_CONTAINER_MultiHashMap *addresses,
111 struct ATS_Address *address,
116 * Updates a single address in the solve
118 * @param solver the solver Handle
119 * @param addresses the address hashmap containing all addresses
120 * @param address the update address
121 * @param session the new session (if changed otherwise current)
122 * @param in_use the new address in use state (if changed otherwise current)
123 * @param prev_ats the latest ATS information
124 * @param prev_atsi_count the atsi count
127 GAS_proportional_address_update (void *solver,
128 struct GNUNET_CONTAINER_MultiHashMap *addresses,
129 struct ATS_Address *address,
132 const struct GNUNET_ATS_Information *atsi,
133 uint32_t atsi_count);
137 * Remove an address from the solver
139 * @param solver the solver handle
140 * @param addresses the address hashmap containing all addresses
141 * @param address the address to remove
142 * @param session_only delete only session not whole address
145 GAS_proportional_address_delete (void *solver,
146 struct GNUNET_CONTAINER_MultiHashMap * addresses,
147 struct ATS_Address *address, int session_only);
151 * Stop notifying about address and bandwidth changes for this peer
153 * @param solver the MLP handle
154 * @param addresses address hashmap
155 * @param peer the peer
158 GAS_proportional_stop_get_preferred_address (void *solver,
159 struct GNUNET_CONTAINER_MultiHashMap *addresses,
160 const struct GNUNET_PeerIdentity *peer);
164 * Get the prefered address for a specific peer
166 * @param solver the solver handle
167 * @param addresses the address hashmap containing all addresses
168 * @param peer the identity of the peer
170 const struct ATS_Address *
171 GAS_proportional_get_preferred_address (void *solver,
172 struct GNUNET_CONTAINER_MultiHashMap * addresses,
173 const struct GNUNET_PeerIdentity *peer);
175 /* end of gnunet-service-ats-solver_proportional.c */