gnunet_peer_lib.h 3.1 KB

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