gnunet-service-transport_validation.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010,2011 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 transport/gnunet-service-transport_validation.h
  18. * @brief address validation API
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H
  22. #define GNUNET_SERVICE_TRANSPORT_VALIDATION_H
  23. #include "gnunet_statistics_service.h"
  24. #include "gnunet_transport_plugin.h"
  25. #include "gnunet_util_lib.h"
  26. #include "gnunet_hello_lib.h"
  27. /**
  28. * Start the validation subsystem.
  29. *
  30. * @param max_fds maximum number of fds to use
  31. */
  32. void
  33. GST_validation_start (unsigned int max_fds);
  34. /**
  35. * Stop the validation subsystem.
  36. */
  37. void
  38. GST_validation_stop (void);
  39. /**
  40. * Update if we are using an address for a connection actively right now.
  41. * Based on this, the validation module will measure latency for the
  42. * address more or less often.
  43. *
  44. * @param address the address that we are now using (or not)
  45. * @param in_use #GNUNET_YES if we are now using the address for a connection,
  46. * #GNUNET_NO if we are no longer using the address for a connection
  47. */
  48. void
  49. GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
  50. int in_use);
  51. /**
  52. * We've received a PING. If appropriate, generate a PONG.
  53. *
  54. * @param sender peer sending the PING
  55. * @param hdr the PING
  56. * @param sender_address address of the sender, NULL if we did not initiate
  57. * @param session session we got the PING from
  58. * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  59. */
  60. int
  61. GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
  62. const struct GNUNET_MessageHeader *hdr,
  63. const struct GNUNET_HELLO_Address *sender_address,
  64. struct GNUNET_ATS_Session *session);
  65. /**
  66. * We've received a PONG. Check if it matches a pending PING and
  67. * mark the respective address as confirmed.
  68. *
  69. * @param sender peer sending the PONG
  70. * @param hdr the PONG
  71. * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  72. */
  73. int
  74. GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
  75. const struct GNUNET_MessageHeader *hdr);
  76. /**
  77. * We've received a HELLO, check which addresses are new and trigger
  78. * validation.
  79. *
  80. * @param hello the HELLO we received
  81. * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  82. */
  83. int
  84. GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
  85. /**
  86. * Validate an individual address.
  87. *
  88. * @param address address we should try to validate
  89. */
  90. void
  91. GST_validation_handle_address (const struct GNUNET_HELLO_Address *address);
  92. /**
  93. * Function called for each address (or address status change) that
  94. * the validation module is aware of (for the given target).
  95. *
  96. * @param cls closure
  97. * @param public_key public key for the peer, never NULL
  98. * @param valid_until is ZERO if we never validated the address,
  99. * otherwise a time up to when we consider it (or was) valid
  100. * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
  101. * is ZERO if the address is considered valid (no validation needed)
  102. * otherwise a time in the future if we're currently denying re-validation
  103. * @param address the address
  104. */
  105. typedef void
  106. (*GST_ValidationAddressCallback) (void *cls,
  107. struct GNUNET_TIME_Absolute valid_until,
  108. struct GNUNET_TIME_Absolute validation_block,
  109. const struct GNUNET_HELLO_Address *address);
  110. /**
  111. * Call the given function for each address for the given target.
  112. *
  113. * @param target peer information is requested for
  114. * @param cb function to call; will not be called after this function returns
  115. * @param cb_cls closure for @a cb
  116. */
  117. void
  118. GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
  119. GST_ValidationAddressCallback cb, void *cb_cls);
  120. #endif
  121. /* end of file gnunet-service-transport_validation.h */