GNUnet 0.25.2-12-g8d1cef5f6
 
Loading...
Searching...
No Matches
Name Store service

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

Collaboration diagram for Name Store service:

Data Structures

struct  GNUNET_NAMESTORE_RecordInfo
 A struct for record bulk import. More...
 

Typedefs

typedef void(* GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, enum GNUNET_ErrorCode ec)
 Continuation called to notify client about result of the operation.
 
typedef void(* GNUNET_NAMESTORE_RecordMonitor) (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore.
 
typedef void(* GNUNET_NAMESTORE_EditRecordSetBeginCallback) (void *cls, enum GNUNET_ErrorCode ec, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, const char *editor_hint)
 Process a record that was stored in the namestore.
 
typedef void(* GNUNET_NAMESTORE_RecordSetMonitor) (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
 Process a record set that was stored in the namestore.
 

Enumerations

enum  GNUNET_NAMESTORE_TxControl { GNUNET_NAMESTORE_TX_BEGIN = 0 , GNUNET_NAMESTORE_TX_COMMIT = 1 , GNUNET_NAMESTORE_TX_ROLLBACK = 2 }
 Transaction control types. More...
 

Functions

struct GNUNET_NAMESTORE_HandleGNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the namestore service.
 
void GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
 Disconnect from the namestore service (and free associated resources).
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *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_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, unsigned int rd_set_count, const struct GNUNET_NAMESTORE_RecordInfo *record_info, unsigned int *rds_sent, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Store one or more record sets in the namestore.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_store_ (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, int is_zonemaster, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
 Store an item in the namestore.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *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.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_records_lookup2 (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, enum GNUNET_GNSRECORD_Filter filter)
 Lookup an item in the namestore with GNSRECORD filter.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const struct GNUNET_CRYPTO_BlindablePublicKey *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.
 
void GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
 Cancel a namestore operation.
 
struct GNUNET_NAMESTORE_ZoneIteratorGNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *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)
 
struct GNUNET_NAMESTORE_ZoneIteratorGNUNET_NAMESTORE_zone_iteration_start2 (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
 Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
 
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.
 
void GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
 Stops iteration and releases the namestore handle for further calls.
 
struct GNUNET_NAMESTORE_ZoneMonitorGNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_BlindablePrivateKey *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)
 
struct GNUNET_NAMESTORE_ZoneMonitorGNUNET_NAMESTORE_zone_monitor_start2 (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
 Begin monitoring a zone for changes.
 
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).
 
void GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm)
 Stop monitoring a zone for changes.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_edit_begin (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, const char *editor_hint, GNUNET_NAMESTORE_EditRecordSetBeginCallback edit_cb, void *edit_cb_cls)
 New API draft.
 
struct GNUNET_NAMESTORE_QueueEntryGNUNET_NAMESTORE_record_set_edit_cancel (struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, const char *editor_hint, const char *editor_hint_replacement, GNUNET_NAMESTORE_ContinuationWithStatus finished_cb, void *finished_cls)
 If the current advisory lock is set to the provided editor hint, this API cancels the editing of a record set and unsets the advisory lock in database.
 

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, enum GNUNET_ErrorCode ec)

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
ecthe GNUNET_ErrorCode, GNUNET_EC_NONE on success.

Definition at line 127 of file gnunet_namestore_service.h.

◆ GNUNET_NAMESTORE_RecordMonitor

