gnunet-service-core.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.h
  18. * @brief Globals for gnunet-service-core
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_CORE_H
  22. #define GNUNET_SERVICE_CORE_H
  23. #include "gnunet_statistics_service.h"
  24. #include "gnunet_core_service.h"
  25. #include "core.h"
  26. #include "gnunet-service-core_typemap.h"
  27. /**
  28. * Opaque handle to a client.
  29. */
  30. struct GSC_Client;
  31. /**
  32. * Record kept for each request for transmission issued by a
  33. * client that is still pending. (This struct is used by
  34. * both the 'CLIENTS' and 'SESSIONS' subsystems.)
  35. */
  36. struct GSC_ClientActiveRequest
  37. {
  38. /**
  39. * Active requests are kept in a doubly-linked list of
  40. * the respective target peer.
  41. */
  42. struct GSC_ClientActiveRequest *next;
  43. /**
  44. * Active requests are kept in a doubly-linked list of
  45. * the respective target peer.
  46. */
  47. struct GSC_ClientActiveRequest *prev;
  48. /**
  49. * Handle to the client.
  50. */
  51. struct GSC_Client *client_handle;
  52. /**
  53. * Which peer is the message going to be for?
  54. */
  55. struct GNUNET_PeerIdentity target;
  56. /**
  57. * At what time did we first see this request?
  58. */
  59. struct GNUNET_TIME_Absolute received_time;
  60. /**
  61. * By what time would the client want to see this message out?
  62. */
  63. struct GNUNET_TIME_Absolute deadline;
  64. /**
  65. * How important is this request.
  66. */
  67. enum GNUNET_MQ_PriorityPreferences priority;
  68. /**
  69. * Has this request been solicited yet?
  70. */
  71. int was_solicited;
  72. /**
  73. * How many bytes does the client intend to send?
  74. */
  75. uint16_t msize;
  76. /**
  77. * Unique request ID (in big endian).
  78. */
  79. uint16_t smr_id;
  80. };
  81. /**
  82. * Tell a client that we are ready to receive the message.
  83. *
  84. * @param car request that is now ready; the responsibility
  85. * for the handle remains shared between CLIENTS
  86. * and SESSIONS after this call.
  87. */
  88. void
  89. GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car);
  90. /**
  91. * We will never be ready to transmit the given message in (disconnect
  92. * or invalid request). Frees resources associated with @a car. We
  93. * don't explicitly tell the client, it'll learn with the disconnect
  94. * (or violated the protocol).
  95. *
  96. * @param car request that now permanently failed; the
  97. * responsibility for the handle is now returned
  98. * to CLIENTS (SESSIONS is done with it).
  99. * @param drop_client #GNUNET_YES if the client violated the protocol
  100. * and we should thus drop the connection
  101. */
  102. void
  103. GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car,
  104. int drop_client);
  105. /**
  106. * Notify a particular client about a change to existing connection to
  107. * one of our neighbours (check if the client is interested). Called
  108. * from #GSC_SESSIONS_notify_client_about_sessions().
  109. *
  110. * @param client client to notify
  111. * @param neighbour identity of the neighbour that changed status
  112. * @param tmap_old previous type map for the neighbour, NULL for connect
  113. * @param tmap_new updated type map for the neighbour, NULL for disconnect
  114. */
  115. void
  116. GSC_CLIENTS_notify_client_about_neighbour (
  117. struct GSC_Client *client,
  118. const struct GNUNET_PeerIdentity *neighbour,
  119. const struct GSC_TypeMap *tmap_old,
  120. const struct GSC_TypeMap *tmap_new);
  121. /**
  122. * Deliver P2P message to interested clients. Caller must have checked
  123. * that the sending peer actually lists the given message type as one
  124. * of its types.
  125. *
  126. * @param sender peer who sent us the message
  127. * @param msg the message
  128. * @param msize number of bytes to transmit
  129. * @param options options for checking which clients should
  130. * receive the message
  131. */
  132. void
  133. GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
  134. const struct GNUNET_MessageHeader *msg,
  135. uint16_t msize,
  136. uint32_t options);
  137. /**
  138. * Notify all clients about a change to existing session.
  139. * Called from SESSIONS whenever there is a change in sessions
  140. * or types processed by the respective peer.
  141. *
  142. * @param neighbour identity of the neighbour that changed status
  143. * @param tmap_old previous type map for the neighbour, NULL for connect
  144. * @param tmap_new updated type map for the neighbour, NULL for disconnect
  145. */
  146. void
  147. GSC_CLIENTS_notify_clients_about_neighbour (
  148. const struct GNUNET_PeerIdentity *neighbour,
  149. const struct GSC_TypeMap *tmap_old,
  150. const struct GSC_TypeMap *tmap_new);
  151. /**
  152. * Our configuration.
  153. */
  154. extern const struct GNUNET_CONFIGURATION_Handle *GSC_cfg;
  155. /**
  156. * For creating statistics.
  157. */
  158. extern struct GNUNET_STATISTICS_Handle *GSC_stats;
  159. /**
  160. * Our identity.
  161. */
  162. extern struct GNUNET_PeerIdentity GSC_my_identity;
  163. #endif