GNUnet 0.21.2
peerstore_api.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2013-2016, 2019 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_protocols.h"
30#include "peerstore.h"
31#include "peerstore_common.h"
33
34#define LOG(kind, ...) GNUNET_log_from (kind, "peerstore-api", __VA_ARGS__)
35
36/******************************************************************************/
37/************************ DATA STRUCTURES ****************************/
38/******************************************************************************/
39
44{
49
54
59
64
69
74
79
84
89
93 uint32_t last_op_id;
94
95};
96
101{
106
111
115 void *cont_cls;
116
121
126
131
136};
137
142{
147
152
157
162
166 uint32_t rid;
167
171 void *cont_cls;
172
177
181 char *key;
182
186 void *value;
187
192
196 size_t size;
197
202
207
212};
213
218{
223
228};
229
234{
239
244
249
254
259
263 char *key;
264
269
274
278 uint32_t rid;
279
284};
285
286
291{
296
301
306
311
315 unsigned int canceled;
316
320 uint32_t rid;
321
322};
323
324/******************************************************************************/
325/******************* DECLARATIONS *********************/
326/******************************************************************************/
327
333static void
334reconnect (void *cls);
335
342static uint32_t
344{
345 return h->last_op_id++;
346}
347
348
354static void
356{
357 if (NULL != h->watches)
358 {
361 }
362 GNUNET_assert (NULL == h->iterate_head);
363 GNUNET_assert (NULL == h->store_head);
364 if (NULL != h->mq)
365 {
367 h->mq = NULL;
368 }
369}
370
371
378static void
380{
381 GNUNET_assert (NULL == h->reconnect_task);
382 disconnect (h);
384 "Scheduling task to reconnect to PEERSTORE service in %s.\n",
387 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
388 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
389}
390
391
392/******************************************************************************/
393/******************* CONNECTION FUNCTIONS *********************/
394/******************************************************************************/
395
396
400static void
402{
403 struct GNUNET_PEERSTORE_Handle *h = cls;
404
406 "Received an error notification from MQ of type: %d\n",
407 error);
409}
410
411
420{
422
424 h->cfg = cfg;
425 reconnect (h);
426 if (NULL == h->mq)
427 {
428 GNUNET_free (h);
429 return NULL;
430 }
431 return h;
432}
433
434
442void
444{
445 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnect initiated from client.\n");
446 disconnect (h);
447 GNUNET_free (h);
448}
449
450
451/******************************************************************************/
452/******************* STORE FUNCTIONS *********************/
453/******************************************************************************/
454
455static void
457{
458 GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
459 GNUNET_free (sc->sub_system);
460 GNUNET_free (sc->value);
461 GNUNET_free (sc->key);
462 GNUNET_free (sc);
463}
464
465
471void
473{
475 "store cancel with sc %p \n",
476 sc);
479 "store cancel with sc %p is null\n",
480 sc);
481}
482
483
502 const char *sub_system,
503 const struct GNUNET_PeerIdentity *peer,
504 const char *key,
505 const void *value,
506 size_t size,
510 void *cont_cls)
511{
512 struct GNUNET_MQ_Envelope *ev;
514
516 "Storing value (size: %llu) for subsystem `%s', peer `%s', key `%s'\n",
517 (unsigned long long) size,
520 key);
522 sc->rid = get_op_id (h);
523 sc->sub_system = GNUNET_strdup (sub_system);
524 GNUNET_assert (NULL != peer);
525 sc->peer = *peer;
526 sc->key = GNUNET_strdup (key);
527 sc->value = GNUNET_memdup (value, size);
528 sc->size = size;
529 sc->expiry = expiry;
530 sc->options = options;
531 sc->cont = cont;
532 sc->cont_cls = cont_cls;
533 sc->h = h;
534 ev =
537 peer,
538 key,
539 value,
540 size,
541 expiry,
542 options,
544
545 GNUNET_CONTAINER_DLL_insert_tail (h->store_head, h->store_tail, sc);
546 if (NULL == h->mq)
547 {
548 sc->env = ev;
549 }
550 else
551 {
552 GNUNET_MQ_send (h->mq, ev);
553 }
554 return sc;
555}
556
557
564static void
566{
567 struct GNUNET_PEERSTORE_Handle *h = cls;
568 struct GNUNET_PEERSTORE_StoreContext *sc = h->store_head;
569
570 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got PeerstoreResultMessage\n");
571 for (sc = h->store_head; NULL != sc; sc = sc->next)
572 {
573 if (sc->rid == ntohs (msg->rid))
574 break;
575 }
576 if (NULL == sc)
577 {
579 _ ("Unexpected store response.\n"));
580 return;
581 }
582 if (NULL != sc->cont)
583 sc->cont (sc->cont_cls, ntohl (msg->result));
585}
586
587
588/******************************************************************************/
589/******************* ITERATE FUNCTIONS *********************/
590/******************************************************************************/
591
592static void
594{
597 GNUNET_free (ic->key);
598 GNUNET_free (ic);
599}
600
601
608static void
610{
611 struct GNUNET_PEERSTORE_Handle *h = cls;
612 struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head;
613
614 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
615 if (ic->rid == ntohs (msg->rid))
616 break;
617 if (NULL == ic)
618 {
620 _ ("Unexpected iteration response.\n"));
621 return;
622 }
623 if (NULL != ic->callback)
624 ic->callback (ic->callback_cls, NULL, NULL);
625 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up iteration with rid %u\n", ic->rid);
627}
628
629
637static int
639{
640 /* we defer validation to #handle_iterate_result */
641 return GNUNET_OK;
642}
643
644
651static void
653{
654 struct GNUNET_PEERSTORE_Handle *h = cls;
657
658 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RecordMessage\n");
659 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
660 if (ic->rid == ntohs (msg->rid))
661 break;
662 if (NULL == ic)
663 {
665 _ (
666 "Unexpected iteration response, no iterating client found, discarding message.\n"));
667 return;
668 }
669 if (NULL == ic->callback)
670 return;
672 if (NULL == record)
673 {
674 ic->callback (ic->callback_cls,
675 NULL,
676 _ ("Received a malformed response from service."));
677 }
678 else
679 {
680 ic->callback (ic->callback_cls, record, NULL);
682 }
683}
684
685
692void
694 uint64_t limit)
695{
696 struct GNUNET_MQ_Envelope *ev;
698
700 "Sending PEERSTORE_ITERATION_NEXT message\n");
702 inm->rid = htons (ic->rid);
703 inm->limit = GNUNET_htonll (limit);
704 if (NULL == ic->h->mq)
705 {
706 ic->env = ev;
707 }
708 else
709 {
710 GNUNET_MQ_send (ic->h->mq, ev);
711 }
712}
713
714
721void
723{
724 struct GNUNET_MQ_Envelope *ev;
726
728 "Sending PEERSTORE_ITERATION_STOP message\n");
729 if (NULL != ic->h->mq)
730 {
732 ism->rid = htons (ic->rid);
733 if (NULL != ic->h->mq)
734 GNUNET_MQ_send (ic->h->mq, ev);
735 }
737}
738
739
742 const char *sub_system,
743 const struct GNUNET_PeerIdentity *peer,
744 const char *key,
746 void *callback_cls)
747{
748 struct GNUNET_MQ_Envelope *ev;
751 size_t ss_size;
752 size_t key_size;
753 size_t msg_size;
754 void *dummy;
755
757 ic->rid = get_op_id (h);
758
759 GNUNET_assert (NULL != sub_system);
760 ss_size = strlen (sub_system) + 1;
761 if (NULL == key)
762 key_size = 0;
763 else
764 key_size = strlen (key) + 1;
765 msg_size = ss_size + key_size;
766 ev = GNUNET_MQ_msg_extra (srm, msg_size,
768 srm->key_size = htons (key_size);
769 srm->rid = htons (ic->rid);
770 srm->sub_system_size = htons (ss_size);
771 dummy = &srm[1];
772 GNUNET_memcpy (dummy, sub_system, ss_size);
773 dummy += ss_size;
774 GNUNET_memcpy (dummy, key, key_size);
775 ic->callback = callback;
777 ic->h = h;
779 if (NULL != peer)
780 {
781 ic->peer = *peer;
782 srm->peer_set = htons (GNUNET_YES);
783 srm->peer = *peer;
784 }
785 if (NULL != key)
786 ic->key = GNUNET_strdup (key);
787 GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, h->iterate_tail, ic);
789 "Sending an iterate request for sub system `%s'\n",
790 sub_system);
791 GNUNET_MQ_send (h->mq, ev);
792 return ic;
793}
794
795
801static void
802reconnect (void *cls)
803{
804 struct GNUNET_PEERSTORE_Handle *h = cls;
805 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
806 GNUNET_MQ_hd_fixed_size (iterate_end,
809 h),
810 GNUNET_MQ_hd_fixed_size (store_result,
813 h),
814 GNUNET_MQ_hd_var_size (iterate_result,
817 h),
819 };
820
821 h->reconnect_task = NULL;
822 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
824 "peerstore",
825 mq_handlers,
827 h);
828 if (NULL == h->mq)
829 {
831 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
832 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
833 return;
834 }
836 "Resending pending requests after reconnect.\n");
837 for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head; NULL != ic;
838 ic = ic->next)
839 {
840 GNUNET_MQ_send (h->mq, ic->env);
841 }
842 for (struct GNUNET_PEERSTORE_StoreContext *sc = h->store_head; NULL != sc;
843 sc = sc->next)
844 {
845 GNUNET_MQ_send (h->mq, sc->env);
846 }
847}
848
849
850static void
851hello_store_success (void *cls, int success)
852{
853 struct GNUNET_PEERSTORE_StoreHelloContext *huc = cls;
854
855 huc->sc = NULL;
856 if (GNUNET_OK != success)
857 {
859 "Storing hello uri failed\n");
860 huc->cont (huc->cont_cls, success);
861 GNUNET_free (huc->hello);
862 GNUNET_free (huc);
863 return;
864 }
865 huc->cont (huc->cont_cls, GNUNET_OK);
866 GNUNET_free (huc->hello);
867 GNUNET_free (huc);
868}
869
870
871static void
873 const char *emsg)
874{
875 struct GNUNET_PEERSTORE_StoreHelloContext *huc = cls;
876 struct GNUNET_TIME_Absolute hello_exp =
878 if ((NULL == record) && (NULL == emsg))
879 {
883 huc->sc = GNUNET_PEERSTORE_store (huc->h,
884 "peerstore",
885 &huc->pid,
887 huc->hello,
888 ntohs (huc->hello->size),
889 hello_exp,
892 huc);
893 return;
894 }
895 if (NULL != emsg)
896 {
897 LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
899 return;
900 }
901 if (GNUNET_TIME_absolute_cmp (record->expiry, >, hello_exp))
902 {
904 "Not storing hello for %s since we seem to have a newer version on record.\n",
905 GNUNET_i2s (&huc->pid));
906 huc->cont (huc->cont_cls, GNUNET_OK);
908 GNUNET_free (huc->hello);
909 GNUNET_free (huc);
910 return;
911 }
913}
914
915
918 const struct GNUNET_MessageHeader *msg,
920 void *cont_cls)
921{
924 const struct GNUNET_PeerIdentity *pid;
926 struct GNUNET_TIME_Absolute hello_exp =
928 struct GNUNET_TIME_Absolute huc_exp;
929 uint16_t size_msg = ntohs (msg->size);
930
931 if (NULL == builder)
932 return NULL;
933 if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
934 return NULL;
935
937 huc->h = h;
938 huc->cont = cont;
939 huc->cont_cls = cont_cls;
940 huc->hello = GNUNET_malloc (size_msg);
941 GNUNET_memcpy (huc->hello, msg, size_msg);
942 huc_exp =
945 huc->pid = *pid;
947 "Adding hello for peer %s with expiration %s msg size %u\n",
948 GNUNET_i2s (&huc->pid),
950 size_msg);
951
952 huc->ic = GNUNET_PEERSTORE_iteration_start (h, "peerstore", &huc->pid,
955 huc);
957 return huc;
958}
959
960
961void
964{
965 if (NULL != huc->sc)
967 if (NULL != huc->ic)
969 GNUNET_free (huc->hello);
970 GNUNET_free (huc);
971}
972
973
974/* end of peerstore_api.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
struct GNUNET_HashCode key
The key used in the DHT.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Helper library for handling HELLO URIs.
API to the peerstore service.
Constants for network protocols.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition: hello-uri.c:373
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg into builder.
Definition: hello-uri.c:391
const struct GNUNET_PeerIdentity * GNUNET_HELLO_builder_get_id(const struct GNUNET_HELLO_Builder *builder)
Get the PeerIdentity for this builder.
Definition: hello-uri.c:366
struct GNUNET_TIME_Absolute GNUNET_HELLO_builder_get_expiration_time(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
Definition: hello-uri.c:470
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iteration_start(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over peerstore entries.
void GNUNET_PEERSTORE_iteration_next(struct GNUNET_PEERSTORE_IterateContext *ic, uint64_t limit)
Cancel an iterate request Please do not call after the iterate request is done.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
void(* GNUNET_PEERSTORE_hello_notify_cb)(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *hello, const char *err_msg)
Function called by PEERSTORE when notifying a client about a changed hello.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
GNUNET_PEERSTORE_StoreOption
Options for storing values in PEERSTORE.
void(* GNUNET_PEERSTORE_Processor)(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Function called by PEERSTORE for each matching record.
void GNUNET_PEERSTORE_hello_add_cancel(struct GNUNET_PEERSTORE_StoreHelloContext *huc)
Cancel the request to add a hello.
struct GNUNET_PEERSTORE_StoreContext * GNUNET_PEERSTORE_store(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, GNUNET_PEERSTORE_Continuation cont, void *cont_cls)
Store a new entry in the PEERSTORE.
void(* GNUNET_PEERSTORE_Continuation)(void *cls, int success)
Continuation called with a status result.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
#define GNUNET_PEERSTORE_HELLO_KEY
Key used for storing HELLO in the peerstore.
struct GNUNET_PEERSTORE_StoreHelloContext * GNUNET_PEERSTORE_hello_add(struct GNUNET_PEERSTORE_Handle *h, const struct GNUNET_MessageHeader *msg, GNUNET_PEERSTORE_Continuation cont, void *cont_cls)
Add hello to peerstore.
@ GNUNET_PEERSTORE_STOREOPTION_REPLACE
Delete any previous values for the given key before storing the given value.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START
Iteration request (see also 828, 829)
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT
Iteration request (see also 821, 829)
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP
Iteration request (see also 821, 828)
#define GNUNET_MESSAGE_TYPE_PEERSTORE_RECORD
Record result message.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END
Iteration end message.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_STORE_RESULT
Store result message.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:617
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Definition: peer.c:68
IPC messages.
static void handle_iterate_result(void *cls, const struct PeerstoreRecordMessage *msg)
When a response for iterate request is received.
static void handle_client_error(void *cls, enum GNUNET_MQ_Error error)
Function called when we had trouble talking to the service.
static void hello_add_iter(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
static void handle_iterate_end(void *cls, const struct PeerstoreResultMessage *msg)
When a response for iterate request is received.
static uint32_t get_op_id(struct GNUNET_PEERSTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
static int check_iterate_result(void *cls, const struct PeerstoreRecordMessage *msg)
When a response for iterate request is received, check the message is well-formed.
static void handle_store_result(void *cls, const struct PeerstoreResultMessage *msg)
When a response for store request is received.
static void disconnect_and_schedule_reconnect(struct GNUNET_PEERSTORE_Handle *h)
Function that will schedule the job that will try to connect us again to the client.
static void disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the peerstore service.
static void destroy_iteratecontext(struct GNUNET_PEERSTORE_IterateContext *ic)
static void destroy_storecontext(struct GNUNET_PEERSTORE_StoreContext *sc)
#define LOG(kind,...)
Definition: peerstore_api.c:34
static void hello_store_success(void *cls, int success)
struct GNUNET_PEERSTORE_Record * PEERSTORE_parse_record_message(const struct PeerstoreRecordMessage *srm)
Parses a message carrying a record.
struct GNUNET_MQ_Envelope * PEERSTORE_create_record_mq_envelope(uint32_t rid, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, const void *value, size_t value_size, struct GNUNET_TIME_Absolute expiry, enum GNUNET_PEERSTORE_StoreOption options, uint16_t msg_type)
Creates a MQ envelope for a single record.
void PEERSTORE_destroy_record(struct GNUNET_PEERSTORE_Record *record)
Free any memory allocated for this record.
Helper peerstore functions.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Internal representation of the hash map.
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1598
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1515
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:205
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
Handle to the PEERSTORE service.
Definition: peerstore_api.c:44
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:73
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:53
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
Definition: peerstore_api.c:88
struct GNUNET_PEERSTORE_StoreContext * store_tail
Tail of active STORE requests.
Definition: peerstore_api.c:63
struct GNUNET_PEERSTORE_StoreContext * store_head
Head of active STORE requests.
Definition: peerstore_api.c:58
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:68
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: peerstore_api.c:48
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
Definition: peerstore_api.c:83
struct GNUNET_CONTAINER_MultiHashMap * watches
Hashmap of watch requests.
Definition: peerstore_api.c:78
Context for a iterate request.
char * sub_system
Which subsystem does the store?
void * callback_cls
Closure for callback.
char * key
Key for the store operation.
GNUNET_PEERSTORE_Processor callback
Callback with each matching record.
struct GNUNET_PEERSTORE_IterateContext * prev
Kept in a DLL.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
struct GNUNET_MQ_Envelope * env
Temporary envelope.
struct GNUNET_PEERSTORE_IterateContext * next
Kept in a DLL.
struct GNUNET_PeerIdentity peer
Peer the store is for.
Context for a monitor.
Context for the info handler.
void * callback_cls
Closure for callback.
GNUNET_PEERSTORE_hello_notify_cb callback
Function to call with information.
unsigned int canceled
Is this request canceled.
struct GNUNET_PEERSTORE_Monitor * wc
The watch for this context.
struct GNUNET_PEERSTORE_Handle * h
Peerstore handle.
Single PEERSTORE record.
Context for a store request.
char * sub_system
Which subsystem does the store?
enum GNUNET_PEERSTORE_StoreOption options
Options for the store operation.
void * value
Contains size bytes.
struct GNUNET_TIME_Absolute expiry
When does the value expire?
struct GNUNET_PEERSTORE_StoreContext * prev
Kept in a DLL.
void * cont_cls
Closure for cont.
struct GNUNET_MQ_Envelope * env
Temporary envelope.
struct GNUNET_PEERSTORE_StoreContext * next
Kept in a DLL.
size_t size
Number of bytes in value.
struct GNUNET_PEERSTORE_Handle * h
Handle to the PEERSTORE service.
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
struct GNUNET_PeerIdentity peer
Peer the store is for.
char * key
Key for the store operation.
Context for a add hello uri request.
struct GNUNET_MessageHeader * hello
Hello uri which was request for storing.
struct GNUNET_PEERSTORE_Handle * h
Peerstore handle.
struct GNUNET_PEERSTORE_IterateContext * ic
The iteration for the merge.
GNUNET_PEERSTORE_Continuation cont
Function to call with information.
struct GNUNET_PeerIdentity pid
The peer id for the hello.
struct GNUNET_PEERSTORE_StoreContext * sc
Store operation for the merge.
void * cont_cls
Closure for callback.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Iteration next message.
Definition: peerstore.h:248
uint32_t rid
Request id.
Definition: peerstore.h:262
uint64_t limit
Number of records to return.
Definition: peerstore.h:257
Iteration start message.
Definition: peerstore.h:202
uint16_t peer_set
GNUNET_YES if peer id value set, GNUNET_NO otherwise
Definition: peerstore.h:221
struct GNUNET_PeerIdentity peer
Peer Identity.
Definition: peerstore.h:211
uint32_t rid
Request id.
Definition: peerstore.h:216
uint16_t sub_system_size
Size of the sub_system string Allocated at position 0 after this struct.
Definition: peerstore.h:227
uint16_t key_size
Size of the key string Allocated at position 1 after this struct.
Definition: peerstore.h:238
uint32_t rid
Request id.
Definition: peerstore.h:275
Message carrying a PEERSTORE record message.
Definition: peerstore.h:38
Message carrying a PEERSTORE result message.
Definition: peerstore.h:96
Closure for store callback when storing hello uris.
struct GNUNET_PEERSTORE_StoreHelloContext * huc
The corresponding hello uri add request.
struct GNUNET_PEERSTORE_StoreContext * sc
The corresponding store context.