typedef void(* GNUNET_NAMESTORE_RecordMonitor) (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *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 245 of file gnunet_namestore_service.h.

◆ GNUNET_NAMESTORE_EditRecordSetBeginCallback

typedef void(* GNUNET_NAMESTORE_EditRecordSetBeginCallback) (void *cls, enum GNUNET_ErrorCode ec, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, const char *editor_hint)

Process a record that was stored in the namestore.

Parameters
clsclosure
ecthe error code. GNUNET_EC_NONE on success.
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store
editor_hintthe advisory lock value that was replaced. NULL of not advisory lock was set or if lock was equal to provided editor hint.

Definition at line 262 of file gnunet_namestore_service.h.

◆ GNUNET_NAMESTORE_RecordSetMonitor

typedef void(* GNUNET_NAMESTORE_RecordSetMonitor) (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)

Process a record set that was stored in the namestore.

The record set expiration value takes existing TOMBSTONE records into account even if those are not returned.

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
expirythe expiration of this record set.

Definition at line 282 of file gnunet_namestore_service.h.

Enumeration Type Documentation

◆ GNUNET_NAMESTORE_TxControl

Transaction control types.

They roughly correspond to DB transaction controls

Enumerator
GNUNET_NAMESTORE_TX_BEGIN 
GNUNET_NAMESTORE_TX_COMMIT 
GNUNET_NAMESTORE_TX_ROLLBACK 

Definition at line 77 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 1040 of file namestore_api.c.

1041{
1042 struct GNUNET_NAMESTORE_Handle *h;
1043
1045 h->cfg = cfg;
1046 reconnect (h);
1047 if (NULL == h->mq)
1048 {
1049 GNUNET_free (h);
1050 return NULL;
1051 }
1052 return h;
1053}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
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
Connection to the NAMESTORE service.

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

Referenced by create_handle(), GNUNET_CONVERSATION_phone_create(), namestore_import(), RECLAIM_TICKETS_init(), REST_namestore_init(), run(), run(), run(), run(), run(), run(), run(), run(), and store_cb().

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 1063 of file namestore_api.c.

1064{
1067
1068 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
1069 GNUNET_break (NULL == h->op_head);
1070 while (NULL != (q = h->op_head))
1071 {
1072 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
1073 GNUNET_free (q);
1074 }
1075 GNUNET_break (NULL == h->z_head);
1076 while (NULL != (z = h->z_head))
1077 {
1078 GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
1079 GNUNET_free (z);
1080 }
1081 if (NULL != h->mq)
1082 {
1084 h->mq = NULL;
1085 }
1086 if (NULL != h->reconnect_task)
1087 {
1089 h->reconnect_task = NULL;
1090 }
1091 GNUNET_free (h);
1092}
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
#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.
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
#define LOG(kind,...)
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition arm_api.c:147
An QueueEntry used to store information for a pending NAMESTORE record operation.
Handle for a zone iterator operation.

References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), h, LOG, GNUNET_ARM_Handle::mq, q, and GNUNET_ARM_Handle::reconnect_task.

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

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

◆ GNUNET_NAMESTORE_record_set_store()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey 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.

This always overwrites the record set and unsets any advisory lock inrrespective of the currently set editor hint/advisory lock value.

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

Definition at line 1121 of file namestore_api.c.

1129{
1131 unsigned int rds_sent;
1132 ri.a_label = label;
1133 ri.a_rd_count = rd_count;
1134 ri.a_rd = (struct GNUNET_GNSRECORD_Data *) rd;
1135 return GNUNET_NAMESTORE_records_store (h, pkey, 1, &ri, &rds_sent,
1136 cont, cont_cls);
1137}
static char * pkey
Public key of the zone to look in, in ASCII.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, unsigned int rd_set_count, const struct GNUNET_NAMESTORE_RecordInfo *record_info, unsigned int *rds_sent, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store one or more record sets in the namestore.
A struct for record bulk import.
enum GNUNET_TIME_RounderInterval ri
Definition time.c:1251

References GNUNET_NAMESTORE_RecordInfo::a_label, GNUNET_NAMESTORE_records_store(), h, pkey, rd, rd_count, and ri.

Referenced by attr_store_task(), cred_add_cb(), del_monitor(), DID_create_namestore_lookup_cb(), get_existing_record(), get_existing_record(), handle_attribute_delete_message(), handle_credential_delete_message(), issue_ticket(), missing_zone_creation_cont(), move_attr_finished(), namestore_delete(), ns_lookup_cb(), process_queue(), process_result(), process_tickets(), purge_attributes(), purge_next_record(), remove_did_document_ego_lookup_cb(), revoke_attrs_cb(), run_with_zone_pkey(), rvk_move_attr_cb(), store_handle_epoch_key(), and update_tickets().

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_BlindablePrivateKey pkey,
unsigned int  rd_set_count,
const struct GNUNET_NAMESTORE_RecordInfo record_info,
unsigned int *  rds_sent,
GNUNET_NAMESTORE_ContinuationWithStatus  cont,
void *  cont_cls 
)

Store one or more record sets in the namestore.

If any 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 records have been stored in the database. They may not yet have been committed. Monitors may be notified asynchronously (basically with a buffer when committed). 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. Uncommitted store requests within a transaction (GNUNET_NAMESTORE_transaction_begin) cause cont to be called immediately before the commit and before notification of monitors.

This always overwrites the record set and unsets any advisory lock inrrespective of the currently set editor hint/advisory lock value.

Parameters
hhandle to the namestore
pkeyprivate key of the zone
rd_set_countthe number of record sets
record_infothe records to add containing rd_set_count records
contcontinuation to call when done
rds_sentset to how many record sets could actually be sent
cont_clsclosure for cont
Returns
handle to abort the request

Definition at line 1141 of file namestore_api.c.

