2 This file is part of GNUnet
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file peerstore/peerstore_common.h
23 * @brief Helper peerstore functions
24 * @author Omar Tarabai
27 #include "peerstore.h"
30 * Creates a hash of the given key combination
34 PEERSTORE_hash_key (const char *sub_system,
35 const struct GNUNET_PeerIdentity *peer, const char *key,
36 struct GNUNET_HashCode *ret);
39 * Creates a record message ready to be sent
41 * @param sub_system sub system string
42 * @param peer Peer identity (can be NULL)
43 * @param key record key string (can be NULL)
44 * @param value record value BLOB (can be NULL)
45 * @param value_size record value size in bytes (set to 0 if value is NULL)
46 * @param expiry absolute time after which the record expires
47 * @param msg_type message type to be set in header
48 * @return pointer to record message struct
50 struct StoreRecordMessage *
51 PEERSTORE_create_record_message (const char *sub_system,
52 const struct GNUNET_PeerIdentity *peer,
53 const char *key, const void *value,
55 struct GNUNET_TIME_Absolute *expiry,
59 * Creates a MQ envelope for a single record
61 * @param sub_system sub system string
62 * @param peer Peer identity (can be NULL)
63 * @param key record key string (can be NULL)
64 * @param value record value BLOB (can be NULL)
65 * @param value_size record value size in bytes (set to 0 if value is NULL)
66 * @param expiry time after which the record expires
67 * @param options options specific to the storage operation
68 * @param msg_type message type to be set in header
69 * @return pointer to record message struct
71 struct GNUNET_MQ_Envelope *
72 PEERSTORE_create_record_mq_envelope (const char *sub_system,
73 const struct GNUNET_PeerIdentity *peer,
74 const char *key, const void *value,
76 struct GNUNET_TIME_Absolute *expiry,
77 enum GNUNET_PEERSTORE_StoreOption options,
81 * Parses a message carrying a record
83 * @param message the actual message
84 * @return Pointer to record or NULL if error
86 struct GNUNET_PEERSTORE_Record *
87 PEERSTORE_parse_record_message (const struct GNUNET_MessageHeader *message);
90 * Free any memory allocated for this record
95 PEERSTORE_destroy_record (struct GNUNET_PEERSTORE_Record *record);