gnunet_peer_lib.h 3.0 KB

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