1149{
1151 struct GNUNET_MQ_Envelope *env;
1152 const char *label;
1153 unsigned int rd_count;
1154 const struct GNUNET_GNSRECORD_Data *rd;
1155 char *name_tmp;
1156 char *rd_ser;
1157 ssize_t rd_ser_len[rd_set_count];
1158 size_t name_len;
1159 uint32_t rid;
1160 struct RecordStoreMessage *msg;
1161 struct RecordSet *rd_set;
1162 ssize_t sret;
1163 int i;
1164 size_t rd_set_len = 0;
1165 size_t key_len = 0;
1166 size_t max_len;
1168 max_len = UINT16_MAX - key_len - sizeof (struct RecordStoreMessage);
1169
1170 *rds_sent = 0;
1171 for (i = 0; i < rd_set_count; i++)
1172 {
1173 label = record_info[i].a_label;
1175 rd = record_info[i].a_rd;
1176 name_len = strlen (label) + 1;
1177 if (name_len > MAX_NAME_LEN)
1178 {
1179 GNUNET_break (0);
1180 *rds_sent = 0;
1181 return NULL;
1182 }
1184 if (rd_ser_len[i] < 0)
1185 {
1186 GNUNET_break (0);
1187 *rds_sent = 0;
1188 return NULL;
1189 }
1190 if (rd_ser_len[i] > max_len)
1191 {
1192 GNUNET_break (0);
1193 *rds_sent = 0;
1194 return NULL;
1195 }
1196 if ((rd_set_len + sizeof (struct RecordSet) + name_len + rd_ser_len[i]) >
1197 max_len)
1198 break;
1199 rd_set_len += sizeof (struct RecordSet) + name_len + rd_ser_len[i];
1200 }
1201 *rds_sent = i;
1203 "Sending %u of %u records!\n", *rds_sent, rd_set_count);
1204 rid = get_op_id (h);
1206 qe->h = h;
1207 qe->cont = cont;
1208 qe->cont_cls = cont_cls;
1209 qe->op_id = rid;
1210 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1211 /* setup msg */
1213 key_len + rd_set_len,
1215 GNUNET_assert (NULL != msg);
1216 GNUNET_assert (NULL != env);
1217 msg->gns_header.r_id = htonl (rid);
1218 msg->key_len = htons (key_len);
1219 msg->single_tx = htons (GNUNET_YES);
1220 msg->rd_set_count = htons ((uint16_t) (*rds_sent));
1222 &msg[1],
1223 key_len);
1224 rd_set = (struct RecordSet*) (((char*) &msg[1]) + key_len);
1225 for (i = 0; i < *rds_sent; i++)
1226 {
1227 label = record_info[i].a_label;
1228 rd = record_info[i].a_rd;
1229 name_len = strlen (label) + 1;
1230 rd_set->name_len = htons (name_len);
1231 rd_set->rd_count = htons (record_info[i].a_rd_count);
1232 rd_set->rd_len = htons (rd_ser_len[i]);
1233 rd_set->reserved = ntohs (0);
1234 name_tmp = (char *) &rd_set[1];
1235 GNUNET_memcpy (name_tmp, label, name_len);
1236 rd_ser = &name_tmp[name_len];
1237 sret = GNUNET_GNSRECORD_records_serialize (record_info[i].a_rd_count,
1238 rd, rd_ser_len[i], rd_ser);
1239 if ((0 > sret) || (sret != rd_ser_len[i]))
1240 {
1241 GNUNET_break (0);
1242 GNUNET_free (env);
1243 return NULL;
1244 }
1245 // Point to next RecordSet
1246 rd_set = (struct RecordSet*) &name_tmp[name_len + rd_ser_len[i]];
1247 }
1249 "Sending NAMESTORE_RECORD_STORE message for name %u record sets\n",
1250 *rds_sent);
1251 qe->timeout_task =
1253 if (NULL == h->mq)
1254 {
1255 qe->env = env;
1257 "Delaying NAMESTORE_RECORD_STORE message as namestore is not ready!\n")
1258 ;
1259 }
1260 else
1261 {
1262 GNUNET_MQ_send (h->mq, env);
1263 }
1264 return qe;
1265}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static struct GNUNET_NAMESTORE_RecordInfo * record_info
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
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.
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_write_blindable_sk_to_buffer(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePrivateKey to a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
ssize_t GNUNET_CRYPTO_blindable_sk_get_length(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePrivateKey.
Definition crypto_pkey.c:64
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
Client to service: store records (as authority)
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:1277
#define MAX_NAME_LEN
Maximum length of any name, including 0-termination.
Definition namecache.h:33
#define NAMESTORE_DELAY_TOLERANCE
We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail.
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...
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
GNUNET_DATASTORE_ContinuationWithStatus cont
Function to call after transmission of the request.
void * cont_cls
Closure for cont.
struct GNUNET_GNSRECORD_Data * a_rd
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:64
uint16_t rd_count
Number of records contained.
Definition namestore.h:69
uint16_t reserved
Reserved for alignment.
Definition namestore.h:74
uint16_t name_len
Name length.
Definition namestore.h:59
Store a record to the namestore (as authority).
Definition namestore.h:87
uint16_t rd_set_count
Number of record sets.
Definition namestore.h:107

References GNUNET_NAMESTORE_RecordInfo::a_label, GNUNET_NAMESTORE_RecordInfo::a_rd, GNUNET_NAMESTORE_RecordInfo::a_rd_count, GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, env, GNUNET_DATASTORE_QueueEntry::env, get_op_id(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_YES, h, GNUNET_DATASTORE_QueueEntry::h, LOG, MAX_NAME_LEN, GNUNET_ARM_Handle::mq, msg, RecordSet::name_len, NAMESTORE_DELAY_TOLERANCE, pkey, qe, rd, rd_count, RecordSet::rd_count, RecordSet::rd_len, RecordStoreMessage::rd_set_count, record_info, RecordSet::reserved, and warn_delay().

Referenced by batch_insert_recordinfo(), bulk_tx_start(), GNUNET_NAMESTORE_record_set_store(), and import_next_cb().

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

◆ GNUNET_NAMESTORE_record_set_store_()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store_ ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey pkey,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
int  is_zonemaster,
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
is_zonemasterupdate tombstones, do not process monitors
contcontinuation to call when done
cont_clsclosure for cont
Returns
handle to abort the request

◆ GNUNET_NAMESTORE_records_lookup()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey 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

Definition at line 1322 of file namestore_api.c.

1330{
1331 return records_lookup (h, pkey, label,
1332 error_cb, error_cb_cls,
1333 rm, rm_cls, GNUNET_GNSRECORD_FILTER_NONE);
1334
1335}
static void error_cb(void *cls)
Function called if lookup fails.
Definition gnunet-abd.c:484
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
static struct GNUNET_NAMESTORE_QueueEntry * records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, enum GNUNET_GNSRECORD_Filter filter)

References error_cb(), GNUNET_NAMESTORE_QueueEntry::error_cb_cls, GNUNET_GNSRECORD_FILTER_NONE, h, pkey, and records_lookup().

Referenced by cred_store_task(), DID_create(), handle_collect(), move_attrs(), namestore_add_or_update(), RECLAIM_TICKETS_revoke(), run_with_zone_pkey(), and store_cb().

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

◆ GNUNET_NAMESTORE_records_lookup2()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup2 ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey pkey,
const char *  label,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor  rm,
void *  rm_cls,
enum GNUNET_GNSRECORD_Filter  filter 
)

Lookup an item in the namestore with GNSRECORD filter.

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
filterthe record set filter to use
Returns
handle to abort the request

Definition at line 1339 of file namestore_api.c.

1348{
1349 return records_lookup (h, pkey, label,
1350 error_cb, error_cb_cls,
1351 rm, rm_cls, filter);
1352
1353}
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.

References error_cb(), GNUNET_NAMESTORE_QueueEntry::error_cb_cls, filter, h, pkey, and records_lookup().

Referenced by namestore_get(), and run_with_zone_pkey().

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_BlindablePrivateKey zone,
const struct GNUNET_CRYPTO_BlindablePublicKey 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

Definition at line 1357 of file namestore_api.c.

1365{
1367 struct GNUNET_MQ_Envelope *env;
1368 struct ZoneToNameMessage *msg;
1369 uint32_t rid;
1370 size_t key_len;
1371 ssize_t pkey_len;
1372
1373 rid = get_op_id (h);
1375 qe->h = h;
1376 qe->error_cb = error_cb;
1377 qe->error_cb_cls = error_cb_cls;
1378 qe->proc = proc;
1379 qe->proc_cls = proc_cls;
1380 qe->op_id = rid;
1381 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1382
1387 msg->gns_header.r_id = htonl (rid);
1388 msg->key_len = htons (key_len);
1389 msg->pkey_len = htons (pkey_len);
1392 (char*) &msg[1] + key_len,
1393 pkey_len);
1394 if (NULL == h->mq)
1395 qe->env = env;
1396 else
1397 GNUNET_MQ_send (h->mq, env);
1398 return qe;
1399}
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:85
ssize_t GNUNET_CRYPTO_write_blindable_pk_to_buffer(const struct GNUNET_CRYPTO_BlindablePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePublicKey to a compact buffer.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
Client to service: "reverse" lookup for zone name based on zone key.
Lookup a name for a zone hash.
Definition namestore.h:341
uint16_t pkey_len
Length of the public value zone key.
Definition namestore.h:355
uint16_t key_len
Length of the zone key.
Definition namestore.h:350

References env, GNUNET_DATASTORE_QueueEntry::env, error_cb(), get_op_id(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_write_blindable_pk_to_buffer(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, ZoneToNameMessage::key_len, GNUNET_ARM_Handle::mq, msg, ZoneToNameMessage::pkey_len, and qe.

Referenced by run_with_zone_pkey().

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 1553 of file namestore_api.c.

1554{
1555 free_qe (qe);
1556}
static void free_qe(struct GNUNET_NAMESTORE_QueueEntry *qe)
Free qe.

References free_qe(), and qe.

Referenced by cleanup_adh(), cleanup_as_handle(), cleanup_handle(), cleanup_issue_handle(), cleanup_rvk(), destroy_epoch_announcement(), destroy_epoch_group(), do_shutdown(), do_shutdown(), do_shutdown(), do_shutdown(), reset_handles(), store_handle_epoch_key(), and warn_delay().

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_BlindablePrivateKey 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 
)
Deprecated:
since 0.16.7 will be replaced in 0.18
See also
GNUNET_NAMESTORE_zone_iteration_start2()

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

Definition at line 1403 of file namestore_api.c.

1412{
1414 struct GNUNET_MQ_Envelope *env;
1416 uint32_t rid;
1417 size_t key_len = 0;
1418
1419 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1420 rid = get_op_id (h);
1422 it->h = h;
1423 it->error_cb = error_cb;
1424 it->error_cb_cls = error_cb_cls;
1425 it->finish_cb = finish_cb;
1426 it->finish_cb_cls = finish_cb_cls;
1427 it->proc = proc;
1428 it->proc_cls = proc_cls;
1429 it->op_id = rid;
1430 if (NULL != zone)
1431 {
1432 it->zone = *zone;
1434 }
1435 GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it);
1437 key_len,
1439 ;
1440 msg->gns_header.r_id = htonl (rid);
1441 msg->key_len = htons (key_len);
1442 if (NULL != zone)
1444 if (NULL == h->mq)
1445 it->env = env;
1446 else
1447 GNUNET_MQ_send (h->mq, env);
1448 return it;
1449}
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
Client to service: please start iteration; receives "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPON...
void * finish_cb_cls
Closure for error_cb.
void * error_cb_cls
Closure for error_cb.
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
void * proc_cls
Closure for proc.
uint32_t op_id
The operation id this zone iteration operation has.
GNUNET_NAMESTORE_RecordMonitor proc
The continuation to call with the results.
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.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Private key of the zone.
Start a zone iteration for the given zone.
Definition namestore.h:556
uint16_t key_len
Length of the zone key.
Definition namestore.h:571

References env, GNUNET_NAMESTORE_ZoneIterator::env, error_cb(), GNUNET_NAMESTORE_ZoneIterator::error_cb, GNUNET_NAMESTORE_ZoneIterator::error_cb_cls, GNUNET_NAMESTORE_ZoneIterator::finish_cb, GNUNET_NAMESTORE_ZoneIterator::finish_cb_cls, get_op_id(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_NAMESTORE_ZoneIterator::h, ZoneIterationStartMessage::key_len, LOG, GNUNET_ARM_Handle::mq, msg, GNUNET_NAMESTORE_ZoneIterator::op_id, GNUNET_NAMESTORE_ZoneIterator::proc, GNUNET_NAMESTORE_ZoneIterator::proc_cls, and GNUNET_NAMESTORE_ZoneIterator::zone.

Referenced by get_ego(), handle_credential_iteration_start(), handle_iteration_start(), iterate_zones(), move_attrs(), RECLAIM_TICKETS_issue(), RECLAIM_TICKETS_iteration_start(), and start_consistency_update().

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

◆ GNUNET_NAMESTORE_zone_iteration_start2()

struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2 ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordSetMonitor  proc,
void *  proc_cls,
GNUNET_SCHEDULER_TaskCallback  finish_cb,
void *  finish_cb_cls,
enum GNUNET_GNSRECORD_Filter  filter 
)

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
filterthe record set filter to use
Returns
an iterator handle to use for iteration

Definition at line 1453 of file namestore_api.c.

1463{
1465 struct GNUNET_MQ_Envelope *env;
1467 uint32_t rid;
1468 size_t key_len = 0;
1469
1470 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1471 rid = get_op_id (h);
1473 it->h = h;
1474 it->error_cb = error_cb;
1475 it->error_cb_cls = error_cb_cls;
1476 it->finish_cb = finish_cb;
1477 it->finish_cb_cls = finish_cb_cls;
1478 it->proc2 = proc;
1479 it->proc_cls = proc_cls;
1480 it->op_id = rid;
1481 if (NULL != zone)
1482 {
1483 it->zone = *zone;
1485 }
1486 GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it);
1488 key_len,
1490 ;
1491 msg->gns_header.r_id = htonl (rid);
1492 msg->key_len = htons (key_len);
1493 msg->filter = htons ((uint16_t) filter);
1494 if (NULL != zone)
1496 if (NULL == h->mq)
1497 it->env = env;
1498 else
1499 GNUNET_MQ_send (h->mq, env);
1500 return it;
1501}
GNUNET_NAMESTORE_RecordSetMonitor proc2
The continuation to call with the results.

