gnunet-service-core_sessions.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2014 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_neighbours.h
  18. * @brief code for managing of 'encrypted' sessions (key exchange done)
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_CORE_SESSIONS_H
  22. #define GNUNET_SERVICE_CORE_SESSIONS_H
  23. #include "gnunet-service-core.h"
  24. #include "gnunet-service-core_kx.h"
  25. /**
  26. * Create a session, a key exchange was just completed.
  27. *
  28. * @param peer peer that is now connected
  29. * @param kx key exchange that completed
  30. */
  31. void
  32. GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
  33. struct GSC_KeyExchangeInfo *kx);
  34. /**
  35. * The other peer has indicated that it 'lost' the session
  36. * (KX down), reinitialize the session on our end, in particular
  37. * this means to restart the typemap transmission.
  38. *
  39. * @param peer peer that is now connected
  40. */
  41. void
  42. GSC_SESSIONS_reinit (const struct GNUNET_PeerIdentity *peer);
  43. /**
  44. * The other peer has confirmed receiving our type map,
  45. * check if it is current and if so, stop retransmitting it.
  46. *
  47. * @param peer peer that confirmed the type map
  48. * @param msg confirmation message we received
  49. */
  50. void
  51. GSC_SESSIONS_confirm_typemap (const struct GNUNET_PeerIdentity *peer,
  52. const struct GNUNET_MessageHeader *msg);
  53. /**
  54. * End the session with the given peer (we are no longer
  55. * connected).
  56. *
  57. * @param pid identity of peer to kill session with
  58. */
  59. void
  60. GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
  61. /**
  62. * Traffic is being solicited for the given peer. This means that the
  63. * message queue on the transport-level (NEIGHBOURS subsystem) is now
  64. * empty and it is now OK to transmit another (non-control) message.
  65. *
  66. * @param pid identity of peer ready to receive data
  67. */
  68. void
  69. GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
  70. /**
  71. * Queue a request from a client for transmission to a particular peer.
  72. *
  73. * @param car request to queue; this handle is then shared between
  74. * the caller (CLIENTS subsystem) and SESSIONS and must not
  75. * be released by either until either 'GNUNET_SESSIONS_dequeue',
  76. * or 'GNUNET_CLIENTS_failed'
  77. * have been invoked on it
  78. */
  79. void
  80. GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
  81. /**
  82. * Dequeue a request from a client from transmission to a particular peer.
  83. *
  84. * @param car request to dequeue; this handle will then be 'owned' by
  85. * the caller (CLIENTS sysbsystem)
  86. */
  87. void
  88. GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
  89. /**
  90. * Transmit a message to a particular peer.
  91. *
  92. * @param car original request that was queued and then solicited,
  93. * ownership does not change (dequeue will be called soon).
  94. * @param msg message to transmit
  95. * @param priority how important is this message
  96. */
  97. void
  98. GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
  99. const struct GNUNET_MessageHeader *msg,
  100. enum GNUNET_MQ_PriorityPreferences priority);
  101. /**
  102. * Broadcast an updated typemap message to all neighbours.
  103. * Restarts the retransmissions until the typemaps are confirmed.
  104. *
  105. * @param msg message to transmit
  106. */
  107. void
  108. GSC_SESSIONS_broadcast_typemap (const struct GNUNET_MessageHeader *msg);
  109. /**
  110. * We have a new client, notify it about all current sessions.
  111. *
  112. * @param client the new client
  113. */
  114. void
  115. GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
  116. /**
  117. * We've received a typemap message from a peer, update ours.
  118. * Notifies clients about the session.
  119. *
  120. * @param peer peer this is about
  121. * @param msg typemap update message
  122. */
  123. void
  124. GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
  125. const struct GNUNET_MessageHeader *msg);
  126. /**
  127. * The given peer send a message of the specified type. Make sure the
  128. * respective bit is set in its type-map and that clients are notified
  129. * about the session.
  130. *
  131. * @param peer peer this is about
  132. * @param type type of the message
  133. */
  134. void
  135. GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
  136. uint16_t type);
  137. /**
  138. * Initialize sessions subsystem.
  139. */
  140. void
  141. GSC_SESSIONS_init (void);
  142. /**
  143. * Shutdown sessions subsystem.
  144. */
  145. void
  146. GSC_SESSIONS_done (void);
  147. #endif