gnunet-service-transport_blacklist.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2010,2011 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file transport/gnunet-service-transport_blacklist.h
  19. * @brief blacklisting API
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
  23. #define GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
  24. #include "gnunet_statistics_service.h"
  25. #include "gnunet_util_lib.h"
  26. /**
  27. * Start blacklist subsystem.
  28. *
  29. * @param server server used to accept clients from
  30. * @param cfg configuration handle
  31. * @param my_id my peer id
  32. */
  33. void
  34. GST_blacklist_start (struct GNUNET_SERVER_Handle *server,
  35. const struct GNUNET_CONFIGURATION_Handle *cfg,
  36. const struct GNUNET_PeerIdentity *my_id);
  37. /**
  38. * Stop blacklist subsystem.
  39. */
  40. void
  41. GST_blacklist_stop (void);
  42. /**
  43. * Initialize a blacklisting client. We got a blacklist-init
  44. * message from this client, add him to the list of clients
  45. * to query for blacklisting.
  46. *
  47. * @param cls unused
  48. * @param client the client
  49. * @param message the blacklist-init message that was sent
  50. */
  51. void
  52. GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client,
  53. const struct GNUNET_MessageHeader *message);
  54. /**
  55. * A blacklisting client has sent us reply. Process it.
  56. *
  57. * @param cls unused
  58. * @param client the client
  59. * @param message the blacklist-init message that was sent
  60. */
  61. void
  62. GST_blacklist_handle_reply (void *cls, struct GNUNET_SERVER_Client *client,
  63. const struct GNUNET_MessageHeader *message);
  64. /**
  65. * Add the given peer to the blacklist (for the given transport).
  66. *
  67. * @param peer peer to blacklist
  68. * @param transport_name transport to blacklist for this peer, NULL for all
  69. */
  70. void
  71. GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
  72. const char *transport_name);
  73. /**
  74. * Handle to an active blacklist check.
  75. */
  76. struct GST_BlacklistCheck;
  77. /**
  78. * Continuation called from a blacklist test.
  79. *
  80. * @param cls closure
  81. * @param peer identity of peer that was tested
  82. * @param result GNUNET_OK if the connection is allowed,
  83. * GNUNET_NO if not
  84. */
  85. typedef void (*GST_BlacklistTestContinuation) (void *cls,
  86. const struct GNUNET_PeerIdentity
  87. * peer, int result);
  88. /**
  89. * Test if a peer/transport combination is blacklisted.
  90. *
  91. * @param peer the identity of the peer to test
  92. * @param transport_name name of the transport to test, never NULL
  93. * @param cont function to call with result
  94. * @param cont_cls closure for 'cont'
  95. * @return handle to the blacklist check, NULL if the decision
  96. * was made instantly and 'cont' was already called
  97. */
  98. struct GST_BlacklistCheck *
  99. GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
  100. const char *transport_name,
  101. GST_BlacklistTestContinuation cont, void *cont_cls);
  102. /**
  103. * Cancel a blacklist check.
  104. *
  105. * @param bc check to cancel
  106. */
  107. void
  108. GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
  109. #endif
  110. /* end of file gnunet-service-transport_blacklist.h */