References env, GNUNET_NAMESTORE_ZoneIterator::env, error_cb(), GNUNET_NAMESTORE_ZoneIterator::error_cb, GNUNET_NAMESTORE_ZoneIterator::error_cb_cls, filter, GNUNET_NAMESTORE_ZoneIterator::finish_cb, GNUNET_NAMESTORE_ZoneIterator::finish_cb_cls, get_op_id(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_NAMESTORE_ZoneIterator::h, ZoneIterationStartMessage::key_len, LOG, GNUNET_ARM_Handle::mq, msg, GNUNET_NAMESTORE_ZoneIterator::op_id, GNUNET_NAMESTORE_ZoneIterator::proc2, GNUNET_NAMESTORE_ZoneIterator::proc_cls, and GNUNET_NAMESTORE_ZoneIterator::zone.

Referenced by namestore_get(), publish_zone_dht_start(), and run_with_zone_pkey().

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 1505 of file namestore_api.c.

1507{
1508 struct GNUNET_NAMESTORE_Handle *h = it->h;
1510 struct GNUNET_MQ_Envelope *env;
1511
1513 "Sending ZONE_ITERATION_NEXT message with limit %llu\n",
1514 (unsigned long long) limit);
1516 msg->gns_header.r_id = htonl (it->op_id);
1517 msg->limit = GNUNET_htonll (limit);
1518 GNUNET_MQ_send (h->mq, env);
1519}
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
Client to service: next record(s) in iteration please.
Ask for next result of zone iteration for the given operation.
Definition namestore.h:583

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, GNUNET_MQ_msg, GNUNET_MQ_send(), h, GNUNET_NAMESTORE_ZoneIterator::h, LOG, GNUNET_ARM_Handle::mq, msg, and GNUNET_NAMESTORE_ZoneIterator::op_id.

