1715288d73a276c34f34f5c27ecac1afd59e5d65
[oweals/gnunet.git] / src / ats / gnunet-service-ats_preferences.h
1 /*
2  This file is part of GNUnet.
3  (C) 2011-2014 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  * @file ats/gnunet-service-ats_preferences.h
22  * @brief manage preferences expressed by clients
23  * @author Matthias Wachs
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_ATS_PREFERENCES_H
27 #define GNUNET_SERVICE_ATS_PREFERENCES_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_ats_service.h"
31 #include "gnunet-service-ats.h"
32 #include "gnunet_statistics_service.h"
33 #include "ats.h"
34
35
36 #define DEFAULT_ABS_PREFERENCE 0.0
37
38 #define DEFAULT_REL_PREFERENCE 0.0
39
40
41 /**
42  * Handle 'preference change' messages from clients.
43  *
44  * @param cls unused, NULL
45  * @param client client that sent the request
46  * @param message the request message
47  */
48 void
49 GAS_handle_preference_change (void *cls,
50                               struct GNUNET_SERVER_Client *client,
51                               const struct GNUNET_MessageHeader *message);
52
53
54 /**
55  * Initialize preferences subsystem.
56  */
57 void
58 GAS_preference_init (void);
59
60
61 /**
62  * Shutdown preferences subsystem.
63  */
64 void
65 GAS_preference_done (void);
66
67
68 /**
69  * Normalize an updated preference value
70  *
71  * @param client the client with this preference
72  * @param peer the peer to change the preference for
73  * @param kind the kind to change the preference
74  * @param score_abs the normalized score
75  */
76 void
77 GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client,
78                                         const struct GNUNET_PeerIdentity *peer,
79                                         enum GNUNET_ATS_PreferenceKind kind,
80                                         float score_abs);
81
82 /**
83  * Get the normalized preference values for a specific peer.
84  *
85  * @param cls ignored
86  * @param id the peer
87  * @return pointer to the values, can be indexed
88  *  with GNUNET_ATS_PreferenceKind, NULL if peer does not exist
89  */
90 const double *
91 GAS_normalization_get_preferences_by_peer (void *cls,
92                                            const struct GNUNET_PeerIdentity *id);
93
94
95 /**
96  * A performance client disconnected
97  *
98  * @param client the disconnecting client
99  */
100 void
101 GAS_normalization_preference_client_disconnect (struct GNUNET_SERVER_Client *client);
102
103
104 #endif