peerstore_common.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013-2016 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 peerstore/peerstore_common.h
  18. * @brief Helper peerstore functions
  19. * @author Omar Tarabai
  20. */
  21. #include "platform.h"
  22. #include "peerstore.h"
  23. /**
  24. * Creates a hash of the given key combination
  25. *
  26. */
  27. void
  28. PEERSTORE_hash_key (const char *sub_system,
  29. const struct GNUNET_PeerIdentity *peer,
  30. const char *key,
  31. struct GNUNET_HashCode *ret);
  32. /**
  33. * Creates a MQ envelope for a single record
  34. *
  35. * @param sub_system sub system string
  36. * @param peer Peer identity (can be NULL)
  37. * @param key record key string (can be NULL)
  38. * @param value record value BLOB (can be NULL)
  39. * @param value_size record value size in bytes (set to 0 if value is NULL)
  40. * @param expiry time after which the record expires
  41. * @param options options specific to the storage operation
  42. * @param msg_type message type to be set in header
  43. * @return pointer to record message struct
  44. */
  45. struct GNUNET_MQ_Envelope *
  46. PEERSTORE_create_record_mq_envelope (const char *sub_system,
  47. const struct GNUNET_PeerIdentity *peer,
  48. const char *key,
  49. const void *value,
  50. size_t value_size,
  51. struct GNUNET_TIME_Absolute expiry,
  52. enum GNUNET_PEERSTORE_StoreOption options,
  53. uint16_t msg_type);
  54. /**
  55. * Parses a message carrying a record
  56. *
  57. * @param srm the actual message
  58. * @return Pointer to record or NULL on error
  59. */
  60. struct GNUNET_PEERSTORE_Record *
  61. PEERSTORE_parse_record_message (const struct StoreRecordMessage *srm);
  62. /**
  63. * Free any memory allocated for this record
  64. *
  65. * @param record
  66. */
  67. void
  68. PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record);
  69. /* end of peerstore_common.h */