Referenced by attr_iter_cb(), collect_tickets_cb(), consistency_iter(), cred_iter_cb(), display_record_iterator(), filter_tickets_cb(), handle_credential_iteration_next(), handle_iteration_next(), namestore_list_iteration(), ns_lookup_result_cb(), publish_zone_namestore_next(), purge_orphans_iterator(), purge_zone_iterator(), RECLAIM_TICKETS_iteration_next(), rvk_ticket_update(), and zone_iterator().

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 1528 of file namestore_api.c.

1529{
1530 struct GNUNET_NAMESTORE_Handle *h = it->h;
1531 struct GNUNET_MQ_Envelope *env;
1533
1534 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_STOP message\n");
1535 if (NULL != h->mq)
1536 {
1537 env =
1539 msg->gns_header.r_id = htonl (it->op_id);
1540 GNUNET_MQ_send (h->mq, env);
1541 }
1542 free_ze (it);
1543}
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
Client to service: stop iterating.
static void free_ze(struct GNUNET_NAMESTORE_ZoneIterator *ze)
Free ze.
Stop zone iteration for the given operation.
Definition namestore.h:602

References env, free_ze(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, GNUNET_MQ_msg, GNUNET_MQ_send(), h, GNUNET_NAMESTORE_ZoneIterator::h, GNUNET_ARM_Handle::mq, msg, and GNUNET_NAMESTORE_ZoneIterator::op_id.

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

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_BlindablePrivateKey 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 
)
Deprecated:
since 0.16.7 will be replaced in 0.18
See also
GNUNET_NAMESTORE_zone_monitor_start2()

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

