more docu
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_simplistic.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_addresses_simplistic.h
23  * @brief ats simplistic ressource assignment
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 #define BIG_M_STRING "unlimited"
32
33 /**
34  * ATS simplistic solver
35  *
36  * General description
37  */
38
39
40
41
42 /**
43  * Init the simplistic problem solving component
44  *
45  * Quotas:
46  * network[i] contains the network type as type GNUNET_ATS_NetworkType[i]
47  * out_quota[i] contains outbound quota for network type i
48  * in_quota[i] contains inbound quota for network type i
49  *
50  * Example
51  * network = {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
52  * network[2]   == GNUNET_ATS_NET_LAN
53  * out_quota[2] == 65353
54  * in_quota[2]  == 65353
55  *
56  * @param cfg configuration handle
57  * @param stats the GNUNET_STATISTICS handle
58  * @param network array of GNUNET_ATS_NetworkType with length dest_length
59  * @param out_quota array of outbound quotas
60  * @param in_quota array of outbound quota
61  * @param dest_length array length for quota arrays
62  * @param bw_changed_cb callback for changed bandwidth amounts
63  * @param bw_changed_cb_cls cls for callback
64  * @return handle for the solver on success, NULL on fail
65  */
66 void *
67 GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
68                      const struct GNUNET_STATISTICS_Handle *stats,
69                      int *network,
70                      unsigned long long *out_quota,
71                      unsigned long long *in_quota,
72                      int dest_length,
73                      GAS_bandwidth_changed_cb bw_changed_cb,
74                      void *bw_changed_cb_cls);
75
76 /**
77  * Shutdown the simplistic problem solving component
78  *
79  * @param solver the respective handle to shutdown
80  */
81 void
82 GAS_simplistic_done (void * solver);
83
84 /**
85  * Add a single address to the solve
86  *
87  * @param solver the solver Handle
88  * @param addresses the address hashmap containing all addresses
89  * @param address the address to add
90  */
91 void
92 GAS_simplistic_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
93
94
95 /**
96  * Updates a single address in the solve
97  *
98  * @param solver the solver Handle
99  * @param addresses the address hashmap containing all addresses
100  * @param address the update address
101  * @param session the new session (if changed otherwise current)
102  * @param in_use the new address in use state (if changed otherwise current)
103  * @param atsi the latest ATS information
104  * @param atsi_count the atsi count
105  */
106 void
107 GAS_simplistic_address_update (void *solver,
108     struct GNUNET_CONTAINER_MultiHashMap *addresses,
109     struct ATS_Address *address,
110     uint32_t session,
111     int in_use,
112     const struct GNUNET_ATS_Information *atsi,
113     uint32_t atsi_count);
114
115
116 /**
117  * Remove an address from the solver
118  *
119  * @param solver the solver handle
120  * @param addresses the address hashmap containing all addresses
121  * @param address the address to remove
122  * @param session_only delete only session not whole address
123  */
124 void
125 GAS_simplistic_address_delete (void *solver,
126     struct GNUNET_CONTAINER_MultiHashMap * addresses,
127     struct ATS_Address *address, int session_only);
128
129
130 /**
131  * Get the prefered address for a specific peer
132  *
133  * @param solver the solver handle
134  * @param addresses the address hashmap containing all addresses
135  * @param peer the identity of the peer
136  */
137 const struct ATS_Address *
138 GAS_simplistic_get_preferred_address (void *solver,
139                                struct GNUNET_CONTAINER_MultiHashMap * addresses,
140                                const struct GNUNET_PeerIdentity *peer);
141
142
143 /**
144  * Changes the preferences for a peer in the problem
145  *
146  * @param solver the solver handle
147  * @param client the client with this preference
148  * @param peer the peer to change the preference for
149  * @param kind the kind to change the preference
150  * @param score the score
151  */
152 void
153 GAS_simplistic_address_change_preference (void *solver,
154                                    void *client,
155                                    const struct GNUNET_PeerIdentity *peer,
156                                    enum GNUNET_ATS_PreferenceKind kind,
157                                    float score);
158
159
160 /* end of gnunet-service-ats_addresses_simplistic.h */