GNUnet 0.22.2
Peer Store service
Collaboration diagram for Peer Store service:

Data Structures

struct  GNUNET_PEERSTORE_Record
 Single PEERSTORE record. More...
 

Macros

#define GNUNET_PEERSTORE_HELLO_KEY   "peerstore-peer-hello-uri"
 Key used for storing HELLO in the peerstore. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY   "transport-communicator-url"
 Key used for storing addresses in URL format in the peerstore. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY   "transport-peer-hello"
 Key used for storing HELLOs in the peerstore. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME    "transport-backchannel-monotonic-time"
 Key used to store sender's monotonic time from backchannel messages. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME    "transport-dv-learn-monotonic-time"
 Key used to store sender's monotonic time from DV learn messages. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE    "transport-tcp-communicator-handshake"
 Key used to store sender's monotonic time from handshake message. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK    "transport-tcp-communicator-handshake-ack"
 Key used to store sender's monotonic time from handshake ack message. More...
 
#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY    "transport-tcp-communicator-rekey"
 Key used to store sender's monotonic time from rekey message. More...
 

Typedefs

typedef void(* GNUNET_PEERSTORE_Continuation) (void *cls, int success)
 Continuation called with a status result. More...
 
typedef void(* GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called by PEERSTORE for each matching record. More...
 
typedef 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. More...
 

Enumerations

enum  GNUNET_PEERSTORE_StoreOption { GNUNET_PEERSTORE_STOREOPTION_MULTIPLE = 0 , GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1 }
 Options for storing values in PEERSTORE. More...
 

Functions

struct GNUNET_PEERSTORE_StoreHelloContextGNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, const struct GNUNET_MessageHeader *msg, GNUNET_PEERSTORE_Continuation cont, void *cont_cls)
 Add hello to peerstore. More...
 
void GNUNET_PEERSTORE_hello_add_cancel (struct GNUNET_PEERSTORE_StoreHelloContext *huc)
 Cancel the request to add a hello. More...
 
struct GNUNET_PEERSTORE_HandleGNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the PEERSTORE service. More...
 
void GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h)
 Disconnect from the PEERSTORE service. More...
 
struct GNUNET_PEERSTORE_StoreContextGNUNET_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. More...
 
void GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
 Cancel a store request. More...
 
struct GNUNET_PEERSTORE_IterateContextGNUNET_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. More...
 
void GNUNET_PEERSTORE_iteration_next (struct GNUNET_PEERSTORE_IterateContext *ic, uint64_t limit)
 Continue an iteration. More...
 
void GNUNET_PEERSTORE_iteration_stop (struct GNUNET_PEERSTORE_IterateContext *ic)
 Cancel an iteration. More...
 
struct GNUNET_PEERSTORE_MonitorGNUNET_PEERSTORE_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, int iterate_first, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
 Request watching a given key The monitoring can be filtered to contain only records matching peer and/or key. More...
 
void GNUNET_PEERSTORE_monitor_next (struct GNUNET_PEERSTORE_Monitor *zm, uint64_t limit)
 Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s). More...
 
void GNUNET_PEERSTORE_monitor_stop (struct GNUNET_PEERSTORE_Monitor *zm)
 Stop monitoring. More...
 

Detailed Description

See also
Documentation

Macro Definition Documentation

◆ GNUNET_PEERSTORE_HELLO_KEY

#define GNUNET_PEERSTORE_HELLO_KEY   "peerstore-peer-hello-uri"

Key used for storing HELLO in the peerstore.

Definition at line 52 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY

#define GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY   "transport-communicator-url"

Key used for storing addresses in URL format in the peerstore.

Definition at line 57 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY

#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY   "transport-peer-hello"

Key used for storing HELLOs in the peerstore.

Definition at line 62 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME

#define GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME    "transport-backchannel-monotonic-time"

Key used to store sender's monotonic time from backchannel messages.

Definition at line 68 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME

#define GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME    "transport-dv-learn-monotonic-time"

Key used to store sender's monotonic time from DV learn messages.