Definition at line 317 of file namestore_api_monitor.c.

327{
329
331 if (NULL != zone)
332 {
334 zm->zone = *zone;
335 }
339 zm->monitor = monitor;
341 zm->sync_cb = sync_cb;
343 zm->cfg = cfg;
344 reconnect (zm);
345 if (NULL == zm->mq)
346 {
347 GNUNET_free (zm);
348 return NULL;
349 }
350 return zm;
351}
static int monitor
Monitor ARM activity.
Definition gnunet-arm.c:63
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
Handle for a monitoring activity.
GNUNET_SCHEDULER_TaskCallback sync_cb
Function called when we've synchronized.
void * monitor_cls
Closure for monitor.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Monitored zone.
void * sync_cb_cls
Closure for sync_cb.
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
GNUNET_NAMESTORE_RecordMonitor monitor
Function to call on events.
void * error_cb_cls
Closure for error_cb.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration (to reconnect).
uint32_t key_len
Zone key length.
int iterate_first
Do we first iterate over all existing records?
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.

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

Here is the call graph for this function:

◆ GNUNET_NAMESTORE_zone_monitor_start2()

struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start2 ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone,
int  iterate_first,
GNUNET_SCHEDULER_TaskCallback  error_cb,
void *  error_cb_cls,
GNUNET_NAMESTORE_RecordSetMonitor  monitor,
void *  monitor_cls,
GNUNET_SCHEDULER_TaskCallback  sync_cb,
void *  sync_cb_cls,
enum GNUNET_GNSRECORD_Filter  filter 
)

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
filterthe record set filter to use
Returns
handle to stop monitoring

