GNUnet 0.21.1
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 interation
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 906 of file peerstore_api.c.

910{
913 const struct GNUNET_PeerIdentity *pid;
915 struct GNUNET_TIME_Absolute hello_exp =
917 struct GNUNET_TIME_Absolute huc_exp;
918 uint16_t size_msg = ntohs (msg->size);
919
920 if (NULL == builder)
921 return NULL;
922 if (GNUNET_TIME_absolute_cmp (hello_exp, <, now))
923 return NULL;
924
926 huc->h = h;
927 huc->cont = cont;
928 huc->cont_cls = cont_cls;
929 huc->hello = GNUNET_malloc (size_msg);
930 GNUNET_memcpy (huc->hello, msg, size_msg);
931 huc_exp =
934 huc->pid = *pid;
936 "Adding hello for peer %s with expiration %s msg size %u\n",
937 GNUNET_i2s (&huc->pid),
939 size_msg);
940
941 huc->ic = GNUNET_PEERSTORE_iteration_start (h, "peerstore", &huc->pid,
944 huc);
946 return huc;
947}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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:617
static void hello_add_iter(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
#define LOG(kind,...)
Definition: peerstore_api.c:36
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:205
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
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 builder, GNUNET_PEERSTORE_StoreHelloContext::cont, GNUNET_PEERSTORE_StoreHelloContext::cont_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_builder_free(), GNUNET_HELLO_builder_from_msg(), GNUNET_HELLO_builder_get_expiration_time(), GNUNET_HELLO_builder_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, GNUNET_PEERSTORE_StoreHelloContext::pid, pid, and GNUNET_MessageHeader::size.

Referenced by callback_download(), handle_hello(), 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 951 of file peerstore_api.c.

953{
954 if (NULL != huc->sc)
956 if (NULL != huc->ic)
958 GNUNET_free (huc->hello);
959 GNUNET_free (huc);
960}
#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(), and GNUNET_HOSTLIST_client_stop().

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 421 of file peerstore_api.c.

422{
424
426 h->cfg = cfg;
427 reconnect (h);
428 if (NULL == h->mq)
429 {
430 GNUNET_free (h);
431 return NULL;
432 }
433 return h;
434}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
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:46

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 445 of file peerstore_api.c.

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

References disconnect(), GNUNET_ERROR_TYPE_DEBUG, 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 496 of file peerstore_api.c.

506{
507 struct GNUNET_MQ_Envelope *ev;
509
511 "Storing value (size: %llu) for subsystem `%s', peer `%s', key `%s'\n",
512 (unsigned long long) size,
515 key);
517 sc->rid = get_op_id (h);
518 sc->sub_system = GNUNET_strdup (sub_system);
519 GNUNET_assert (NULL != peer);
520 sc->peer = *peer;
521 sc->key = GNUNET_strdup (key);
522 sc->value = GNUNET_memdup (value, size);
523 sc->size = size;
524 sc->expiry = expiry;
525 sc->options = options;
526 sc->cont = cont;
527 sc->cont_cls = cont_cls;
528 sc->h = h;
529 ev =
532 peer,
533 key,
534 value,
535 size,
536 expiry,
537 options,
539
540 GNUNET_CONTAINER_DLL_insert_tail (h->store_head, h->store_tail, sc);
541 if (NULL == h->mq)
542 {
543 sc->env = ev;
544 }
545 else
546 {
547 GNUNET_MQ_send (h->mq, ev);
548 }
549 return sc;
550}
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:304
#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 463 of file peerstore_api.c.

464{
466 "store cancel with sc %p \n",
467 sc);
468 GNUNET_CONTAINER_DLL_remove (sc->h->store_head, sc->h->store_tail, sc);
469 GNUNET_free (sc->sub_system);
470 GNUNET_free (sc->value);
471 GNUNET_free (sc->key);
472 GNUNET_free (sc);
474 "store cancel with sc %p is null\n",
475 sc);
476}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_FS_SearchContext::h, 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 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 730 of file peerstore_api.c.

