changes
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses.c
1 /*
2      This file is part of GNUnet.
3      (C) 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 /**
22  * @file ats/gnunet-service-ats_addresses.c
23  * @brief ats service address management
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #include "platform.h"
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"
34 #if HAVE_LIBGLPK
35 #include "gnunet-service-ats_addresses_mlp.h"
36 #endif
37 #include "gnunet-service-ats_addresses_simplistic.h"
38
39 /**
40  * ATS address management
41  *
42  * Adding addresses:
43  *
44  * - If you add a new address without a session, a new address will be added
45  * - If you add this address again now with a session a, the existing address
46  *   will be updated with this session
47  * - If you add this address again now with a session b, a new address object
48  *   with this session will be added
49
50  * Destroying addresses:
51  *
52  * - If you destroy an address without a session, the address itself and all
53  *   address instances with an session will be removed
54  * - If you destroy an address with a session, the session for this address
55  *   will be removed
56  *
57  * Conclusion
58  * Addresses without a session will be updated with a new session and if the
59  * the session is destroyed the session is removed and address itself still
60  * exists for suggestion
61  *
62  */
63
64
65 /**
66  * Available ressource assignment modes
67  */
68 enum ATS_Mode
69 {
70   /*
71    * Simplistic mode:
72    *
73    * Assign each peer an equal amount of bandwidth (bw)
74    *
75    * bw_per_peer = bw_total / #active addresses
76    */
77   MODE_SIMPLISTIC,
78
79   /*
80    * MLP mode:
81    *
82    * Solve ressource assignment as an optimization problem
83    * Uses an mixed integer programming solver
84    */
85   MODE_MLP
86 };
87
88 /**
89  * Pending Address suggestion requests
90  */
91 struct GAS_Addresses_Suggestion_Requests
92 {
93   /**
94    * Next in DLL
95    */
96   struct GAS_Addresses_Suggestion_Requests *next;
97
98   /**
99    * Previous in DLL
100    */
101   struct GAS_Addresses_Suggestion_Requests *prev;
102
103   /**
104    * Peer ID
105    */
106   struct GNUNET_PeerIdentity id;
107 };
108
109 /**
110  * Handle for ATS address component
111  */
112 struct GAS_Addresses_Handle
113 {
114   /**
115    *
116    */
117   struct GNUNET_STATISTICS_Handle *stat;
118
119   /**
120    * A multihashmap to store all addresses
121    */
122   struct GNUNET_CONTAINER_MultiHashMap *addresses;
123
124   /**
125    * Configure WAN quota in
126    */
127   unsigned long long wan_quota_in;
128
129   /**
130    * Configure WAN quota out
131    */
132   unsigned long long wan_quota_out;
133
134   /**
135    * Is ATS addresses running
136    */
137   int running;
138
139   /**
140    * Configured ATS solver
141    */
142   int ats_mode;
143
144   /**
145    *  Solver handle
146    */
147   void *solver;
148
149   /**
150    * Address suggestion requests DLL head
151    */
152   struct GAS_Addresses_Suggestion_Requests *r_head;
153
154   /**
155    * Address suggestion requests DLL tail
156    */
157   struct GAS_Addresses_Suggestion_Requests *r_tail;
158
159   /* Solver functions */
160
161   /**
162    * Initialize solver
163    */
164   GAS_solver_init s_init;
165
166   /**
167    * Add an address to the solver
168    */
169   GAS_solver_address_add s_add;
170
171   /**
172    * Update address in solver
173    */
174   GAS_solver_address_update s_update;
175
176   /**
177    * Get address from solver
178    */
179   GAS_solver_get_preferred_address s_get;
180
181   /**
182    * Delete address in solver
183    */
184   GAS_solver_address_delete s_del;
185
186   /**
187    * Change preference for quality in solver
188    */
189   GAS_solver_address_change_preference s_pref;
190
191   /**
192    * Shutdown solver
193    */
194   GAS_solver_done s_done;
195 };
196
197
198 static unsigned int
199 assemble_ats_information (const struct ATS_Address *aa,  struct GNUNET_ATS_Information **dest)
200 {
201   unsigned int ats_count = GNUNET_ATS_PropertyCount - 1;
202   struct GNUNET_ATS_Information *ats = GNUNET_malloc (ats_count * sizeof (struct GNUNET_ATS_Information));
203   (*dest) = ats;
204
205   ats[0].type = ntohl(GNUNET_ATS_UTILIZATION_UP);
206   ats[0].value = aa->atsp_utilization_out.value__;
207   ats[1].type = ntohl(GNUNET_ATS_UTILIZATION_DOWN);
208   ats[1].value = aa->atsp_utilization_in.value__;
209   ats[2].type = ntohl(GNUNET_ATS_NETWORK_TYPE);
210   ats[2].value = ntohl(aa->atsp_network_type);
211   ats[3].type = ntohl(GNUNET_ATS_QUALITY_NET_DELAY);
212   ats[3].value = ntohl(aa->atsp_latency.rel_value);
213   ats[4].type = ntohl(GNUNET_ATS_QUALITY_NET_DISTANCE);
214   ats[4].value = ntohl(aa->atsp_distance);
215   ats[5].type = ntohl(GNUNET_ATS_COST_WAN);
216   ats[5].value = ntohl (aa->atsp_cost_wan);
217   ats[6].type = ntohl(GNUNET_ATS_COST_LAN);
218   ats[6].value = ntohl (aa->atsp_cost_lan);
219   ats[7].type = ntohl(GNUNET_ATS_COST_WLAN);
220   ats[7].value = ntohl (aa->atsp_cost_wlan);
221   return ats_count;
222 }
223
224 static unsigned int
225 disassemble_ats_information (const struct GNUNET_ATS_Information *src,
226                              uint32_t ats_count,
227                              struct ATS_Address *dest)
228 {
229   int i;
230   int res = 0;
231   for (i = 0; i < ats_count; i++)
232     switch (ntohl (src[i].type))
233     {
234     case GNUNET_ATS_UTILIZATION_UP:
235       dest->atsp_utilization_out.value__ = src[i].value;
236       res ++;
237       break;
238     case GNUNET_ATS_UTILIZATION_DOWN:
239       dest->atsp_utilization_in.value__ = src[i].value;
240       res ++;
241       break;
242     case GNUNET_ATS_QUALITY_NET_DELAY:
243       dest->atsp_latency.rel_value = ntohl (src[i].value);
244       res ++;
245       break;
246     case GNUNET_ATS_QUALITY_NET_DISTANCE:
247       dest->atsp_distance = ntohl (src[i].value);
248       res ++;
249       break;
250     case GNUNET_ATS_COST_WAN:
251       dest->atsp_cost_wan = ntohl (src[i].value);
252       res ++;
253       break;
254     case GNUNET_ATS_COST_LAN:
255       dest->atsp_cost_lan = ntohl (src[i].value);
256       res ++;
257       break;
258     case GNUNET_ATS_COST_WLAN:
259       dest->atsp_cost_wlan = ntohl (src[i].value);
260       res ++;
261       break;
262     case GNUNET_ATS_NETWORK_TYPE:
263       dest->atsp_network_type = ntohl (src[i].value);
264       res ++;
265       break;
266     case GNUNET_ATS_ARRAY_TERMINATOR:
267       break;
268     default:
269       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
270                   "Received unsupported ATS type %u\n", ntohl (src[i].type));
271       GNUNET_break (0);
272       break;
273     }
274   return res;
275 }
276
277 /**
278  * Free the given address
279  * @param addr address to destroy
280  */
281 static void
282 free_address (struct ATS_Address *addr)
283 {
284   GNUNET_free (addr->plugin);
285   GNUNET_free (addr);
286 }
287
288 /**
289  * Create a ATS_address with the given information
290  * @param peer peer
291  * @param plugin_name plugin
292  * @param plugin_addr address
293  * @param plugin_addr_len address length
294  * @param session_id session
295  * @return the ATS_Address
296  */
297 static struct ATS_Address *
298 create_address (const struct GNUNET_PeerIdentity *peer,
299                 const char *plugin_name,
300                 const void *plugin_addr, size_t plugin_addr_len,
301                 uint32_t session_id)
302 {
303   struct ATS_Address *aa = NULL;
304
305   aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len);
306   aa->peer = *peer;
307   aa->addr_len = plugin_addr_len;
308   aa->addr = &aa[1];
309   memcpy (&aa[1], plugin_addr, plugin_addr_len);
310   aa->plugin = GNUNET_strdup (plugin_name);
311   aa->session_id = session_id;
312   aa->active = GNUNET_NO;
313   aa->solver_information = NULL;
314   aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init(0);
315   aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(0);
316   return aa;
317 }
318
319
320 /**
321  * Destroy the given address.
322  *
323  * @param addr address to destroy
324  * @return GNUNET_YES if bandwidth allocations should be recalcualted
325  */
326 static int
327 destroy_address (struct GAS_Addresses_Handle *handle, struct ATS_Address *addr)
328 {
329   int ret;
330
331   ret = GNUNET_NO;
332   GNUNET_assert (GNUNET_YES ==
333                  GNUNET_CONTAINER_multihashmap_remove (handle->addresses,
334                                                        &addr->peer.hashPubKey,
335                                                        addr));
336   free_address (addr);
337   return ret;
338 }
339
340
341 struct CompareAddressContext
342 {
343   const struct ATS_Address *search;
344
345   /* exact_address != NULL if address and session is equal */
346   struct ATS_Address *exact_address;
347   /* exact_address != NULL if address and session is 0 */
348   struct ATS_Address *base_address;
349 };
350
351
352 static int
353 compare_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
354 {
355   struct CompareAddressContext *cac = cls;
356   struct ATS_Address *aa = value;
357
358   /* Find an matching exact address:
359    *
360    * Compare by:
361    * aa->addr_len == cac->search->addr_len
362    * aa->plugin == cac->search->plugin
363    * aa->addr == cac->search->addr
364    * aa->session == cac->search->session
365    *
366    * return as exact address
367    */
368   if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
369   {
370       if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == cac->search->session_id))
371         cac->exact_address = aa;
372   }
373
374   /* Find an matching base address:
375    *
376    * Properties:
377    *
378    * aa->session_id == 0
379    *
380    * Compare by:
381    * aa->addr_len == cac->search->addr_len
382    * aa->plugin == cac->search->plugin
383    * aa->addr == cac->search->addr
384    *
385    * return as base address
386    */
387   if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
388   {
389       if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == 0))
390         cac->base_address = aa;
391   }
392
393   /* Find an matching exact address based on session:
394    *
395    * Properties:
396    *
397    * cac->search->addr_len == 0
398    *
399    * Compare by:
400    * aa->plugin == cac->search->plugin
401    * aa->session_id == cac->search->session_id
402    *
403    * return as exact address
404    */
405   if (0 == cac->search->addr_len)
406   {
407       if ((0 == strcmp (aa->plugin, cac->search->plugin)) && (aa->session_id == cac->search->session_id))
408         cac->exact_address = aa;
409   }
410
411   if (cac->exact_address == NULL)
412     return GNUNET_YES; /* Continue iteration to find exact address */
413   else
414     return GNUNET_NO; /* Stop iteration since we have an exact address */
415 }
416
417
418 /**
419  * Find an existing equivalent address record.
420  * Compares by peer identity and network address OR by session ID
421  * (one of the two must match).
422  *
423  * @param peer peer to lookup addresses for
424  * @param addr existing address record
425  * @return existing address record, NULL for none
426  */
427 struct ATS_Address *
428 find_equivalent_address (struct GAS_Addresses_Handle *handle,
429                          const struct GNUNET_PeerIdentity *peer,
430                          const struct ATS_Address *addr)
431 {
432   struct CompareAddressContext cac;
433
434   cac.exact_address = NULL;
435   cac.base_address = NULL;
436   cac.search = addr;
437   GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey,
438                                               &compare_address_it, &cac);
439
440   if (cac.exact_address == NULL)
441     return cac.base_address;
442   return cac.exact_address;
443 }
444
445
446 static struct ATS_Address *
447 lookup_address (struct GAS_Addresses_Handle *handle,
448                 const struct GNUNET_PeerIdentity *peer,
449                 const char *plugin_name,
450                 const void *plugin_addr,
451                 size_t plugin_addr_len,
452                 uint32_t session_id,
453                 const struct GNUNET_ATS_Information *atsi,
454                 uint32_t atsi_count)
455 {
456   struct ATS_Address *aa;
457   struct ATS_Address *ea;
458
459   aa = create_address (peer,
460                        plugin_name,
461                        plugin_addr, plugin_addr_len,
462                        session_id);
463
464   /* Get existing address or address with session == 0 */
465   ea = find_equivalent_address (handle, peer, aa);
466   free_address (aa);
467   if (ea == NULL)
468   {
469     return NULL;
470   }
471   else if (ea->session_id != session_id)
472   {
473     return NULL;
474   }
475   return ea;
476 }
477
478
479 void
480 GAS_addresses_add (struct GAS_Addresses_Handle *handle,
481                    const struct GNUNET_PeerIdentity *peer,
482                    const char *plugin_name, const void *plugin_addr,
483                    size_t plugin_addr_len, uint32_t session_id,
484                    const struct GNUNET_ATS_Information *atsi,
485                    uint32_t atsi_count)
486 {
487   struct ATS_Address *aa;
488   struct ATS_Address *ea;
489   unsigned int ats_res;
490
491   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
492               "Received `%s' for peer `%s'\n",
493               "ADDRESS ADD",
494               GNUNET_i2s (peer));
495
496   if (GNUNET_NO == handle->running)
497     return;
498
499   GNUNET_assert (NULL != handle->addresses);
500
501   aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
502                        session_id);
503   if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count, aa)))
504   {
505       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
506                 "While adding address: had %u ATS elements to add, could only add %u\n",
507                 atsi_count, ats_res);
508   }
509
510   /* Get existing address or address with session == 0 */
511   ea = find_equivalent_address (handle, peer, aa);
512   if (ea == NULL)
513   {
514     /* We have a new address */
515     GNUNET_assert (GNUNET_OK ==
516                    GNUNET_CONTAINER_multihashmap_put (handle->addresses,
517                                                       &peer->hashPubKey, aa,
518                                                       GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
519     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' session id %u, %p\n",
520                 GNUNET_i2s (peer), session_id, aa);
521     /* Tell solver about new address */
522     handle->s_add (handle->solver, handle->addresses, aa);
523
524
525
526     return;
527   }
528   GNUNET_free (aa->plugin);
529   GNUNET_free (aa);
530
531   if (ea->session_id != 0)
532   {
533       /* This addresswith the same session is already existing */
534       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
535                 "Added already existing address for peer `%s' `%s' %p with new session %u\n",
536                 GNUNET_i2s (peer), plugin_name, session_id);
537       GNUNET_break (0);
538       return;
539   }
540
541   /* We have an address without an session, update this address */
542   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
543             "Updated existing address for peer `%s' %p with new session %u\n",
544             GNUNET_i2s (peer), ea, session_id);
545   ea->session_id = session_id;
546   if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count, ea)))
547   {
548       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549                 "While updating address: had %u ATS elements to add, could only add %u\n",
550                 atsi_count, ats_res);
551   }
552
553   handle->s_update (handle->solver, handle->addresses, ea);
554 }
555
556
557 void
558 GAS_addresses_update (struct GAS_Addresses_Handle *handle,
559                       const struct GNUNET_PeerIdentity *peer,
560                       const char *plugin_name, const void *plugin_addr,
561                       size_t plugin_addr_len, uint32_t session_id,
562                       const struct GNUNET_ATS_Information *atsi,
563                       uint32_t atsi_count)
564 {
565   struct ATS_Address *aa;
566   uint32_t ats_res;
567
568   if (GNUNET_NO == handle->running)
569     return;
570
571   GNUNET_assert (NULL != handle->addresses);
572
573   /* Get existing address */
574   aa = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
575                        session_id, atsi, atsi_count);
576   if (aa == NULL)
577   {
578     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Tried to update unknown address for peer `%s' `%s' session id %u\n",
579                 GNUNET_i2s (peer), plugin_name, session_id);
580     GNUNET_break (0);
581     return;
582   }
583
584   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
585                 "Received `%s' for peer `%s' address \n",
586                 "ADDRESS UPDATE",
587                 GNUNET_i2s (peer), aa);
588
589   if (atsi_count != (ats_res = disassemble_ats_information (atsi, atsi_count, aa)))
590   {
591       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592                 "While adding address: had %u ATS elements to add, could only add %u\n",
593                 atsi_count, ats_res);
594   }
595   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
596             "Updated %u ATS elements for address %p\n",
597             ats_res, aa);
598
599   /* Tell solver about update */
600   handle->s_update (handle->solver, handle->addresses, aa);
601 }
602
603
604 struct DestroyContext
605 {
606   struct ATS_Address *aa;
607
608   struct GAS_Addresses_Handle *handle;
609
610   /**
611    * GNUNET_NO  : full address
612    * GNUNET_YES : just session
613    */
614   int result;
615 };
616
617
618 /**
619  * Delete an address
620  *
621  * If session != 0, just the session is deleted, the address itself still exists
622  * If session == 0, remove full address
623  * If session == 0 and addrlen == 0, destroy inbound address
624  *
625  * @param cls unused
626  * @param key unused
627  * @param value the 'struct ATS_Address'
628  * @return GNUNET_OK (continue to iterate)
629  */
630 static int
631 destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, void *value)
632 {
633   struct DestroyContext *dc = cls;
634   struct GAS_Addresses_Handle *handle = dc->handle;
635   const struct ATS_Address *des = dc->aa;
636   struct ATS_Address *aa = value;
637
638   GNUNET_assert (0 == memcmp (&aa->peer, &des->peer,
639                               sizeof (struct GNUNET_PeerIdentity)));
640
641
642   if (des->session_id == 0)
643   {
644     /* Session == 0, remove full address  */
645     if ((0 == strcmp (des->plugin, aa->plugin)) &&
646         (aa->addr_len == des->addr_len) &&
647         (0 == memcmp (des->addr, aa->addr, aa->addr_len)))
648     {
649
650       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
651                   "Deleting full address for peer `%s' session %u %p\n",
652                   GNUNET_i2s (&aa->peer), aa->session_id, aa);
653
654       /* Notify solver about deletion */
655       handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
656       destroy_address (handle, aa);
657       dc->result = GNUNET_NO;
658       return GNUNET_OK; /* Continue iteration */
659     }
660   }
661   else
662   {
663     /* Session != 0, just remove session */
664     if (aa->session_id != des->session_id)
665       return GNUNET_OK; /* irrelevant */
666
667     if ((aa->session_id != 0) &&
668         (0 != strcmp (des->plugin, aa->plugin)))
669     {
670         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
671                     "Different plugins during removal: `%s' vs `%s' \n",
672                     des->plugin, aa->plugin);
673         GNUNET_break (0);
674         return GNUNET_OK;
675     }
676
677     if (aa->addr_len == 0)
678     {
679         /* Inbound connection died, delete full address */
680         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
681                     "Deleting inbound address for peer `%s': `%s' session %u\n",
682                     GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
683
684         /* Notify solver about deletion */
685         handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
686         destroy_address (handle, aa);
687         dc->result = GNUNET_NO;
688         return GNUNET_OK; /* Continue iteration */
689     }
690     else
691     {
692         /* Session died */
693         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
694                     "Deleting session for peer `%s': `%s' %u\n",
695                     GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
696         /* Notify solver to delete session */
697         handle->s_del (handle->solver, handle->addresses, aa, GNUNET_YES);
698         aa->session_id = 0;
699         return GNUNET_OK;
700     }
701   }
702   return GNUNET_OK;
703 }
704
705 void
706 GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
707                        const struct GNUNET_PeerIdentity *peer,
708                        const char *plugin_name, const void *plugin_addr,
709                        size_t plugin_addr_len, uint32_t session_id)
710 {
711   struct ATS_Address *ea;
712   struct DestroyContext dc;
713
714   if (GNUNET_NO == handle->running)
715     return;
716
717   /* Get existing address */
718   ea = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
719                        session_id, NULL, 0);
720
721   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
722               "Received `%s' for peer `%s' address %p session %u\n",
723               "ADDRESS DESTROY",
724               GNUNET_i2s (peer), ea, session_id);
725
726   if (ea == NULL)
727   {
728     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tried to destroy unknown address for peer `%s' `%s' session id %u\n",
729                 GNUNET_i2s (peer), plugin_name, session_id);
730     return;
731   }
732
733   GNUNET_break (0 < strlen (plugin_name));
734   dc.handle = handle;
735   dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id);
736
737   GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey,
738                                               &destroy_by_session_id, &dc);
739   free_address (dc.aa);
740 }
741
742
743 int
744 GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
745                       const struct GNUNET_PeerIdentity *peer,
746                       const char *plugin_name, const void *plugin_addr,
747                       size_t plugin_addr_len, uint32_t session_id, int in_use)
748 {
749   struct ATS_Address *ea;
750
751   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752                 "Received `%s' for peer `%s'\n",
753                 "ADDRESS IN USE",
754                 GNUNET_i2s (peer));
755
756   if (GNUNET_NO == handle->running)
757     return GNUNET_SYSERR;
758
759   ea = lookup_address (handle, peer, plugin_name,
760                         plugin_addr, plugin_addr_len,
761                         session_id, NULL, 0);
762   if (NULL == ea)
763   {
764     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
765                 "Trying to set unknown address `%s', %s %u %s \n",
766                 GNUNET_i2s (peer),
767                 plugin_name, session_id,
768                 (GNUNET_NO == in_use) ? "NO" : "YES");
769     GNUNET_break (0);
770     return GNUNET_SYSERR;
771   }
772   if (ea->used == in_use)
773   {
774     GNUNET_break (0);
775     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
776                 "Address in use called multiple times for peer `%s': %s -> %s \n",
777                 GNUNET_i2s (peer),
778                 (GNUNET_NO == ea->used) ? "NO" : "YES",
779                 (GNUNET_NO == in_use) ? "NO" : "YES");
780     return GNUNET_SYSERR;
781   }
782   ea->used = in_use;
783
784   /* Tell solver about update */
785   handle->s_update (handle->solver, handle->addresses, ea);
786
787   return GNUNET_OK;
788 }
789
790
791 /**
792  * Cancel address suggestions for a peer
793  *
794  * @param peer the respective peer
795  */
796 void
797 GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
798                                       const struct GNUNET_PeerIdentity *peer)
799 {
800   struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
801
802   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
803               "Received request: `%s' for peer %s\n", "request_address_cancel", GNUNET_i2s (peer));
804
805   while (NULL != cur)
806   {
807       if (0 == memcmp (peer, &cur->id, sizeof (cur->id)))
808         break; /* found */
809       cur = cur->next;
810   }
811
812   if (NULL == cur)
813   {
814       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
815                   "No address requests pending for peer `%s', cannot remove!\n", GNUNET_i2s (peer));
816       return;
817   }
818   GAS_addresses_handle_backoff_reset (handle, peer);
819   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
820               "Removed request pending for peer `%s\n", GNUNET_i2s (peer));
821   GNUNET_CONTAINER_DLL_remove (handle->r_head, handle->r_tail, cur);
822   GNUNET_free (cur);
823 }
824
825
826 /**
827  * Add an address suggestions for a peer
828  *
829  * @param peer the respective peer
830  */
831 void
832 GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
833                                const struct GNUNET_PeerIdentity *peer)
834 {
835   struct GAS_Addresses_Suggestion_Requests *cur = handle->r_head;
836   struct ATS_Address *aa;
837   struct GNUNET_ATS_Information *ats;
838   unsigned int ats_count;
839
840   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
841               "Received `%s' for peer `%s'\n",
842               "REQUEST ADDRESS",
843               GNUNET_i2s (peer));
844
845   if (GNUNET_NO == handle->running)
846     return;
847   while (NULL != cur)
848   {
849       if (0 == memcmp (peer, &cur->id, sizeof (cur->id)))
850         break; /* already suggesting */
851       cur = cur->next;
852   }
853   if (NULL == cur)
854   {
855       cur = GNUNET_malloc (sizeof (struct GAS_Addresses_Suggestion_Requests));
856       cur->id = (*peer);
857       GNUNET_CONTAINER_DLL_insert (handle->r_head, handle->r_tail, cur);
858   }
859
860   /* Get prefered address from solver */
861   aa = (struct ATS_Address *) handle->s_get (handle->solver, handle->addresses, peer);
862   if (NULL == aa)
863   {
864     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
865                 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
866     return;
867   }
868
869   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870               "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
871
872   ats_count = assemble_ats_information (aa, &ats);
873   GAS_scheduling_transmit_address_suggestion (peer,
874                                               aa->plugin,
875                                               aa->addr, aa->addr_len,
876                                               aa->session_id,
877                                               ats, ats_count,
878                                               aa->assigned_bw_out,
879                                               aa->assigned_bw_in);
880
881   aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval, ATS_BLOCKING_DELTA);
882   aa->blocked_until = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), aa->block_interval);
883
884   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
885        "Address %p ready for suggestion, block interval now %llu \n",
886        aa, aa->block_interval);
887
888   GNUNET_free (ats);
889 }
890
891
892 static int
893 reset_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
894 {
895   struct ATS_Address *aa = value;
896
897   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
898               "Resetting interval for peer `%s' address %p from %llu to 0\n",
899               GNUNET_i2s (&aa->peer), aa, aa->block_interval);
900
901   aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS;
902   aa->block_interval = GNUNET_TIME_UNIT_ZERO;
903   return GNUNET_OK;
904 }
905
906
907 void
908 GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
909                                     const struct GNUNET_PeerIdentity *peer)
910 {
911   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
912               "Received `%s' for peer `%s'\n",
913               "RESET BACKOFF",
914               GNUNET_i2s (peer));
915
916   GNUNET_break (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses,
917                                               &peer->hashPubKey,
918                                               &reset_address_it,
919                                               NULL));
920 }
921
922
923 void
924 GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
925                                  const struct GNUNET_PeerIdentity *peer,
926                                  enum GNUNET_ATS_PreferenceKind kind,
927                                  float score)
928 {
929   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930               "Received `%s' for peer `%s'\n",
931               "CHANGE PREFERENCE",
932               GNUNET_i2s (peer));
933
934   if (GNUNET_NO == handle->running)
935     return;
936
937   /* Tell solver about update */
938   handle->s_pref (handle->solver, peer, kind, score);
939 }
940
941 static unsigned int
942 load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
943 {
944   int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
945   char * entry_in = NULL;
946   char * entry_out = NULL;
947   char * quota_out_str;
948   char * quota_in_str;
949   int c;
950
951   for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++)
952   {
953     in_dest[c] = 0;
954     out_dest[c] = 0;
955     switch (quotas[c]) {
956       case GNUNET_ATS_NET_UNSPECIFIED:
957         entry_out = "UNSPECIFIED_QUOTA_OUT";
958         entry_in = "UNSPECIFIED_QUOTA_IN";
959         break;
960       case GNUNET_ATS_NET_LOOPBACK:
961         entry_out = "LOOPBACK_QUOTA_OUT";
962         entry_in = "LOOPBACK_QUOTA_IN";
963         break;
964       case GNUNET_ATS_NET_LAN:
965         entry_out = "LAN_QUOTA_OUT";
966         entry_in = "LAN_QUOTA_IN";
967         break;
968       case GNUNET_ATS_NET_WAN:
969         entry_out = "WAN_QUOTA_OUT";
970         entry_in = "WAN_QUOTA_IN";
971         break;
972       case GNUNET_ATS_NET_WLAN:
973         entry_out = "WLAN_QUOTA_OUT";
974         entry_in = "WLAN_QUOTA_IN";
975         break;
976       default:
977         break;
978     }
979
980     if ((entry_in == NULL) || (entry_out == NULL))
981       continue;
982
983     /* quota out */
984     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
985     {
986       if (0 == strcmp(quota_out_str, BIG_M_STRING) ||
987           (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c])))
988         out_dest[c] = UINT32_MAX;
989
990       GNUNET_free (quota_out_str);
991       quota_out_str = NULL;
992     }
993     else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
994       out_dest[c] = UINT32_MAX;
995     else
996       out_dest[c] = UINT32_MAX;
997
998     /* quota in */
999     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
1000     {
1001       if (0 == strcmp(quota_in_str, BIG_M_STRING) ||
1002           (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c])))
1003         in_dest[c] = UINT32_MAX;
1004
1005       GNUNET_free (quota_in_str);
1006       quota_in_str = NULL;
1007     }
1008     else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
1009     {
1010       in_dest[c] = UINT32_MAX;
1011     }
1012     else
1013     {
1014         in_dest[c] = UINT32_MAX;
1015     }
1016     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded quota: %s %u, %s %u\n", entry_in, in_dest[c], entry_out, out_dest[c]);
1017
1018   }
1019   return GNUNET_ATS_NetworkTypeCount;
1020 }
1021
1022
1023 static void
1024 bandwidth_changed_cb (void *cls, struct ATS_Address *address)
1025 {
1026   struct GAS_Addresses_Handle *handle = cls;
1027   struct GAS_Addresses_Suggestion_Requests *cur;
1028
1029   GNUNET_assert (handle != NULL);
1030   GNUNET_assert (address != NULL);
1031
1032   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth assignment changed for peer %s \n", GNUNET_i2s(&address->peer));
1033   struct GNUNET_ATS_Information *ats;
1034   unsigned int ats_count;
1035
1036   cur = handle->r_head;
1037   while (NULL != cur)
1038   {
1039       if (0 == memcmp (&address->peer, &cur->id, sizeof (cur->id)))
1040         break; /* we have an address request pending*/
1041       cur = cur->next;
1042   }
1043   if (NULL == cur)
1044   {
1045       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1046                   "Nobody is interested in peer `%s' :(\n",GNUNET_i2s (&address->peer));
1047       return;
1048   }
1049
1050   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1051               "Sending bandwidth update for peer `%s'\n",GNUNET_i2s (&address->peer));
1052
1053   ats_count = assemble_ats_information (address, &ats);
1054   GAS_scheduling_transmit_address_suggestion (&address->peer,
1055                                               address->plugin,
1056                                               address->addr, address->addr_len,
1057                                               address->session_id,
1058                                               ats, ats_count,
1059                                               address->assigned_bw_out,
1060                                               address->assigned_bw_in);
1061   GNUNET_free (ats);
1062 }
1063
1064
1065 /**
1066  * Initialize address subsystem.
1067  *
1068  * @param cfg configuration to use
1069  * @param stats the statistics handle to use
1070  */
1071 struct GAS_Addresses_Handle *
1072 GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1073                     const struct GNUNET_STATISTICS_Handle *stats)
1074 {
1075   struct GAS_Addresses_Handle *ah;
1076   int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
1077   unsigned long long  quotas_in[GNUNET_ATS_NetworkTypeCount];
1078   unsigned long long  quotas_out[GNUNET_ATS_NetworkTypeCount];
1079   int quota_count;
1080   char *mode_str;
1081   int c;
1082
1083   ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle));
1084   ah->running = GNUNET_NO;
1085
1086   ah->stat = (struct GNUNET_STATISTICS_Handle *) stats;
1087   /* Initialize the addresses database */
1088   ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
1089   GNUNET_assert (NULL != ah->addresses);
1090
1091   /* Figure out configured solution method */
1092   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
1093   {
1094       GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "No ressource assignment method configured, using simplistic approch\n");
1095       ah->ats_mode = MODE_SIMPLISTIC;
1096   }
1097   else
1098   {
1099       for (c = 0; c < strlen (mode_str); c++)
1100         mode_str[c] = toupper (mode_str[c]);
1101       if (0 == strcmp (mode_str, "SIMPLISTIC"))
1102       {
1103           ah->ats_mode = MODE_SIMPLISTIC;
1104       }
1105       else if (0 == strcmp (mode_str, "MLP"))
1106       {
1107           ah->ats_mode = MODE_MLP;
1108 #if !HAVE_LIBGLPK
1109           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Assignment method `%s' configured, but GLPK is not availabe, please install \n", mode_str);
1110           ah->ats_mode = MODE_SIMPLISTIC;
1111 #endif
1112       }
1113       else
1114       {
1115           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid ressource assignment method `%s' configured, using simplistic approch\n", mode_str);
1116           ah->ats_mode = MODE_SIMPLISTIC;
1117       }
1118       GNUNET_free (mode_str);
1119   }
1120   /* Start configured solution method */
1121   switch (ah->ats_mode)
1122   {
1123     case MODE_MLP:
1124       /* Init the MLP solver with default values */
1125 #if HAVE_LIBGLPK
1126       ah->ats_mode = MODE_MLP;
1127       ah->s_init = &GAS_mlp_init;
1128       ah->s_add = &GAS_mlp_address_add;
1129       ah->s_update = &GAS_mlp_address_update;
1130       ah->s_get = &GAS_mlp_get_preferred_address;
1131       ah->s_pref = &GAS_mlp_address_change_preference;
1132       ah->s_del =  &GAS_mlp_address_delete;
1133       ah->s_done = &GAS_mlp_done;
1134 #else
1135       GNUNET_free (ah);
1136       return NULL;
1137 #endif
1138       break;
1139     case MODE_SIMPLISTIC:
1140       /* Init the simplistic solver with default values */
1141       ah->ats_mode = MODE_SIMPLISTIC;
1142       ah->s_init = &GAS_simplistic_init;
1143       ah->s_add = &GAS_simplistic_address_add;
1144       ah->s_update = &GAS_simplistic_address_update;
1145       ah->s_get = &GAS_simplistic_get_preferred_address;
1146       ah->s_pref = &GAS_simplistic_address_change_preference;
1147       ah->s_del  = &GAS_simplistic_address_delete;
1148       ah->s_done = &GAS_simplistic_done;
1149       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started in %s mode\n", "SIMPLISTIC");
1150       break;
1151     default:
1152       return NULL;
1153       break;
1154   }
1155
1156   GNUNET_assert (NULL != ah->s_init);
1157   GNUNET_assert (NULL != ah->s_add);
1158   GNUNET_assert (NULL != ah->s_update);
1159   GNUNET_assert (NULL != ah->s_get);
1160   GNUNET_assert (NULL != ah->s_pref);
1161   GNUNET_assert (NULL != ah->s_del);
1162   GNUNET_assert (NULL != ah->s_done);
1163
1164   quota_count = load_quotas(cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount);
1165
1166   ah->solver = ah->s_init (cfg, stats, quotas, quotas_in, quotas_out, quota_count, &bandwidth_changed_cb, ah);
1167   if (NULL == ah->solver)
1168   {
1169     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize solver!\n");
1170     GNUNET_free (ah);
1171     return NULL;
1172   }
1173
1174   /* up and running */
1175   ah->running = GNUNET_YES;
1176   return ah;
1177 }
1178
1179
1180 /**
1181  * Free memory of address.
1182  *
1183  * @param cls NULL
1184  * @param key peer identity (unused)
1185  * @param value the 'struct ATS_Address' to free
1186  * @return GNUNET_OK (continue to iterate)
1187  */
1188 static int
1189 free_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
1190 {
1191   struct GAS_Addresses_Handle *handle = cls;
1192   struct ATS_Address *aa = value;
1193   handle->s_del (handle->solver, handle->addresses, aa, GNUNET_NO);
1194   destroy_address (handle, aa);
1195   return GNUNET_OK;
1196 }
1197
1198
1199 void
1200 GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle)
1201 {
1202   if (GNUNET_NO == handle->running)
1203     return;
1204
1205   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1206               "Received `%s'\n",
1207               "DESTROY ALL");
1208
1209   if (handle->addresses != NULL)
1210     GNUNET_CONTAINER_multihashmap_iterate (handle->addresses, &free_address_it, handle);
1211 }
1212
1213
1214 /**
1215  * Shutdown address subsystem.
1216  */
1217 void
1218 GAS_addresses_done (struct GAS_Addresses_Handle *handle)
1219 {
1220   struct GAS_Addresses_Suggestion_Requests *cur;
1221
1222   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1223               "Shutting down addresses\n");
1224   GNUNET_assert (NULL != handle);
1225   GAS_addresses_destroy_all (handle);
1226   handle->running = GNUNET_NO;
1227   GNUNET_CONTAINER_multihashmap_destroy (handle->addresses);
1228   handle->addresses = NULL;
1229   while (NULL != (cur = handle->r_head))
1230   {
1231       GNUNET_CONTAINER_DLL_remove (handle->r_head, handle->r_tail, cur);
1232       GNUNET_free (cur);
1233   }
1234   handle->s_done (handle->solver);
1235   GNUNET_free (handle);
1236   /* Stop configured solution method */
1237
1238 }
1239
1240 struct PeerIteratorContext
1241 {
1242   GNUNET_ATS_Peer_Iterator it;
1243   void *it_cls;
1244   struct GNUNET_CONTAINER_MultiHashMap *peers_returned;
1245 };
1246
1247 static int
1248 peer_it (void *cls,
1249          const struct GNUNET_HashCode * key,
1250          void *value)
1251 {
1252   struct PeerIteratorContext *ip_ctx = cls;
1253   struct GNUNET_PeerIdentity tmp;
1254
1255   if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(ip_ctx->peers_returned, key))
1256   {
1257       GNUNET_CONTAINER_multihashmap_put(ip_ctx->peers_returned, key, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1258       tmp.hashPubKey = (*key);
1259       ip_ctx->it (ip_ctx->it_cls, &tmp);
1260   }
1261
1262   return GNUNET_OK;
1263 }
1264
1265 /**
1266  * Return all peers currently known to ATS
1267  *
1268  * @param p_it the iterator to call for every peer, callbach with id == NULL
1269  *        when done
1270  * @param p_it_cls the closure for the iterator
1271  */
1272 void
1273 GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle, GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls)
1274 {
1275   struct PeerIteratorContext ip_ctx;
1276   unsigned int size;
1277
1278   if (NULL == p_it)
1279       return;
1280   GNUNET_assert (NULL != handle->addresses);
1281
1282   size = GNUNET_CONTAINER_multihashmap_size(handle->addresses);
1283   if (0 != size)
1284   {
1285     ip_ctx.it = p_it;
1286     ip_ctx.it_cls = p_it_cls;
1287     ip_ctx.peers_returned = GNUNET_CONTAINER_multihashmap_create (size, GNUNET_NO);
1288     GNUNET_CONTAINER_multihashmap_iterate (handle->addresses, &peer_it, &ip_ctx);
1289     GNUNET_CONTAINER_multihashmap_destroy (ip_ctx.peers_returned);
1290   }
1291   p_it (p_it_cls, NULL);
1292 }
1293
1294 struct PeerInfoIteratorContext
1295 {
1296   GNUNET_ATS_PeerInfo_Iterator it;
1297   void *it_cls;
1298 };
1299
1300
1301 static int 
1302 peerinfo_it (void *cls,
1303              const struct GNUNET_HashCode * key,
1304              void *value)
1305 {
1306   struct PeerInfoIteratorContext *pi_ctx = cls;
1307   struct ATS_Address *addr = (struct ATS_Address *)  value;
1308   struct GNUNET_ATS_Information *ats;
1309   uint32_t ats_count;
1310
1311   if (NULL != pi_ctx->it)
1312   {
1313     ats_count = assemble_ats_information (addr, &ats);
1314
1315     pi_ctx->it (pi_ctx->it_cls,
1316                 &addr->peer,
1317                 addr->plugin,
1318                 addr->addr, addr->addr_len,
1319                 addr->active,
1320                 ats, ats_count,
1321                 addr->assigned_bw_out,
1322                 addr->assigned_bw_in);
1323     GNUNET_free (ats);
1324   }
1325   return GNUNET_YES;
1326 }
1327
1328
1329 /**
1330  * Return all peers currently known to ATS
1331  *
1332  * @param peer the respective peer
1333  * @param pi_it the iterator to call for every peer
1334  * @param pi_it_cls the closure for the iterator
1335  */
1336 void
1337 GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
1338                              const struct GNUNET_PeerIdentity *peer,
1339                              GNUNET_ATS_PeerInfo_Iterator pi_it,
1340                              void *pi_it_cls)
1341 {
1342   struct PeerInfoIteratorContext pi_ctx;
1343   struct GNUNET_BANDWIDTH_Value32NBO zero_bw;
1344   GNUNET_assert (NULL != peer);
1345   GNUNET_assert (NULL != handle->addresses);
1346   if (NULL == pi_it)
1347     return; /* does not make sense without callback */
1348
1349   zero_bw = GNUNET_BANDWIDTH_value_init (0);
1350   pi_ctx.it = pi_it;
1351   pi_ctx.it_cls = pi_it_cls;
1352
1353   GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey, &peerinfo_it, &pi_ctx);
1354
1355   if (NULL != pi_it)
1356     pi_it (pi_it_cls, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, zero_bw, zero_bw);
1357
1358 }
1359
1360
1361 /* end of gnunet-service-ats_addresses.c */