Definition at line 355 of file namestore_api_monitor.c.

366{
368
370 if (NULL != zone)
371 {
373 zm->zone = *zone;
374 }
380 zm->sync_cb = sync_cb;
382 zm->cfg = cfg;
383 zm->filter = filter;
384 reconnect (zm);
385 if (NULL == zm->mq)
386 {
387 GNUNET_free (zm);
388 return NULL;
389 }
390 return zm;
391}
enum GNUNET_GNSRECORD_Filter filter
Record set filter for this monitor.
GNUNET_NAMESTORE_RecordSetMonitor monitor2
Function to call on events.

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

Referenced by run(), run_with_zone_pkey(), and set_handle_key().

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 416 of file namestore_api_monitor.c.

418{
419 struct GNUNET_MQ_Envelope *env;
420 struct ZoneMonitorNextMessage *nm;
421
423 nm->limit = GNUNET_htonll (limit);
425}
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
Client to service: I am now ready for the next (set of) monitor events.
Ask for next result of zone iteration for the given operation.
Definition namestore.h:532
uint64_t limit
Number of records to return to the iterator in one shot (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_M...
Definition namestore.h:548

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

Referenced by cb_key_monitor(), cleanup_job(), display_record_monitor(), handle_monitor_event(), and run().

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 434 of file namestore_api_monitor.c.

435{
436 if (NULL != zm->mq)
437 {
439 zm->mq = NULL;
440 }
441 GNUNET_free (zm);
442}

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

Referenced by destroy_handle(), reset_handles(), set_handle_key(), and shutdown_task().

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

◆ GNUNET_NAMESTORE_record_set_edit_begin()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_edit_begin ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey pkey,
const char *  label,
const char *  editor_hint,
GNUNET_NAMESTORE_EditRecordSetBeginCallback  edit_cb,
void *  edit_cb_cls 
)

New API draft.

Experimental This function is used to initiate the editing of a record set under #label. It will set the editor hint of the record set to #editor_hint. The editor hint serves as an advisory lock that is used in #GNUNET_NAMESTORE_EdtirRecordSetBeginCallback if #editor_hint differs from the currently set advisory lock in the database.

Parameters
hhandle to the namestore
pkeythe private key of the zone to edit
labelthe label of the record set to edit
editor_hintthe editor hint to set as advisory lock
error_cbthe error callback
error_cb_clsclosure to error_cb
edit_cbthe GNUNET_NAMESTORE_EditRecordSetBeginCallback
edit_cb_clsclosure to #edit_cb
Returns
handle to the operation

Experimental

Definition at line 1564 of file namestore_api.c.

1572{
1574 struct GNUNET_MQ_Envelope *env;
1575 struct EditRecordSetMessage *msg;
1576 size_t label_len;
1577 size_t key_len;
1578 size_t editor_hint_len;
1579
1580 if (1 == (label_len = strlen (label) + 1))
1581 {
1582 GNUNET_break (0);
1583 return NULL;
1584 }
1585 GNUNET_assert (editor_hint != NULL);
1586 editor_hint_len = strlen (editor_hint) + 1;
1588 qe->h = h;
1589 qe->edit_proc = edit_cb;
1590 qe->proc_cls = edit_cb_cls;
1591 qe->op_id = get_op_id (h);
1592 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1593
1598 msg->gns_header.r_id = htonl (qe->op_id);
1600 &msg[1],
1601 key_len);
1602
1603 msg->key_len = htons (key_len);
1604 msg->label_len = htons (label_len);
1605 msg->editor_hint_len = htons (editor_hint_len);
1606 GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len);
1607 GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len, editor_hint,
1609 if (NULL == h->mq)
1610 qe->env = env;
1611 else
1612 GNUNET_MQ_send (h->mq, env);
1613 return qe;
1614}
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT
Message type for start of record edit with advisory lock.
Edit a record set and set editor hint/advisory lock.
Definition namestore.h:215
uint16_t editor_hint_len
Unused.
Definition namestore.h:229
uint16_t label_len
Length of the name.
Definition namestore.h:224
uint16_t key_len
Length of the zone key.
Definition namestore.h:239

