gnunet-service-core_kx.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009, 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 core/gnunet-service-core_kx.h
  18. * @brief code for managing the key exchange (SET_KEY, PING, PONG) with other peers
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_CORE_KX_H
  22. #define GNUNET_SERVICE_CORE_KX_H
  23. #include "gnunet_util_lib.h"
  24. #include "gnunet_transport_service.h"
  25. /**
  26. * Information about the status of a key exchange with another peer.
  27. */
  28. struct GSC_KeyExchangeInfo;
  29. /**
  30. * Encrypt and transmit a message with the given payload.
  31. *
  32. * @param kx key exchange context
  33. * @param payload payload of the message
  34. * @param payload_size number of bytes in 'payload'
  35. */
  36. void
  37. GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
  38. const void *payload,
  39. size_t payload_size);
  40. /**
  41. * Initialize KX subsystem.
  42. *
  43. * @param pk private key to use for the peer
  44. * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
  45. */
  46. int
  47. GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk);
  48. /**
  49. * Shutdown KX subsystem.
  50. */
  51. void
  52. GSC_KX_done (void);
  53. /**
  54. * Check if the given neighbour has excess bandwidth available.
  55. *
  56. * @param target neighbour to check
  57. * @return #GNUNET_YES if excess bandwidth is available, #GNUNET_NO if not
  58. */
  59. int
  60. GSC_NEIGHBOURS_check_excess_bandwidth (const struct
  61. GSC_KeyExchangeInfo *target);
  62. /**
  63. * Check how many messages are queued for the given neighbour.
  64. *
  65. * @param target neighbour to check
  66. * @return number of items in the message queue
  67. */
  68. unsigned int
  69. GSC_NEIGHBOURS_get_queue_length (const struct GSC_KeyExchangeInfo *target);
  70. /**
  71. * Handle #GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS request. For this
  72. * request type, the client does not have to have transmitted an INIT
  73. * request. All current peers are returned, regardless of which
  74. * message types they accept.
  75. *
  76. * @param mq message queue to add for monitoring
  77. */
  78. void
  79. GSC_KX_handle_client_monitor_peers (struct GNUNET_MQ_Handle *mq);
  80. #endif
  81. /* end of gnunet-service-core_kx.h */