gnunet-service-transport_plugins.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_plugins.h
  18. * @brief plugin management API
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_TRANSPORT_PLUGINS_H
  22. #define GNUNET_SERVICE_TRANSPORT_PLUGINS_H
  23. #include "gnunet_statistics_service.h"
  24. #include "gnunet_transport_service.h"
  25. #include "gnunet_transport_plugin.h"
  26. #include "gnunet_util_lib.h"
  27. #include "gnunet_hello_lib.h"
  28. /**
  29. * Load and initialize all plugins. The respective functions will be
  30. * invoked by the plugins when the respective events happen. The
  31. * closure will be set to a 'const char*' containing the name of the
  32. * plugin that caused the call.
  33. *
  34. * @param recv_cb function to call when data is received
  35. * @param register_quota_cb function to call to register a quota callback
  36. * @param unregister_quota_cb function to call to unregister a quota callback
  37. * @param address_cb function to call when our public addresses changed
  38. * @param session_start_cb function to call when a session was created
  39. * @param session_end_cb function to call when a session was terminated
  40. * @param address_type_cb function to call when a address type is requested
  41. * @param metric_update_cb function to call when address metrics change
  42. */
  43. void
  44. GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
  45. GNUNET_TRANSPORT_AddressNotification address_cb,
  46. GNUNET_TRANSPORT_SessionStart session_start_cb,
  47. GNUNET_TRANSPORT_SessionEnd session_end_cb);
  48. /**
  49. * Unload all plugins
  50. */
  51. void
  52. GST_plugins_unload (void);
  53. /**
  54. * Obtain the plugin API based on a plugin name.
  55. *
  56. * @param name name of the plugin
  57. * @return the plugin's API, NULL if the plugin is not loaded
  58. */
  59. struct GNUNET_TRANSPORT_PluginFunctions *
  60. GST_plugins_find (const char *name);
  61. /**
  62. * Obtain the plugin API based on a the stripped plugin name after the underscore.
  63. *
  64. * Example: GST_plugins_printer_find (http_client) will return all plugins
  65. * starting with the prefix "http":
  66. * http_client or server if loaded
  67. *
  68. * @param name name of the plugin
  69. * @return the plugin's API, NULL if the plugin is not loaded
  70. */
  71. struct GNUNET_TRANSPORT_PluginFunctions *
  72. GST_plugins_printer_find (const char *name);
  73. /**
  74. * Convert a given address to a human-readable format. Note that the
  75. * return value will be overwritten on the next call to this function.
  76. *
  77. * @param address address to convert
  78. * @return statically allocated (!) human-readable address
  79. */
  80. const char *
  81. GST_plugins_a2s (const struct GNUNET_HELLO_Address *address);
  82. /**
  83. * Register callback with all plugins to monitor their status.
  84. *
  85. * @param cb callback to register, NULL to unsubscribe
  86. * @param cb_cls closure for @a cb
  87. */
  88. void
  89. GST_plugins_monitor_subscribe (GNUNET_TRANSPORT_SessionInfoCallback cb,
  90. void *cb_cls);
  91. #endif
  92. /* end of file gnunet-service-transport_plugins.h */