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