GNUnet  0.11.x
gnunet-service-transport_ats.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
25 #include "platform.h"
30 #include "gnunet_ats_service.h"
31 
35 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-ats", __VA_ARGS__)
36 
37 
42 {
48 
53 
58 
63 
72 
78 
85 
90  int expired;
91 };
92 
93 
99 
103 static unsigned int num_blocked;
104 
105 
110 {
115 
120 
124  struct AddressInfo *ret;
125 };
126 
127 
133 static void
135 {
137  gettext_noop ("# Addresses given to ATS"),
139  GNUNET_NO);
141  "# blocked addresses",
142  num_blocked,
143  GNUNET_NO);
144 }
145 
146 
157 static int
158 find_ai_cb (void *cls,
159  const struct GNUNET_PeerIdentity *key,
160  void *value)
161 {
162  struct FindClosure *fc = cls;
163  struct AddressInfo *ai = value;
164 
165  if ((0 ==
167  ai->address)) &&
168  (fc->session == ai->session))
169  {
170  fc->ret = ai;
171  return GNUNET_NO;
172  }
173  return GNUNET_YES;
174 }
175 
176 
185 static struct AddressInfo *
187  struct GNUNET_ATS_Session *session)
188 {
189  struct FindClosure fc;
190 
191  fc.address = address;
192  fc.session = session;
193  fc.ret = NULL;
195  &address->peer,
196  &find_ai_cb,
197  &fc);
198  return fc.ret;
199 }
200 
201 
211 static int
213  const struct GNUNET_PeerIdentity *key,
214  void *value)
215 {
216  struct FindClosure *fc = cls;
217  struct AddressInfo *ai = value;
218 
219  if (ai->expired)
220  return GNUNET_YES; /* expired do not count here */
221  if (0 ==
223  ai->address))
224  {
225  fc->ret = ai;
226  return GNUNET_NO;
227  }
228  return GNUNET_YES;
229 }
230 
231 
239 static struct AddressInfo *
241 {
242  struct FindClosure fc;
243 
244  fc.address = address;
245  fc.session = NULL;
246  fc.ret = NULL;
248  &address->peer,
250  &fc);
251  return fc.ret;
252 }
253 
254 
264 int
266  struct GNUNET_ATS_Session *session)
267 {
268  return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
269 }
270 
271 
279 int
281 {
282  return (NULL != find_ai_no_session (address))
283  ? GNUNET_YES
284  : GNUNET_NO;
285 }
286 
287 
294 static void
295 unblock_address (void *cls)
296 {
297  struct AddressInfo *ai = cls;
298 
299  ai->unblock_task = NULL;
301  "Unblocking address %s of peer %s\n",
302  GST_plugins_a2s (ai->address),
303  GNUNET_i2s (&ai->address->peer));
305  ai->address,
306  ai->session,
307  &ai->properties);
308  GNUNET_break (NULL != ai->ar);
309  num_blocked--;
311 }
312 
313 
323 void
325  struct GNUNET_ATS_Session *session)
326 {
327  struct AddressInfo *ai;
328 
329  if (0 ==
330  memcmp (&GST_my_identity,
331  &address->peer,
332  sizeof(struct GNUNET_PeerIdentity)))
333  return; /* our own, ignore! */
334  ai = find_ai (address,
335  session);
336  if ((NULL == ai) || (NULL == ai->ar))
337  {
338  /* The address is already gone/blocked, this can happen during a blacklist
339  * callback. */
340  return;
341  }
343  if (GNUNET_YES ==
347  "Removing address %s of peer %s from use (inbound died)\n",
348  GST_plugins_a2s (address),
349  GNUNET_i2s (&address->peer));
350  else
352  "Blocking address %s of peer %s from use for %s\n",
353  GST_plugins_a2s (address),
354  GNUNET_i2s (&address->peer),
356  GNUNET_YES));
357  /* destroy session and address */
358  if ((NULL == session) ||
359  (GNUNET_NO ==
361  session)))
362  {
364  }
365  /* "ar" has been freed, regardless how the branch
366  above played out: it was either freed in
367  #GNUNET_ATS_address_del_session() because it was
368  incoming, or explicitly in
369  #GNUNET_ATS_address_del_session(). */ai->ar = NULL;
370 
371  /* determine when the address should come back to life */
375  ai);
376  num_blocked++;
378 }
379 
380 
389 void
391  struct GNUNET_ATS_Session *session)
392 {
393  struct AddressInfo *ai;
394 
395  if (0 ==
396  memcmp (&GST_my_identity,
397  &address->peer,
398  sizeof(struct GNUNET_PeerIdentity)))
399  return; /* our own, ignore! */
400  ai = find_ai (address, session);
401  if (NULL == ai)
402  {
403  GNUNET_break (0);
404  return;
405  }
406  /* address is in successful use, so it should not be blocked right now */
407  GNUNET_break (NULL == ai->unblock_task);
409 }
410 
411 
422 void
424  struct GNUNET_ATS_Session *session,
425  const struct GNUNET_ATS_Properties *prop)
426 {
428  struct AddressInfo *ai;
429 
430  if (0 ==
431  memcmp (&GST_my_identity,
432  &address->peer,
433  sizeof(struct GNUNET_PeerIdentity)))
434  return; /* our own, ignore! */
435 
436  /* Sanity checks for a valid inbound address */
437  if (NULL == address->transport_name)
438  {
439  GNUNET_break (0);
440  return;
441  }
446  GNUNET_assert (NULL != session);
447  ai = find_ai (address, session);
448  if (NULL != ai)
449  {
450  /* This should only be called for new sessions, and thus
451  we should not already have the address */
452  GNUNET_break (0);
453  return;
454  }
455  /* Is indeed new, let's tell ATS */
457  "Notifying ATS about peer `%s''s new inbound address `%s' session %p in network %s\n",
458  GNUNET_i2s (&address->peer),
459  GST_plugins_a2s (address),
460  session,
461  GNUNET_NT_to_string (prop->scope));
463  address,
464  session,
465  prop);
466  GNUNET_assert (NULL != ar);
467  ai = GNUNET_new (struct AddressInfo);
468  ai->address = GNUNET_HELLO_address_copy (address);
469  ai->session = session;
470  ai->properties = *prop;
471  ai->ar = ar;
473  &ai->address->peer,
474  ai,
477 }
478 
479 
487 void
489  const struct GNUNET_ATS_Properties *prop)
490 {
492  struct AddressInfo *ai;
493 
494  if (0 ==
495  memcmp (&GST_my_identity,
496  &address->peer,
497  sizeof(struct GNUNET_PeerIdentity)))
498  return; /* our own, ignore! */
499  /* validadte address */
500  if (NULL == address->transport_name)
501  {
502  GNUNET_break (0);
503  return;
504  }
508  ai = find_ai_no_session (address);
509  GNUNET_assert (NULL == ai);
511 
512  /* address seems sane, let's tell ATS */
514  "Notifying ATS about peer %s's new address `%s'\n",
515  GNUNET_i2s (&address->peer),
516  GST_plugins_a2s (address));
518  address,
519  NULL,
520  prop);
521  GNUNET_assert (NULL != ar);
522  ai = GNUNET_new (struct AddressInfo);
523  ai->address = GNUNET_HELLO_address_copy (address);
524  ai->ar = ar;
525  ai->properties = *prop;
527  &ai->address->peer,
528  ai,
531 }
532 
533 
543 void
545  struct GNUNET_ATS_Session *session)
546 {
547  struct AddressInfo *ai;
548 
549  if (0 ==
550  memcmp (&GST_my_identity,
551  &address->peer,
552  sizeof(struct GNUNET_PeerIdentity)))
553  return; /* our own, ignore! */
554  ai = find_ai (address, NULL);
555  if (NULL == ai)
556  {
557  /* We may simply already be aware of the session, even if some
558  other part of the code could not tell if it just created a new
559  session or just got one recycled from the plugin; hence, we may
560  be called with "new" session even for an "old" session; in that
561  case, check that this is the case, but just ignore it. */GNUNET_assert (NULL != (find_ai (address, session)));
562  return;
563  }
564  GNUNET_assert (NULL == ai->session);
565  ai->session = session;
567  "Telling ATS about new session for peer %s\n",
568  GNUNET_i2s (&address->peer));
569  /* Note that the address might currently be blocked; we only
570  tell ATS about the session if the address is currently not
571  blocked; otherwise, ATS will be told about the session on
572  unblock. */
573  if (NULL != ai->ar)
575  session);
576  else
577  GNUNET_assert (NULL != ai->unblock_task);
578 }
579 
580 
586 static void
588 {
589  GNUNET_assert (NULL == ai->session);
590  if (NULL != ai->unblock_task)
591  {
593  ai->unblock_task = NULL;
594  num_blocked--;
595  }
598  &ai->address->peer,
599  ai));
601  "Telling ATS to destroy address from peer %s\n",
602  GNUNET_i2s (&ai->address->peer));
603  if (NULL != ai->ar)
604  {
606  ai->ar = NULL;
607  }
610  GNUNET_free (ai);
611 }
612 
613 
625 void
627  struct GNUNET_ATS_Session *session)
628 {
629  struct AddressInfo *ai;
630 
631  if (0 ==
632  memcmp (&GST_my_identity,
633  &address->peer,
634  sizeof(struct GNUNET_PeerIdentity)))
635  return; /* our own, ignore! */
636  if (NULL == session)
637  {
638  GNUNET_break (0);
639  return;
640  }
641  ai = find_ai (address,
642  session);
643  if (NULL == ai)
644  {
645  /* We sometimes create sessions just for sending a PING,
646  and if those are destroyed they were never known to
647  ATS which means we end up here (however, in this
648  case, the address must be an outbound address). */
652  return;
653  }
654  GNUNET_assert (session == ai->session);
655  ai->session = NULL;
657  "Telling ATS to destroy session %p from peer %s\n",
658  session,
659  GNUNET_i2s (&address->peer));
660  if (GNUNET_YES == ai->expired)
661  {
662  /* last reason to keep this 'ai' around is now gone, the
663  session is dead as well, clean up */
664  if (NULL != ai->ar)
665  {
666  /* Address expired but not blocked, and thus 'ar' was still
667  live because of the session; deleting just the session
668  will do for an inbound session, but for an outbound we
669  then also need to destroy the address with ATS. */
670  if (GNUNET_NO ==
672  session))
673  {
675  }
676  /* "ar" has been freed, regardless how the branch
677  above played out: it was either freed in
678  #GNUNET_ATS_address_del_session() because it was
679  incoming, or explicitly in
680  #GNUNET_ATS_address_del_session(). */ai->ar = NULL;
681  }
682  destroy_ai (ai);
683  return;
684  }
685 
686  if (NULL == ai->ar)
687  {
688  /* If ATS doesn't know about the address/session, this means
689  this address was blocked. */
690  if (GNUNET_YES ==
693  {
694  /* This was a blocked inbound session, which now lost the
695  session. But inbound addresses are by themselves useless,
696  so we must forget about the address as well. */
697  destroy_ai (ai);
698  return;
699  }
700  /* Otherwise, we are done as we have set `ai->session` to NULL
701  already and ATS will simply not be told about the session when
702  the connection is unblocked and the outbound address becomes
703  available again. . */
704  return;
705  }
706 
707  /* This is the "simple" case where ATS knows about the session and
708  the address is neither blocked nor expired. Delete the session,
709  and if it was inbound, free the address as well. */
710  if (GNUNET_YES ==
712  session))
713  {
714  /* This was an inbound address, the session is now gone, so we
715  need to also forget about the address itself. */
716  ai->ar = NULL;
717  destroy_ai (ai);
718  }
719 }
720 
721 
729 void
731  uint32_t distance)
732 {
733  struct AddressInfo *ai;
734 
735  ai = find_ai_no_session (address);
736  if (NULL == ai)
737  {
738  /* We do not know about this address, do nothing. */
739  return;
740  }
742  "Updated distance for peer `%s' to %u\n",
743  GNUNET_i2s (&address->peer),
744  distance);
745  ai->properties.distance = distance;
746  /* Give manipulation its chance to change metrics */
748  ai->session,
749  &ai->properties);
750  /* Address may be blocked, only give ATS if address is
751  currently active. */
752  if (NULL != ai->ar)
754  &ai->properties);
755 }
756 
757 
765 void
768 {
769  struct AddressInfo *ai;
770 
771  ai = find_ai_no_session (address);
772  if (NULL == ai)
773  {
774  /* We do not know about this address, do nothing. */
775  return;
776  }
778  "Updated latency for peer `%s' to %s\n",
779  GNUNET_i2s (&address->peer),
781  GNUNET_YES));
782  ai->properties.delay = delay;
783  /* Give manipulation its chance to change metrics */
785  ai->session,
786  &ai->properties);
787  /* Address may be blocked, only give ATS if address is
788  currently active. */
789  if (NULL != ai->ar)
791  &ai->properties);
792 }
793 
794 
803 void
805  uint32_t bps_in,
806  uint32_t bps_out)
807 {
808  struct AddressInfo *ai;
809 
810  ai = find_ai_no_session (address);
811  if (NULL == ai)
812  {
813  /* We do not know about this address, do nothing. */
814  return;
815  }
817  "Updating utilization for peer `%s' address %s: %u/%u\n",
818  GNUNET_i2s (&address->peer),
819  GST_plugins_a2s (address),
820  (unsigned int) bps_in,
821  (unsigned int) bps_out);
822  ai->properties.utilization_in = bps_in;
823  ai->properties.utilization_out = bps_out;
824  /* Give manipulation its chance to change metrics */
826  ai->session,
827  &ai->properties);
828  /* Address may be blocked, only give ATS if address is
829  currently active. */
830  if (NULL != ai->ar)
832  &ai->properties);
833 }
834 
835 
843 void
845 {
846  struct AddressInfo *ai;
847 
848  if (0 ==
849  memcmp (&GST_my_identity,
850  &address->peer,
851  sizeof(struct GNUNET_PeerIdentity)))
852  return; /* our own, ignore! */
854  "Address %s of peer %s expired\n",
855  GST_plugins_a2s (address),
856  GNUNET_i2s (&address->peer));
857  ai = find_ai_no_session (address);
858  if (NULL == ai)
859  {
860  GNUNET_assert (0);
861  return;
862  }
863  if (NULL != ai->session)
864  {
865  /* Got an active session, just remember the expiration
866  and act upon it when the session goes down. */
867  ai->expired = GNUNET_YES;
868  return;
869  }
870  /* Address expired, no session, free resources */
871  destroy_ai (ai);
872 }
873 
874 
878 void
880 {
882 }
883 
884 
893 static int
894 destroy_ai_cb (void *cls,
895  const struct GNUNET_PeerIdentity *key,
896  void *value)
897 {
898  struct AddressInfo *ai = value;
899 
900  destroy_ai (ai);
901  return GNUNET_OK;
902 }
903 
904 
908 void
910 {
912  &destroy_ai_cb,
913  NULL);
916  p2a = NULL;
917 }
918 
919 
920 /* end of gnunet-service-transport_ats.c */
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
struct GNUNET_ATS_Session * session
Session to look for (only used if the address is inbound).
void GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_ATS_Properties *prop)
Function that will be called to manipulate ATS information according to current manipulation settings...
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:44
int GST_ats_is_known(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Test if ATS knows about this address and session.
struct GNUNET_TIME_Relative back_off
If an address is blocked as part of an exponential back-off, we track the current size of the backoff...
void GST_ats_done()
Shutdown ATS subsystem.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
Closure for find_ai_cb() and find_ai_no_session_cb().
void GST_ats_update_distance(const struct GNUNET_HELLO_Address *address, uint32_t distance)
Notify ATS about DV distance change to an address.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct AddressInfo * ret
Where to store the result.
struct GNUNET_SCHEDULER_Task * unblock_task
Task scheduled to unblock an ATS-blocked address at blocked time, or NULL if the address is not block...
void GST_ats_add_address(const struct GNUNET_HELLO_Address *address, const struct GNUNET_ATS_Properties *prop)
Notify ATS about the new address including the network this address is located in.
struct GNUNET_ATS_Properties properties
Performance properties of this address.
static unsigned int num_blocked
Number of blocked addresses.
interfacing between transport and ATS service
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GST_ats_update_utilization(const struct GNUNET_HELLO_Address *address, uint32_t bps_in, uint32_t bps_out)
Notify ATS about utilization changes to an address.
ATS performance characteristics for an address.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static void destroy_ai(struct AddressInfo *ai)
Release memory used by the given address data.
static struct GNUNET_CONTAINER_MultiPeerMap * p2a
Map from peer identities to one or more struct AddressInfo values for the peer.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct GNUNET_ATS_AddressRecord * ar
Record with ATS API for the address.
static char * value
Value of the record to add/remove.
Session handle for connections.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
void GNUNET_ATS_address_update(struct GNUNET_ATS_AddressRecord *ar, const struct GNUNET_ATS_Properties *prop)
We have updated performance statistics for a given address.
struct GNUNET_TIME_Absolute blocked
Time until when this address is blocked and should thus not be made available to ATS (ar should be NU...
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:687
const char * transport_name
Name of the transport plugin enabling the communication using this address.
struct GNUNET_TIME_Relative delay
Delay.
#define LOG(kind,...)
Log convenience function.
void GST_ats_expire_address(const struct GNUNET_HELLO_Address *address)
Notify ATS that the address has expired and thus cannot be used any longer.
void GST_ats_add_inbound_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
Notify ATS about a new inbound address.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
Information we track per address, incoming or outgoing.
Internal representation of the hash map.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct GNUNET_ATS_AddressRecord * GNUNET_ATS_address_add(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
We have a new address ATS should know.
Information we track for each address known to ATS.
int GST_ats_is_known_no_session(const struct GNUNET_HELLO_Address *address)
Test if ATS knows about this address.
static int destroy_ai_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Release memory used by the given address data.
static struct AddressInfo * find_ai_no_session(const struct GNUNET_HELLO_Address *address)
Find the address information struct for the given address (ignoring sessions)
int GNUNET_ATS_address_del_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
A session was destroyed, disassociate it from the given address record.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static void unblock_address(void *cls)
The blocking time for an address has expired, allow ATS to suggest it again.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
const struct GNUNET_HELLO_Address * address
Address to look for.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
The identity of the host (wraps the signing key of the peer).
void GST_ats_block_reset(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Reset address blocking time.
static struct AddressInfo * find_ai(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Find the address information struct for the given address and session.
An address for communicating with a peer.
void GST_ats_update_delay(const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Relative delay)
Notify ATS about delay changes to properties of an address.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
Automatic transport selection and outbound bandwidth determination.
Entry in list of pending tasks.
Definition: scheduler.c:134
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
static int find_ai_no_session_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find matching address info, ignoring sessions and expired addresses.
void GST_ats_del_session(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Notify ATS that the session (but not the address) of a given address is no longer relevant...
struct GNUNET_HELLO_Address * address
The address (with peer identity).
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_ATS_address_add_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
An address was used to initiate a session.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_ATS_Session * session
Session (can be NULL)
static int find_ai_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find matching address info.
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GST_ats_block_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Temporarily block a valid address for use by ATS for address suggestions.
#define GNUNET_HELLO_address_free(addr)
Free an address.
int expired
Set to GNUNET_YES if the address has expired but we could not yet remove it because we still have a v...
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static void publish_p2a_stat_update()
Provide an update on the p2a map size to statistics.
void GST_ats_new_session(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Notify ATS about a new session now existing for the given address.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
#define gettext_noop(String)
Definition: gettext.h:69
Category of last resort.
Definition: gnunet_nt_lib.h:40
void GST_ats_init()
Initialize ATS subsystem.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966