gnunet-service-transport_plugins.h 3.9 KB

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