Definition at line 75 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE    "transport-tcp-communicator-handshake"

Key used to store sender's monotonic time from handshake message.

Definition at line 81 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK    "transport-tcp-communicator-handshake-ack"

Key used to store sender's monotonic time from handshake ack message.

Definition at line 87 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY

#define GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY    "transport-tcp-communicator-rekey"

Key used to store sender's monotonic time from rekey message.

Definition at line 93 of file gnunet_peerstore_service.h.

Typedef Documentation

◆ GNUNET_PEERSTORE_Continuation

typedef void(* GNUNET_PEERSTORE_Continuation) (void *cls, int success)

Continuation called with a status result.

Parameters
clsclosure
successGNUNET_OK or GNUNET_SYSERR

Definition at line 174 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_Processor

typedef void(* GNUNET_PEERSTORE_Processor) (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)

Function called by PEERSTORE for each matching record.

Parameters
clsclosure
seqsequence in iteration
recordpeerstore record information
emsgerror message, or NULL if no errors

Definition at line 191 of file gnunet_peerstore_service.h.

◆ GNUNET_PEERSTORE_hello_notify_cb

typedef 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.

Parameters
clsclosure
hello_uriHello uri.

Definition at line 202 of file gnunet_peerstore_service.h.

Enumeration Type Documentation

◆ GNUNET_PEERSTORE_StoreOption

Options for storing values in PEERSTORE.

Enumerator
GNUNET_PEERSTORE_STOREOPTION_MULTIPLE 

Possibly store multiple values under given key.

GNUNET_PEERSTORE_STOREOPTION_REPLACE 

Delete any previous values for the given key before storing the given value.

Definition at line 100 of file gnunet_peerstore_service.h.

101{
106
112
113};
@ GNUNET_PEERSTORE_STOREOPTION_MULTIPLE
Possibly store multiple values under given key.
@ GNUNET_PEERSTORE_STOREOPTION_REPLACE
Delete any previous values for the given key before storing the given value.

Function Documentation

◆ GNUNET_PEERSTORE_hello_add()

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.

Parameters
hhandle for peerstore.
msgThe hello to add.
contThe continuation function to execute after storing.
cont_clsThe continuation function closure.
Returns
The context for storing.

Definition at line 922 of file peerstore_api.c.

