diff options
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/Makefile.am | 4 | ||||
-rw-r--r-- | src/ats/ats.h | 210 | ||||
-rw-r--r-- | src/ats/ats_api.c | 34 | ||||
-rw-r--r-- | src/ats/ats_api.h | 2 | ||||
-rw-r--r-- | src/ats/ats_api_new.c | 129 | ||||
-rw-r--r-- | src/ats/ats_api_peer_change_preference.c | 10 | ||||
-rw-r--r-- | src/ats/ats_api_performance.c | 128 | ||||
-rw-r--r-- | src/ats/test_ats_api.c | 2 | ||||
-rw-r--r-- | src/ats/test_ats_api_update_address.c | 2 |
9 files changed, 494 insertions, 27 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 | |||
11 | lib_LTLIBRARIES = libgnunetats.la | 11 | lib_LTLIBRARIES = libgnunetats.la |
12 | 12 | ||
13 | libgnunetats_la_SOURCES = \ | 13 | libgnunetats_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 | ||
17 | libgnunetats_la_LIBADD = \ | 17 | libgnunetats_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 | |||
32 | enum 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 | |||
45 | struct 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 | |||
57 | struct RequestAddressMessage | ||
58 | { | ||
59 | struct GNUNET_MessageHeader header; | ||
60 | |||
61 | uint32_t reserved GNUNET_PACKED; | ||
62 | |||
63 | struct GNUNET_PeerIdentity peer; | ||
64 | }; | ||
65 | |||
66 | struct 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 | |||
88 | struct 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 | |||
110 | struct 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 | |||
137 | struct 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 | |||
164 | struct ReservationRequestMessage | ||
165 | { | ||
166 | struct GNUNET_MessageHeader header; | ||
167 | |||
168 | int32_t amount GNUNET_PACKED; | ||
169 | |||
170 | struct GNUNET_PeerIdentity peer; | ||
171 | }; | ||
172 | |||
173 | |||
174 | struct 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 | |||
186 | struct PreferenceInformation | ||
187 | { | ||
188 | |||
189 | uint32_t preference_kind GNUNET_PACKED; | ||
190 | |||
191 | float preference_value GNUNET_PACKED; | ||
192 | |||
193 | }; | ||
194 | |||
195 | |||
196 | struct 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 | */ |
190 | static void | 190 | static void |
191 | update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 191 | update_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 | */ |
220 | static void | 220 | static void |
221 | update_bandwidth_assignment (struct GNUNET_ATS_Handle *atc, | 221 | update_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 | */ |
279 | struct GNUNET_ATS_SuggestionContext * | 279 | struct GNUNET_ATS_SuggestionContext * |
280 | GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, | 280 | GNUNET_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 | */ |
335 | struct GNUNET_ATS_Handle * | 335 | struct GNUNET_ATS_SchedulingHandle * |
336 | GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 336 | GNUNET_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 | */ |
384 | void | 384 | void |
385 | GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc) | 385 | GNUNET_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, | |||
556 | static int | 556 | static int |
557 | disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value) | 557 | disconnect_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 | */ |
585 | void | 585 | void |
586 | GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, | 586 | GNUNET_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 | */ |
630 | void | 630 | void |
631 | GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc, | 631 | GNUNET_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 | */ |
701 | void | 701 | void |
702 | GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, | 702 | GNUNET_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 | */ |
758 | void | 758 | void |
759 | GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, | 759 | GNUNET_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 | */ |
94 | struct GNUNET_ATS_Handle | 94 | struct 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 | */ | ||
33 | struct 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 | */ | ||
46 | struct GNUNET_ATS_SchedulingHandle * | ||
47 | GNUNET_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 | */ | ||
60 | void | ||
61 | GNUNET_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 | */ | ||
73 | void | ||
74 | GNUNET_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 | */ | ||
97 | void | ||
98 | GNUNET_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 | */ | ||
119 | void | ||
120 | GNUNET_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 | */ |
126 | struct GNUNET_ATS_InformationRequestContext * | 126 | struct GNUNET_ATS_InformationRequestContext * |
127 | GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, | 127 | GNUNET_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 | */ |
220 | struct GNUNET_ATS_InformationRequestContext * | 220 | struct GNUNET_ATS_InformationRequestContext * |
221 | GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, | 221 | GNUNET_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 | */ | ||
34 | struct 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 | */ | ||
47 | struct GNUNET_ATS_PerformanceHandle * | ||
48 | GNUNET_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 | */ | ||
61 | void | ||
62 | GNUNET_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 | */ | ||
70 | struct 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 | */ | ||
89 | struct GNUNET_ATS_ReservationContext * | ||
90 | GNUNET_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 | */ | ||
105 | void | ||
106 | GNUNET_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 | */ | ||
120 | void | ||
121 | GNUNET_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 | ||
43 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 43 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
44 | 44 | ||
45 | static struct GNUNET_ATS_Handle *ats; | 45 | static struct GNUNET_ATS_SchedulingHandle *ats; |
46 | 46 | ||
47 | static void | 47 | static void |
48 | alloc_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | 48 | alloc_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 | ||
47 | static struct GNUNET_ATS_Handle *ats; | 47 | static struct GNUNET_ATS_SchedulingHandle *ats; |
48 | 48 | ||
49 | static struct GNUNET_ATS_SuggestionContext *asc; | 49 | static struct GNUNET_ATS_SuggestionContext *asc; |
50 | 50 | ||