diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-05-14 16:40:45 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-05-14 16:40:45 +0000 |
commit | a760c1b877f3a9ac17f2577cdc298f793c574407 (patch) | |
tree | 7411c99a1865aa1b1a6e1141172aa9a1378d4db7 /src/peerstore/peerstore_api.c | |
parent | cb67c0bb1e6f2a5bae0295a75bc1f4b1b9f9f765 (diff) | |
download | gnunet-a760c1b877f3a9ac17f2577cdc298f793c574407.tar.gz gnunet-a760c1b877f3a9ac17f2577cdc298f793c574407.zip |
peerstore helper file
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r-- | src/peerstore/peerstore_api.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index fe6ff0fe3..68c171d52 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "peerstore.h" | 28 | #include "peerstore.h" |
29 | #include "peerstore_common.h" | ||
29 | 30 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "peerstore-api",__VA_ARGS__) | 31 | #define LOG(kind,...) GNUNET_log_from (kind, "peerstore-api",__VA_ARGS__) |
31 | 32 | ||
@@ -209,11 +210,7 @@ GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, | |||
209 | void *cont_cls) | 210 | void *cont_cls) |
210 | { | 211 | { |
211 | struct GNUNET_PEERSTORE_StoreContext *sc; | 212 | struct GNUNET_PEERSTORE_StoreContext *sc; |
212 | struct StoreRequestMessage *srm; | 213 | struct StoreRecordMessage *srm; |
213 | size_t ss_size; | ||
214 | size_t key_size; | ||
215 | size_t request_size; | ||
216 | void *dummy; | ||
217 | 214 | ||
218 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 215 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
219 | "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n", | 216 | "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n", |
@@ -222,26 +219,12 @@ GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, | |||
222 | sc->cont = cont; | 219 | sc->cont = cont; |
223 | sc->cont_cls = cont_cls; | 220 | sc->cont_cls = cont_cls; |
224 | sc->h = h; | 221 | sc->h = h; |
225 | ss_size = strlen(sub_system) + 1; | 222 | srm = PEERSTORE_create_record_message(sub_system, |
226 | key_size = strlen(key) + 1; | 223 | peer, |
227 | request_size = sizeof(struct StoreRequestMessage) + | 224 | key, |
228 | ss_size + | 225 | value, |
229 | key_size + | 226 | size, |
230 | size; | 227 | lifetime); |
231 | srm = GNUNET_malloc(request_size); | ||
232 | srm->header.size = htons(request_size); | ||
233 | srm->header.type = htons(GNUNET_MESSAGE_TYPE_PEERSTORE_STORE); | ||
234 | srm->key_size = htons(key_size); | ||
235 | srm->lifetime = lifetime; | ||
236 | srm->peer = *peer; | ||
237 | srm->sub_system_size = htons(ss_size); | ||
238 | srm->value_size = htons(size); | ||
239 | dummy = &srm[1]; | ||
240 | memcpy(dummy, sub_system, ss_size); | ||
241 | dummy += ss_size; | ||
242 | memcpy(dummy, key, key_size); | ||
243 | dummy += key_size; | ||
244 | memcpy(dummy, value, size); | ||
245 | GNUNET_CLIENT_transmit_and_get_response(h->client, | 228 | GNUNET_CLIENT_transmit_and_get_response(h->client, |
246 | (const struct GNUNET_MessageHeader *)srm, | 229 | (const struct GNUNET_MessageHeader *)srm, |
247 | GNUNET_TIME_UNIT_FOREVER_REL, | 230 | GNUNET_TIME_UNIT_FOREVER_REL, |