gnunet_transport_application_service.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2015, 2018, 2019 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file
  18. * Bandwidth allocation API for applications to interact with
  19. *
  20. * @author Christian Grothoff
  21. * @author Matthias Wachs
  22. *
  23. * @defgroup TRANSPORT service
  24. * Bandwidth allocation
  25. *
  26. * @{
  27. */
  28. #ifndef GNUNET_TRANSPORT_APPLICATION_SERVICE_H
  29. #define GNUNET_TRANSPORT_APPLICATION_SERVICE_H
  30. #include "gnunet_constants.h"
  31. #include "gnunet_util_lib.h"
  32. #include "gnunet_nt_lib.h"
  33. /**
  34. * Handle to the TRANSPORT subsystem for making suggestions about
  35. * connections the peer would like to have.
  36. */
  37. struct GNUNET_TRANSPORT_ApplicationHandle;
  38. /**
  39. * Initialize the TRANSPORT application client handle.
  40. *
  41. * @param cfg configuration to use
  42. * @return ats application handle, NULL on error
  43. */
  44. struct GNUNET_TRANSPORT_ApplicationHandle *
  45. GNUNET_TRANSPORT_application_init (
  46. const struct GNUNET_CONFIGURATION_Handle *cfg);
  47. /**
  48. * Shutdown TRANSPORT application client.
  49. *
  50. * @param ch handle to destroy
  51. */
  52. void
  53. GNUNET_TRANSPORT_application_done (
  54. struct GNUNET_TRANSPORT_ApplicationHandle *ch);
  55. /**
  56. * An application would like TRANSPORT to connect to a peer.
  57. *
  58. * @param ch handle
  59. * @param peer identity of the peer we need an address for
  60. * @param pk what kind of application will the application require (can be
  61. * #GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
  62. * @param bw desired bandwith, can be zero (we will still try to connect)
  63. * @return suggest handle, NULL if a request is already pending
  64. */
  65. struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
  66. GNUNET_TRANSPORT_application_suggest (
  67. struct GNUNET_TRANSPORT_ApplicationHandle *ch,
  68. const struct GNUNET_PeerIdentity *peer,
  69. enum GNUNET_MQ_PriorityPreferences pk,
  70. struct GNUNET_BANDWIDTH_Value32NBO bw);
  71. /**
  72. * We no longer care about being connected to a peer.
  73. *
  74. * @param sh handle to stop
  75. */
  76. void
  77. GNUNET_TRANSPORT_application_suggest_cancel (
  78. struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh);
  79. /**
  80. * An application (or a communicator) has received a HELLO (or other address
  81. * data of another peer) and wants TRANSPORT to validate that the address is
  82. * correct. The result is NOT returned, in fact TRANSPORT may do nothing
  83. * (i.e. if it has too many active validations or recently tried this one
  84. * already). If the @a addr validates, TRANSPORT will persist the address
  85. * with PEERSTORE.
  86. *
  87. * @param ch handle
  88. * @param peer identity of the peer we have an address for
  89. * @param nt network type of @a addr (as claimed by the other peer);
  90. * used by TRANSPORT to avoid trying @a addr's that really cannot work
  91. * due to network type missmatches
  92. * @param addr address to validate
  93. */
  94. void
  95. GNUNET_TRANSPORT_application_validate (
  96. struct GNUNET_TRANSPORT_ApplicationHandle *ch,
  97. const struct GNUNET_PeerIdentity *peer,
  98. enum GNUNET_NetworkType nt,
  99. const char *addr);
  100. /** @} */ /* end of group */
  101. #endif
  102. /* end of file gnunet_ats_application_service.h */