gnunet_peer_lib.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2006, 2009 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. * @author Christian Grothoff
  18. *
  19. * @file
  20. * Helper library for interning of peer identifiers
  21. *
  22. * @defgroup peer Peer library
  23. * Helper library for interning of peer identifiers
  24. * @{
  25. */
  26. #ifndef GNUNET_PEER_LIB_H
  27. #define GNUNET_PEER_LIB_H
  28. #include "gnunet_util_lib.h"
  29. #ifdef __cplusplus
  30. extern "C"
  31. {
  32. #if 0 /* keep Emacsens' auto-indent happy */
  33. }
  34. #endif
  35. #endif
  36. /**
  37. * A GNUNET_PEER_Id is simply a shorter version of a "struct
  38. * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to
  39. * save memory when the same identifier needs to be used over and over
  40. * again.
  41. */
  42. typedef unsigned int GNUNET_PEER_Id;
  43. /**
  44. * Search for a peer identity. The reference counter is not changed.
  45. *
  46. * @param pid identity to find
  47. * @return the interned identity or 0.
  48. */
  49. GNUNET_PEER_Id
  50. GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid);
  51. /**
  52. * Intern an peer identity. If the identity is already known, its
  53. * reference counter will be increased by one.
  54. *
  55. * @param pid identity to intern
  56. * @return the interned identity.
  57. */
  58. GNUNET_PEER_Id
  59. GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid);
  60. /**
  61. * Change the reference counter of an interned PID.
  62. *
  63. * @param id identity to change the RC of
  64. * @param delta how much to change the RC
  65. */
  66. void
  67. GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta);
  68. /**
  69. * Decrement multiple RCs of peer identities by one.
  70. *
  71. * @param ids array of PIDs to decrement the RCs of
  72. * @param count size of the @a ids array
  73. */
  74. void
  75. GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids,
  76. unsigned int count);
  77. /**
  78. * Convert an interned PID to a normal peer identity.
  79. *
  80. * @param id interned PID to convert
  81. * @param pid where to write the normal peer identity
  82. */
  83. void
  84. GNUNET_PEER_resolve (GNUNET_PEER_Id id,
  85. struct GNUNET_PeerIdentity *pid);
  86. /**
  87. * Convert an interned PID to a normal peer identity.
  88. *
  89. * @param id interned PID to convert
  90. * @return pointer to peer identity, valid as long @a id is valid
  91. */
  92. const struct GNUNET_PeerIdentity *
  93. GNUNET_PEER_resolve2 (GNUNET_PEER_Id id);
  94. #if 0 /* keep Emacsens' auto-indent happy */
  95. {
  96. #endif
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. /* ifndef GNUNET_PEER_LIB_H */
  101. #endif
  102. /** @} */ /* end of group */
  103. /* end of gnunet_peer_lib.h */