2 This file is part of GNUnet.
3 (C) 2011-2015 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file ats/gnunet-service-ats_addresses.c
23 * @brief ats service address management
24 * @author Matthias Wachs
25 * @author Christian Grothoff
28 #include "gnunet_ats_service.h"
29 #include "gnunet-service-ats.h"
30 #include "gnunet-service-ats_addresses.h"
31 #include "gnunet-service-ats_normalization.h"
32 #include "gnunet-service-ats_performance.h"
33 #include "gnunet-service-ats_plugins.h"
34 #include "gnunet-service-ats_scheduling.h"
35 #include "gnunet-service-ats_reservations.h"
39 * NOTE: Do not change this documentation. This documentation is based on
40 * gnunet.org:/vcs/fsnsg/2014-p2p-ats.git/tech-doku/ats-tech-guide.tex
41 * use build_txt.sh to generate plaintext output
43 * 1 ATS addresses : ATS address management
45 * This ATS addresses ("addresses") component manages the addresses known to
46 * ATS service and suggests addresses to transport service when it is
47 * interested in address suggestion for a peer. ATS addresses also
48 * instantiates the bandwidth assignment mechanism (solver), notifies it
49 * about changes to addresses and forwards changes to bandwidth assignments
50 * to transport, depending if transport is interested in this change.
56 * Addresses are added by specifying peer ID, plugin, address, address length
57 * and session, if available. ATS information can be specified if available.
61 * ATS specifies a fix set of networks an address can belong to. For each
62 * network an inbound and outbound quota will be specified. The available
63 * networks and addtional helper varaibles are defined in
64 * gnunet_ats_service.h. At the moment 5 networks are defined:
65 * * GNUNET_ATS_NET_UNSPECIFIED
66 * * GNUNET_ATS_NET_LOOPBACK
67 * * GNUNET_ATS_NET_LAN
68 * * GNUNET_ATS_NET_WAN
69 * * GNUNET_ATS_NET_WLAN
71 * The total number of networks defined is stored in
72 * GNUNET_ATS_NetworkTypeCount GNUNET_ATS_NetworkType can be used array
73 * initializer for an int array, while GNUNET_ATS_NetworkType is an
74 * initializer for a char array containing a string description of all
79 * An inbound and outbound quota for each of the networks mentioned in 1.1.2
80 * is loaded from ats configuration during initialization. This quota defines
81 * to total amount of inbound and outbound traffic allowed for a specific
82 * network. The configuration values used are in section ats:
83 * * "NETWORK"_QUOTA_IN = <value>
84 * * "NETWORK"_QUOTA_IN = <value>
86 * You can specify quotas by setting the <value> to a:
87 * * unrestricted: unlimited
88 * * number of bytes: e.g. 10240
89 * * fancy value: e.g. 64 Kib
91 * unlimited is defined as GNUNET_ATS_MaxBandwidthString and equivalent to
92 * the value GNUNET_ATS_MaxBandwidth Important predefined values for quotas
94 * * GNUNET_ATS_DefaultBandwidth: 65536
95 * * GNUNET_ATS_MaxBandwidth: UINT32_MAX
96 * * GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT: 1024
98 * Details of loading quotas and default values will be described on
100 * 1.1.4 Preference values
102 * 1.2 Data structures used
104 * Addresse uses struct ATS_Address for each address. The structs are stored
105 * in a linked list and provides a pointer void *solver_information for the
106 * solver to store address specific information. It provides the int values
107 * active which is set to GNUNET_YES if the address is select for transport
108 * use and used, representing that transport service is actively using this
109 * address. Address information are stored in peer, addr, addr_len, plugin.
113 * During initialization a hashmap to store addresses is created. The quotas
114 * for all networks defined for ATS are loaded from configuration. For each
115 * network first the logic will check if the string
116 * GNUNET_ATS_MaxBandwidthString is configured, if not it will try to convert
117 * the configured value as a fancy size and if this fails it will try to use
118 * it as a value_number. If no configuration value is found it will assign
119 * GNUNET_ATS_DefaultBandwidth. The most important step is to load the
120 * configured solver using configuration "[ats]:MODE". Current solvers are
121 * MODE_PROPORTIONAL, MODE_MLP. Interaction is done using a solver API
126 * * s_init: init the solver with required information
127 * * s_add: add a new address
128 * * s_update: update ATS values or session for an address
129 * * s_get: get prefered address for a peer
130 * * s_del: delete an address
131 * * s_pref: change preference value for a peer
132 * * s_done: shutdown solver
134 * Callbacks: addresses provides a bandwidth_changed_cb callback to the
135 * solver which is called when bandwidth assigned to peer has changed
139 * During shutdown all addresses are freed and the solver told to shutdown
141 * 1.6 Addresses and sessions
143 * Addresses consist of the address itself and a numerical session. When a
144 * new address without a session is added it has no session, so it gets
145 * session 0 assigned. When an address with a session is added and an address
146 * object with session 0 is found, this object is updated with the session
147 * otherwise a new address object with this session assigned is created.
151 * Addresses a1,a2 with session s1, s2 are "exact" if:
152 * (a1 == a2)&&(s1 == s2)
153 * Addresses a1,a2 with session s1, s2 are "equivalent" if:
154 * (a1 == a2)&&((s1 == s2)||(s1 == 0)||(s2 == 0)
156 * 1.7 Address management
158 * Transport service notifies ATS about changes to the addresses known to
161 * 1.7.1 Adding an address
163 * When transport learns a new address it tells ATS and ATS is telling
164 * addresses about it using GAS_address_add. If not known to addresses it
165 * creates a new address object and calls solver's s_add. ATS information are
166 * deserialized and solver is notified about the session and ATS information
169 * 1.7.2 Updating an address
171 * Addresses does an lookup up for the existing address with the given
172 * session. If disassembles included ATS information and notifies the solver
173 * using s_update about the update.
175 * 1.7.3 Deleting an address
177 * Addresses does an lookup for the exact address and session and if removes
178 * this address. If session != 0 the session is set to 0 and the address is
179 * kept. If session == 0, the addresses is removed.
181 * 1.7.4 Requesting an address suggestion
183 * The address client issues a request address message to be notified about
184 * address suggestions for a specific peer. Addresses asks the solver with
185 * s_get. If no address is available, it will not send a response, otherwise
186 * it will respond with the choosen address.
188 * 1.7.5 Address suggestions
190 * Addresses will notify the client automatically on any bandwidth_changed_cb
191 * by the solver if a address suggestion request is pending. If no address is
192 * available it will not respond at all If the client is not interested
193 * anymore, it has to cancel the address suggestion request.
195 * 1.7.6 Address lifecycle
198 * * (updated address)
201 * 1.8 Bandwidth assignment
203 * The addresses are used to perform resource allocation operations. ATS
204 * addresses takes care of instantiating the solver configured and notifies
205 * the respective solver about address changes and receives changes to the
206 * bandwidth assignment from the solver. The current bandwidth assignment is
207 * sent to transport. The specific solvers will be described in the specific
210 * 1.9 Changing peer preferences
212 * The bandwidth assigned to a peer can be influenced by setting a preference
213 * for a peer. The prefernce will be given to to the solver with s_pref which
214 * has to take care of the preference value
222 * A multihashmap to store all addresses
224 struct GNUNET_CONTAINER_MultiPeerMap *GSA_addresses;
228 * Value we pass for zero bandwidth.
230 static const struct GNUNET_BANDWIDTH_Value32NBO zero_bw;
234 * Disassemble ATS information and update performance information in address
236 * Updates existing information and adds new information
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
247 disassemble_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)
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;
265 delta_atsi_count = 0;
267 if (0 == update_count)
270 if (NULL == dest->atsi)
272 /* Create performance information */
274 GNUNET_malloc (update_count * sizeof (struct GNUNET_ATS_Information));
275 dest->atsi_count = update_count;
276 memcpy (dest->atsi, update,
277 update_count * sizeof(struct GNUNET_ATS_Information));
279 GNUNET_malloc (update_count * sizeof (struct GNUNET_ATS_Information));
280 for (c1 = 0; c1 < update_count; c1++)
282 (*delta_dest)[c1].type = update[c1].type;
283 (*delta_dest)[c1].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
285 (*delta_count) = update_count;
289 for (c1 = 0; c1 < update_count; c1++)
291 /* Update existing performance information */
293 for (c2 = 0; c2 < dest->atsi_count; c2++)
295 if (update[c1].type == dest->atsi[c2].type)
297 if (update[c1].value != dest->atsi[c2].value)
299 /* Save previous value in delta */
300 delta_atsi[delta_atsi_count] = dest->atsi[c2];
303 dest->atsi[c2].value = update[c1].value;
310 if (GNUNET_NO == found)
312 add_atsi[add_atsi_count] = update[c1];
314 delta_atsi[delta_atsi_count].type = update[c1].type;
315 delta_atsi[delta_atsi_count].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
320 if (add_atsi_count > 0)
322 /* Extend ats performance information */
324 tmp_atsi = GNUNET_malloc ((dest->atsi_count + add_atsi_count) *
325 (sizeof (struct GNUNET_ATS_Information)));
326 memcpy (tmp_atsi, dest->atsi,
327 dest->atsi_count * sizeof(struct GNUNET_ATS_Information));
328 memcpy (&tmp_atsi[dest->atsi_count], add_atsi,
329 add_atsi_count * sizeof(struct GNUNET_ATS_Information));
330 GNUNET_free(dest->atsi);
331 dest->atsi = tmp_atsi;
332 dest->atsi_count = dest->atsi_count + add_atsi_count;
336 if (delta_atsi_count > 0)
340 GNUNET_malloc (delta_atsi_count * sizeof (struct GNUNET_ATS_Information));
341 memcpy ((*delta_dest), delta_atsi,
342 delta_atsi_count * sizeof(struct GNUNET_ATS_Information));
343 (*delta_count) = delta_atsi_count;
351 * Free the given address
353 * @param addr address to destroy
356 free_address (struct ATS_Address *addr)
358 GNUNET_free (addr->plugin);
359 GNUNET_free_non_null (addr->atsi);
365 * Create a ATS_address with the given information
368 * @param plugin_name plugin
369 * @param plugin_addr address
370 * @param plugin_addr_len address length
371 * @param local_address_info additional local info for the address
372 * @param session_id session identifier, can never be 0
373 * @return the ATS_Address
375 static struct ATS_Address *
376 create_address (const struct GNUNET_PeerIdentity *peer,
377 const char *plugin_name,
378 const void *plugin_addr,
379 size_t plugin_addr_len,
380 uint32_t local_address_info,
383 struct ATS_Address *aa;
387 aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len);
389 aa->addr_len = plugin_addr_len;
391 memcpy (&aa[1], plugin_addr, plugin_addr_len);
392 aa->plugin = GNUNET_strdup (plugin_name);
393 aa->session_id = session_id;
394 aa->local_address_info = local_address_info;
396 for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++)
398 aa->atsin[c1].avg_queue_index = 0;
399 for (c2 = 0; c2 < GAS_normalization_queue_length; c2++)
400 aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED;
407 * Closure for #compare_address_it()
409 struct CompareAddressContext
411 const struct ATS_Address *search;
413 /* exact_address != NULL if address and session is equal */
414 struct ATS_Address *exact_address;
415 /* exact_address != NULL if address and session is 0 */
416 struct ATS_Address *base_address;
423 * @param cls a CompareAddressContext containin the source address
425 * @param value the address to compare with
426 * @return #GNUNET_YES to continue, #GNUNET_NO if address is founce
429 compare_address_it (void *cls,
430 const struct GNUNET_PeerIdentity *key,
433 struct CompareAddressContext *cac = cls;
434 struct ATS_Address *aa = value;
436 /* Find an matching exact address:
439 * aa->addr_len == cac->search->addr_len
440 * aa->plugin == cac->search->plugin
441 * aa->addr == cac->search->addr
442 * aa->session == cac->search->session
444 * return as exact address
446 if ((aa->addr_len == cac->search->addr_len)
447 && (0 == strcmp (aa->plugin, cac->search->plugin)))
449 if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len))
450 && (aa->session_id == cac->search->session_id))
451 cac->exact_address = aa;
454 /* Find an matching base address:
458 * aa->session_id == 0
461 * aa->addr_len == cac->search->addr_len
462 * aa->plugin == cac->search->plugin
463 * aa->addr == cac->search->addr
465 * return as base address
467 if ((aa->addr_len == cac->search->addr_len)
468 && (0 == strcmp (aa->plugin, cac->search->plugin)))
470 if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len))
471 && (aa->session_id == 0))
472 cac->base_address = aa;
475 /* Find an matching exact address based on session:
479 * cac->search->addr_len == 0
482 * aa->plugin == cac->search->plugin
483 * aa->session_id == cac->search->session_id
485 * return as exact address
487 if (0 == cac->search->addr_len)
489 if ((0 == strcmp (aa->plugin, cac->search->plugin))
490 && (aa->session_id == cac->search->session_id))
491 cac->exact_address = aa;
494 if (cac->exact_address == NULL )
495 return GNUNET_YES; /* Continue iteration to find exact address */
497 return GNUNET_NO; /* Stop iteration since we have an exact address */
502 * Find an existing equivalent address record.
503 * Compares by peer identity and network address OR by session ID
504 * (one of the two must match).
506 * @param peer peer to lookup addresses for
507 * @param addr existing address record
508 * @return existing address record, NULL for none
511 find_equivalent_address (const struct GNUNET_PeerIdentity *peer,
512 const struct ATS_Address *addr)
514 struct CompareAddressContext cac;
516 cac.exact_address = NULL;
517 cac.base_address = NULL;
519 GNUNET_CONTAINER_multipeermap_get_multiple (GSA_addresses,
521 &compare_address_it, &cac);
523 if (NULL == cac.exact_address)
524 return cac.base_address;
525 return cac.exact_address;
530 * Closure for #find_address_cb()
532 struct FindAddressContext
535 * Session Id to look for.
540 * Where to store matching address result.
542 struct ATS_Address *exact_address;
548 * Find session matching given session ID.
550 * @param cls a `struct FindAddressContext`
552 * @param value the address to compare with
553 * @return #GNUNET_YES to continue, #GNUNET_NO if address is found
556 find_address_cb (void *cls,
557 const struct GNUNET_PeerIdentity *key,
560 struct FindAddressContext *fac = cls;
561 struct ATS_Address *aa = value;
563 if (aa->session_id == fac->session_id)
565 fac->exact_address = aa;
573 * Find the exact address
576 * @param session_id session id, can never be 0
577 * @return an ATS_address or NULL
579 static struct ATS_Address *
580 find_exact_address (const struct GNUNET_PeerIdentity *peer,
583 struct FindAddressContext fac;
585 fac.exact_address = NULL;
586 fac.session_id = session_id;
587 GNUNET_CONTAINER_multipeermap_get_multiple (GSA_addresses,
589 &find_address_cb, &fac);
590 return fac.exact_address;
595 * Extract an ATS performance info from an address
597 * @param address the address
598 * @param type the type to extract in HBO
599 * @return the value in HBO or #GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist
602 get_performance_info (struct ATS_Address *address, uint32_t type)
605 GNUNET_assert(NULL != address);
607 if ((NULL == address->atsi) || (0 == address->atsi_count))
608 return GNUNET_ATS_VALUE_UNDEFINED;
610 for (c1 = 0; c1 < address->atsi_count; c1++)
612 if (ntohl (address->atsi[c1].type) == type)
613 return ntohl (address->atsi[c1].value);
615 return GNUNET_ATS_VALUE_UNDEFINED;
620 * Add a new address for a peer.
623 * @param plugin_name transport plugin name
624 * @param plugin_addr plugin address
625 * @param plugin_addr_len length of the plugin address in @a plugin_addr
626 * @param local_address_info the local address for the address
627 * @param session_id session id, can be 0
628 * @param atsi performance information for this address
629 * @param atsi_count number of performance information contained in @a atsi
632 GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
633 const char *plugin_name,
634 const void *plugin_addr,
635 size_t plugin_addr_len,
636 uint32_t local_address_info,
638 const struct GNUNET_ATS_Information *atsi,
641 struct ATS_Address *new_address;
642 struct ATS_Address *existing_address;
643 struct GNUNET_ATS_Information *atsi_delta;
644 uint32_t atsi_delta_count;
647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
648 "Received `%s' for peer `%s'\n",
651 new_address = create_address (peer,
658 disassemble_ats_information (new_address,
662 GNUNET_free_non_null (atsi_delta);
663 addr_net = get_performance_info (new_address, GNUNET_ATS_NETWORK_TYPE);
664 if (GNUNET_ATS_VALUE_UNDEFINED == addr_net)
665 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
667 /* Get existing address or address with session == 0 */
668 existing_address = find_equivalent_address (peer, new_address);
669 if (NULL != existing_address)
672 GNUNET_free(new_address->plugin);
673 GNUNET_free_non_null(new_address->atsi);
674 GNUNET_free(new_address);
677 /* Add a new address */
678 new_address->t_added = GNUNET_TIME_absolute_get();
679 new_address->t_last_activity = GNUNET_TIME_absolute_get();
680 GNUNET_assert(GNUNET_OK ==
681 GNUNET_CONTAINER_multipeermap_put (GSA_addresses,
684 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
686 GNUNET_STATISTICS_set (GSA_stats,
688 GNUNET_CONTAINER_multipeermap_size (GSA_addresses),
691 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
692 "Adding new address %p for peer `%s', length %u, session id %u, %s\n",
697 GNUNET_ATS_print_network_type (addr_net));
699 /* Tell solver about new address */
700 GAS_plugin_new_address (new_address,
704 /* Notify performance clients about new address */
705 GAS_performance_notify_all_clients (&new_address->peer,
708 new_address->addr_len,
711 new_address->atsi_count,
712 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_out),
713 GNUNET_BANDWIDTH_value_init (new_address->assigned_bw_in));
718 * Update an address with new performance information for a peer.
721 * @param session_id session id, never 0
722 * @param atsi performance information for this address
723 * @param atsi_count number of performance information contained in @a atsi
726 GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
728 const struct GNUNET_ATS_Information *atsi,
731 struct ATS_Address *aa;
732 struct GNUNET_ATS_Information *atsi_delta;
733 uint32_t atsi_delta_count;
735 /* Get existing address */
736 aa = find_exact_address (peer,
743 if (NULL == aa->solver_information)
748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
749 "Received `%s' for peer `%s' address \n",
755 aa->t_last_activity = GNUNET_TIME_absolute_get();
757 atsi_delta_count = 0;
759 disassemble_ats_information (aa, atsi,
764 /* Notify performance clients about updated address */
765 GAS_performance_notify_all_clients (&aa->peer,
772 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
773 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
775 GAS_plugin_update_address (aa,
779 GNUNET_free_non_null (atsi_delta);
784 * Remove an address or just a session for a peer.
787 * @param session_id session id, can never be 0
790 GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
793 struct ATS_Address *ea;
795 /* Get existing address */
796 ea = find_exact_address (peer,
801 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
802 "Tried to destroy unknown address for peer `%s' session id %u\n",
808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
809 "Received `%s' for peer `%s' address %p session %u\n",
814 GNUNET_CONTAINER_multipeermap_remove (GSA_addresses,
817 GAS_plugin_delete_address (ea);
818 GAS_performance_notify_all_clients (peer,
827 GNUNET_STATISTICS_set (GSA_stats,
829 GNUNET_CONTAINER_multipeermap_size (GSA_addresses),
838 * Initialize address subsystem. The addresses subsystem manages the addresses
839 * known and current performance information. It has a solver component
840 * responsible for the resource allocation. It tells the solver about changes
841 * and receives updates when the solver changes the resource allocation.
844 GAS_addresses_init ()
846 /* Initialize the addresses database */
847 GSA_addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
848 GNUNET_STATISTICS_set (GSA_stats,
850 GNUNET_CONTAINER_multipeermap_size (GSA_addresses),
856 * Destroy all addresses iterator
859 * @param key peer identity (unused)
860 * @param value the 'struct ATS_Address' to free
861 * @return #GNUNET_OK (continue to iterate)
864 destroy_all_address_it (void *cls,
865 const struct GNUNET_PeerIdentity *key,
868 struct ATS_Address *aa = value;
871 GNUNET_assert (GNUNET_YES ==
872 GNUNET_CONTAINER_multipeermap_remove (GSA_addresses,
876 GAS_plugin_delete_address (aa);
878 GAS_performance_notify_all_clients (&aa->peer,
892 * Remove all addresses
895 GAS_addresses_destroy_all ()
897 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
898 "Destroying all addresses\n");
899 GAS_plugin_solver_lock ();
900 if (NULL != GSA_addresses)
901 GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
902 &destroy_all_address_it,
904 GAS_plugin_solver_unlock ();
909 * Shutdown address subsystem.
912 GAS_addresses_done ()
914 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
915 "Shutting down addresses\n");
916 GAS_addresses_destroy_all ();
917 GNUNET_CONTAINER_multipeermap_destroy (GSA_addresses);
918 GSA_addresses = NULL;
923 * Closure for #peerinfo_it().
925 struct PeerInfoIteratorContext
928 * Function to call for each address.
930 GNUNET_ATS_PeerInfo_Iterator it;
940 * Iterator to iterate over a peer's addresses
942 * @param cls a `struct PeerInfoIteratorContext`
943 * @param key the peer id
944 * @param value the `struct ATS_address`
945 * @return #GNUNET_OK to continue
948 peerinfo_it (void *cls,
949 const struct GNUNET_PeerIdentity *key,
952 struct PeerInfoIteratorContext *pi_ctx = cls;
953 struct ATS_Address *addr = value;
955 pi_ctx->it (pi_ctx->it_cls,
961 addr->atsi, addr->atsi_count,
962 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_out),
963 GNUNET_BANDWIDTH_value_init (addr->assigned_bw_in));
969 * Return information all peers currently known to ATS
971 * @param peer the respective peer, NULL for 'all' peers
972 * @param pi_it the iterator to call for every peer
973 * @param pi_it_cls the closure for @a pi_it
976 GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
977 GNUNET_ATS_PeerInfo_Iterator pi_it,
980 struct PeerInfoIteratorContext pi_ctx;
984 /* does not make sense without callback */
988 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
989 "Returning information for %s from a total of %u known addresses\n",
993 (unsigned int) GNUNET_CONTAINER_multipeermap_size (GSA_addresses));
995 pi_ctx.it_cls = pi_it_cls;
997 GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
1001 GNUNET_CONTAINER_multipeermap_get_multiple (GSA_addresses,
1003 &peerinfo_it, &pi_ctx);
1005 NULL, NULL, NULL, 0,
1012 /* end of gnunet-service-ats_addresses.c */