aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-13 11:59:13 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-13 11:59:13 +0000
commit86ad1393cdf6c8b37437c330fce25ebfffbc8ffd (patch)
treea74f38f8f6379361490ca8b9395d1ee161943b98
parent0a5333c2df162d6f6f9bd35ea04d57e6abcc0b6f (diff)
downloadgnunet-86ad1393cdf6c8b37437c330fce25ebfffbc8ffd.tar.gz
gnunet-86ad1393cdf6c8b37437c330fce25ebfffbc8ffd.zip
new ATS API -- code won't compile
-rw-r--r--src/ats/Makefile.am4
-rw-r--r--src/ats/ats.h210
-rw-r--r--src/ats/ats_api.c34
-rw-r--r--src/ats/ats_api.h2
-rw-r--r--src/ats/ats_api_new.c129
-rw-r--r--src/ats/ats_api_peer_change_preference.c10
-rw-r--r--src/ats/ats_api_performance.c128
-rw-r--r--src/ats/test_ats_api.c2
-rw-r--r--src/ats/test_ats_api_update_address.c2
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c2
-rw-r--r--src/fs/gnunet-service-fs_cp.c2
-rw-r--r--src/include/gnunet_ats_service.h294
-rw-r--r--src/include/gnunet_protocols.h21
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/gnunet-service-transport.h2
15 files changed, 687 insertions, 157 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index ca896147e..5adb5f3ef 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -11,8 +11,8 @@ endif
11lib_LTLIBRARIES = libgnunetats.la 11lib_LTLIBRARIES = libgnunetats.la
12 12
13libgnunetats_la_SOURCES = \ 13libgnunetats_la_SOURCES = \
14 ats_api.c ats_api.h \ 14 ats_api_new.c \
15 ats_api_peer_change_preference.c 15 ats_api_performance.c
16 16
17libgnunetats_la_LIBADD = \ 17libgnunetats_la_LIBADD = \
18 $(top_builddir)/src/util/libgnunetutil.la 18 $(top_builddir)/src/util/libgnunetutil.la
diff --git a/src/ats/ats.h b/src/ats/ats.h
new file mode 100644
index 000000000..317528cad
--- /dev/null
+++ b/src/ats/ats.h
@@ -0,0 +1,210 @@
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.h
22 * @brief automatic transport selection messages
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#ifndef ATS_H
27#define ATS_H
28
29#include "gnunet_util_lib.h"
30
31
32enum StartFlag
33{
34
35 START_FLAG_SCHEDULING = 0,
36
37 START_FLAG_PERFORMANCE_WITH_PIC = 1,
38
39 START_FLAG_PERFORMANCE_NO_PIC = 2
40
41};
42
43
44
45struct ClientStart
46{
47 struct GNUNET_MessageHeader header;
48
49 /**
50 * NBO value of an 'enum StartFlag'.
51 */
52 uint32_t start_flag;
53};
54
55
56
57struct RequestAddressMessage
58{
59 struct GNUNET_MessageHeader header;
60
61 uint32_t reserved GNUNET_PACKED;
62
63 struct GNUNET_PeerIdentity peer;
64};
65
66struct AddressUpdateMessage
67{
68 struct GNUNET_MessageHeader header;
69
70 uint32_t ats_count GNUNET_PACKED;
71
72 struct GNUNET_PeerIdentity peer;
73
74 uint16_t address_length GNUNET_PACKED;
75
76 uint16_t plugin_name_length GNUNET_PACKED;
77
78 uint32_t session_id GNUNET_PACKED;
79
80 /* followed by:
81 - struct GNUNET_TRANSPORT_ATS_Information [ats_count];
82 - char address[address_length]
83 - char plugin_name[plugin_name_length] (including '\0'-termination).
84 */
85
86};
87
88struct AddressDestroyedMessage
89{
90 struct GNUNET_MessageHeader header;
91
92 uint32_t reserved GNUNET_PACKED;
93
94 struct GNUNET_PeerIdentity peer;
95
96 uint16_t address_length GNUNET_PACKED;
97
98 uint16_t plugin_name_length GNUNET_PACKED;
99
100 uint32_t session_id GNUNET_PACKED;
101
102 /* followed by:
103 - char address[address_length]
104 - char plugin_name[plugin_name_length] (including '\0'-termination).
105 */
106
107};
108
109
110struct AddressSuggestionMessage
111{
112 struct GNUNET_MessageHeader header;
113
114 uint32_t reserved GNUNET_PACKED;
115
116 struct GNUNET_PeerIdentity peer;
117
118 uint16_t address_length GNUNET_PACKED;
119
120 uint16_t plugin_name_length GNUNET_PACKED;
121
122 uint32_t session_id GNUNET_PACKED;
123
124 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
125
126 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
127
128 /* followed by:
129 - char address[address_length]
130 - char plugin_name[plugin_name_length] (including '\0'-termination).
131 */
132
133};
134
135
136
137struct PeerInformationMessage
138{
139 struct GNUNET_MessageHeader header;
140
141 uint32_t ats_count GNUNET_PACKED;
142
143 struct GNUNET_PeerIdentity peer;
144
145 uint16_t address_length GNUNET_PACKED;
146
147 uint16_t plugin_name_length GNUNET_PACKED;
148
149 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
150
151 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
152
153 /* followed by:
154 - struct GNUNET_TRANSPORT_ATS_Information [ats_count];
155 - char address[address_length]
156 - char plugin_name[plugin_name_length] (including '\0'-termination).
157 */
158
159};
160
161
162
163
164struct ReservationRequestMessage
165{
166 struct GNUNET_MessageHeader header;
167
168 int32_t amount GNUNET_PACKED;
169
170 struct GNUNET_PeerIdentity peer;
171};
172
173
174struct ReservationResultMessage
175{
176 struct GNUNET_MessageHeader header;
177
178 int32_t amount GNUNET_PACKED;
179
180 struct GNUNET_PeerIdentity peer;
181
182 struct GNUNET_TIME_RelativeNBO res_delay;
183};
184
185
186struct PreferenceInformation
187{
188
189 uint32_t preference_kind GNUNET_PACKED;
190
191 float preference_value GNUNET_PACKED;
192
193};
194
195
196struct ChangePreferenceMessage
197{
198 struct GNUNET_MessageHeader header;
199
200 uint32_t num_preferences GNUNET_PACKED;
201
202 struct GNUNET_PeerIdentity peer;
203
204 /* followed by 'num_preferences'
205 struct PreferenceInformation values */
206};
207
208
209
210#endif
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c
index ef2fa1bed..29a273e3e 100644
--- a/src/ats/ats_api.c
+++ b/src/ats/ats_api.c
@@ -70,7 +70,7 @@ struct GNUNET_ATS_SuggestionContext
70 /** 70 /**
71 * Global ATS handle. 71 * Global ATS handle.
72 */ 72 */
73 struct GNUNET_ATS_Handle *atc; 73 struct GNUNET_ATS_SchedulingHandle *atc;
74 74
75 /** 75 /**
76 * Which peer are we monitoring? 76 * Which peer are we monitoring?
@@ -108,7 +108,7 @@ struct SetBandwidthContext
108 /** 108 /**
109 * ATS handle. 109 * ATS handle.
110 */ 110 */
111 struct GNUNET_ATS_Handle *atc; 111 struct GNUNET_ATS_SchedulingHandle *atc;
112 112
113 /** 113 /**
114 * Inbound bandwidth to assign. 114 * Inbound bandwidth to assign.
@@ -184,13 +184,13 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value)
184/** 184/**
185 * Task run to update bandwidth assignments. 185 * Task run to update bandwidth assignments.
186 * 186 *
187 * @param cls the 'struct GNUNET_ATS_Handle' 187 * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
188 * @param tc scheduler context 188 * @param tc scheduler context
189 */ 189 */
190static void 190static void
191update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 191update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
192{ 192{
193 struct GNUNET_ATS_Handle *atc = cls; 193 struct GNUNET_ATS_SchedulingHandle *atc = cls;
194 unsigned int ac = 0; 194 unsigned int ac = 0;
195 struct SetBandwidthContext bwc; 195 struct SetBandwidthContext bwc;
196 196
@@ -218,7 +218,7 @@ update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
218 * @param change which allocation record changed? 218 * @param change which allocation record changed?
219 */ 219 */
220static void 220static void
221update_bandwidth_assignment (struct GNUNET_ATS_Handle *atc, 221update_bandwidth_assignment (struct GNUNET_ATS_SchedulingHandle *atc,
222 struct AllocationRecord *change) 222 struct AllocationRecord *change)
223{ 223{
224 /* FIXME: based on the 'change', update the LP-problem... */ 224 /* FIXME: based on the 'change', update the LP-problem... */
@@ -277,7 +277,7 @@ map_it (void *cls, const GNUNET_HashCode * key, void *value)
277 * @param cb_cls closure for cb 277 * @param cb_cls closure for cb
278 */ 278 */
279struct GNUNET_ATS_SuggestionContext * 279struct GNUNET_ATS_SuggestionContext *
280GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, 280GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
281 const struct GNUNET_PeerIdentity *peer, 281 const struct GNUNET_PeerIdentity *peer,
282 GNUNET_ATS_AddressSuggestionCallback cb, 282 GNUNET_ATS_AddressSuggestionCallback cb,
283 void *cb_cls) 283 void *cb_cls)
@@ -332,17 +332,17 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc)
332 * @param alloc_cb_cls closure for 'alloc_cb' 332 * @param alloc_cb_cls closure for 'alloc_cb'
333 * @return ats context 333 * @return ats context
334 */ 334 */
335struct GNUNET_ATS_Handle * 335struct GNUNET_ATS_SchedulingHandle *
336GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 336GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
337 GNUNET_ATS_AddressSuggestionCallback alloc_cb, 337 GNUNET_ATS_AddressSuggestionCallback alloc_cb,
338 void *alloc_cb_cls) 338 void *alloc_cb_cls)
339{ 339{
340 struct GNUNET_ATS_Handle *atc; 340 struct GNUNET_ATS_SchedulingHandle *atc;
341 341
342#if DEBUG_ATS 342#if DEBUG_ATS
343 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n"); 343 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n");
344#endif 344#endif
345 atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_Handle)); 345 atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle));
346 atc->cfg = cfg; 346 atc->cfg = cfg;
347 atc->alloc_cb = alloc_cb; 347 atc->alloc_cb = alloc_cb;
348 atc->alloc_cb_cls = alloc_cb_cls; 348 atc->alloc_cb_cls = alloc_cb_cls;
@@ -382,7 +382,7 @@ destroy_allocation_record (void *cls, const GNUNET_HashCode * key, void *value)
382 * @param atc handle 382 * @param atc handle
383 */ 383 */
384void 384void
385GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc) 385GNUNET_ATS_shutdown (struct GNUNET_ATS_SchedulingHandle *atc)
386{ 386{
387#if DEBUG_ATS 387#if DEBUG_ATS
388 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n"); 388 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n");
@@ -410,7 +410,7 @@ struct UpdateSessionContext
410 /** 410 /**
411 * Ats handle. 411 * Ats handle.
412 */ 412 */
413 struct GNUNET_ATS_Handle *atc; 413 struct GNUNET_ATS_SchedulingHandle *atc;
414 414
415 /** 415 /**
416 * Allocation record with new information. 416 * Allocation record with new information.
@@ -556,7 +556,7 @@ create_allocation_record (const char *plugin_name, struct Session *session,
556static int 556static int
557disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value) 557disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value)
558{ 558{
559 struct GNUNET_ATS_Handle *atc = cls; 559 struct GNUNET_ATS_SchedulingHandle *atc = cls;
560 struct AllocationRecord *ar = value; 560 struct AllocationRecord *ar = value;
561 561
562 if (GNUNET_YES == ar->connected) 562 if (GNUNET_YES == ar->connected)
@@ -583,7 +583,7 @@ disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value)
583 * @param ats_count number of performance records in 'ats' 583 * @param ats_count number of performance records in 'ats'
584 */ 584 */
585void 585void
586GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, 586GNUNET_ATS_peer_connect (struct GNUNET_ATS_SchedulingHandle *atc,
587 const struct GNUNET_PeerIdentity *peer, 587 const struct GNUNET_PeerIdentity *peer,
588 const char *plugin_name, struct Session *session, 588 const char *plugin_name, struct Session *session,
589 const void *plugin_addr, size_t plugin_addr_len, 589 const void *plugin_addr, size_t plugin_addr_len,
@@ -628,7 +628,7 @@ GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc,
628 * @param peer identity of the new peer 628 * @param peer identity of the new peer
629 */ 629 */
630void 630void
631GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc, 631GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc,
632 const struct GNUNET_PeerIdentity *peer) 632 const struct GNUNET_PeerIdentity *peer)
633{ 633{
634#if DEBUG_ATS 634#if DEBUG_ATS
@@ -650,7 +650,7 @@ struct SessionDestroyContext
650 /** 650 /**
651 * Ats handle. 651 * Ats handle.
652 */ 652 */
653 struct GNUNET_ATS_Handle *atc; 653 struct GNUNET_ATS_SchedulingHandle *atc;
654 654
655 /** 655 /**
656 * Session being destroyed. 656 * Session being destroyed.
@@ -699,7 +699,7 @@ destroy_session (void *cls, const GNUNET_HashCode * key, void *value)
699 * @param session session handle that is no longer valid 699 * @param session session handle that is no longer valid
700 */ 700 */
701void 701void
702GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, 702GNUNET_ATS_session_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
703 const struct GNUNET_PeerIdentity *peer, 703 const struct GNUNET_PeerIdentity *peer,
704 const struct Session *session) 704 const struct Session *session)
705{ 705{
@@ -756,7 +756,7 @@ notify_valid (void *cls, const GNUNET_HashCode * key, void *value)
756 * @param ats_count number of performance records in 'ats' 756 * @param ats_count number of performance records in 'ats'
757 */ 757 */
758void 758void
759GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, 759GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
760 const struct GNUNET_PeerIdentity *peer, 760 const struct GNUNET_PeerIdentity *peer,
761 struct GNUNET_TIME_Absolute valid_until, 761 struct GNUNET_TIME_Absolute valid_until,
762 const char *plugin_name, struct Session *session, 762 const char *plugin_name, struct Session *session,
diff --git a/src/ats/ats_api.h b/src/ats/ats_api.h
index a2c248cd8..2c98194be 100644
--- a/src/ats/ats_api.h
+++ b/src/ats/ats_api.h
@@ -91,7 +91,7 @@ struct AllocationRecord
91/** 91/**
92 * Handle to the ATS subsystem. 92 * Handle to the ATS subsystem.
93 */ 93 */
94struct GNUNET_ATS_Handle 94struct GNUNET_ATS_SchedulingHandle
95{ 95{
96 /** 96 /**
97 * Configuration. 97 * Configuration.
diff --git a/src/ats/ats_api_new.c b/src/ats/ats_api_new.c
new file mode 100644
index 000000000..dc06d901d
--- /dev/null
+++ b/src/ats/ats_api_new.c
@@ -0,0 +1,129 @@
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 include/gnunet_ats_service.h
22 * @brief automatic transport selection and outbound bandwidth determination
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet_ats_service.h"
28
29
30/**
31 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
32 */
33struct GNUNET_ATS_SchedulingHandle
34{
35};
36
37
38/**
39 * Initialize the ATS subsystem.
40 *
41 * @param cfg configuration to use
42 * @param alloc_cb notification to call whenever the allocation changed
43 * @param alloc_cb_cls closure for 'alloc_cb'
44 * @return ats context
45 */
46struct GNUNET_ATS_SchedulingHandle *
47GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
48 GNUNET_ATS_AddressSuggestionCallback alloc_cb,
49 void *alloc_cb_cls)
50{
51 return NULL;
52}
53
54
55/**
56 * Client is done with ATS scheduling, release resources.
57 *
58 * @param atc handle to release
59 */
60void
61GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc)
62{
63}
64
65
66/**
67 * We would like to establish a new connection with a peer. ATS
68 * should suggest a good address to begin with.
69 *
70 * @param atc handle
71 * @param peer identity of the peer we need an address for
72 */
73void
74GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
75 const struct GNUNET_PeerIdentity *peer)
76{
77}
78
79
80/**
81 * We have updated performance statistics for a given address. Note
82 * that this function can be called for addresses that are currently
83 * in use as well as addresses that are valid but not actively in use.
84 * Furthermore, the peer may not even be connected to us right now (in
85 * which case the call may be ignored or the information may be stored
86 * for later use). Update bandwidth assignments.
87 *
88 * @param atc handle
89 * @param peer identity of the new peer
90 * @param plugin_name name of the transport plugin
91 * @param plugin_addr address (if available)
92 * @param plugin_addr_len number of bytes in plugin_addr
93 * @param session session handle (if available)
94 * @param ats performance data for the address
95 * @param ats_count number of performance records in 'ats'
96 */
97void
98GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
99 const struct GNUNET_PeerIdentity *peer,
100 const char *plugin_name,
101 const void *plugin_addr, size_t plugin_addr_len,
102 struct Session *session,
103 const struct GNUNET_TRANSPORT_ATS_Information *ats,
104 uint32_t ats_count)
105{
106}
107
108
109/**
110 * A session got destroyed, stop including it as a valid address.
111 *
112 * @param atc handle
113 * @param peer identity of the peer
114 * @param plugin_name name of the transport plugin
115 * @param plugin_addr address (if available)
116 * @param plugin_addr_len number of bytes in plugin_addr
117 * @param session session handle that is no longer valid
118 */
119void
120GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
121 const struct GNUNET_PeerIdentity *peer,
122 const char *plugin_name,
123 const void *plugin_addr,
124 size_t plugin_addr_len,
125 const struct Session *session)
126{
127}
128
129/* end of ats_api_new.c */
diff --git a/src/ats/ats_api_peer_change_preference.c b/src/ats/ats_api_peer_change_preference.c
index 76e8364fc..322727e63 100644
--- a/src/ats/ats_api_peer_change_preference.c
+++ b/src/ats/ats_api_peer_change_preference.c
@@ -40,7 +40,7 @@ struct GNUNET_ATS_InformationRequestContext
40 /** 40 /**
41 * Our connection to the service. 41 * Our connection to the service.
42 */ 42 */
43 struct GNUNET_ATS_Handle *h; 43 struct GNUNET_ATS_SchedulingHandle *h;
44 44
45 int32_t amount; 45 int32_t amount;
46 46
@@ -124,7 +124,7 @@ exec_pcp (void *cls,
124 * @return NULL on error 124 * @return NULL on error
125 */ 125 */
126struct GNUNET_ATS_InformationRequestContext * 126struct GNUNET_ATS_InformationRequestContext *
127GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, 127GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
128 const struct GNUNET_PeerIdentity *peer, 128 const struct GNUNET_PeerIdentity *peer,
129 int32_t amount, uint64_t preference, 129 int32_t amount, uint64_t preference,
130 GNUNET_ATS_PeerConfigurationInfoCallback 130 GNUNET_ATS_PeerConfigurationInfoCallback
@@ -173,7 +173,7 @@ struct GNUNET_ATS_InformationRequestContext
173 /** 173 /**
174 * Our connection to the service. 174 * Our connection to the service.
175 */ 175 */
176 struct GNUNET_ATS_Handle *h; 176 struct GNUNET_ATS_SchedulingHandle *h;
177 177
178 /** 178 /**
179 * Link to control message, NULL if CM was sent. 179 * Link to control message, NULL if CM was sent.
@@ -218,7 +218,7 @@ change_preference_send_continuation (void *cls, int success)
218 * @return NULL on error 218 * @return NULL on error
219 */ 219 */
220struct GNUNET_ATS_InformationRequestContext * 220struct GNUNET_ATS_InformationRequestContext *
221GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, 221GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
222 const struct GNUNET_PeerIdentity *peer, 222 const struct GNUNET_PeerIdentity *peer,
223 int32_t amount, uint64_t preference, 223 int32_t amount, uint64_t preference,
224 GNUNET_ATS_PeerConfigurationInfoCallback 224 GNUNET_ATS_PeerConfigurationInfoCallback
@@ -290,7 +290,7 @@ GNUNET_ATS_peer_change_preference_cancel (struct
290 GNUNET_ATS_InformationRequestContext 290 GNUNET_ATS_InformationRequestContext
291 *irc) 291 *irc)
292{ 292{
293 struct GNUNET_ATS_Handle *h = irc->h; 293 struct GNUNET_ATS_SchedulingHandle *h = irc->h;
294 struct PeerRecord *pr = irc->pr; 294 struct PeerRecord *pr = irc->pr;
295 295
296 GNUNET_assert (pr->pcic_ptr == irc); 296 GNUNET_assert (pr->pcic_ptr == irc);
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
new file mode 100644
index 000000000..0b0bd1042
--- /dev/null
+++ b/src/ats/ats_api_performance.c
@@ -0,0 +1,128 @@
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 include/gnunet_ats_service.h
22 * @brief automatic transport selection and outbound bandwidth determination
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet_ats_service.h"
28
29/* ******************************** Performance API ***************************** */
30
31/**
32 * ATS Handle to obtain and/or modify performance information.
33 */
34struct GNUNET_ATS_PerformanceHandle
35{
36};
37
38
39/**
40 * Get handle to access performance API of the ATS subsystem.
41 *
42 * @param cfg configuration to use
43 * @param infocb function to call on allocation changes, can be NULL
44 * @param infocb_cls closure for infocb
45 * @return ats performance context
46 */
47struct GNUNET_ATS_PerformanceHandle *
48GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
49 GNUNET_ATS_PeerInformationCallback infocb,
50 void *infocb_cls)
51{
52 return NULL;
53}
54
55
56/**
57 * Client is done using the ATS performance subsystem, release resources.
58 *
59 * @param atc handle
60 */
61void
62GNUNET_ATS_performance_done (struct GNUNET_ATS_SchedulingHandle *atc)
63{
64}
65
66
67/**
68 * Context that can be used to cancel a peer information request.
69 */
70struct GNUNET_ATS_ReservationContext
71{
72};
73
74
75/**
76 * Reserve inbound bandwidth from the given peer. ATS will look at
77 * the current amount of traffic we receive from the peer and ensure
78 * that the peer could add 'amount' of data to its stream.
79 *
80 * @param h core handle
81 * @param peer identifies the peer
82 * @param amount reserve N bytes for receiving, negative
83 * amounts can be used to undo a (recent) reservation;
84 * @param info function to call with the resulting reservation information
85 * @param info_cls closure for info
86 * @return NULL on error
87 * @deprecated will be replaced soon
88 */
89struct GNUNET_ATS_ReservationContext *
90GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *h,
91 const struct GNUNET_PeerIdentity *peer,
92 int32_t amount,
93 GNUNET_ATS_ReservationCallback info,
94 void *info_cls)
95{
96 return NULL;
97}
98
99
100/**
101 * Cancel request for reserving bandwidth.
102 *
103 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
104 */
105void
106GNUNET_ATS_reserve_bandwidth_cancel (struct
107 GNUNET_ATS_ReservationContext *rc)
108{
109}
110
111
112/**
113 * Change preferences for the given peer. Preference changes are forgotten if peers
114 * disconnect.
115 *
116 * @param cls closure
117 * @param peer identifies the peer
118 * @param ... 0-terminated specification of the desired changes
119 */
120void
121GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
122 const struct GNUNET_PeerIdentity *peer,
123 ...)
124{
125}
126
127/* end of ats_api_performance.c */
128
diff --git a/src/ats/test_ats_api.c b/src/ats/test_ats_api.c
index 42d485994..4a4bf9772 100644
--- a/src/ats/test_ats_api.c
+++ b/src/ats/test_ats_api.c
@@ -42,7 +42,7 @@
42 42
43static struct GNUNET_CONFIGURATION_Handle *cfg; 43static struct GNUNET_CONFIGURATION_Handle *cfg;
44 44
45static struct GNUNET_ATS_Handle *ats; 45static struct GNUNET_ATS_SchedulingHandle *ats;
46 46
47static void 47static void
48alloc_cb (void *cls, const struct GNUNET_PeerIdentity *peer, 48alloc_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
diff --git a/src/ats/test_ats_api_update_address.c b/src/ats/test_ats_api_update_address.c
index 556f13ce4..54383c1d3 100644
--- a/src/ats/test_ats_api_update_address.c
+++ b/src/ats/test_ats_api_update_address.c
@@ -44,7 +44,7 @@
44 44
45#define VALID GNUNET_TIME_absolute_get_forever () 45#define VALID GNUNET_TIME_absolute_get_forever ()
46 46
47static struct GNUNET_ATS_Handle *ats; 47static struct GNUNET_ATS_SchedulingHandle *ats;
48 48
49static struct GNUNET_ATS_SuggestionContext *asc; 49static struct GNUNET_ATS_SuggestionContext *asc;
50 50
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 6de93c0eb..902f3029c 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -415,7 +415,7 @@ static struct GNUNET_CORE_Handle *coreAPI;
415/** 415/**
416 * Handle to ATS. 416 * Handle to ATS.
417 */ 417 */
418static struct GNUNET_ATS_Handle *atsAPI; 418static struct GNUNET_ATS_SchedulingHandle *atsAPI;
419 419
420 420
421 421
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 0fed7b855..8f4528cfb 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -305,7 +305,7 @@ static char *trustDirectory;
305/** 305/**
306 * Handle to ATS service. 306 * Handle to ATS service.
307 */ 307 */
308static struct GNUNET_ATS_Handle *ats; 308static struct GNUNET_ATS_SchedulingHandle *ats;
309 309
310/** 310/**
311 * Get the filename under which we would store the GNUNET_HELLO_Message 311 * Get the filename under which we would store the GNUNET_HELLO_Message
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index 713178411..12446991a 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -25,8 +25,6 @@
25 * 25 *
26 * TODO: 26 * TODO:
27 * - move GNUNET_TRANSPORT_ATS* in here and rename... 27 * - move GNUNET_TRANSPORT_ATS* in here and rename...
28 * - extend API to express communication preferences to ATS
29 * (to be called DIRECTLY from apps, not from transport/core!)
30 */ 28 */
31#ifndef GNUNET_ATS_SERVICE_H 29#ifndef GNUNET_ATS_SERVICE_H
32#define GNUNET_ATS_SERVICE_H 30#define GNUNET_ATS_SERVICE_H
@@ -37,24 +35,26 @@
37#include "gnunet_transport_plugin.h" 35#include "gnunet_transport_plugin.h"
38 36
39 37
38/* ******************************** Scheduling API ***************************** */
39
40/** 40/**
41 * Handle to the ATS subsystem. 41 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
42 */ 42 */
43struct GNUNET_ATS_Handle; 43struct GNUNET_ATS_SchedulingHandle;
44 44
45 45
46/** 46/**
47 * Signature of a function that takes an address suggestion 47 * Signature of a function called by ATS with the current bandwidth
48 * and address preferences as determined by ATS.
48 * 49 *
49 * @param cls closure 50 * @param cls closure
50 * @param peer identity of the new peer 51 * @param peer identity of the new peer
51 * @param plugin_name name of the plugin, NULL if we have no suggestion 52 * @param plugin_name name of the plugin, NULL if we have no suggestion
52 * @param plugin_addr suggested address, NULL if we have no suggestion 53 * @param plugin_addr suggested address, NULL if we have no suggestion
53 * @param plugin_addr_len number of bytes in plugin_addr 54 * @param plugin_addr_len number of bytes in plugin_addr
55 * @param session session to use
54 * @param bandwidth_out assigned outbound bandwidth for the connection 56 * @param bandwidth_out assigned outbound bandwidth for the connection
55 * @param bandwidth_in assigned inbound bandwidth for the connection 57 * @param bandwidth_in assigned inbound bandwidth for the connection
56 * @param ats performance data for the address (as far as known)
57 * @param ats_count number of performance records in 'ats'
58 */ 58 */
59typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, 59typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
60 const struct 60 const struct
@@ -69,11 +69,7 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
69 bandwidth_out, 69 bandwidth_out,
70 struct 70 struct
71 GNUNET_BANDWIDTH_Value32NBO 71 GNUNET_BANDWIDTH_Value32NBO
72 bandwidth_in, 72 bandwidth_in);
73 const struct
74 GNUNET_TRANSPORT_ATS_Information
75 * ats,
76 uint32_t ats_count);
77 73
78 74
79/** 75/**
@@ -84,86 +80,58 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
84 * @param alloc_cb_cls closure for 'alloc_cb' 80 * @param alloc_cb_cls closure for 'alloc_cb'
85 * @return ats context 81 * @return ats context
86 */ 82 */
87struct GNUNET_ATS_Handle * 83struct GNUNET_ATS_SchedulingHandle *
88GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 84GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
89 GNUNET_ATS_AddressSuggestionCallback alloc_cb, 85 GNUNET_ATS_AddressSuggestionCallback alloc_cb,
90 void *alloc_cb_cls); 86 void *alloc_cb_cls);
91 87
92 88
93/** 89/**
94 * Shutdown the ATS subsystem. 90 * Client is done with ATS scheduling, release resources.
95 * 91 *
96 * @param atc handle 92 * @param atc handle to release
97 */ 93 */
98void 94void
99GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc); 95GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc);
100
101
102/**
103 * Handle to cancel suggestion request.
104 */
105struct GNUNET_ATS_SuggestionContext;
106 96
107 97
108/** 98/**
109 * We would like to establish a new connection with a peer. 99 * We would like to establish a new connection with a peer. ATS
110 * ATS should suggest a good address to begin with. 100 * should suggest a good address to begin with.
111 * 101 *
112 * @param atc handle 102 * @param atc handle
113 * @param peer identity of the new peer 103 * @param peer identity of the peer we need an address for
114 * @param cb function to call with the address
115 * @param cb_cls closure for cb
116 */
117struct GNUNET_ATS_SuggestionContext *
118GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
119 const struct GNUNET_PeerIdentity *peer,
120 GNUNET_ATS_AddressSuggestionCallback cb,
121 void *cb_cls);
122
123
124/**
125 * Cancel suggestion request.
126 *
127 * @param asc handle of the request to cancel
128 */ 104 */
129void 105void
130GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc); 106GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
107 const struct GNUNET_PeerIdentity *peer);
131 108
132 109
133/** 110/**
134 * We established a new connection with a peer (for example, because 111 * We have updated performance statistics for a given address. Note
135 * core asked for it or because the other peer connected to us). 112 * that this function can be called for addresses that are currently
136 * Calculate bandwidth assignments including the new peer. 113 * in use as well as addresses that are valid but not actively in use.
114 * Furthermore, the peer may not even be connected to us right now (in
115 * which case the call may be ignored or the information may be stored
116 * for later use). Update bandwidth assignments.
137 * 117 *
138 * @param atc handle 118 * @param atc handle
139 * @param peer identity of the new peer 119 * @param peer identity of the new peer
140 * @param plugin_name name of the currently used transport plugin 120 * @param plugin_name name of the transport plugin
141 * @param session session in use (if available) 121 * @param plugin_addr address (if available)
142 * @param plugin_addr address in use (if available)
143 * @param plugin_addr_len number of bytes in plugin_addr 122 * @param plugin_addr_len number of bytes in plugin_addr
144 * @param ats performance data for the connection 123 * @param session session handle (if available)
124 * @param ats performance data for the address
145 * @param ats_count number of performance records in 'ats' 125 * @param ats_count number of performance records in 'ats'
146 */ 126 */
147void 127void
148GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, 128GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
149 const struct GNUNET_PeerIdentity *peer, 129 const struct GNUNET_PeerIdentity *peer,
150 const char *plugin_name, struct Session *session, 130 const char *plugin_name,
151 const void *plugin_addr, size_t plugin_addr_len, 131 const void *plugin_addr, size_t plugin_addr_len,
152 const struct GNUNET_TRANSPORT_ATS_Information *ats, 132 struct Session *session,
153 uint32_t ats_count); 133 const struct GNUNET_TRANSPORT_ATS_Information *ats,
154 134 uint32_t ats_count);
155
156/**
157 * We disconnected from the given peer (for example, because ats, core
158 * or blacklist asked for it or because the other peer disconnected).
159 * Calculate bandwidth assignments without the peer.
160 *
161 * @param atc handle
162 * @param peer identity of the peer
163 */
164void
165GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
166 const struct GNUNET_PeerIdentity *peer);
167 135
168 136
169/** 137/**
@@ -171,45 +139,85 @@ GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
171 * 139 *
172 * @param atc handle 140 * @param atc handle
173 * @param peer identity of the peer 141 * @param peer identity of the peer
142 * @param plugin_name name of the transport plugin
143 * @param plugin_addr address (if available)
144 * @param plugin_addr_len number of bytes in plugin_addr
174 * @param session session handle that is no longer valid 145 * @param session session handle that is no longer valid
175 */ 146 */
176void 147void
177GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, 148GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
178 const struct GNUNET_PeerIdentity *peer, 149 const struct GNUNET_PeerIdentity *peer,
150 const char *plugin_name,
151 const void *plugin_addr,
152 size_t plugin_addr_len,
179 const struct Session *session); 153 const struct Session *session);
180 154
181 155
156/* ******************************** Performance API ***************************** */
157
182/** 158/**
183 * We have updated performance statistics for a given address. Note 159 * ATS Handle to obtain and/or modify performance information.
184 * that this function can be called for addresses that are currently 160 */
185 * in use as well as addresses that are valid but not actively in use. 161struct GNUNET_ATS_PerformanceHandle;
186 * Furthermore, the peer may not even be connected to us right now (in 162
187 * which case the call may be ignored or the information may be stored 163
188 * for later use). Update bandwidth assignments. 164/**
165 * Signature of a function that is called with QoS information about a peer.
189 * 166 *
190 * @param atc handle 167 * @param cls closure
191 * @param peer identity of the new peer 168 * @param peer identity of the new peer
192 * @param valid_until how long is the address valid? 169 * @param plugin_name name of the plugin, NULL if we have no suggestion
193 * @param plugin_name name of the transport plugin 170 * @param plugin_addr suggested address, NULL if we have no suggestion
194 * @param session session handle (if available)
195 * @param plugin_addr address (if available)
196 * @param plugin_addr_len number of bytes in plugin_addr 171 * @param plugin_addr_len number of bytes in plugin_addr
197 * @param ats performance data for the address 172 * @param bandwidth_out assigned outbound bandwidth for the connection
173 * @param bandwidth_in assigned inbound bandwidth for the connection
174 * @param ats performance data for the address (as far as known)
198 * @param ats_count number of performance records in 'ats' 175 * @param ats_count number of performance records in 'ats'
199 */ 176 */
200void 177typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
201GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, 178 const struct
202 const struct GNUNET_PeerIdentity *peer, 179 GNUNET_PeerIdentity *
203 struct GNUNET_TIME_Absolute valid_until, 180 peer,
204 const char *plugin_name, struct Session *session, 181 const char *plugin_name,
205 const void *plugin_addr, size_t plugin_addr_len, 182 const void *plugin_addr,
206 const struct GNUNET_TRANSPORT_ATS_Information *ats, 183 size_t plugin_addr_len,
207 uint32_t ats_count); 184 struct
185 GNUNET_BANDWIDTH_Value32NBO
186 bandwidth_out,
187 struct
188 GNUNET_BANDWIDTH_Value32NBO
189 bandwidth_in,
190 const struct
191 GNUNET_TRANSPORT_ATS_Information
192 * ats,
193 uint32_t ats_count);
208 194
209 195
196/**
197 * Get handle to access performance API of the ATS subsystem.
198 *
199 * @param cfg configuration to use
200 * @param infocb function to call on allocation changes, can be NULL
201 * @param infocb_cls closure for infocb
202 * @return ats performance context
203 */
204struct GNUNET_ATS_PerformanceHandle *
205GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
206 GNUNET_ATS_PeerInformationCallback infocb,
207 void *infocb_cls);
208
209
210/**
211 * Client is done using the ATS performance subsystem, release resources.
212 *
213 * @param atc handle
214 */
215void
216GNUNET_ATS_performance_done (struct GNUNET_ATS_SchedulingHandle *atc);
217
210 218
211/** 219/**
212 * Function called with perference change information about the given peer. 220 * Function called with reservation result.
213 * 221 *
214 * @param cls closure 222 * @param cls closure
215 * @param peer identifies the peer 223 * @param peer identifies the peer
@@ -218,65 +226,99 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
218 * @param res_delay if the reservation could not be satisfied (amount was 0), how 226 * @param res_delay if the reservation could not be satisfied (amount was 0), how
219 * long should the client wait until re-trying? 227 * long should the client wait until re-trying?
220 */ 228 */
221typedef void (*GNUNET_ATS_PeerConfigurationInfoCallback) (void *cls, 229typedef void (*GNUNET_ATS_ReservationCallback) (void *cls,
222 const struct 230 const struct
223 GNUNET_PeerIdentity * 231 GNUNET_PeerIdentity *
224 peer, 232 peer,
225 int32_t amount, 233 int32_t amount,
226 struct 234 struct
227 GNUNET_TIME_Relative 235 GNUNET_TIME_Relative
228 res_delay); 236 res_delay);
229 237
230 238
231 239
232/** 240/**
233 * Context that can be used to cancel a peer information request. 241 * Context that can be used to cancel a peer information request.
234 */ 242 */
235struct GNUNET_ATS_InformationRequestContext; 243struct GNUNET_ATS_ReservationContext;
236 244
237 245
238/** 246/**
239 * Obtain statistics and/or change preferences for the given peer. 247 * Reserve inbound bandwidth from the given peer. ATS will look at
240 * You can only have one such pending request per peer. 248 * the current amount of traffic we receive from the peer and ensure
249 * that the peer could add 'amount' of data to its stream.
241 * 250 *
242 * @param h core handle 251 * @param h core handle
243 * @param peer identifies the peer 252 * @param peer identifies the peer
244 * @param amount reserve N bytes for receiving, negative 253 * @param amount reserve N bytes for receiving, negative
245 * amounts can be used to undo a (recent) reservation; 254 * amounts can be used to undo a (recent) reservation;
246 * @param preference increase incoming traffic share preference by this amount; 255 * @param info function to call with the resulting reservation information
247 * in the absence of "amount" reservations, we use this
248 * preference value to assign proportional bandwidth shares
249 * to all connected peers; in the future, this should be
250 * replaced with more specific QoS expressions...
251 * @param info function to call with the resulting configuration information
252 * @param info_cls closure for info 256 * @param info_cls closure for info
253 * @return NULL on error 257 * @return NULL on error
254 * @deprecated will be replaced soon 258 * @deprecated will be replaced soon
255 */ 259 */
256struct GNUNET_ATS_InformationRequestContext * 260struct GNUNET_ATS_ReservationContext *
257GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, 261GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *h,
258 const struct GNUNET_PeerIdentity *peer, 262 const struct GNUNET_PeerIdentity *peer,
259 int32_t amount, uint64_t preference, 263 int32_t amount,
260 GNUNET_ATS_PeerConfigurationInfoCallback 264 GNUNET_ATS_ReservationCallback info,
261 info, void *info_cls); 265 void *info_cls);
262 266
263 267
264/** 268/**
265 * Cancel request for getting information about a peer. 269 * Cancel request for reserving bandwidth.
266 * Note that an eventual change in preference, trust or bandwidth
267 * assignment MAY have already been committed at the time,
268 * so cancelling a request is NOT sure to undo the original
269 * request. The original request may or may not still commit.
270 * The only thing cancellation ensures is that the callback
271 * from the original request will no longer be called.
272 * 270 *
273 * @param irc context returned by the original GNUNET_ATS_peer_get_info call 271 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
274 * @deprecated will be replaced soon 272 */
273void
274GNUNET_ATS_reserve_bandwidth_cancel (struct
275 GNUNET_ATS_ReservationContext *rc);
276
277
278
279/**
280 * Enum defining all known preference categories.
281 */
282enum GNUNET_ATS_PreferenceKind
283{
284
285 /**
286 * End of preference list.
287 */
288 GNUNET_ATS_PREFERENCE_END = 0,
289
290 /**
291 * Change the peer's bandwidth value (value per byte of bandwidth in
292 * the goal function) to the given amount. The argument is followed
293 * by a double value giving the desired value (can be negative).
294 * Preference changes are forgotten if peers disconnect.
295 */
296 GNUNET_ATS_PREFERENCE_BANDWIDTH,
297
298 /**
299 * Change the peer's latency value to the given amount. The
300 * argument is followed by a double value giving the desired value
301 * (can be negative). The absolute score in the goal function is
302 * the inverse of the latency in ms (minimum: 1 ms) multiplied by
303 * the latency preferences.
304 */
305 GNUNET_ATS_PREFERENCE_LATENCY
306
307};
308
309
310/**
311 * Change preferences for the given peer. Preference changes are forgotten if peers
312 * disconnect.
313 *
314 * @param cls closure
315 * @param peer identifies the peer
316 * @param ... 0-terminated specification of the desired changes
275 */ 317 */
276void 318void
277GNUNET_ATS_peer_change_preference_cancel (struct 319GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
278 GNUNET_ATS_InformationRequestContext 320 const struct GNUNET_PeerIdentity *peer,
279 *irc); 321 ...);
280 322
281 323
282 324
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 418c9f8ef..9f106c3a9 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -987,6 +987,27 @@ extern "C"
987#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334 987#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334
988 988
989/******************************************************************************* 989/*******************************************************************************
990 * ATS message types
991 ******************************************************************************/
992
993#define GNUNET_MESSAGE_TYPE_ATS_START 340
994
995#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS 341
996
997#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE 342
998
999#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED 343
1000
1001#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION 344
1002
1003#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST 345
1004
1005#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT 346
1006
1007#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE 347
1008
1009
1010/*******************************************************************************
990 * TODO: we need a way to register message types centrally (via some webpage). 1011 * TODO: we need a way to register message types centrally (via some webpage).
991 * For now: unofficial extensions should start at 48k, internal extensions 1012 * For now: unofficial extensions should start at 48k, internal extensions
992 * define here should leave some room (4-10 additional messages to the previous 1013 * define here should leave some room (4-10 additional messages to the previous
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index fb5a5c5e6..ce4c240a7 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -73,7 +73,7 @@ struct GNUNET_CRYPTO_RsaPrivateKey *GST_my_private_key;
73/** 73/**
74 * ATS handle. 74 * ATS handle.
75 */ 75 */
76struct GNUNET_ATS_Handle *GST_ats; 76struct GNUNET_ATS_SchedulingHandle *GST_ats;
77 77
78 78
79/** 79/**
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h
index 36469df06..adc28ba6d 100644
--- a/src/transport/gnunet-service-transport.h
+++ b/src/transport/gnunet-service-transport.h
@@ -65,7 +65,7 @@ extern struct GNUNET_CRYPTO_RsaPrivateKey *GST_my_private_key;
65/** 65/**
66 * ATS handle. 66 * ATS handle.
67 */ 67 */
68extern struct GNUNET_ATS_Handle *GST_ats; 68extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
69 69
70 70
71#endif 71#endif