aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_addresses.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c465
1 files changed, 53 insertions, 412 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index c4d7f2da9..17f030a6c 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -32,186 +32,6 @@
32 32
33 33
34/** 34/**
35 * NOTE: Do not change this documentation. This documentation is based on
36 * gnunet.org:/vcs/fsnsg/2014-p2p-ats.git/tech-doku/ats-tech-guide.tex
37 * use build_txt.sh to generate plaintext output
38 *
39 * 1 ATS addresses : ATS address management
40 *
41 * This ATS addresses ("addresses") component manages the addresses known to
42 * ATS service and suggests addresses to transport service when it is
43 * interested in address suggestion for a peer. ATS addresses also
44 * instantiates the bandwidth assignment mechanism (solver), notifies it
45 * about changes to addresses and forwards changes to bandwidth assignments
46 * to transport, depending if transport is interested in this change.
47 *
48 * 1.1 Input data
49 *
50 * 1.1.1 Addresses
51 *
52 * Addresses are added by specifying peer ID, plugin, address, address length
53 * and session, if available. ATS information can be specified if available.
54 *
55 * 1.1.2 Networks
56 *
57 * ATS specifies a fix set of networks an address can belong to. For each
58 * network an inbound and outbound quota will be specified. The available
59 * networks and addtional helper varaibles are defined in
60 * gnunet_ats_service.h. At the moment 5 networks are defined:
61 * * GNUNET_ATS_NET_UNSPECIFIED
62 * * GNUNET_ATS_NET_LOOPBACK
63 * * GNUNET_ATS_NET_LAN
64 * * GNUNET_ATS_NET_WAN
65 * * GNUNET_ATS_NET_WLAN
66 *
67 * The total number of networks defined is stored in
68 * GNUNET_ATS_NetworkTypeCount GNUNET_ATS_NetworkType can be used array
69 * initializer for an int array, while GNUNET_ATS_NetworkType is an
70 * initializer for a char array containing a string description of all
71 * networks
72 *
73 * 1.1.3 Quotas
74 *
75 * An inbound and outbound quota for each of the networks mentioned in 1.1.2
76 * is loaded from ats configuration during initialization. This quota defines
77 * to total amount of inbound and outbound traffic allowed for a specific
78 * network. The configuration values used are in section ats:
79 * * "NETWORK"_QUOTA_IN = <value>
80 * * "NETWORK"_QUOTA_IN = <value>
81 *
82 * You can specify quotas by setting the <value> to a:
83 * * unrestricted: unlimited
84 * * number of bytes: e.g. 10240
85 * * fancy value: e.g. 64 Kib
86 *
87 * unlimited is defined as GNUNET_ATS_MaxBandwidthString and equivalent to
88 * the value GNUNET_ATS_MaxBandwidth Important predefined values for quotas
89 * are:
90 * * GNUNET_ATS_DefaultBandwidth: 65536
91 * * GNUNET_ATS_MaxBandwidth: UINT32_MAX
92 * * GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT: 1024
93 *
94 * Details of loading quotas and default values will be described on
95 *
96 * 1.1.4 Preference values
97 *
98 * 1.2 Data structures used
99 *
100 * Addresse uses struct ATS_Address for each address. The structs are stored
101 * in a linked list and provides a pointer void *solver_information for the
102 * solver to store address specific information. It provides the int values
103 * active which is set to GNUNET_YES if the address is select for transport
104 * use and used, representing that transport service is actively using this
105 * address. Address information are stored in peer, addr, addr_len, plugin.
106 *
107 * 1.3 Initialization
108 *
109 * During initialization a hashmap to store addresses is created. The quotas
110 * for all networks defined for ATS are loaded from configuration. For each
111 * network first the logic will check if the string
112 * GNUNET_ATS_MaxBandwidthString is configured, if not it will try to convert
113 * the configured value as a fancy size and if this fails it will try to use
114 * it as a value_number. If no configuration value is found it will assign
115 * GNUNET_ATS_DefaultBandwidth. The most important step is to load the
116 * configured solver using configuration "[ats]:MODE". Current solvers are
117 * MODE_PROPORTIONAL, MODE_MLP. Interaction is done using a solver API
118 *
119 * 1.4 Solver API
120 *
121 * Solver functions:
122 * * s_init: init the solver with required information
123 * * s_add: add a new address
124 * * s_update: update ATS values or session for an address
125 * * s_get: get prefered address for a peer
126 * * s_del: delete an address
127 * * s_pref: change preference value for a peer
128 * * s_done: shutdown solver
129 *
130 * Callbacks: addresses provides a bandwidth_changed_cb callback to the
131 * solver which is called when bandwidth assigned to peer has changed
132 *
133 * 1.5 Shutdown
134 *
135 * During shutdown all addresses are freed and the solver told to shutdown
136 *
137 * 1.6 Addresses and sessions
138 *
139 * Addresses consist of the address itself and a numerical session. When a
140 * new address without a session is added it has no session, so it gets
141 * session 0 assigned. When an address with a session is added and an address
142 * object with session 0 is found, this object is updated with the session
143 * otherwise a new address object with this session assigned is created.
144 *
145 * 1.6.1 Terminology
146 *
147 * Addresses a1,a2 with session s1, s2 are "exact" if:
148 * (a1 == a2)&&(s1 == s2)
149 * Addresses a1,a2 with session s1, s2 are "equivalent" if:
150 * (a1 == a2)&&((s1 == s2)||(s1 == 0)||(s2 == 0)
151 *
152 * 1.7 Address management
153 *
154 * Transport service notifies ATS about changes to the addresses known to
155 * him.
156 *
157 * 1.7.1 Adding an address
158 *
159 * When transport learns a new address it tells ATS and ATS is telling
160 * addresses about it using GAS_address_add. If not known to addresses it
161 * creates a new address object and calls solver's s_add. ATS information are
162 * deserialized and solver is notified about the session and ATS information
163 * using s_update.
164 *
165 * 1.7.2 Updating an address
166 *
167 * Addresses does an lookup up for the existing address with the given
168 * session. If disassembles included ATS information and notifies the solver
169 * using s_update about the update.
170 *
171 * 1.7.3 Deleting an address
172 *
173 * Addresses does an lookup for the exact address and session and if removes
174 * this address. If session != 0 the session is set to 0 and the address is
175 * kept. If session == 0, the addresses is removed.
176 *
177 * 1.7.4 Requesting an address suggestion
178 *
179 * The address client issues a request address message to be notified about
180 * address suggestions for a specific peer. Addresses asks the solver with
181 * s_get. If no address is available, it will not send a response, otherwise
182 * it will respond with the choosen address.
183 *
184 * 1.7.5 Address suggestions
185 *
186 * Addresses will notify the client automatically on any bandwidth_changed_cb
187 * by the solver if a address suggestion request is pending. If no address is
188 * available it will not respond at all If the client is not interested
189 * anymore, it has to cancel the address suggestion request.
190 *
191 * 1.7.6 Address lifecycle
192 *
193 * * (add address)
194 * * (updated address)
195 * * (delete address)
196 *
197 * 1.8 Bandwidth assignment
198 *
199 * The addresses are used to perform resource allocation operations. ATS
200 * addresses takes care of instantiating the solver configured and notifies
201 * the respective solver about address changes and receives changes to the
202 * bandwidth assignment from the solver. The current bandwidth assignment is
203 * sent to transport. The specific solvers will be described in the specific
204 * section.
205 *
206 * 1.9 Changing peer preferences
207 *
208 * The bandwidth assigned to a peer can be influenced by setting a preference
209 * for a peer. The prefernce will be given to to the solver with s_pref which
210 * has to take care of the preference value
211 */
212
213
214/**
215 * A multihashmap to store all addresses 35 * A multihashmap to store all addresses
216 */ 36 */
217struct GNUNET_CONTAINER_MultiPeerMap *GSA_addresses; 37struct GNUNET_CONTAINER_MultiPeerMap *GSA_addresses;
@@ -231,124 +51,6 @@ update_addresses_stat ()
231 51
232 52
233/** 53/**
234 * Disassemble ATS information and update performance information in address
235 *
236 * Updates existing information and adds new information
237 *
238 * @param dest destination address
239 * @param update source ATS information
240 * @param update_count number of ATS information in @a update
241 * @param delta_dest ats performance information which were updated
242 * including previous value
243 * @param delta_count number of ATS information in the @a delta_dest
244 * @return #GNUNET_YES if address was address updated, GNUNET_NO otherwise
245 */
246static unsigned int
247disassemble_ats_information (struct ATS_Address *dest,
248 const struct GNUNET_ATS_Information *update,
249 uint32_t update_count,
250 struct GNUNET_ATS_Information **delta_dest,
251 uint32_t *delta_count)
252{
253 int c1;
254 int c2;
255 int found;
256 int change;
257 struct GNUNET_ATS_Information add_atsi[update_count];
258 struct GNUNET_ATS_Information delta_atsi[update_count];
259 struct GNUNET_ATS_Information *tmp_atsi;
260 uint32_t add_atsi_count;
261 uint32_t delta_atsi_count;
262
263 change = GNUNET_NO;
264 add_atsi_count = 0;
265 delta_atsi_count = 0;
266
267 if (0 == update_count)
268 return GNUNET_NO;
269
270 if (NULL == dest->atsi)
271 {
272 /* Create performance information */
273 dest->atsi =
274 GNUNET_malloc (update_count * sizeof (struct GNUNET_ATS_Information));
275 dest->atsi_count = update_count;
276 memcpy (dest->atsi,
277 update,
278 update_count * sizeof(struct GNUNET_ATS_Information));
279 *delta_dest =
280 GNUNET_malloc (update_count * sizeof (struct GNUNET_ATS_Information));
281 for (c1 = 0; c1 < update_count; c1++)
282 {
283 (*delta_dest)[c1].type = update[c1].type;
284 (*delta_dest)[c1].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
285 }
286 (*delta_count) = update_count;
287 return GNUNET_YES;
288 }
289
290 for (c1 = 0; c1 < update_count; c1++)
291 {
292 /* Update existing performance information */
293 found = GNUNET_NO;
294 for (c2 = 0; c2 < dest->atsi_count; c2++)
295 {
296 if (update[c1].type == dest->atsi[c2].type)
297 {
298 if (update[c1].value != dest->atsi[c2].value)
299 {
300 /* Save previous value in delta */
301 delta_atsi[delta_atsi_count] = dest->atsi[c2];
302 delta_atsi_count++;
303 /* Set new value */
304 dest->atsi[c2].value = update[c1].value;
305 change = GNUNET_YES;
306 }
307 found = GNUNET_YES;
308 break;
309 }
310 }
311 if (GNUNET_NO == found)
312 {
313 add_atsi[add_atsi_count] = update[c1];
314 add_atsi_count++;
315 delta_atsi[delta_atsi_count].type = update[c1].type;
316 delta_atsi[delta_atsi_count].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
317 delta_atsi_count++;
318 }
319 }
320
321 if (add_atsi_count > 0)
322 {
323 /* Extend ats performance information */
324
325 tmp_atsi = GNUNET_malloc ((dest->atsi_count + add_atsi_count) *
326 (sizeof (struct GNUNET_ATS_Information)));
327 memcpy (tmp_atsi, dest->atsi,
328 dest->atsi_count * sizeof(struct GNUNET_ATS_Information));
329 memcpy (&tmp_atsi[dest->atsi_count], add_atsi,
330 add_atsi_count * sizeof(struct GNUNET_ATS_Information));
331 GNUNET_free (dest->atsi);
332 dest->atsi = tmp_atsi;
333 dest->atsi_count = dest->atsi_count + add_atsi_count;
334 change = GNUNET_YES;
335 }
336
337 if (delta_atsi_count > 0)
338 {
339 /* Copy delta */
340 (*delta_dest) =
341 GNUNET_malloc (delta_atsi_count * sizeof (struct GNUNET_ATS_Information));
342 memcpy ((*delta_dest), delta_atsi,
343 delta_atsi_count * sizeof(struct GNUNET_ATS_Information));
344 (*delta_count) = delta_atsi_count;
345 }
346
347 return change;
348}
349
350
351/**
352 * Free the given address 54 * Free the given address
353 * 55 *
354 * @param addr address to destroy 56 * @param addr address to destroy
@@ -366,16 +68,30 @@ free_address (struct ATS_Address *addr)
366 addr->addr, 68 addr->addr,
367 addr->addr_len, 69 addr->addr_len,
368 GNUNET_NO, 70 GNUNET_NO,
369 NULL, 0, 71 NULL,
370 GNUNET_BANDWIDTH_ZERO, 72 GNUNET_BANDWIDTH_ZERO,
371 GNUNET_BANDWIDTH_ZERO); 73 GNUNET_BANDWIDTH_ZERO);
372 GNUNET_free (addr->plugin); 74 GNUNET_free (addr->plugin);
373 GNUNET_free_non_null (addr->atsi);
374 GNUNET_free (addr); 75 GNUNET_free (addr);
375} 76}
376 77
377 78
378/** 79/**
80 * Initialize @a norm. Sets all historic values to undefined.
81 *
82 * @param norm normalization data to initialize
83 */
84static void
85init_norm (struct GAS_NormalizationInfo *norm)
86{
87 unsigned int c;
88
89 for (c = 0; c < GAS_normalization_queue_length; c++)
90 norm->atsi_abs[c] = UINT64_MAX;
91}
92
93
94/**
379 * Create a ATS_address with the given information 95 * Create a ATS_address with the given information
380 * 96 *
381 * @param peer peer 97 * @param peer peer
@@ -395,8 +111,6 @@ create_address (const struct GNUNET_PeerIdentity *peer,
395 uint32_t session_id) 111 uint32_t session_id)
396{ 112{
397 struct ATS_Address *aa; 113 struct ATS_Address *aa;
398 unsigned int c1;
399 unsigned int c2;
400 114
401 aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len); 115 aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len);
402 aa->peer = *peer; 116 aa->peer = *peer;
@@ -408,14 +122,10 @@ create_address (const struct GNUNET_PeerIdentity *peer,
408 aa->plugin = GNUNET_strdup (plugin_name); 122 aa->plugin = GNUNET_strdup (plugin_name);
409 aa->session_id = session_id; 123 aa->session_id = session_id;
410 aa->local_address_info = local_address_info; 124 aa->local_address_info = local_address_info;
411 125 init_norm (&aa->norm_delay);
412 for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++) 126 init_norm (&aa->norm_distance);
413 { 127 init_norm (&aa->norm_utilization_in);
414 aa->atsin[c1].avg_queue_index = 0; 128 init_norm (&aa->norm_utilization_out);
415 aa->atsin[c1].norm = DEFAULT_REL_QUALITY;
416 for (c2 = 0; c2 < GAS_normalization_queue_length; c2++)
417 aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED;
418 }
419 return aa; 129 return aa;
420} 130}
421 131
@@ -486,31 +196,6 @@ find_exact_address (const struct GNUNET_PeerIdentity *peer,
486 196
487 197
488/** 198/**
489 * Extract an ATS performance info from an address
490 *
491 * @param address the address
492 * @param type the type to extract in HBO
493 * @return the value in HBO or #GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist
494 */
495static int
496get_performance_info (struct ATS_Address *address,
497 uint32_t type)
498{
499 uint32_t c1;
500
501 if ((NULL == address->atsi) || (0 == address->atsi_count))
502 return GNUNET_ATS_VALUE_UNDEFINED;
503
504 for (c1 = 0; c1 < address->atsi_count; c1++)
505 {
506 if (ntohl (address->atsi[c1].type) == type)
507 return ntohl (address->atsi[c1].value);
508 }
509 return GNUNET_ATS_VALUE_UNDEFINED;
510}
511
512
513/**
514 * Add a new address for a peer. 199 * Add a new address for a peer.
515 * 200 *
516 * @param peer peer 201 * @param peer peer
@@ -519,8 +204,7 @@ get_performance_info (struct ATS_Address *address,
519 * @param plugin_addr_len length of the plugin address in @a plugin_addr 204 * @param plugin_addr_len length of the plugin address in @a plugin_addr
520 * @param local_address_info the local address for the address 205 * @param local_address_info the local address for the address
521 * @param session_id session id, can be 0 206 * @param session_id session id, can be 0
522 * @param atsi performance information for this address 207 * @param prop performance information for this address
523 * @param atsi_count number of performance information contained in @a atsi
524 */ 208 */
525void 209void
526GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, 210GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
@@ -529,15 +213,12 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
529 size_t plugin_addr_len, 213 size_t plugin_addr_len,
530 uint32_t local_address_info, 214 uint32_t local_address_info,
531 uint32_t session_id, 215 uint32_t session_id,
532 const struct GNUNET_ATS_Information *atsi, 216 const struct GNUNET_ATS_Properties *prop)
533 uint32_t atsi_count)
534{ 217{
535 struct ATS_Address *new_address; 218 struct ATS_Address *new_address;
536 struct GNUNET_ATS_Information *atsi_delta;
537 uint32_t atsi_delta_count;
538 uint32_t addr_net;
539 219
540 if (NULL != find_exact_address (peer, session_id)) 220 if (NULL != find_exact_address (peer,
221 session_id))
541 { 222 {
542 GNUNET_break (0); 223 GNUNET_break (0);
543 return; 224 return;
@@ -548,17 +229,8 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
548 plugin_addr_len, 229 plugin_addr_len,
549 local_address_info, 230 local_address_info,
550 session_id); 231 session_id);
551 atsi_delta = NULL;
552 disassemble_ats_information (new_address,
553 atsi, atsi_count,
554 &atsi_delta,
555 &atsi_delta_count);
556 GNUNET_free_non_null (atsi_delta);
557 addr_net = get_performance_info (new_address, GNUNET_ATS_NETWORK_TYPE);
558 if (GNUNET_ATS_VALUE_UNDEFINED == addr_net)
559 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
560
561 /* Add a new address */ 232 /* Add a new address */
233 new_address->properties = *prop;
562 new_address->t_added = GNUNET_TIME_absolute_get(); 234 new_address->t_added = GNUNET_TIME_absolute_get();
563 new_address->t_last_activity = GNUNET_TIME_absolute_get(); 235 new_address->t_last_activity = GNUNET_TIME_absolute_get();
564 GNUNET_assert(GNUNET_OK == 236 GNUNET_assert(GNUNET_OK ==
@@ -573,11 +245,8 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
573 session_id); 245 session_id);
574 /* Tell solver about new address */ 246 /* Tell solver about new address */
575 GAS_plugin_solver_lock (); 247 GAS_plugin_solver_lock ();
576 GAS_plugin_new_address (new_address, 248 GAS_plugin_new_address (new_address);
577 addr_net); 249 GAS_normalization_update_property (new_address); // FIXME: needed?
578 GAS_normalization_update_property (new_address,
579 atsi,
580 atsi_count);
581 GAS_plugin_solver_unlock (); 250 GAS_plugin_solver_unlock ();
582 /* Notify performance clients about new address */ 251 /* Notify performance clients about new address */
583 GAS_performance_notify_all_clients (&new_address->peer, 252 GAS_performance_notify_all_clients (&new_address->peer,
@@ -585,8 +254,7 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
585 new_address->addr, 254 new_address->addr,
586 new_address->addr_len, 255 new_address->addr_len,
587 new_address->active, 256 new_address->active,
588 new_address->atsi, 257 &new_address->properties,
589 new_address->atsi_count,
590 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_out), 258 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_out),
591 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_in)); 259 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_in));
592} 260}
@@ -597,18 +265,14 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
597 * 265 *
598 * @param peer peer 266 * @param peer peer
599 * @param session_id session id, never 0 267 * @param session_id session id, never 0
600 * @param atsi performance information for this address 268 * @param prop performance information for this address
601 * @param atsi_count number of performance information contained in @a atsi
602 */ 269 */
603void 270void
604GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, 271GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
605 uint32_t session_id, 272 uint32_t session_id,
606 const struct GNUNET_ATS_Information *atsi, 273 const struct GNUNET_ATS_Properties *prop)
607 uint32_t atsi_count)
608{ 274{
609 struct ATS_Address *aa; 275 struct ATS_Address *aa;
610 struct GNUNET_ATS_Information *atsi_delta;
611 uint32_t atsi_delta_count;
612 276
613 /* Get existing address */ 277 /* Get existing address */
614 aa = find_exact_address (peer, 278 aa = find_exact_address (peer,
@@ -630,30 +294,18 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
630 294
631 /* Update address */ 295 /* Update address */
632 aa->t_last_activity = GNUNET_TIME_absolute_get(); 296 aa->t_last_activity = GNUNET_TIME_absolute_get();
633 atsi_delta = NULL; 297 aa->properties = *prop;
634 atsi_delta_count = 0; 298 /* Notify performance clients about updated address */
635 if (GNUNET_YES == 299 GAS_performance_notify_all_clients (&aa->peer,
636 disassemble_ats_information (aa, atsi, 300 aa->plugin,
637 atsi_count, 301 aa->addr,
638 &atsi_delta, 302 aa->addr_len,
639 &atsi_delta_count)) 303 aa->active,
640 { 304 prop,
641 /* Notify performance clients about updated address */ 305 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
642 GAS_performance_notify_all_clients (&aa->peer, 306 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
643 aa->plugin, 307
644 aa->addr, 308 GAS_normalization_update_property (aa);
645 aa->addr_len,
646 aa->active,
647 aa->atsi,
648 aa->atsi_count,
649 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
650 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
651
652 GAS_normalization_update_property (aa,
653 atsi,
654 atsi_count);
655 }
656 GNUNET_free_non_null (atsi_delta);
657} 309}
658 310
659 311
@@ -793,7 +445,7 @@ peerinfo_it (void *cls,
793 addr->addr, 445 addr->addr,
794 addr->addr_len, 446 addr->addr_len,
795 addr->active, 447 addr->active,
796 addr->atsi, addr->atsi_count, 448 &addr->properties,
797 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_out), 449 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_out),
798 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_in)); 450 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_in));
799 return GNUNET_OK; 451 return GNUNET_OK;
@@ -839,7 +491,7 @@ GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
839 pi_it (pi_it_cls, 491 pi_it (pi_it_cls,
840 NULL, NULL, NULL, 0, 492 NULL, NULL, NULL, 0,
841 GNUNET_NO, 493 GNUNET_NO,
842 NULL, 0, 494 NULL,
843 GNUNET_BANDWIDTH_ZERO, 495 GNUNET_BANDWIDTH_ZERO,
844 GNUNET_BANDWIDTH_ZERO); 496 GNUNET_BANDWIDTH_ZERO);
845} 497}
@@ -879,8 +531,7 @@ struct AddressIteration
879 * @param plugin_addr address 531 * @param plugin_addr address
880 * @param plugin_addr_len length of @a plugin_addr 532 * @param plugin_addr_len length of @a plugin_addr
881 * @param active #GNUNET_YES if this address is actively used 533 * @param active #GNUNET_YES if this address is actively used
882 * @param atsi ats performance information 534 * @param prop performance information
883 * @param atsi_count number of ats performance elements in @a atsi
884 * @param bandwidth_out current outbound bandwidth assigned to address 535 * @param bandwidth_out current outbound bandwidth assigned to address
885 * @param bandwidth_in current inbound bandwidth assigned to address 536 * @param bandwidth_in current inbound bandwidth assigned to address
886 */ 537 */
@@ -891,13 +542,11 @@ transmit_req_addr (struct AddressIteration *ai,
891 const void *plugin_addr, 542 const void *plugin_addr,
892 size_t plugin_addr_len, 543 size_t plugin_addr_len,
893 int active, 544 int active,
894 const struct GNUNET_ATS_Information *atsi, 545 const struct GNUNET_ATS_Properties *prop,
895 uint32_t atsi_count,
896 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 546 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
897 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 547 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
898 548
899{ 549{
900 struct GNUNET_ATS_Information *atsp;
901 struct PeerInformationMessage *msg; 550 struct PeerInformationMessage *msg;
902 char *addrp; 551 char *addrp;
903 size_t plugin_name_length; 552 size_t plugin_name_length;
@@ -909,18 +558,13 @@ transmit_req_addr (struct AddressIteration *ai,
909 else 558 else
910 plugin_name_length = 0; 559 plugin_name_length = 0;
911 msize = sizeof (struct PeerInformationMessage) + 560 msize = sizeof (struct PeerInformationMessage) +
912 atsi_count * sizeof (struct GNUNET_ATS_Information) +
913 plugin_addr_len + plugin_name_length; 561 plugin_addr_len + plugin_name_length;
914 char buf[msize] GNUNET_ALIGN; 562 char buf[msize] GNUNET_ALIGN;
915 563
916 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); 564 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
917 GNUNET_assert (atsi_count <
918 GNUNET_SERVER_MAX_MESSAGE_SIZE /
919 sizeof (struct GNUNET_ATS_Information));
920 msg = (struct PeerInformationMessage *) buf; 565 msg = (struct PeerInformationMessage *) buf;
921 msg->header.size = htons (msize); 566 msg->header.size = htons (msize);
922 msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE); 567 msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE);
923 msg->ats_count = htonl (atsi_count);
924 msg->id = htonl (ai->id); 568 msg->id = htonl (ai->id);
925 if (NULL != id) 569 if (NULL != id)
926 msg->peer = *id; 570 msg->peer = *id;
@@ -931,9 +575,9 @@ transmit_req_addr (struct AddressIteration *ai,
931 msg->plugin_name_length = htons (plugin_name_length); 575 msg->plugin_name_length = htons (plugin_name_length);
932 msg->bandwidth_out = bandwidth_out; 576 msg->bandwidth_out = bandwidth_out;
933 msg->bandwidth_in = bandwidth_in; 577 msg->bandwidth_in = bandwidth_in;
934 atsp = (struct GNUNET_ATS_Information *) &msg[1]; 578 GNUNET_ATS_properties_hton (&msg->properties,
935 memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count); 579 prop);
936 addrp = (char *) &atsp[atsi_count]; 580 addrp = (char *) &msg[1];
937 if (NULL != plugin_addr) 581 if (NULL != plugin_addr)
938 memcpy (addrp, plugin_addr, plugin_addr_len); 582 memcpy (addrp, plugin_addr, plugin_addr_len);
939 if (NULL != plugin_name) 583 if (NULL != plugin_name)
@@ -962,8 +606,7 @@ transmit_req_addr (struct AddressIteration *ai,
962 * @param plugin_addr address 606 * @param plugin_addr address
963 * @param plugin_addr_len length of @a plugin_addr 607 * @param plugin_addr_len length of @a plugin_addr
964 * @param active is address actively used 608 * @param active is address actively used
965 * @param atsi ats performance information 609 * @param prop performance information
966 * @param atsi_count number of ats performance elements in @a atsi
967 * @param bandwidth_out current outbound bandwidth assigned to address 610 * @param bandwidth_out current outbound bandwidth assigned to address
968 * @param bandwidth_in current inbound bandwidth assigned to address 611 * @param bandwidth_in current inbound bandwidth assigned to address
969 */ 612 */
@@ -974,8 +617,7 @@ req_addr_peerinfo_it (void *cls,
974 const void *plugin_addr, 617 const void *plugin_addr,
975 size_t plugin_addr_len, 618 size_t plugin_addr_len,
976 int active, 619 int active,
977 const struct GNUNET_ATS_Information *atsi, 620 const struct GNUNET_ATS_Properties *prop,
978 uint32_t atsi_count,
979 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 621 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
980 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 622 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
981{ 623{
@@ -1006,8 +648,7 @@ req_addr_peerinfo_it (void *cls,
1006 plugin_name, 648 plugin_name,
1007 plugin_addr, plugin_addr_len, 649 plugin_addr, plugin_addr_len,
1008 active, 650 active,
1009 atsi, 651 prop,
1010 atsi_count,
1011 bandwidth_out, 652 bandwidth_out,
1012 bandwidth_in); 653 bandwidth_in);
1013} 654}
@@ -1061,7 +702,7 @@ GAS_handle_request_address_list (void *cls,
1061 transmit_req_addr (&ai, 702 transmit_req_addr (&ai,
1062 NULL, NULL, NULL, 703 NULL, NULL, NULL,
1063 0, GNUNET_NO, 704 0, GNUNET_NO,
1064 NULL, 0, 705 NULL,
1065 GNUNET_BANDWIDTH_ZERO, 706 GNUNET_BANDWIDTH_ZERO,
1066 GNUNET_BANDWIDTH_ZERO); 707 GNUNET_BANDWIDTH_ZERO);
1067 GNUNET_SERVER_receive_done (client, 708 GNUNET_SERVER_receive_done (client,