926{
929 const struct GNUNET_PeerIdentity *pid;
931 struct GNUNET_TIME_Absolute hello_exp =
933 struct GNUNET_TIME_Absolute huc_exp;
934 uint16_t size_msg = ntohs (msg->size);
935
936 if (NULL == parser)
937 return NULL;
938 if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
939 return NULL;
940
942 huc->h = h;
943 huc->cont = cont;
944 huc->cont_cls = cont_cls;
945 huc->hello = GNUNET_malloc (size_msg);
946 GNUNET_memcpy (huc->hello, msg, size_msg);
947 huc_exp =
950 huc->pid = *pid;
952 "Adding hello for peer %s with expiration %s msg size %u\n",
953 GNUNET_i2s (&huc->pid),
955 size_msg);
956
957 huc->ic = GNUNET_PEERSTORE_iteration_start (h, "peerstore", &huc->pid,
960 huc);
962 return huc;
963}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
Definition: hello-uri.c:435
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg.
Definition: hello-uri.c:471
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
Definition: hello-uri.c:619
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id(const struct GNUNET_HELLO_Parser *parser)
Get the PeerIdentity for this builder.
Definition: hello-uri.c:412
#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.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
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.
#define GNUNET_PEERSTORE_HELLO_KEY
Key used for storing HELLO in the peerstore.
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:640
static void hello_add_iter(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
#define LOG(kind,...)
Definition: peerstore_api.c:34
Context for parsing HELLOs.
Definition: hello-uri.c:258
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.
void * cont_cls
Closure for callback.
The identity of the host (wraps the signing key of the peer).
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_PEERSTORE_StoreHelloContext::cont, GNUNET_PEERSTORE_StoreHelloContext::cont_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_msg(), GNUNET_HELLO_parser_get_id(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_iteration_start(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_cmp, GNUNET_TIME_absolute_get(), h, GNUNET_PEERSTORE_StoreHelloContext::h, GNUNET_PEERSTORE_StoreHelloContext::hello, hello_add_iter(), GNUNET_PEERSTORE_StoreHelloContext::ic, LOG, msg, consensus-simulation::parser, GNUNET_PEERSTORE_StoreHelloContext::pid, pid, and GNUNET_MessageHeader::size.

Referenced by callback_download(), handle_hello(), run(), and store_pi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_hello_add_cancel()

void GNUNET_PEERSTORE_hello_add_cancel ( struct GNUNET_PEERSTORE_StoreHelloContext huc)

Cancel the request to add a hello.

Parameters
hucThe context for storing a hello.

Definition at line 967 of file peerstore_api.c.

969{
970 if (NULL != huc->sc)
972 if (NULL != huc->ic)
974 GNUNET_free (huc->hello);
975 GNUNET_free (huc);
976}
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
struct GNUNET_PEERSTORE_StoreContext * sc
Store operation for the merge.

References GNUNET_free, GNUNET_PEERSTORE_iteration_stop(), GNUNET_PEERSTORE_store_cancel(), GNUNET_PEERSTORE_StoreHelloContext::hello, GNUNET_PEERSTORE_StoreHelloContext::ic, and GNUNET_PEERSTORE_StoreHelloContext::sc.

Referenced by cleaning_task(), GNUNET_HOSTLIST_client_stop(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_connect()

struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the PEERSTORE service.

Returns
NULL on error
Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 419 of file peerstore_api.c.

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}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static void reconnect(void *cls)
Close the existing connection to PEERSTORE and reconnect.
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
Handle to the PEERSTORE service.
Definition: peerstore_api.c:44

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_free, GNUNET_new, h, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by DHTU_gnunet_init(), GCH_init(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_server_start(), GNUNET_TRANSPORT_TESTING_start_peer(), GSF_connected_peer_init_(), run(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_disconnect()

void GNUNET_PEERSTORE_disconnect ( struct GNUNET_PEERSTORE_Handle h)

Disconnect from the PEERSTORE service.

Any pending ITERATE and WATCH and STORE requests will be canceled.

Parameters
hhandle to disconnect

Any pending ITERATE and WATCH requests will be canceled. Any pending STORE requests will depend on snyc_first flag.

Parameters
hhandle to disconnect

Definition at line 443 of file peerstore_api.c.

444{
445 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnect initiated from client.\n");
446 disconnect (h);
447 GNUNET_free (h);
448}
static void disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the peerstore service.

References disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, and LOG.

Referenced by cleaning_task(), DHTU_gnunet_done(), do_shutdown(), GCH_shutdown(), GNUNET_HOSTLIST_client_stop(), GNUNET_HOSTLIST_server_stop(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_connected_peer_done_(), shutdown_task(), and stop_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_store()

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.

Note that stored entries can be lost in some cases such as power failure.

Parameters
hHandle to the PEERSTORE service
sub_systemname of the sub system
peerPeer Identity
keyentry key
valueentry value BLOB
sizesize of value
expiryabsolute time after which the entry is (possibly) deleted
optionsoptions specific to the storage operation
contContinuation function after the store request is sent
cont_clsClosure for cont

Definition at line 501 of file peerstore_api.c.

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}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
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_MESSAGE_TYPE_PEERSTORE_STORE
Store request message.
static unsigned int size
Size of the "table".
Definition: peer.c:68
static uint32_t get_op_id(struct GNUNET_PEERSTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
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.
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 a store request.
char * sub_system
Which subsystem does the store?
struct GNUNET_TIME_Absolute expiry
When does the value expire?
void * cont_cls
Closure for cont.
GNUNET_PEERSTORE_Continuation cont
Continuation called with service response.
struct GNUNET_PeerIdentity peer
Peer the store is for.

References GNUNET_PEERSTORE_StoreContext::cont, GNUNET_PEERSTORE_StoreContext::cont_cls, GNUNET_PEERSTORE_StoreContext::expiry, get_op_id(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memdup, GNUNET_MESSAGE_TYPE_PEERSTORE_STORE, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, h, GNUNET_FS_SearchContext::h, key, LOG, GNUNET_ARM_Handle::mq, options, GNUNET_FS_SearchContext::options, GNUNET_PEERSTORE_StoreContext::peer, PEERSTORE_create_record_mq_envelope(), sc, size, GNUNET_PEERSTORE_StoreContext::sub_system, and value.

Referenced by flush_respect(), handle_dv_learn(), handle_validation_response(), handshake_ack_monotime_cb(), handshake_monotime_cb(), rekey_monotime_cb(), shc_cont(), and update_backtalker_monotime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_store_cancel()

void GNUNET_PEERSTORE_store_cancel ( struct GNUNET_PEERSTORE_StoreContext sc)

Cancel a store request.

Parameters
scStore request context

Definition at line 472 of file peerstore_api.c.

473{
475 "store cancel with sc %p \n",
476 sc);
479 "store cancel with sc %p is null\n",
480 sc);
481}
static void destroy_storecontext(struct GNUNET_PEERSTORE_StoreContext *sc)

References destroy_storecontext(), GNUNET_ERROR_TYPE_DEBUG, LOG, and sc.

Referenced by free_address_list_entry(), free_backtalker(), free_neighbour(), free_validation_state(), handle_dv_learn(), and queue_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_iteration_start()

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.

The iteration can be filtered to contain only records matching peer and/or key. The sub_system to match must be provided. callback will be called with (each) matching record. GNUNET_PEERSTORE_iteration_next() must be invoked to continue processing until the end of the iteration is reached.

Parameters
hhandle to the PEERSTORE service
sub_systemname of sub system
peerPeer identity (can be NULL)
keyentry key string (can be NULL)
callbackfunction called with each matching record. The record will be NULL to indicate end.
callback_clsclosure for callback
Returns
Handle to iteration request

Definition at line 741 of file peerstore_api.c.

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}
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
@ GNUNET_YES
#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:61
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START
Iteration request (see also 828, 829)
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_Handle * h
Handle to the PEERSTORE service.
struct GNUNET_PeerIdentity peer
Peer the store is for.
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

References GNUNET_PEERSTORE_IterateContext::callback, GNUNET_PEERSTORE_IterateContext::callback_cls, dummy, get_op_id(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_START, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_strdup, GNUNET_YES, h, GNUNET_PEERSTORE_IterateContext::h, key, GNUNET_PEERSTORE_IterateContext::key, PeerstoreIterationStartMessage::key_size, LOG, GNUNET_ARM_Handle::mq, PeerstoreIterationStartMessage::peer, GNUNET_PEERSTORE_IterateContext::peer, PeerstoreIterationStartMessage::peer_set, PeerstoreIterationStartMessage::rid, GNUNET_PEERSTORE_IterateContext::rid, GNUNET_PEERSTORE_IterateContext::sub_system, and PeerstoreIterationStartMessage::sub_system_size.

Referenced by decrypt_and_check_tc(), do_rekey(), GNUNET_PEERSTORE_hello_add(), GNUNET_TRANSPORT_TESTING_restart_peer(), GSF_peer_connect_handler(), handle_add_queue_message(), handle_dv_box(), queue_burst(), retrieve_hello(), run(), and try_handle_plaintext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_iteration_next()

void GNUNET_PEERSTORE_iteration_next ( struct GNUNET_PEERSTORE_IterateContext ic,
uint64_t  limit 
)

Continue an iteration.

Do NOT call after the iterate request is done.

Parameters
icIterate request context as returned by GNUNET_PEERSTORE_iteration_start()
limithow many records to return max until #GNUNET_PEERSTORE_iterate_next() needs to be called again.

Continue an iteration.

Parameters
icIterate request context as returned by GNUNET_PEERSTORE_iterate()

Definition at line 693 of file peerstore_api.c.

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}
#define GNUNET_log(kind,...)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT
Iteration request (see also 821, 829)
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:53
struct GNUNET_MQ_Envelope * env
Temporary envelope.
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

References GNUNET_PEERSTORE_IterateContext::env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_log, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_PEERSTORE_IterateContext::h, PeerstoreIterationNextMessage::limit, GNUNET_PEERSTORE_Handle::mq, PeerstoreIterationNextMessage::rid, and GNUNET_PEERSTORE_IterateContext::rid.

Referenced by backtalker_monotime_cb(), handshake_ack_monotime_cb(), handshake_ack_monotime_store_cb(), handshake_monotime_cb(), handshake_monotime_store_cb(), hello_add_iter(), hello_iter(), neighbour_dv_monotime_cb(), peer_respect_cb(), rekey_monotime_cb(), and rekey_monotime_store_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_iteration_stop()

void GNUNET_PEERSTORE_iteration_stop ( struct GNUNET_PEERSTORE_IterateContext ic)

Cancel an iteration.

Do NOT call after the iterate request is done

Parameters
icIterate request context as returned by GNUNET_PEERSTORE_iteration_start()

Cancel an iteration.

Parameters
icIterate request context as returned by GNUNET_PEERSTORE_iterate()

Definition at line 722 of file peerstore_api.c.

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}
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP
Iteration request (see also 821, 828)
static void destroy_iteratecontext(struct GNUNET_PEERSTORE_IterateContext *ic)
uint32_t rid
Request id.
Definition: peerstore.h:275

References destroy_iteratecontext(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_PEERSTORE_IterateContext::h, GNUNET_PEERSTORE_Handle::mq, PeerstoreIterationStopMessage::rid, and GNUNET_PEERSTORE_IterateContext::rid.

Referenced by check_for_burst_address(), free_backtalker(), free_neighbour(), GNUNET_PEERSTORE_hello_add_cancel(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSF_peer_disconnect_handler(), handshake_ack_monotime_cb(), handshake_monotime_cb(), hello_add_iter(), hello_iter(), hello_iter_cb(), peer_respect_cb(), queue_destroy(), rekey_monotime_cb(), shutdown_task(), and stop_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_monitor_start()

struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start ( const struct GNUNET_CONFIGURATION_Handle cfg,
int  iterate_first,
const char *  sub_system,
const struct GNUNET_PeerIdentity peer,
const char *  key,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_SCHEDULER_TaskCallback  sync_cb,
void *  sync_cb_cls,
GNUNET_PEERSTORE_Processor  callback,
void *  callback_cls 
)

Request watching a given key The monitoring can be filtered to contain only records matching peer and/or key.

The sub_system to match must be provided. callback will be called with (each) matching new record. GNUNET_PEERSTORE_monitor_next() must be invoked to continue processing until sync_cb is called, indicating that the caller should be up-to-date. The caller will be notified with any new values added to key through callback. If iterate_first is set to GNUNET_YES, the monitor will first iterate over all existing, matching records. In any case, after sync_cb is called the first time monitoring starts.

Parameters
hhandle to the PEERSTORE service
iterate_firstfirst iterated of all results if GNUNET_YES
sub_systemname of sub system
peerPeer identity
keyentry key string
error_cbfunction to call on error (i.e. disconnect); note that unlike the other error callbacks in this API, a call to this function does NOT destroy the monitor handle, it merely signals that monitoring is down. You need to still explicitly call GNUNET_PEERSTORE_monitor_stop().
error_cb_clsclosure for error_cb
sync_cbfunction called when we're in sync with the peerstore
sync_cb_clsclosure for sync_cb
callbackfunction called with each new value
callback_clsclosure for callback
Returns
Handle to watch request

Definition at line 239 of file peerstore_api_monitor.c.

251{
253
255 mc->callback = callback;
256 mc->callback_cls = callback_cls;
257 mc->sync_cb = sync_cb;
258 mc->sync_cb_cls = sync_cb_cls;
259 mc->error_cb = error_cb;
260 mc->error_cb_cls = error_cb_cls;
261 mc->key = key;
262 mc->peer = peer;
263 mc->iterate_first = iterate_first;
264 mc->sub_system = GNUNET_strdup (sub_system);
265 mc->cfg = cfg;
266 reconnect (mc);
267 if (NULL == mc->mq)
268 {
269 GNUNET_free (mc);
270 return NULL;
271 }
272 return mc;
273}
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:480
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static void reconnect(struct GNUNET_PEERSTORE_Monitor *mc)
Context for a monitor.
void * error_cb_cls
Closure for error_cb.
void * callback_cls
Closure for callback.
const struct GNUNET_PeerIdentity * peer
The peer we are watching for values.
int iterate_first
Iterate first flag.
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
char * sub_system
The sub system requested the watch.

References GNUNET_PEERSTORE_Monitor::callback, GNUNET_PEERSTORE_Monitor::callback_cls, cfg, error_cb(), GNUNET_PEERSTORE_Monitor::error_cb_cls, GNUNET_free, GNUNET_new, GNUNET_strdup, GNUNET_PEERSTORE_Monitor::iterate_first, key, mc, GNUNET_PEERSTORE_Monitor::peer, reconnect(), GNUNET_PEERSTORE_Monitor::sub_system, sync_cb(), and GNUNET_PEERSTORE_Monitor::sync_cb_cls.

Referenced by core_init_cb(), GCH_init(), handle_add_queue_message(), handle_suggest(), handle_validation_challenge(), process_peer(), run(), and start_notify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_monitor_next()

void GNUNET_PEERSTORE_monitor_next ( struct GNUNET_PEERSTORE_Monitor zm,
uint64_t  limit 
)

Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).

This function is used to allow clients that merely monitor the NAMESTORE to still throttle namestore operations, so we can be sure that the monitors can keep up.

Note that GNUNET_PEERSTORE_store() only waits for this call if the previous limit set by the client was already reached. Thus, by using a limit greater than 1, monitors basically enable a queue of notifications to be processed asynchronously with some delay. Note that even with a limit of 1 the GNUNET_PEERSTORE_store() function will run asynchronously and the continuation may be invoked before the monitors completed (or even started) processing the notification. Thus, monitors will only closely track the current state of the peerstore, but not be involved in the transactions.

Parameters
zmthe monitor
limitnumber of records to return to the iterator in one shot (before GNUNET_PEERSTORE_monitor_next is to be called again)

Definition at line 295 of file peerstore_api_monitor.c.

297{
298 struct GNUNET_MQ_Envelope *env;
300
302 nm->limit = GNUNET_htonll (limit);
304}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT
Monitor next request.
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
Iteration next message.
Definition: peerstore.h:185
uint64_t limit
Number of records to return.
Definition: peerstore.h:194

References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), PeerstoreMonitorNextMessage::limit, GNUNET_NAMESTORE_ZoneMonitor::mq, and zm.

Referenced by check_for_global_natted(), got_hello(), handle_hello_for_client(), handle_hello_for_incoming(), peerinfo_cb(), process_notify(), process_peer(), and process_peerinfo_peers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PEERSTORE_monitor_stop()

void GNUNET_PEERSTORE_monitor_stop ( struct GNUNET_PEERSTORE_Monitor zm)

Stop monitoring.

Parameters
zmhandle to the monitor activity to stop

Definition at line 282 of file peerstore_api_monitor.c.

283{
284 if (NULL != zm->mq)
285 {
287 zm->mq = NULL;
288 }
289 GNUNET_free (zm->sub_system);
290 GNUNET_free (zm);
291}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NAMESTORE_ZoneMonitor::mq, and zm.

Referenced by cleaning_task(), DHTU_gnunet_done(), free_incoming_request(), free_queue(), GCH_shutdown(), GNUNET_HOSTLIST_server_stop(), process_peer(), shutdown_task(), and stop_peer_request().

Here is the call graph for this function:
Here is the caller graph for this function: