docu
[oweals/gnunet.git] / src / ats / gnunet-service-ats-solver_proportional.h
1 /*
2      This file is part of GNUnet.
3      (C) 2011 Christian Grothoff (and other contributing authors)
4
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.
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      General Public License for more details.
14
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.
19 */
20
21 /**
22  * @file ats/gnunet-service-ats-solver_proportional.h
23  * @brief ATS proportional solver
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #include "platform.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet-service-ats_addresses.h"
30
31 /**
32  * ATS proportional solver
33  *
34  * General description
35  */
36
37 /**
38  * Init the proportional problem solver
39  *
40  * Quotas:
41  * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
42  * out_quota[i] contains outbound quota for network type i
43  * in_quota[i] contains inbound quota for network type i
44  *
45  * Example
46  * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
47  * network[2]   == GNUNET_ATS_NET_LAN
48  * out_quota[2] == 65353
49  * in_quota[2]  == 65353
50  *
51  * @param cfg configuration handle
52  * @param stats the GNUNET_STATISTICS handle
53  * @param network array of GNUNET_ATS_NetworkType with length dest_length
54  * @param out_quota array of outbound quotas
55  * @param in_quota array of outbound quota
56  * @param dest_length array length for quota arrays
57  * @param bw_changed_cb callback for changed bandwidth amounts
58  * @param bw_changed_cb_cls cls for callback
59  * @return handle for the solver on success, NULL on fail
60  */
61 void *
62 GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
63                      const struct GNUNET_STATISTICS_Handle *stats,
64                      int *network,
65                      unsigned long long *out_quota,
66                      unsigned long long *in_quota,
67                      int dest_length,
68                      GAS_bandwidth_changed_cb bw_changed_cb,
69                      void *bw_changed_cb_cls);
70
71
72 /**
73  * Shutdown the proportional problem solver
74  *
75  * @param solver the respective handle to shutdown
76  */
77 GAS_proportional_done (void * solver);
78
79 /**
80  * Add a single address within a network to the solver
81  *
82  * @param solver the solver Handle
83  * @param addresses the address hashmap containing all addresses
84  * @param address the address to add
85  * @param network network type of this address
86  */
87 void
88 GAS_proportional_address_add (void *solver,
89                                                         struct GNUNET_CONTAINER_MultiHashMap *addresses,
90                                                         struct ATS_Address *address,
91                                                         uint32_t network);
92
93
94 /**
95  * Updates a single address in the solve
96  *
97  * @param solver the solver Handle
98  * @param addresses the address hashmap containing all addresses
99  * @param address the update address
100  * @param session the new session (if changed otherwise current)
101  * @param in_use the new address in use state (if changed otherwise current)
102  * @param prev_ats the latest ATS information
103  * @param prev_atsi_count the atsi count
104  */
105 void
106 GAS_proportional_address_update (void *solver,
107     struct GNUNET_CONTAINER_MultiHashMap *addresses,
108     struct ATS_Address *address,
109     uint32_t session,
110     int in_use,
111     const struct GNUNET_ATS_Information *atsi,
112     uint32_t atsi_count);
113
114
115 /**
116  * Remove an address from the solver
117  *
118  * @param solver the solver handle
119  * @param addresses the address hashmap containing all addresses
120  * @param address the address to remove
121  * @param session_only delete only session not whole address
122  */
123 void
124 GAS_proportional_address_delete (void *solver,
125     struct GNUNET_CONTAINER_MultiHashMap * addresses,
126     struct ATS_Address *address, int session_only);
127
128
129 /**
130  * Stop notifying about address and bandwidth changes for this peer
131  *
132  * @param solver the MLP handle
133  * @param addresses address hashmap
134  * @param peer the peer
135  */
136 void
137 GAS_proportional_stop_get_preferred_address (void *solver,
138                                      struct GNUNET_CONTAINER_MultiHashMap *addresses,
139                                      const struct GNUNET_PeerIdentity *peer);
140
141 /**
142  * Get the prefered address for a specific peer
143  *
144  * @param solver the solver handle
145  * @param addresses the address hashmap containing all addresses
146  * @param peer the identity of the peer
147  */
148 const struct ATS_Address *
149 GAS_proportional_get_preferred_address (void *solver,
150                                struct GNUNET_CONTAINER_MultiHashMap * addresses,
151                                const struct GNUNET_PeerIdentity *peer);
152
153
154 /**
155  * Changes the preferences for a peer in the problem
156  *
157  * @param solver the solver handle
158  * @param client the client with this preference
159  * @param peer the peer to change the preference for
160  * @param kind the kind to change the preference
161  * @param score the score
162  */
163 void
164 GAS_simplistic_address_change_preference (void *solver,
165                                    void *client,
166                                    const struct GNUNET_PeerIdentity *peer,
167                                    enum GNUNET_ATS_PreferenceKind kind,
168                                    float score);
169
170
171 /* end of gnunet-service-ats-solver_proportional.c */