- added benchmarking for updates
[oweals/gnunet.git] / src / ats / ats_api.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010,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  * @file ats/ats_api.h
22  * @brief automatic transport selection API common includes
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25  */
26 #ifndef ATS_API_H
27 #define ATS_API_H
28
29 #include "gnunet_util_lib.h"
30
31 /**
32  * Allocation record for a peer's address.
33  */
34 struct AllocationRecord
35 {
36
37   /**
38    * Performance information associated with this address (array).
39    */
40   struct GNUNET_ATS_Information *ats;
41
42   /**
43    * Name of the plugin
44    */
45   char *plugin_name;
46
47   /**
48    * Address this record represents, allocated at the end of this struct.
49    */
50   const void *plugin_addr;
51
52   /**
53    * Session associated with this record.
54    */
55   struct Session *session;
56
57   /**
58    * Number of bytes in plugin_addr.
59    */
60   size_t plugin_addr_len;
61
62   /**
63    * Number of entries in 'ats'.
64    */
65   uint32_t ats_count;
66
67   /**
68    * Inbound bandwidth assigned to this address right now, 0 for none.
69    */
70   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
71
72   /**
73    * Outbound bandwidth assigned to this address right now, 0 for none.
74    */
75   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
76
77   /**
78    * Tracking bandwidth for receiving from this peer.  Used for
79    * applications that want to 'reserve' bandwidth for replies.
80    */
81   struct GNUNET_BANDWIDTH_Tracker available_recv_window;
82
83   /**
84    * Set to GNUNET_YES if this is the connected address of a connected peer.
85    */
86   int connected;
87
88 };
89
90
91 /**
92  * Handle to the ATS subsystem.
93  */
94 struct GNUNET_ATS_SchedulingHandle
95 {
96   /**
97    * Configuration.
98    */
99   const struct GNUNET_CONFIGURATION_Handle *cfg;
100
101   /**
102    * Function to call when the allocation changes.
103    */
104   GNUNET_ATS_AddressSuggestionCallback alloc_cb;
105
106   /**
107    * Closure for 'alloc_cb'.
108    */
109   void *alloc_cb_cls;
110
111   /**
112    * Information about all connected peers.  Maps peer identities
113    * to one or more 'struct AllocationRecord' values.
114    */
115   struct GNUNET_CONTAINER_MultiHashMap *peers;
116
117   /**
118    * Map of PeerIdentities to 'struct GNUNET_ATS_SuggestionContext's.
119    */
120   struct GNUNET_CONTAINER_MultiHashMap *notify_map;
121
122   /**
123    * Task scheduled to update our bandwidth assignment.
124    */
125   GNUNET_SCHEDULER_TaskIdentifier ba_task;
126
127   /**
128    * Total inbound bandwidth per configuration.
129    */
130   unsigned long long total_bps_in;
131
132   /**
133    * Total outbound bandwidth per configuration.
134    */
135   unsigned long long total_bps_out;
136 };
137
138 #endif