aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-18 16:22:14 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-18 16:22:14 +0000
commitfb12af8319a84389a536ab2f3735daf3b24f11bd (patch)
tree53e1424149fe8e7d5673e783868fcaa8a6bdbb55 /src/peerstore
parentd19064a18f3fcf35c94d7f56485e41fb3425d066 (diff)
downloadgnunet-fb12af8319a84389a536ab2f3735daf3b24f11bd.tar.gz
gnunet-fb12af8319a84389a536ab2f3735daf3b24f11bd.zip
-use const in peerstore callback
Diffstat (limited to 'src/peerstore')
-rw-r--r--src/peerstore/gnunet-service-peerstore.c6
-rw-r--r--src/peerstore/peerstore.h27
-rw-r--r--src/peerstore/peerstore_api.c58
-rw-r--r--src/peerstore/perf_peerstore_store.c10
-rw-r--r--src/peerstore/test_peerstore_api_iterate.c13
-rw-r--r--src/peerstore/test_peerstore_api_store.c23
-rw-r--r--src/peerstore/test_peerstore_api_sync.c10
7 files changed, 78 insertions, 69 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c
index f8ec631b9..bdd93e63a 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -239,7 +239,9 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
239 * @return #GNUNET_YES to continue iteration 239 * @return #GNUNET_YES to continue iteration
240 */ 240 */
241static int 241static int
242record_iterator (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 242record_iterator (void *cls,
243 const struct GNUNET_PEERSTORE_Record *record,
244 const char *emsg)
243{ 245{
244 struct GNUNET_PEERSTORE_Record *cls_record = cls; 246 struct GNUNET_PEERSTORE_Record *cls_record = cls;
245 struct StoreRecordMessage *srm; 247 struct StoreRecordMessage *srm;
@@ -410,7 +412,7 @@ handle_iterate (void *cls, struct GNUNET_SERVER_Client *client,
410 412
411 413
412/** 414/**
413 * Continuation of store_record called by the peerstore plugin 415 * Continuation of store_record called by the peerstore plugin
414 * 416 *
415 * @param cls closure 417 * @param cls closure
416 * @param success result 418 * @param success result
diff --git a/src/peerstore/peerstore.h b/src/peerstore/peerstore.h
index ef134feef..6644464ec 100644
--- a/src/peerstore/peerstore.h
+++ b/src/peerstore/peerstore.h
@@ -30,10 +30,11 @@
30 30
31 31
32GNUNET_NETWORK_STRUCT_BEGIN 32GNUNET_NETWORK_STRUCT_BEGIN
33
33/** 34/**
34 * Message carrying a PEERSTORE record message 35 * Message carrying a PEERSTORE record message
35 */ 36 */
36 struct StoreRecordMessage 37struct StoreRecordMessage
37{ 38{
38 39
39 /** 40 /**
@@ -47,15 +48,20 @@ GNUNET_NETWORK_STRUCT_BEGIN
47 uint16_t peer_set GNUNET_PACKED; 48 uint16_t peer_set GNUNET_PACKED;
48 49
49 /** 50 /**
51 * Size of the sub_system string
52 * Allocated at position 0 after this struct
53 */
54 uint16_t sub_system_size GNUNET_PACKED;
55
56 /**
50 * Peer Identity 57 * Peer Identity
51 */ 58 */
52 struct GNUNET_PeerIdentity peer; 59 struct GNUNET_PeerIdentity peer;
53 60
54 /** 61 /**
55 * Size of the sub_system string 62 * Expiry time of entry
56 * Allocated at position 0 after this struct
57 */ 63 */
58 uint16_t sub_system_size GNUNET_PACKED; 64 struct GNUNET_TIME_Absolute expiry GNUNET_PACKED;
59 65
60 /** 66 /**
61 * Size of the key string 67 * Size of the key string
@@ -70,18 +76,14 @@ GNUNET_NETWORK_STRUCT_BEGIN
70 uint16_t value_size GNUNET_PACKED; 76 uint16_t value_size GNUNET_PACKED;
71 77
72 /** 78 /**
73 * Expiry time of entry
74 */
75 struct GNUNET_TIME_Absolute expiry GNUNET_PACKED;
76
77 /**
78 * Options, needed only in case of a 79 * Options, needed only in case of a
79 * store operation 80 * store operation
80 */ 81 */
81 enum GNUNET_PEERSTORE_StoreOption options GNUNET_PACKED; 82 uint32_t /* enum GNUNET_PEERSTORE_StoreOption */ options GNUNET_PACKED;
82 83
83}; 84};
84 85
86
85/** 87/**
86 * Message carrying record key hash 88 * Message carrying record key hash
87 */ 89 */
@@ -94,6 +96,11 @@ struct StoreKeyHashMessage
94 struct GNUNET_MessageHeader header; 96 struct GNUNET_MessageHeader header;
95 97
96 /** 98 /**
99 * Always 0, for alignment.
100 */
101 uint32_t reserved GNUNET_PACKED;
102
103 /**
97 * Hash of a record key 104 * Hash of a record key
98 */ 105 */
99 struct GNUNET_HashCode keyhash; 106 struct GNUNET_HashCode keyhash;
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index 90594f73a..46f170a23 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 3 (C) 2013-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -17,11 +17,11 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file peerstore/peerstore_api.c 21 * @file peerstore/peerstore_api.c
23 * @brief API for peerstore 22 * @brief API for peerstore
24 * @author Omar Tarabai 23 * @author Omar Tarabai
24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
@@ -292,15 +292,30 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h);
292 * @param cls a 'struct GNUNET_PEERSTORE_WatchContext *' 292 * @param cls a 'struct GNUNET_PEERSTORE_WatchContext *'
293 */ 293 */
294static void 294static void
295watch_request_sent (void *cls); 295watch_request_sent (void *cls)
296{
297 struct GNUNET_PEERSTORE_WatchContext *wc = cls;
298
299 wc->request_sent = GNUNET_YES;
300 wc->ev = NULL;
301}
302
296 303
297/** 304/**
298 * Callback after MQ envelope is sent 305 * Callback after MQ envelope is sent
299 * 306 *
300 * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *' 307 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
301 */ 308 */
302static void 309static void
303iterate_request_sent (void *cls); 310iterate_request_sent (void *cls)
311{
312 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
313
314 LOG (GNUNET_ERROR_TYPE_DEBUG,
315 "Iterate request sent to service.\n");
316 ic->iterating = GNUNET_YES;
317 ic->ev = NULL;
318}
304 319
305 320
306/** 321/**
@@ -724,7 +739,6 @@ handle_iterate_result (void *cls,
724 callback_cls = ic->callback_cls; 739 callback_cls = ic->callback_cls;
725 if (NULL == msg) /* Connection error */ 740 if (NULL == msg) /* Connection error */
726 { 741 {
727
728 if (NULL != callback) 742 if (NULL != callback)
729 callback (callback_cls, NULL, 743 callback (callback_cls, NULL,
730 _("Error communicating with `PEERSTORE' service.")); 744 _("Error communicating with `PEERSTORE' service."));
@@ -759,23 +773,6 @@ handle_iterate_result (void *cls,
759 773
760 774
761/** 775/**
762 * Callback after MQ envelope is sent
763 *
764 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
765 */
766static void
767iterate_request_sent (void *cls)
768{
769 struct GNUNET_PEERSTORE_IterateContext *ic = cls;
770
771 LOG (GNUNET_ERROR_TYPE_DEBUG,
772 "Iterate request sent to service.\n");
773 ic->iterating = GNUNET_YES;
774 ic->ev = NULL;
775}
776
777
778/**
779 * Called when the iterate request is timedout 776 * Called when the iterate request is timedout
780 * 777 *
781 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *` 778 * @param cls a `struct GNUNET_PEERSTORE_IterateContext *`
@@ -923,21 +920,6 @@ handle_watch_result (void *cls, const struct GNUNET_MessageHeader *msg)
923 920
924 921
925/** 922/**
926 * Callback after MQ envelope is sent
927 *
928 * @param cls a `struct GNUNET_PEERSTORE_WatchContext *`
929 */
930static void
931watch_request_sent (void *cls)
932{
933 struct GNUNET_PEERSTORE_WatchContext *wc = cls;
934
935 wc->request_sent = GNUNET_YES;
936 wc->ev = NULL;
937}
938
939
940/**
941 * Cancel a watch request 923 * Cancel a watch request
942 * 924 *
943 * @param wc handle to the watch request 925 * @param wc handle to the watch request
diff --git a/src/peerstore/perf_peerstore_store.c b/src/peerstore/perf_peerstore_store.c
index e97699fe2..ad7c70195 100644
--- a/src/peerstore/perf_peerstore_store.c
+++ b/src/peerstore/perf_peerstore_store.c
@@ -37,9 +37,9 @@ static struct GNUNET_PeerIdentity p;
37static char *k = "test_peerstore_stress_key"; 37static char *k = "test_peerstore_stress_key";
38static char *v = "test_peerstore_stress_val"; 38static char *v = "test_peerstore_stress_val";
39 39
40int count = 0; 40static int count = 0;
41 41
42void 42static void
43disconnect () 43disconnect ()
44{ 44{
45 if (NULL != h) 45 if (NULL != h)
@@ -48,7 +48,7 @@ disconnect ()
48} 48}
49 49
50 50
51void 51static void
52store () 52store ()
53{ 53{
54 GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1, 54 GNUNET_PEERSTORE_store (h, ss, &p, k, v, strlen (v) + 1,
@@ -61,7 +61,9 @@ store ()
61 61
62 62
63static int 63static int
64watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 64watch_cb (void *cls,
65 const struct GNUNET_PEERSTORE_Record *record,
66 const char *emsg)
65{ 67{
66 GNUNET_assert (NULL == emsg); 68 GNUNET_assert (NULL == emsg);
67 if (STORES == count) 69 if (STORES == count)
diff --git a/src/peerstore/test_peerstore_api_iterate.c b/src/peerstore/test_peerstore_api_iterate.c
index 626a020de..5952d45d1 100644
--- a/src/peerstore/test_peerstore_api_iterate.c
+++ b/src/peerstore/test_peerstore_api_iterate.c
@@ -39,8 +39,11 @@ static char *k3 = "test_peerstore_api_iterate_key3";
39static char *val = "test_peerstore_api_iterate_val"; 39static char *val = "test_peerstore_api_iterate_val";
40static int count = 0; 40static int count = 0;
41 41
42
42static int 43static int
43iter3_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 44iter3_cb (void *cls,
45 const struct GNUNET_PEERSTORE_Record *record,
46 const char *emsg)
44{ 47{
45 if (NULL != emsg) 48 if (NULL != emsg)
46 return GNUNET_NO; 49 return GNUNET_NO;
@@ -58,7 +61,9 @@ iter3_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
58 61
59 62
60static int 63static int
61iter2_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 64iter2_cb (void *cls,
65 const struct GNUNET_PEERSTORE_Record *record,
66 const char *emsg)
62{ 67{
63 if (NULL != emsg) 68 if (NULL != emsg)
64 return GNUNET_NO; 69 return GNUNET_NO;
@@ -76,7 +81,9 @@ iter2_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
76 81
77 82
78static int 83static int
79iter1_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 84iter1_cb (void *cls,
85 const struct GNUNET_PEERSTORE_Record *record,
86 const char *emsg)
80{ 87{
81 if (NULL != emsg) 88 if (NULL != emsg)
82 return GNUNET_NO; 89 return GNUNET_NO;
diff --git a/src/peerstore/test_peerstore_api_store.c b/src/peerstore/test_peerstore_api_store.c
index 06ad34756..794a2b048 100644
--- a/src/peerstore/test_peerstore_api_store.c
+++ b/src/peerstore/test_peerstore_api_store.c
@@ -37,10 +37,12 @@ static char *val1 = "test_peerstore_api_store_val1";
37static char *val2 = "test_peerstore_api_store_val2-"; 37static char *val2 = "test_peerstore_api_store_val2-";
38static char *val3 = "test_peerstore_api_store_val3--"; 38static char *val3 = "test_peerstore_api_store_val3--";
39 39
40int count = 0; 40static int count = 0;
41 41
42int 42static int
43test3_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 43test3_cont2 (void *cls,
44 const struct GNUNET_PEERSTORE_Record *record,
45 const char *emsg)
44{ 46{
45 if (NULL != emsg) 47 if (NULL != emsg)
46 return GNUNET_NO; 48 return GNUNET_NO;
@@ -83,8 +85,10 @@ test3 ()
83} 85}
84 86
85 87
86int 88static int
87test2_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 89test2_cont2 (void *cls,
90 const struct GNUNET_PEERSTORE_Record *record,
91 const char *emsg)
88{ 92{
89 if (NULL != emsg) 93 if (NULL != emsg)
90 return GNUNET_NO; 94 return GNUNET_NO;
@@ -128,8 +132,10 @@ test2 ()
128} 132}
129 133
130 134
131int 135static int
132test1_cont2 (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 136test1_cont2 (void *cls,
137 const struct GNUNET_PEERSTORE_Record *record,
138 const char *emsg)
133{ 139{
134 if (NULL != emsg) 140 if (NULL != emsg)
135 return GNUNET_NO; 141 return GNUNET_NO;
@@ -172,7 +178,8 @@ test1 ()
172 178
173 179
174static void 180static void
175run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, 181run (void *cls,
182 const struct GNUNET_CONFIGURATION_Handle *cfg,
176 struct GNUNET_TESTING_Peer *peer) 183 struct GNUNET_TESTING_Peer *peer)
177{ 184{
178 h = GNUNET_PEERSTORE_connect (cfg); 185 h = GNUNET_PEERSTORE_connect (cfg);
diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c
index 3803d72c1..8bd8328f8 100644
--- a/src/peerstore/test_peerstore_api_sync.c
+++ b/src/peerstore/test_peerstore_api_sync.c
@@ -26,9 +26,9 @@
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_peerstore_service.h" 27#include "gnunet_peerstore_service.h"
28 28
29int ok = 1; 29static int ok = 1;
30 30
31const struct GNUNET_CONFIGURATION_Handle *cfg; 31static const struct GNUNET_CONFIGURATION_Handle *cfg;
32 32
33static struct GNUNET_PEERSTORE_Handle *h; 33static struct GNUNET_PEERSTORE_Handle *h;
34 34
@@ -37,8 +37,10 @@ static struct GNUNET_PeerIdentity pid;
37static char *key = "test_peerstore_api_store_key"; 37static char *key = "test_peerstore_api_store_key";
38static char *val = "test_peerstore_api_store_val"; 38static char *val = "test_peerstore_api_store_val";
39 39
40int 40static int
41iterate_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 41iterate_cb (void *cls,
42 const struct GNUNET_PEERSTORE_Record *record,
43 const char *emsg)
42{ 44{
43 const char *rec_val; 45 const char *rec_val;
44 46