736{
737 struct GNUNET_MQ_Envelope *ev;
740 size_t ss_size;
741 size_t key_size;
742 size_t msg_size;
743 void *dummy;
744
746 ic->rid = get_op_id (h);
747
748 GNUNET_assert (NULL != sub_system);
749 ss_size = strlen (sub_system) + 1;
750 if (NULL == key)
751 key_size = 0;
752 else
753 key_size = strlen (key) + 1;
754 msg_size = ss_size + key_size;
755 ev = GNUNET_MQ_msg_extra (srm, msg_size,
757 srm->key_size = htons (key_size);
758 srm->rid = htons (ic->rid);
759 srm->sub_system_size = htons (ss_size);
760 dummy = &srm[1];
761 GNUNET_memcpy (dummy, sub_system, ss_size);
762 dummy += ss_size;
763 GNUNET_memcpy (dummy, key, key_size);
764 ic->callback = callback;
766 ic->h = h;
768 if (NULL != peer)
769 {
770 ic->peer = *peer;
771 srm->peer_set = htons (GNUNET_YES);
772 srm->peer = *peer;
773 }
774 if (NULL != key)
775 ic->key = GNUNET_strdup (key);
776 GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, h->iterate_tail, ic);
778 "Sending an iterate request for sub system `%s'\n",
779 sub_system);
780 GNUNET_MQ_send (h->mq, ev);
781 return ic;
782}
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:63
#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(), retrieve_hello(), 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 679 of file peerstore_api.c.

681{
682 struct GNUNET_MQ_Envelope *ev;
684
686 "Sending PEERSTORE_ITERATION_NEXT message\n");
688 inm->rid = htons (ic->rid);
689 inm->limit = GNUNET_htonll (limit);
690 if (NULL == ic->h->mq)
691 {
692 ic->env = ev;
693 }
694 else
695 {
696 GNUNET_MQ_send (ic->h->mq, ev);
697 }
698}
#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:78
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_NEXT
Iteration request (see also 821, 829)
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: peerstore_api.c:55
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(), 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 708 of file peerstore_api.c.

709{
710 struct GNUNET_MQ_Envelope *ev;
712
714 "Sending PEERSTORE_ITERATION_STOP message\n");
715 if (NULL != ic->h->mq)
716 {
718 ism->rid = htons (ic->rid);
719 if (NULL != ic->h->mq)
720 GNUNET_MQ_send (ic->h->mq, ev);
721 }
724 GNUNET_free (ic->key);
725 GNUNET_free (ic);
726}
#define GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP
Iteration request (see also 821, 828)
struct GNUNET_PEERSTORE_IterateContext * iterate_tail
Tail of active ITERATE requests.
Definition: peerstore_api.c:75
struct GNUNET_PEERSTORE_IterateContext * iterate_head
Head of active ITERATE requests.
Definition: peerstore_api.c:70
uint32_t rid
Request id.
Definition: peerstore.h:275

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_PEERSTORE_IterateContext::h, GNUNET_PEERSTORE_Handle::iterate_head, GNUNET_PEERSTORE_Handle::iterate_tail, GNUNET_PEERSTORE_IterateContext::key, GNUNET_PEERSTORE_Handle::mq, PeerstoreIterationStopMessage::rid, GNUNET_PEERSTORE_IterateContext::rid, and GNUNET_PEERSTORE_IterateContext::sub_system.

Referenced by 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_cb(), peer_respect_cb(), queue_destroy(), rekey_monotime_cb(), 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 240 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:479
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.
const char * sub_system
The sub system requested the watch.
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.

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 294 of file peerstore_api_monitor.c.

296{
297 struct GNUNET_MQ_Envelope *env;
299
301 nm->limit = GNUNET_htonll (limit);
303}
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);
290}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683

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: