2 This file is part of GNUnet.
3 (C) 2011 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_performance.h"
32 #include "gnunet-service-ats_scheduling.h"
33 #include "gnunet-service-ats_reservations.h"
35 #include "gnunet-service-ats_addresses_mlp.h"
38 #define VERBOSE GNUNET_NO
40 #define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
45 * Assign each peer an equal amount of bandwidth (bw)
47 * bw_per_peer = bw_total / #active addresses
52 * Use MLP solver to assign bandwidth
57 static struct GNUNET_CONTAINER_MultiHashMap *addresses;
60 static struct GAS_MLP_Handle *mlp;
63 static unsigned long long wan_quota_in;
65 static unsigned long long wan_quota_out;
67 static unsigned int active_addr_count;
75 send_bw_notification (struct ATS_Address *aa)
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n",
78 GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__),
79 ntohl (aa->assigned_bw_out.value__));
80 GAS_scheduling_transmit_address_suggestion (&aa->peer, aa->plugin, aa->addr,
81 aa->addr_len, aa->session_id,
82 aa->ats, aa->ats_count,
85 GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in);
86 GAS_performance_notify_clients (&aa->peer, aa->plugin, aa->addr, aa->addr_len,
87 aa->ats, aa->ats_count, aa->assigned_bw_out,
92 * Update a bandwidth assignment for a peer. This trivial method currently
93 * simply assigns the same share to all active connections.
97 * @param value the 'struct ATS_Address'
98 * @return GNUNET_OK (continue to iterate)
101 update_bw_simple_it (void *cls, const struct GNUNET_HashCode * key, void *value)
103 struct ATS_Address *aa = value;
105 if (GNUNET_YES != aa->active)
107 GNUNET_assert (active_addr_count > 0);
111 aa->assigned_bw_in.value__ = htonl (wan_quota_in / active_addr_count);
112 aa->assigned_bw_out.value__ = htonl (wan_quota_out / active_addr_count);
114 send_bw_notification (aa);
121 * Some (significant) input changed, recalculate bandwidth assignment
125 recalculate_assigned_bw ()
127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
128 "Recalculating bandwidth for all active connections\n");
129 GNUNET_STATISTICS_update (GSA_stats, "# bandwidth recalculations performed",
131 GNUNET_STATISTICS_set (GSA_stats, "# active addresses", active_addr_count,
134 GNUNET_CONTAINER_multihashmap_iterate (addresses, &update_bw_simple_it, NULL);
138 * Free the given address
139 * @param addr address to destroy
142 free_address (struct ATS_Address *addr)
144 GNUNET_free_non_null (addr->ats);
145 GNUNET_free (addr->plugin);
150 * Create a ATS_address with the given information
152 * @param plugin_name plugin
153 * @param plugin_addr address
154 * @param plugin_addr_len address length
155 * @param session_id session
156 * @return the ATS_Address
158 static struct ATS_Address *
159 create_address (const struct GNUNET_PeerIdentity *peer,
160 const char *plugin_name,
161 const void *plugin_addr, size_t plugin_addr_len,
164 struct ATS_Address *aa = NULL;
166 aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len);
168 aa->addr_len = plugin_addr_len;
170 memcpy (&aa[1], plugin_addr, plugin_addr_len);
171 aa->plugin = GNUNET_strdup (plugin_name);
172 aa->session_id = session_id;
178 * Destroy the given address.
180 * @param addr address to destroy
181 * @return GNUNET_YES if bandwidth allocations should be recalcualted
184 destroy_address (struct ATS_Address *addr)
189 GNUNET_assert (GNUNET_YES ==
190 GNUNET_CONTAINER_multihashmap_remove (addresses,
191 &addr->peer.hashPubKey,
196 GAS_mlp_address_delete (mlp, addresses, addr);
199 if (GNUNET_YES == addr->active)
202 addr->active = GNUNET_NO;
210 struct CompareAddressContext
212 const struct ATS_Address *search;
214 /* exact_address != NULL if address and session is equal */
215 struct ATS_Address *exact_address;
216 /* exact_address != NULL if address and session is 0 */
217 struct ATS_Address *base_address;
222 compare_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
224 struct CompareAddressContext *cac = cls;
225 struct ATS_Address *aa = value;
227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
228 "Comparing to: %s %s %u session %u\n",
229 GNUNET_i2s (&aa->peer), aa->plugin, aa->addr_len, aa->session_id);
232 /* find an exact matching address: aa->addr == cac->search->addr && aa->session == cac->search->session */
233 if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
235 if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == cac->search->session_id))
237 cac->exact_address = aa;
241 /* find an matching address: aa->addr == cac->search->addr && aa->session == 0 */
242 /* this address can be used to be updated */
243 if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
245 if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == 0))
247 cac->base_address = aa;
251 if (cac->exact_address == NULL)
259 * Find an existing equivalent address record.
260 * Compares by peer identity and network address OR by session ID
261 * (one of the two must match).
263 * @param peer peer to lookup addresses for
264 * @param addr existing address record
265 * @return existing address record, NULL for none
268 find_address (const struct GNUNET_PeerIdentity *peer,
269 const struct ATS_Address *addr)
271 struct CompareAddressContext cac;
273 cac.exact_address = NULL;
274 cac.base_address = NULL;
276 GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
277 &compare_address_it, &cac);
280 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
281 "exact address: %s base address: %s\n",
282 (cac.exact_address != NULL) ? "YES" : "NO",
283 (cac.base_address != NULL) ? "YES" : "NO");
285 if (cac.exact_address == NULL)
286 return cac.base_address;
287 return cac.exact_address;
292 compare_address_session_it (void *cls, const struct GNUNET_HashCode * key, void *value)
294 struct CompareAddressContext *cac = cls;
295 struct ATS_Address *aa = value;
297 if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
299 if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == cac->search->session_id))
301 cac->exact_address = aa;
310 * Find an existing equivalent address record.
311 * Compares by peer identity and network address AND by session ID
312 * (one of the two must match).
314 * @param peer peer to lookup addresses for
315 * @param addr existing address record
316 * @return existing address record, NULL for none
319 find_exact_address (const struct GNUNET_PeerIdentity *peer,
320 const struct ATS_Address *addr)
322 struct CompareAddressContext cac;
324 cac.exact_address = NULL;
326 GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
327 &compare_address_session_it, &cac);
328 return cac.exact_address;
333 GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
334 const char *plugin_name, const void *plugin_addr,
335 size_t plugin_addr_len, uint32_t session_id,
336 const struct GNUNET_ATS_Information *atsi,
339 struct ATS_Address *aa;
340 struct ATS_Address *old;
343 if (GNUNET_NO == running)
346 GNUNET_assert (NULL != addresses);
348 aa = create_address (peer,
350 plugin_addr, plugin_addr_len,
353 aa->mlp_information = NULL;
354 aa->ats = GNUNET_malloc (atsi_count * sizeof (struct GNUNET_ATS_Information));
355 aa->ats_count = atsi_count;
356 memcpy (aa->ats, atsi, atsi_count * sizeof (struct GNUNET_ATS_Information));
358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' %u\n",
362 /* Get existing address or address with session == 0 */
363 old = find_address (peer, aa);
366 GNUNET_assert (GNUNET_OK ==
367 GNUNET_CONTAINER_multihashmap_put (addresses,
368 &peer->hashPubKey, aa,
369 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' %X\n",
372 GNUNET_i2s (peer), aa);
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "Updated existing address for peer `%s' %p old session %u new session %u\n",
381 GNUNET_i2s (peer), old,
382 old->session_id, session_id);
384 GNUNET_free_non_null (old->ats);
385 old->session_id = session_id;
389 old->ats_count = aa->ats_count;
390 GNUNET_free (aa->plugin);
393 for (i = 0; i < atsi_count; i++)
394 switch (ntohl (atsi[i].type))
396 case GNUNET_ATS_UTILIZATION_UP:
397 old->atsp_utilization_out.value__ = atsi[i].value;
399 case GNUNET_ATS_UTILIZATION_DOWN:
400 old->atsp_utilization_in.value__ = atsi[i].value;
402 case GNUNET_ATS_QUALITY_NET_DELAY:
403 old->atsp_latency.rel_value = ntohl (atsi[i].value);
405 case GNUNET_ATS_QUALITY_NET_DISTANCE:
406 old->atsp_distance = ntohl (atsi[i].value);
408 case GNUNET_ATS_COST_WAN:
409 old->atsp_cost_wan = ntohl (atsi[i].value);
411 case GNUNET_ATS_COST_LAN:
412 old->atsp_cost_lan = ntohl (atsi[i].value);
414 case GNUNET_ATS_COST_WLAN:
415 old->atsp_cost_wlan = ntohl (atsi[i].value);
417 case GNUNET_ATS_NETWORK_TYPE:
418 old->atsp_network_type = ntohl (atsi[i].value);
422 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
423 "Received unsupported ATS type %u\n", ntohl (atsi[i].type));
429 GAS_mlp_address_update (mlp, addresses, old);
437 * If session != 0, just the session is deleted, the address itself still exists
438 * If session == 0, remove full address
439 * If session == 0 and addrlen == 0, destroy inbound address
443 * @param value the 'struct ATS_Address'
444 * @return GNUNET_OK (continue to iterate)
447 destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *value)
449 const struct ATS_Address *info = cls;
450 struct ATS_Address *aa = value;
453 memcmp (&aa->peer, &info->peer,
454 sizeof (struct GNUNET_PeerIdentity)));
455 /* session == 0, remove full address */
456 if ((info->session_id == 0) && (0 == strcmp (info->plugin, aa->plugin)) &&
457 (aa->addr_len == info->addr_len) &&
458 (0 == memcmp (info->addr, aa->addr, aa->addr_len)))
461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
462 "Deleting address for peer `%s': `%s' %u\n",
463 GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
465 if (GNUNET_YES == destroy_address (aa))
466 recalculate_assigned_bw ();
469 /* session != 0, just remove session */
470 if (aa->session_id != info->session_id)
471 return GNUNET_OK; /* irrelevant */
472 if (aa->session_id != 0)
473 GNUNET_break (0 == strcmp (info->plugin, aa->plugin));
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
477 "Deleting session for peer `%s': `%s' %u\n",
478 GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
482 if (GNUNET_YES == aa->active)
484 aa->active = GNUNET_NO;
486 recalculate_assigned_bw ();
489 /* session == 0 and addrlen == 0 : destroy address */
490 if (aa->addr_len == 0)
493 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
494 "Deleting session and address for peer `%s': `%s' %u\n",
495 GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
497 (void) destroy_address (aa);
501 /* session was set to 0, update address */
504 GAS_mlp_address_update (mlp, addresses, aa);
512 GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
513 const char *plugin_name, const void *plugin_addr,
514 size_t plugin_addr_len, uint32_t session_id)
516 struct ATS_Address *aa;
518 if (GNUNET_NO == running)
521 GNUNET_break (0 < strlen (plugin_name));
522 aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id);
524 GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
525 &destroy_by_session_id, aa);
532 * Find a "good" address to use for a peer. If we already have an existing
533 * address, we stick to it. Otherwise, we pick by lowest distance and then
536 * @param cls the 'struct ATS_Address**' where we store the result
538 * @param value another 'struct ATS_Address*' to consider using
539 * @return GNUNET_OK (continue to iterate)
542 find_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
544 struct ATS_Address **ap = cls;
545 struct ATS_Address *aa = (struct ATS_Address *) value;
546 struct ATS_Address *ab = *ap;
547 struct GNUNET_TIME_Absolute now;
549 now = GNUNET_TIME_absolute_get();
551 if (aa->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, aa->blocked_until).abs_value)
553 /* This address is blocked for suggestion */
554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
555 "Address %p blocked for suggestion for %llu ms \n",
557 GNUNET_TIME_absolute_get_difference(now, aa->blocked_until).rel_value);
561 aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval, ATS_BLOCKING_DELTA);
562 aa->blocked_until = GNUNET_TIME_absolute_add (now, aa->block_interval);
564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
565 "Address %p ready for suggestion, block interval now %llu \n", aa, aa->block_interval);
567 /* FIXME this is a hack */
572 if ((0 == strcmp (ab->plugin, "tcp")) &&
573 (0 == strcmp (aa->plugin, "tcp")))
575 if ((0 != ab->addr_len) &&
578 /* saved address was an outbound address, but we have an inbound address */
582 if (0 == ab->addr_len)
584 /* saved address was an inbound address, so do not overwrite */
589 /* FIXME end of hack */
596 if ((ntohl (ab->assigned_bw_in.value__) == 0) &&
597 (ntohl (aa->assigned_bw_in.value__) > 0))
599 /* stick to existing connection */
603 if (ab->atsp_distance > aa->atsp_distance)
605 /* user shorter distance */
609 if (ab->atsp_latency.rel_value > aa->atsp_latency.rel_value)
611 /* user lower latency */
621 GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer,
622 const char *plugin_name, const void *plugin_addr,
623 size_t plugin_addr_len, uint32_t session_id, int in_use)
626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
627 "Received `%s' message for peer `%s': %i\n", "ADDRESS_IN_USE",
628 GNUNET_i2s (peer), in_use);
631 struct ATS_Address *aa;
632 struct ATS_Address *old;
634 if (GNUNET_NO == running)
635 return GNUNET_SYSERR;
637 aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id);
638 old = find_exact_address (peer, aa);
644 return GNUNET_SYSERR;
646 if (old->used == in_use)
649 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
650 "Address in use called multiple times for peer `%s': %s -> %s \n",
652 (GNUNET_NO == old->used) ? "NO" : "YES",
653 (GNUNET_NO == in_use) ? "NO" : "YES");
654 return GNUNET_SYSERR;
659 GAS_mlp_address_update (mlp, addresses, old);
665 void request_address_mlp (const struct GNUNET_PeerIdentity *peer)
667 struct ATS_Address *aa;
671 /* Get preferred address from MLP */
672 struct ATS_PreferedAddress * paddr = NULL;
673 paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer);
675 aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(paddr->bandwidth_out);
676 /* FIXME use bw in value */
677 paddr->bandwidth_in = paddr->bandwidth_out;
678 aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init (paddr->bandwidth_in);
684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
685 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
688 if (aa->active == GNUNET_NO)
690 aa->active = GNUNET_YES;
693 send_bw_notification (aa);
697 /* just to be sure... */
698 GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
699 aa->addr_len, aa->session_id,
700 aa->ats, aa->ats_count,
707 void request_address_simple (const struct GNUNET_PeerIdentity *peer)
709 struct ATS_Address *aa;
712 /* Get address with: stick to current address, lower distance, lower latency */
713 GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
714 &find_address_it, &aa);
717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
718 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
723 "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
725 if (aa->active == GNUNET_NO)
727 aa->active = GNUNET_YES;
729 if (ats_mode == SIMPLE)
731 recalculate_assigned_bw ();
736 /* just to be sure... */
737 GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
738 aa->addr_len, aa->session_id,
739 aa->ats, aa->ats_count,
747 GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
749 if (GNUNET_NO == running)
752 if (ats_mode == SIMPLE)
754 request_address_simple (peer);
758 request_address_mlp(peer);
764 reset_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
766 struct ATS_Address *aa = value;
768 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
769 "Resetting interval for peer `%s' address %p from %llu to 0\n", GNUNET_i2s (&aa->peer), aa, aa->block_interval);
771 aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS;
772 aa->block_interval = GNUNET_TIME_UNIT_ZERO;
777 GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer)
779 GNUNET_break (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple (addresses,
787 // FIXME: this function should likely end up in the LP-subsystem and
788 // not with 'addresses' in the future...
790 GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
791 enum GNUNET_ATS_PreferenceKind kind,
794 if (GNUNET_NO == running)
798 GAS_mlp_address_change_preference (mlp, peer, kind, score);
805 * Initialize address subsystem.
807 * @param cfg configuration to use
808 * @param stats the statistics handle to use
811 GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
812 const struct GNUNET_STATISTICS_Handle *stats)
816 char *quota_wan_in_str;
817 char *quota_wan_out_str;
821 addresses = GNUNET_CONTAINER_multihashmap_create (128);
822 GNUNET_assert (NULL != addresses);
824 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", "a_wan_in_str))
826 if (0 == strcmp(quota_wan_in_str, "unlimited") ||
827 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_in_str, &wan_quota_in)))
828 wan_quota_in = (UINT32_MAX) /10;
830 GNUNET_free (quota_wan_in_str);
831 quota_wan_in_str = NULL;
835 wan_quota_in = (UINT32_MAX) /10;
838 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", "a_wan_out_str))
840 if (0 == strcmp(quota_wan_out_str, "unlimited") ||
841 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_out_str, &wan_quota_out)))
842 wan_quota_out = (UINT32_MAX) /10;
844 GNUNET_free (quota_wan_out_str);
845 quota_wan_out_str = NULL;
849 wan_quota_out = (UINT32_MAX) /10;
852 mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP");
853 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP mode %u", mode);
860 /* Init the MLP solver with default values */
861 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
864 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode\n");
865 GNUNET_STATISTICS_update (GSA_stats, "MLP mode enabled", 0, GNUNET_NO);
870 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 1, GNUNET_NO);
874 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode");
875 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
881 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
884 /* No configuration value */
886 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
892 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP");
893 running = GNUNET_YES;
898 * Free memory of address.
901 * @param key peer identity (unused)
902 * @param value the 'struct ATS_Address' to free
903 * @return GNUNET_OK (continue to iterate)
906 free_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
908 struct ATS_Address *aa = value;
910 destroy_address (aa);
916 GAS_addresses_destroy_all ()
918 if (GNUNET_NO == running)
921 if (addresses != NULL)
922 GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL);
923 GNUNET_assert (active_addr_count == 0);
928 * Shutdown address subsystem.
931 GAS_addresses_done ()
933 GAS_addresses_destroy_all ();
935 GNUNET_CONTAINER_multihashmap_destroy (addresses);
947 /* end of gnunet-service-ats_addresses.c */