References EditRecordSetMessage::editor_hint_len, env, GNUNET_DATASTORE_QueueEntry::env, get_op_id(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, EditRecordSetMessage::key_len, EditRecordSetMessage::label_len, GNUNET_ARM_Handle::mq, msg, pkey, and qe.

Here is the call graph for this function:

◆ GNUNET_NAMESTORE_record_set_edit_cancel()

struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_edit_cancel ( struct GNUNET_NAMESTORE_Handle h,
const struct GNUNET_CRYPTO_BlindablePrivateKey pkey,
const char *  label,
const char *  editor_hint,
const char *  editor_hint_replacement,
GNUNET_NAMESTORE_ContinuationWithStatus  finished_cb,
void *  finished_cls 
)

If the current advisory lock is set to the provided editor hint, this API cancels the editing of a record set and unsets the advisory lock in database.

Optionally, a new editor hint can be provided: For example, the value that was returned in in the callback to GNUNET_NAMESTORE_record_set_edit_begin.

If provided editor hint does not match the current advisory lock, this function is not doing anything (NOP).

Parameters
hhandle to the namestore
pkeythe private key of the zone to edit
labelthe label of the record set to edit
editor_hintthe editor hint to set as advisory lock
editor_hint_replacementthe editor hint to set as advisory lock instead of clearing it
finished_cbthe callback called when cancelled
finished_cb_clsclosure to finished_cb
Returns
handle to the operation

Definition at line 1618 of file namestore_api.c.

1628{
1630 struct GNUNET_MQ_Envelope *env;
1632 size_t label_len;
1633 size_t key_len;
1634 size_t editor_hint_len;
1636
1637 if (1 == (label_len = strlen (label) + 1))
1638 {
1639 GNUNET_break (0);
1640 return NULL;
1641 }
1642 GNUNET_assert (editor_hint != NULL);
1643 editor_hint_len = strlen (editor_hint) + 1;
1644 GNUNET_assert (editor_hint != NULL);
1645 editor_hint_replacement_len = strlen (editor_hint_replacement) + 1;
1647 qe->h = h;
1648 qe->op_id = get_op_id (h);
1649 qe->cont = finished_cb;
1650 qe->cont_cls = finished_cls;
1651 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1652
1658 msg->gns_header.r_id = htonl (qe->op_id);
1660 &msg[1],
1661 key_len);
1662
1663 msg->key_len = htons (key_len);
1664 msg->label_len = htons (label_len);
1665 msg->editor_hint_len = htons (editor_hint_len);
1666 msg->editor_hint_replacement_len = htons (editor_hint_replacement_len);
1667 GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len);
1668 GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len, editor_hint,
1670 GNUNET_memcpy (((char*) &msg[1]) + key_len + label_len + editor_hint_len,
1671 editor_hint_replacement,
1673 if (NULL == h->mq)
1674 qe->env = env;
1675 else
1676 GNUNET_MQ_send (h->mq, env);
1677 return qe;
1678}
static void finished_cb(void *cls, enum GNUNET_GenericReturnValue rv)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL
Message type for cancellation/reset of editor hint/advisory lock.
Edit a record set and set editor hint/advisory lock.
Definition namestore.h:253
uint16_t editor_hint_replacement_len
Unused.
Definition namestore.h:272
uint16_t editor_hint_len
Unused.
Definition namestore.h:267
uint16_t label_len
Length of the name.
Definition namestore.h:262
uint16_t key_len
Length of the zone key.
Definition namestore.h:277

References GNUNET_DATASTORE_QueueEntry::cont, GNUNET_DATASTORE_QueueEntry::cont_cls, EditRecordSetCancelMessage::editor_hint_len, EditRecordSetCancelMessage::editor_hint_replacement_len, env, GNUNET_DATASTORE_QueueEntry::env, finished_cb(), get_op_id(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_blindable_sk_get_length(), GNUNET_CRYPTO_write_blindable_sk_to_buffer(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_DATASTORE_QueueEntry::h, EditRecordSetCancelMessage::key_len, EditRecordSetCancelMessage::label_len, GNUNET_ARM_Handle::mq, msg, pkey, and qe.

Here is the call graph for this function: