GNUnet  0.10.x
Typedefs | Functions
Name Store service

Store naming information on a GNUnet node. More...

Typedefs

typedef void(* GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, int32_t success, const char *emsg)
 Continuation called to notify client about result of the operation. More...
 
typedef void(* GNUNET_NAMESTORE_RecordMonitor) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore. More...
 

Functions

struct GNUNET_NAMESTORE_HandleGNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the namestore service. More...
 
void GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
 Disconnect from the namestore service (and free associated resources). More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Store an item in the namestore. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *nick, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Set the desired nick name for a zone. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
 Lookup an item in the namestore. More...
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
 Look for an existing PKEY delegation record for a given public key. More...
 
void GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
 Cancel a namestore operation. More...
 
struct GNUNET_NAMESTORE_ZoneIteratorGNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
 Starts a new zone iteration (used to periodically PUT all of our records into our DHT). More...
 
void GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
 Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record. More...
 
void GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
 Stops iteration and releases the namestore handle for further calls. More...
 
struct GNUNET_NAMESTORE_ZoneMonitorGNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls)
 Begin monitoring a zone for changes. More...
 
void GNUNET_NAMESTORE_zone_monitor_next (struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
 Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s). More...
 
void GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm)
 Stop monitoring a zone for changes. More...
 

Detailed Description

Store naming information on a GNUnet node.

Naming information can either be records for which this peer/user is authoritative, or blocks which are cached, encrypted naming data from other peers.

See also
Documentation

Typedef Documentation

◆ GNUNET_NAMESTORE_ContinuationWithStatus

typedef void(* GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, int32_t success, const char *emsg)

Continuation called to notify client about result of the operation.

Parameters
clsclosure
successGNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) GNUNET_NO if content was already there or not found GNUNET_YES (or other positive value) on success
emsgNULL on success, otherwise an error message

Definition at line 102 of file gnunet_namestore_service.h.

◆ GNUNET_NAMESTORE_RecordMonitor

typedef void(* GNUNET_NAMESTORE_RecordMonitor) (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)

Process a record that was stored in the namestore.

Parameters
clsclosure
zoneprivate key of the zone
labellabel of the records
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store

Definition at line 147 of file gnunet_namestore_service.h.

Function Documentation

◆ GNUNET_NAMESTORE_connect()

struct GNUNET_NAMESTORE_Handle* GNUNET_NAMESTORE_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the namestore service.

Parameters
cfgconfiguration to use
Returns
handle to use to access the service

Connect to the namestore service.

Parameters
cfgconfiguration to use
Returns
handle to the GNS service, or NULL on error

Definition at line 885 of file namestore_api.c.

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

Referenced by GNUNET_CONVERSATION_phone_create(), RECLAIM_TICKETS_init(), rest_identity_process_request(), rest_process_request(), run(), and run_with_zone_pkey().

886 {
887  struct GNUNET_NAMESTORE_Handle *h;
888 
889  h = GNUNET_new (struct GNUNET_NAMESTORE_Handle);
890  h->cfg = cfg;
891  reconnect (h);
892  if (NULL == h->mq)
893  {
894  GNUNET_free (h);
895  return NULL;
896  }
897  return h;
898 }
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Connection to the NAMESTORE service.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void reconnect(struct GNUNET_NAMESTORE_Handle *h)
Reconnect to namestore service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_disconnect()

void GNUNET_NAMESTORE_disconnect ( struct GNUNET_NAMESTORE_Handle h)

Disconnect from the namestore service (and free associated resources).

Must not be called from within operation callbacks of the API.

Parameters
hhandle to the namestore
hhandle to the namestore

Definition at line 908 of file namestore_api.c.

References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_NAMESTORE_Handle::mq, GNUNET_NAMESTORE_Handle::op_head, GNUNET_NAMESTORE_Handle::op_tail, q, GNUNET_NAMESTORE_Handle::reconnect_task, GNUNET_NAMESTORE_Handle::z_head, and GNUNET_NAMESTORE_Handle::z_tail.

Referenced by cleanup(), cleanup_handle(), do_shutdown(), GNUNET_CONVERSATION_phone_destroy(), RECLAIM_TICKETS_deinit(), and shutdown_task().

909 {
912 
913  LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
914  GNUNET_break (NULL == h->op_head);
915  while (NULL != (q = h->op_head))
916  {
918  GNUNET_free (q);
919  }
920  GNUNET_break (NULL == h->z_head);
921  while (NULL != (z = h->z_head))
922  {
924  GNUNET_free (z);
925  }
926  if (NULL != h->mq)
927  {
928  GNUNET_MQ_destroy (h->mq);
929  h->mq = NULL;
930  }
931  if (NULL != h->reconnect_task)
932  {
934  h->reconnect_task = NULL;
935  }
936  GNUNET_free (h);
937 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for a zone iterator operation.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
struct GNUNET_NAMESTORE_QueueEntry * op_tail
Tail of pending namestore queue entries.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
#define LOG(kind,...)
Definition: namestore_api.c:41
struct GNUNET_NAMESTORE_QueueEntry * op_head
Head of pending namestore queue entries.
struct GNUNET_NAMESTORE_ZoneIterator * z_head
Head of pending namestore zone iterator entries.
struct GNUNET_SCHEDULER_Task * reconnect_task
Reconnect task.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_NAMESTORE_ZoneIterator * z_tail
Tail of pending namestore zone iterator entries.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_records_store()

struct GNUNET_NAMESTORE_QueueEntry* GNUNET_NAMESTORE_records_store ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey pkey,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
GNUNET_NAMESTORE_ContinuationWithStatus  cont,
void *  cont_cls 
)

Store an item in the namestore.

If the item is already present, it is replaced with the new record. Use an empty array to remove all records under the given name.

The continuation is called after the value has been stored in the database. Monitors may be notified asynchronously (basically with a buffer). However, if any monitor is consistently too slow to keep up with the changes, calling cont will be delayed until the monitors do keep up.

Parameters
hhandle to the namestore
pkeyprivate key of the zone
labelname that is being mapped
rd_countnumber of records in the 'rd' array
rdarray of records with data to store
contcontinuation to call when done
cont_clsclosure for cont
Returns
handle to abort the request

If the item is already present, it is replaced with the new record. Use an empty array to remove all records under the given name.

Parameters
hhandle to the namestore
pkeyprivate key of the zone
labelname that is being mapped (at most 255 characters long)
rd_countnumber of records in the rd array
rdarray of records with data to store
contcontinuation to call when done
cont_clsclosure for cont
Returns
handle to abort the request

Definition at line 980 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::cont, GNUNET_NAMESTORE_QueueEntry::cont_cls, GNUNET_NAMESTORE_QueueEntry::env, get_op_id(), RecordStoreMessage::gns_header, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_NAMESTORE_QueueEntry::h, LOG, MAX_NAME_LEN, GNUNET_NAMESTORE_Handle::mq, msg, RecordStoreMessage::name_len, NAMESTORE_DELAY_TOLERANCE, GNUNET_NAMESTORE_Handle::op_head, GNUNET_NAMESTORE_QueueEntry::op_id, GNUNET_NAMESTORE_Handle::op_tail, pkey, RecordStoreMessage::private_key, qe, GNUNET_NAMESTORE_Header::r_id, RecordStoreMessage::rd_count, RecordStoreMessage::rd_len, RecordStoreMessage::reserved, GNUNET_NAMESTORE_QueueEntry::timeout_task, and warn_delay().

Referenced by attr_store_task(), del_monitor(), get_existing_record(), GNUNET_NAMESTORE_set_nick(), handle_attribute_delete_message(), issue_ticket(), move_attr_finished(), namestore_delete(), ns_lookup_cb(), process_result(), process_tickets(), revoke_attrs_cb(), run_with_zone_pkey(), rvk_move_attr_cb(), update_tickets(), and zone_to_name_cb().

988 {
990  struct GNUNET_MQ_Envelope *env;
991  char *name_tmp;
992  char *rd_ser;
993  ssize_t rd_ser_len;
994  size_t name_len;
995  uint32_t rid;
996  struct RecordStoreMessage *msg;
997  ssize_t sret;
998 
999  name_len = strlen (label) + 1;
1000  if (name_len > MAX_NAME_LEN)
1001  {
1002  GNUNET_break (0);
1003  return NULL;
1004  }
1005  rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1006  if (rd_ser_len < 0)
1007  {
1008  GNUNET_break (0);
1009  return NULL;
1010  }
1011  if (rd_ser_len > UINT16_MAX)
1012  {
1013  GNUNET_break (0);
1014  return NULL;
1015  }
1016  rid = get_op_id (h);
1018  qe->h = h;
1019  qe->cont = cont;
1020  qe->cont_cls = cont_cls;
1021  qe->op_id = rid;
1023 
1024  /* setup msg */
1025  env = GNUNET_MQ_msg_extra (msg,
1026  name_len + rd_ser_len,
1028  msg->gns_header.r_id = htonl (rid);
1029  msg->name_len = htons (name_len);
1030  msg->rd_count = htons (rd_count);
1031  msg->rd_len = htons (rd_ser_len);
1032  msg->reserved = htons (0);
1033  msg->private_key = *pkey;
1034 
1035  name_tmp = (char *) &msg[1];
1036  GNUNET_memcpy (name_tmp, label, name_len);
1037  rd_ser = &name_tmp[name_len];
1038  sret = GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_ser);
1039  if ((0 > sret) || (sret != rd_ser_len))
1040  {
1041  GNUNET_break (0);
1042  GNUNET_free (env);
1043  return NULL;
1044  }
1045  GNUNET_assert (rd_ser_len == sret);
1047  "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n",
1048  label,
1049  rd_count);
1050  qe->timeout_task =
1052  if (NULL == h->mq)
1053  {
1054  qe->env = env;
1056  "Delaying NAMESTORE_RECORD_STORE message as namestore is not ready!\n");
1057  }
1058  else
1059  {
1060  GNUNET_MQ_send (h->mq, env);
1061  }
1062  return qe;
1063 }
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
Definition: namestore_api.c:69
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE.
Definition: namestore.h:63
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static char * pkey
Public key of the zone to look in, in ASCII.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t reserved
always zero (for alignment)
Definition: namestore.h:88
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#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:52
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:1246
uint16_t rd_len
Length of serialized record data.
Definition: namestore.h:78
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
Client to service: store records (as authority)
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
#define NAMESTORE_DELAY_TOLERANCE
We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail...
Definition: namestore_api.c:47
uint16_t name_len
Name length.
Definition: namestore.h:73
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
static void warn_delay(void *cls)
Task launched to warn the user that the namestore is excessively slow and that a query was thus dropp...
uint16_t rd_count
Number of records contained.
Definition: namestore.h:83
struct GNUNET_NAMESTORE_QueueEntry * op_tail
Tail of pending namestore queue entries.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
uint32_t op_id
The operation id this zone iteration operation has.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
GNUNET_NAMESTORE_ContinuationWithStatus cont
Continuation to call.
Definition: namestore_api.c:74
#define LOG(kind,...)
Definition: namestore_api.c:41
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key of the authority.
Definition: namestore.h:93
Store a record to the namestore (as authority).
Definition: namestore.h:58
void * cont_cls
Closure for cont.
Definition: namestore_api.c:79
struct GNUNET_NAMESTORE_QueueEntry * op_head
Head of pending namestore queue entries.
#define MAX_NAME_LEN
Maximum length of any name, including 0-termination.
Definition: namecache.h:33
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
struct GNUNET_SCHEDULER_Task * timeout_task
Task scheduled to warn us if the namestore is way too slow.
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:353
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_set_nick()

struct GNUNET_NAMESTORE_QueueEntry* GNUNET_NAMESTORE_set_nick ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey pkey,
const char *  nick,
GNUNET_NAMESTORE_ContinuationWithStatus  cont,
void *  cont_cls 
)

Set the desired nick name for a zone.

Parameters
hhandle to the namestore
pkeyprivate key of the zone
nickthe nick name to set
contcontinuation to call when done
cont_clsclosure for cont
Returns
handle to abort the request

Definition at line 1077 of file namestore_api.c.

References GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_TYPE_NICK, GNUNET_NAMESTORE_records_store(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_NAMESTORE_Handle::mq, and GNUNET_GNSRECORD_Data::record_type.

Referenced by run_with_zone_pkey().

1082 {
1083  struct GNUNET_GNSRECORD_Data rd;
1084 
1085  if (NULL == h->mq)
1086  return NULL;
1087  memset (&rd, 0, sizeof (rd));
1088  rd.data = nick;
1089  rd.data_size = strlen (nick) + 1;
1090  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
1091  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
1092  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
1094  pkey,
1096  1,
1097  &rd,
1098  cont,
1099  cont_cls);
1100 }
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
#define GNUNET_GNSRECORD_TYPE_NICK
Record type for GNS nick names ("NICK").
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
This is a private record of this peer and it should thus not be handed out to other peers...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_records_lookup()

struct GNUNET_NAMESTORE_QueueEntry* GNUNET_NAMESTORE_records_lookup ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey pkey,
const char *  label,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  rm,
void *  rm_cls 
)

Lookup an item in the namestore.

Parameters
hhandle to the namestore
pkeyprivate key of the zone
labelname that is being mapped
error_cbfunction to call on error (i.e. disconnect) the handle is afterwards invalid
error_cb_clsclosure for error_cb
rmfunction to call with the result (with 0 records if we don't have that label); the handle is afterwards invalid
rm_clsclosure for rm
Returns
handle to abort the request
Parameters
hhandle to the namestore
pkeyprivate key of the zone
labelname that is being mapped (at most 255 characters long)
error_cbfunction to call on error (i.e. disconnect)
error_cb_clsclosure for error_cb
rmfunction to call with the result (with 0 records if we don't have that label)
rm_clsclosure for rm
Returns
handle to abort the request

Definition at line 1116 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::env, GNUNET_NAMESTORE_QueueEntry::error_cb, GNUNET_NAMESTORE_QueueEntry::error_cb_cls, get_op_id(), LabelLookupMessage::gns_header, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_NAMESTORE_QueueEntry::h, LabelLookupMessage::label_len, GNUNET_NAMESTORE_Handle::mq, msg, GNUNET_NAMESTORE_Handle::op_head, GNUNET_NAMESTORE_QueueEntry::op_id, GNUNET_NAMESTORE_Handle::op_tail, pkey, GNUNET_NAMESTORE_QueueEntry::proc, GNUNET_NAMESTORE_QueueEntry::proc_cls, qe, GNUNET_NAMESTORE_Header::r_id, and LabelLookupMessage::zone.

Referenced by move_attrs(), namestore_add(), RECLAIM_TICKETS_revoke(), and run_with_zone_pkey().

1124 {
1126  struct GNUNET_MQ_Envelope *env;
1127  struct LabelLookupMessage *msg;
1128  size_t label_len;
1129 
1130  if (1 == (label_len = strlen (label) + 1))
1131  {
1132  GNUNET_break (0);
1133  return NULL;
1134  }
1135 
1137  qe->h = h;
1138  qe->error_cb = error_cb;
1139  qe->error_cb_cls = error_cb_cls;
1140  qe->proc = rm;
1141  qe->proc_cls = rm_cls;
1142  qe->op_id = get_op_id (h);
1144 
1145  env = GNUNET_MQ_msg_extra (msg,
1146  label_len,
1148  msg->gns_header.r_id = htonl (qe->op_id);
1149  msg->zone = *pkey;
1150  msg->label_len = htonl (label_len);
1151  GNUNET_memcpy (&msg[1], label, label_len);
1152  if (NULL == h->mq)
1153  qe->env = env;
1154  else
1155  GNUNET_MQ_send (h->mq, env);
1156  return qe;
1157 }
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
Definition: namestore_api.c:69
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t label_len
Length of the name.
Definition: namestore.h:132
static char * pkey
Public key of the zone to look in, in ASCII.
GNUNET_NAMESTORE_RecordMonitor proc
Function to call with the records we get back; or NULL.
Definition: namestore_api.c:84
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: namestore_api.c:94
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
Client to service: lookup label.
void * proc_cls
Closure for proc.
Definition: namestore_api.c:89
void * error_cb_cls
Closure for error_cb.
Definition: namestore_api.c:99
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#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:52
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
struct GNUNET_NAMESTORE_QueueEntry * op_tail
Tail of pending namestore queue entries.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
uint32_t op_id
The operation id this zone iteration operation has.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_NAMESTORE_QueueEntry * op_head
Head of pending namestore queue entries.
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP.
Definition: namestore.h:127
Lookup a label.
Definition: namestore.h:122
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:353
struct GNUNET_CRYPTO_EcdsaPrivateKey zone
The private key of the zone to look up in.
Definition: namestore.h:137
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_to_name()

struct GNUNET_NAMESTORE_QueueEntry* GNUNET_NAMESTORE_zone_to_name ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const struct GNUNET_CRYPTO_EcdsaPublicKey value_zone,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  proc,
void *  proc_cls 
)

Look for an existing PKEY delegation record for a given public key.

Returns at most one result to the processor.

Parameters
hhandle to the namestore
zoneprivate key of the zone to look up in, never NULL
value_zonepublic key of the target zone (value), never NULL
error_cbfunction to call on error (i.e. disconnect) the handle is afterwards invalid
error_cb_clsclosure for error_cb
procfunction to call on the matching records, or with NULL (rd_count == 0) if there are no matching records; the handle is afterwards invalid
proc_clsclosure for proc
Returns
a handle that can be used to cancel

Returns at most one result to the processor.

Parameters
hhandle to the namestore
zonepublic key of the zone to look up in, never NULL
value_zonepublic key of the target zone (value), never NULL
error_cbfunction to call on error (i.e. disconnect)
error_cb_clsclosure for error_cb
procfunction to call on the matching records, or with NULL (rd_count == 0) if there are no matching records
proc_clsclosure for proc
Returns
a handle that can be used to cancel

Definition at line 1176 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::env, GNUNET_NAMESTORE_QueueEntry::error_cb, GNUNET_NAMESTORE_QueueEntry::error_cb_cls, get_op_id(), ZoneToNameMessage::gns_header, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NAMESTORE_QueueEntry::h, GNUNET_NAMESTORE_Handle::mq, msg, GNUNET_NAMESTORE_Handle::op_head, GNUNET_NAMESTORE_QueueEntry::op_id, GNUNET_NAMESTORE_Handle::op_tail, GNUNET_NAMESTORE_QueueEntry::proc, GNUNET_NAMESTORE_QueueEntry::proc_cls, qe, GNUNET_NAMESTORE_Header::r_id, ZoneToNameMessage::value_zone, ZoneToNameMessage::zone, and zone.

Referenced by lookup_it_finished(), and run_with_zone_pkey().

1184 {
1186  struct GNUNET_MQ_Envelope *env;
1187  struct ZoneToNameMessage *msg;
1188  uint32_t rid;
1189 
1190  rid = get_op_id (h);
1192  qe->h = h;
1193  qe->error_cb = error_cb;
1194  qe->error_cb_cls = error_cb_cls;
1195  qe->proc = proc;
1196  qe->proc_cls = proc_cls;
1197  qe->op_id = rid;
1199 
1201  msg->gns_header.r_id = htonl (rid);
1202  msg->zone = *zone;
1203  msg->value_zone = *value_zone;
1204  if (NULL == h->mq)
1205  qe->env = env;
1206  else
1207  GNUNET_MQ_send (h->mq, env);
1208  return qe;
1209 }
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
Definition: namestore_api.c:69
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_NAMESTORE_RecordMonitor proc
Function to call with the records we get back; or NULL.
Definition: namestore_api.c:84
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: namestore_api.c:94
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME.
Definition: namestore.h:197
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
void * proc_cls
Closure for proc.
Definition: namestore_api.c:89
void * error_cb_cls
Closure for error_cb.
Definition: namestore_api.c:99
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static char * zone
Name of the zone we manage.
struct GNUNET_CRYPTO_EcdsaPublicKey value_zone
The public key of the target zone.
Definition: namestore.h:207
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
Client to service: "reverse" lookup for zone name based on zone key.
struct GNUNET_NAMESTORE_QueueEntry * op_tail
Tail of pending namestore queue entries.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
uint32_t op_id
The operation id this zone iteration operation has.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_CRYPTO_EcdsaPrivateKey zone
The private key of the zone to look up in.
Definition: namestore.h:202
struct GNUNET_NAMESTORE_QueueEntry * op_head
Head of pending namestore queue entries.
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
Lookup a name for a zone hash.
Definition: namestore.h:192
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:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_cancel()

void GNUNET_NAMESTORE_cancel ( struct GNUNET_NAMESTORE_QueueEntry qe)

Cancel a namestore operation.

The final callback from the operation must not have been done yet. Must be called on any namestore operation that has not yet completed prior to calling GNUNET_NAMESTORE_disconnect.

Parameters
qeoperation to cancel

The final callback from the operation must not have been done yet.

Parameters
qeoperation to cancel

Definition at line 1330 of file namestore_api.c.

References free_qe().

Referenced by cleanup_adh(), cleanup_as_handle(), cleanup_handle(), cleanup_issue_handle(), cleanup_rvk(), do_shutdown(), request_completed_callback(), and warn_delay().

1331 {
1332  free_qe (qe);
1333 }
static void free_qe(struct GNUNET_NAMESTORE_QueueEntry *qe)
Free qe.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_iteration_start()

struct GNUNET_NAMESTORE_ZoneIterator* GNUNET_NAMESTORE_zone_iteration_start ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  proc,
void *  proc_cls,
GNUNET_SCHEDULER_TaskCallback  finish_cb,
void *  finish_cb_cls 
)

Starts a new zone iteration (used to periodically PUT all of our records into our DHT).

This MUST lock the struct GNUNET_NAMESTORE_Handle for any other calls than GNUNET_NAMESTORE_zone_iterator_next() and GNUNET_NAMESTORE_zone_iteration_stop. proc will be called once immediately, and then again after GNUNET_NAMESTORE_zone_iterator_next() is invoked.

On error (disconnect), error_cb will be invoked. On normal completion, finish_cb proc will be invoked.

Parameters
hhandle to the namestore
zonezone to access, NULL for all zones
error_cbfunction to call on error (i.e. disconnect), the handle is afterwards invalid
error_cb_clsclosure for error_cb
procfunction to call on each name from the zone; it will be called repeatedly with a value (if available)
proc_clsclosure for proc
finish_cbfunction to call on completion the handle is afterwards invalid
finish_cb_clsclosure for finish_cb
Returns
an iterator handle to use for iteration

This MUST lock the struct GNUNET_NAMESTORE_Handle for any other calls than GNUNET_NAMESTORE_zone_iterator_next and GNUNET_NAMESTORE_zone_iteration_stop. proc will be called once immediately, and then again after GNUNET_NAMESTORE_zone_iterator_next is invoked.

Parameters
hhandle to the namestore
zonezone to access, NULL for all zones
error_cbfunction to call on error (i.e. disconnect)
error_cb_clsclosure for error_cb
procfunction to call on each name from the zone; it will be called repeatedly with a value (if available)
proc_clsclosure for proc
finish_cbfunction to call on completion
finish_cb_clsclosure for finish_cb
Returns
an iterator handle to use for iteration

Definition at line 1232 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::env, GNUNET_NAMESTORE_ZoneIterator::env, GNUNET_NAMESTORE_QueueEntry::error_cb, GNUNET_NAMESTORE_ZoneIterator::error_cb, GNUNET_NAMESTORE_QueueEntry::error_cb_cls, GNUNET_NAMESTORE_ZoneIterator::error_cb_cls, GNUNET_NAMESTORE_ZoneIterator::finish_cb, GNUNET_NAMESTORE_ZoneIterator::finish_cb_cls, get_op_id(), ZoneIterationStartMessage::gns_header, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NAMESTORE_QueueEntry::h, GNUNET_NAMESTORE_ZoneIterator::h, LOG, GNUNET_NAMESTORE_Handle::mq, msg, GNUNET_NAMESTORE_ZoneIterator::op_id, GNUNET_NAMESTORE_QueueEntry::proc, GNUNET_NAMESTORE_ZoneIterator::proc, GNUNET_NAMESTORE_QueueEntry::proc_cls, GNUNET_NAMESTORE_ZoneIterator::proc_cls, GNUNET_NAMESTORE_Header::r_id, GNUNET_NAMESTORE_Handle::z_head, GNUNET_NAMESTORE_Handle::z_tail, GNUNET_NAMESTORE_ZoneIterator::zone, zone, and ZoneIterationStartMessage::zone.

Referenced by create_response(), get_ego(), handle_collect(), handle_iteration_start(), iterate_zones(), move_attrs(), namestore_get(), publish_zone_dht_start(), RECLAIM_TICKETS_issue(), RECLAIM_TICKETS_iteration_start(), run_with_zone_pkey(), start_ticket_update(), and update_zoneinfo_page().

1241 {
1242  struct GNUNET_NAMESTORE_ZoneIterator *it;
1243  struct GNUNET_MQ_Envelope *env;
1245  uint32_t rid;
1246 
1247  LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1248  rid = get_op_id (h);
1250  it->h = h;
1251  it->error_cb = error_cb;
1252  it->error_cb_cls = error_cb_cls;
1253  it->finish_cb = finish_cb;
1254  it->finish_cb_cls = finish_cb_cls;
1255  it->proc = proc;
1256  it->proc_cls = proc_cls;
1257  it->op_id = rid;
1258  if (NULL != zone)
1259  it->zone = *zone;
1262  msg->gns_header.r_id = htonl (rid);
1263  if (NULL != zone)
1264  msg->zone = *zone;
1265  if (NULL == h->mq)
1266  it->env = env;
1267  else
1268  GNUNET_MQ_send (h->mq, env);
1269  return it;
1270 }
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
GNUNET_NAMESTORE_RecordMonitor proc
The continuation to call with the results.
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
uint32_t op_id
The operation id this zone iteration operation has.
Start a zone iteration for the given zone.
Definition: namestore.h:350
void * proc_cls
Closure for proc.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * error_cb_cls
Closure for error_cb.
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static char * zone
Name of the zone we manage.
Handle for a zone iterator operation.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START.
Definition: namestore.h:355
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
Client to service: please start iteration; receives "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPON...
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define LOG(kind,...)
Definition: namestore_api.c:41
void * finish_cb_cls
Closure for error_cb.
struct GNUNET_NAMESTORE_ZoneIterator * z_head
Head of pending namestore zone iterator entries.
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
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:353
struct GNUNET_NAMESTORE_ZoneIterator * z_tail
Tail of pending namestore zone iterator entries.
struct GNUNET_CRYPTO_EcdsaPrivateKey zone
Zone key.
Definition: namestore.h:360
struct GNUNET_CRYPTO_EcdsaPrivateKey zone
Private key of the zone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_iterator_next()

void GNUNET_NAMESTORE_zone_iterator_next ( struct GNUNET_NAMESTORE_ZoneIterator it,
uint64_t  limit 
)

Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record.

Parameters
itthe iterator
limitnumber of records to return to the iterator in one shot (before GNUNET_NAMESTORE_zone_iterator_next is to be called again)

Definition at line 1282 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::env, ZoneIterationNextMessage::gns_header, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NAMESTORE_QueueEntry::h, GNUNET_NAMESTORE_ZoneIterator::h, ZoneIterationNextMessage::limit, LOG, GNUNET_NAMESTORE_Handle::mq, msg, GNUNET_NAMESTORE_ZoneIterator::op_id, and GNUNET_NAMESTORE_Header::r_id.

Referenced by attr_iter_cb(), collect_next(), collect_tickets_cb(), display_record(), display_record_iterator(), filter_tickets_cb(), handle_iteration_next(), iterate_cb(), lookup_it_processor(), namestore_list_iteration(), ns_lookup_result_cb(), publish_zone_namestore_next(), RECLAIM_TICKETS_iteration_next(), rvk_ticket_update(), ticket_iter(), and zone_iterator().

1284 {
1285  struct GNUNET_NAMESTORE_Handle *h = it->h;
1286  struct ZoneIterationNextMessage *msg;
1287  struct GNUNET_MQ_Envelope *env;
1288 
1290  "Sending ZONE_ITERATION_NEXT message with limit %llu\n",
1291  (unsigned long long) limit);
1293  msg->gns_header.r_id = htonl (it->op_id);
1294  msg->limit = GNUNET_htonll (limit);
1295  GNUNET_MQ_send (h->mq, env);
1296 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Ask for next result of zone iteration for the given operation.
Definition: namestore.h:368
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
uint32_t op_id
The operation id this zone iteration operation has.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Connection to the NAMESTORE service.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
Client to service: next record(s) in iteration please.
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define LOG(kind,...)
Definition: namestore_api.c:41
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:353
uint64_t limit
Number of records to return to the iterator in one shot (before GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_IT...
Definition: namestore.h:380
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT.
Definition: namestore.h:373
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_iteration_stop()

void GNUNET_NAMESTORE_zone_iteration_stop ( struct GNUNET_NAMESTORE_ZoneIterator it)

Stops iteration and releases the namestore handle for further calls.

Must be called on any iteration that has not yet completed prior to calling GNUNET_NAMESTORE_disconnect.

Parameters
itthe iterator
itthe iterator

Definition at line 1305 of file namestore_api.c.

References GNUNET_NAMESTORE_QueueEntry::env, free_ze(), ZoneIterationStopMessage::gns_header, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NAMESTORE_QueueEntry::h, GNUNET_NAMESTORE_ZoneIterator::h, GNUNET_NAMESTORE_Handle::mq, msg, GNUNET_NAMESTORE_ZoneIterator::op_id, and GNUNET_NAMESTORE_Header::r_id.

Referenced by cleanup_adh(), cleanup_handle(), cleanup_iter(), cleanup_rvk(), do_shutdown(), filter_tickets_cb(), RECLAIM_TICKETS_iteration_stop(), and shutdown_task().

1306 {
1307  struct GNUNET_NAMESTORE_Handle *h = it->h;
1308  struct GNUNET_MQ_Envelope *env;
1309  struct ZoneIterationStopMessage *msg;
1310 
1311  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_STOP message\n");
1312  if (NULL != h->mq)
1313  {
1314  env =
1316  msg->gns_header.r_id = htonl (it->op_id);
1317  GNUNET_MQ_send (h->mq, env);
1318  }
1319  free_ze (it);
1320 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t r_id
Request ID in NBO.
Definition: namestore.h:51
uint32_t op_id
The operation id this zone iteration operation has.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
Client to service: stop iterating.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static void free_ze(struct GNUNET_NAMESTORE_ZoneIterator *ze)
Free ze.
Connection to the NAMESTORE service.
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
Stop zone iteration for the given operation.
Definition: namestore.h:388
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
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:353
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP.
Definition: namestore.h:393
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_monitor_start()

struct GNUNET_NAMESTORE_ZoneMonitor* GNUNET_NAMESTORE_zone_monitor_start ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
int  iterate_first,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  monitor,
void *  monitor_cls,
GNUNET_SCHEDULER_TaskCallback  sync_cb,
void *  sync_cb_cls 
)

Begin monitoring a zone for changes.

Will first call the monitor function on all existing records in the selected zone(s) if iterate_first is GNUNET_YES. In any case, we will then call sync_cb, and then afterwards call the monitor whenever a record changes. If the namestore disconnects, the error_cb function is called with a disconnect event. Once the connection is re-established, the process begins from the start (depending on iterate_first, we will again first do all existing records, then sync, then updates).

Parameters
cfgconfiguration to use to connect to namestore
zonezone to monitor, NULL for all zones
iterate_firstGNUNET_YES to first iterate over all existing records, GNUNET_NO to only return changes that happen from now on
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_NAMESTORE_zone_monitor_stop().
error_cb_clsclosure for error_cb
monitorfunction to call on zone changes, with an initial limit of 1
monitor_clsclosure for monitor
sync_cbfunction called when we're in sync with the namestore
sync_cb_clsclosure for sync_cb
Returns
handle to stop monitoring

If iterate_first is set, we Will first call the monitor function on all existing records in the selected zone(s). In any case, we will call sync and afterwards call monitor whenever a record changes.

Parameters
cfgconfiguration to use to connect to namestore
zonezone to monitor
iterate_firstGNUNET_YES to first iterate over all existing records, GNUNET_NO to only return changes that happen from now on
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_NAMESTORE_zone_monitor_stop().
error_cb_clsclosure for error_cb
monitorfunction to call on zone changes
monitor_clsclosure for monitor
sync_cbfunction called when we're in sync with the namestore
clsclosure for sync_cb
Returns
handle to stop monitoring

Definition at line 303 of file namestore_api_monitor.c.

References GNUNET_NAMESTORE_ZoneMonitor::cfg, GNUNET_NAMESTORE_ZoneMonitor::error_cb, GNUNET_NAMESTORE_ZoneMonitor::error_cb_cls, GNUNET_free, GNUNET_new, GNUNET_NAMESTORE_ZoneMonitor::iterate_first, GNUNET_NAMESTORE_ZoneMonitor::monitor, GNUNET_NAMESTORE_ZoneMonitor::monitor_cls, GNUNET_NAMESTORE_ZoneMonitor::mq, reconnect(), GNUNET_NAMESTORE_ZoneMonitor::sync_cb, GNUNET_NAMESTORE_ZoneMonitor::sync_cb_cls, zm, and GNUNET_NAMESTORE_ZoneMonitor::zone.

Referenced by run(), and run_with_zone_pkey().

313 {
315 
317  if (NULL != zone)
318  zm->zone = *zone;
320  zm->error_cb = error_cb;
322  zm->monitor = monitor;
323  zm->monitor_cls = monitor_cls;
324  zm->sync_cb = sync_cb;
325  zm->sync_cb_cls = sync_cb_cls;
326  zm->cfg = cfg;
327  reconnect (zm);
328  if (NULL == zm->mq)
329  {
330  GNUNET_free (zm);
331  return NULL;
332  }
333  return zm;
334 }
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
void * error_cb_cls
Closure for error_cb.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void reconnect(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Reconnect to the namestore service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration (to reconnect).
GNUNET_SCHEDULER_TaskCallback sync_cb
Function called when we&#39;ve synchronized.
GNUNET_NAMESTORE_RecordMonitor monitor
Function to call on events.
static char * zone
Name of the zone we manage.
Handle for a monitoring activity.
int iterate_first
Do we first iterate over all existing records?
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
void * sync_cb_cls
Closure for sync_cb.
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:59
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
struct GNUNET_CRYPTO_EcdsaPrivateKey zone
Monitored zone.
void * monitor_cls
Closure for monitor.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_monitor_next()

void GNUNET_NAMESTORE_zone_monitor_next ( struct GNUNET_NAMESTORE_ZoneMonitor zm,
uint64_t  limit 
)

Calls the monitor processor specified in GNUNET_NAMESTORE_zone_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_NAMESTORE_records_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_NAMESTORE_records_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 namestore, but not be involved in the transactions.

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

Definition at line 359 of file namestore_api_monitor.c.

References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), ZoneMonitorNextMessage::limit, and GNUNET_NAMESTORE_ZoneMonitor::mq.

Referenced by dht_put_monitor_continuation(), display_record_monitor(), handle_monitor_event(), and run().

361 {
362  struct GNUNET_MQ_Envelope *env;
363  struct ZoneMonitorNextMessage *nm;
364 
366  nm->limit = GNUNET_htonll (limit);
367  GNUNET_MQ_send (zm->mq, env);
368 }
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
Client to service: I am now ready for the next (set of) monitor events.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint64_t limit
Number of records to return to the iterator in one shot (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_M...
Definition: namestore.h:341
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Ask for next result of zone iteration for the given operation.
Definition: namestore.h:324
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:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_NAMESTORE_zone_monitor_stop()

void GNUNET_NAMESTORE_zone_monitor_stop ( struct GNUNET_NAMESTORE_ZoneMonitor zm)

Stop monitoring a zone for changes.

Parameters
zmhandle to the monitor activity to stop

Definition at line 377 of file namestore_api_monitor.c.

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

Referenced by do_shutdown(), and shutdown_task().

378 {
379  if (NULL != zm->mq)
380  {
381  GNUNET_MQ_destroy (zm->mq);
382  zm->mq = NULL;
383  }
384  GNUNET_free (zm);
385 }
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: