aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/peerstore_common.h
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-05-14 16:40:45 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-05-14 16:40:45 +0000
commita760c1b877f3a9ac17f2577cdc298f793c574407 (patch)
tree7411c99a1865aa1b1a6e1141172aa9a1378d4db7 /src/peerstore/peerstore_common.h
parentcb67c0bb1e6f2a5bae0295a75bc1f4b1b9f9f765 (diff)
downloadgnunet-a760c1b877f3a9ac17f2577cdc298f793c574407.tar.gz
gnunet-a760c1b877f3a9ac17f2577cdc298f793c574407.zip
peerstore helper file
Diffstat (limited to 'src/peerstore/peerstore_common.h')
-rw-r--r--src/peerstore/peerstore_common.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/peerstore/peerstore_common.h b/src/peerstore/peerstore_common.h
new file mode 100644
index 000000000..93fb9931b
--- /dev/null
+++ b/src/peerstore/peerstore_common.h
@@ -0,0 +1,93 @@
1/*
2 This file is part of GNUnet
3 (C)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21/**
22 * @file peerstore/peerstore_common.h
23 * @brief Helper peerstore functions
24 * @author Omar Tarabai
25 */
26
27#include "peerstore.h"
28
29/**
30 * PEERSTORE single record
31 */
32struct GNUNET_PEERSTORE_Record
33{
34
35 /**
36 * Responsible sub system string
37 */
38 char *sub_system;
39
40 /**
41 * Peer Identity
42 */
43 struct GNUNET_PeerIdentity *peer;
44
45 /**
46 * Record key string
47 */
48 char *key;
49
50 /**
51 * Record value BLOB
52 */
53 void *value;
54
55 /**
56 * Size of value BLOB
57 */
58 size_t value_size;
59
60 /**
61 * Lifetime of record
62 */
63 struct GNUNET_TIME_Relative lifetime;
64
65};
66
67/**
68 * Creates a record message ready to be sent
69 *
70 * @param sub_system sub system string
71 * @param peer Peer identity (can be NULL)
72 * @param key record key string (can be NULL)
73 * @param value record value BLOB (can be NULL)
74 * @param value_size record value size in bytes (set to 0 if value is NULL)
75 * @param lifetime relative time after which the record expires
76 * @return pointer to record message struct
77 */
78struct StoreRecordMessage *
79PEERSTORE_create_record_message(const char *sub_system,
80 const struct GNUNET_PeerIdentity *peer,
81 const char *key,
82 const void *value,
83 size_t value_size,
84 struct GNUNET_TIME_Relative lifetime);
85
86/**
87 * Parses a message carrying a record
88 *
89 * @param message the actual message
90 * @return Pointer to record or NULL if error
91 */
92struct GNUNET_PEERSTORE_Record *
93PEERSTORE_parse_record_message(const struct GNUNET_MessageHeader *message);