33 #include "gnunet_signatures.h"
36 #define LOG_STRERROR_FILE(kind, syscall, filename) \
37 GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
42 #define MONITOR_STALL_WARN_DELAY GNUNET_TIME_UNIT_MINUTES
470 for (
unsigned int c = 0; c <
rd_count; c++)
476 (*res)->data = &(*res)[1];
502 for (
unsigned int i = 0; i <
NC_SIZE; i++)
506 if ((NULL == oldest) ||
547 for (
unsigned int i = 0; i <
NC_SIZE; i++)
556 nick->
data = &nick[1];
571 #if ! defined(GNUNET_CULL_LOGGING)
584 "No nick name set for zone `%s'\n",
616 unsigned int rd2_length,
618 unsigned int *rdc_res,
621 uint64_t latest_expiration;
627 (*rdc_res) = 1 + rd2_length;
628 if (0 == 1 + rd2_length)
635 for (
unsigned int i = 0; i < rd2_length; i++)
649 data = (
char *) &target[1 + rd2_length];
651 latest_expiration = 0;
652 for (
unsigned int i = 0; i < rd2_length; i++)
665 target[i].
data = (
void *) &
data[data_offset];
670 target[rd2_length] = *nick_rd;
674 target[rd2_length].
data = (
void *) &
data[data_offset];
710 unsigned int res_count;
711 unsigned int rd_nf_count;
748 res_count = rd_nf_count;
763 name_len = strlen (
name) + 1;
773 if (((
size_t) rd_ser_len) >= UINT16_MAX - name_len -
sizeof(*zir_msg))
783 name_len + rd_ser_len + key_len,
786 zir_msg->
name_len = htons (name_len);
787 zir_msg->
rd_count = htons (res_count);
788 zir_msg->
rd_len = htons ((uint16_t) rd_ser_len);
789 zir_msg->
key_len = htons (key_len);
794 name_tmp = (
char *) &zir_msg[1] + key_len;
796 rd_ser = &name_tmp[name_len];
801 "Sending RECORD_RESULT message with %u records\n",
804 "Record sets sent to clients",
830 "Sending RECORD_STORE_RESPONSE message\n");
832 "Store requests completed",
838 rcr_msg->
ec = htonl (
ec);
881 "No response from monitor since %s\n",
902 const char *name_tmp;
912 "Transaction not yet committed, delaying monitor and cache updates\n");
918 buf = (
const char *) &sa[1];
919 for (
int i = sa->
rd_set_pos; i < sa->rd_set_count; i++)
924 rd_ser_len = ntohs (rd_set->
rd_len);
925 name_tmp = (
const char *) &rd_set[1];
939 "Checking monitors watching for `%s'\n",
949 if (
zm->limit ==
zm->iteration_cnt)
953 if (NULL !=
zm->sa_wait_warning)
955 zm->sa_wait_warning =
960 "Monitor is blocking client for `%s'\n",
966 "Notifying monitor about changes under label `%s'\n",
1014 "Client in transaction, rolling back...\n");
1016 nc->GSN_database->cls,
1020 "Unable to roll back: %s\n", emsg);
1028 if ((
nc != sa->
nc) ||
1045 if (NULL !=
zm->task)
1050 if (NULL !=
zm->sa_wait_warning)
1053 zm->sa_wait_warning = NULL;
1055 for (sa =
sa_head; NULL != sa; sa = sn)
1080 while (NULL != (no =
nc->op_head))
1126 if (NULL ==
nc->GSN_database)
1129 "Could not load database backend `%s'\n",
1199 unsigned int rd_count_nf,
1210 if (0 != strcmp (label, rlc->
label))
1239 unsigned int rdc_res;
1320 key_len = ntohs (ll_msg->
key_len);
1345 const char *name_tmp;
1353 key_len = ntohs (ll_msg->
key_len);
1359 (kb_read != key_len))
1362 "Error reading private key\n");
1366 name_tmp = (
const char *) &ll_msg[1] + key_len;
1369 "Received NAMESTORE_RECORD_LOOKUP message for name `%s'\n",
1373 if (NULL == conv_name)
1376 "Error converting name `%s'\n",
1381 name_len = strlen (conv_name) + 1;
1382 rlc.
label = conv_name;
1384 "Looking up with filter %u\n", ntohs (ll_msg->
filter));
1392 res =
nc->GSN_database->lookup_records (
nc->GSN_database->cls,
1398 res =
nc->GSN_database->edit_records (
nc->GSN_database->cls,
1411 llr_msg->
name_len = htons (name_len);
1415 res_name = ((
char *) &llr_msg[1]) + key_len;
1442 size_t min_size_exp;
1443 size_t rd_set_count;
1449 key_len = ntohs (rp_msg->
key_len);
1451 min_size_exp =
sizeof(*rp_msg) + key_len +
sizeof (
struct RecordSet)
1453 if (msg_size < min_size_exp)
1499 unsigned int rd_pub_count;
1532 const char *name_tmp;
1550 rd_ser_len = ntohs (rd_set->
rd_len);
1552 name_tmp = (
const char *) &rd_set[1];
1559 if (NULL == conv_name)
1562 "Error normalizing name `%s'\n",
1571 "Label invalid: `%s'\n",
1587 "Well-formed store requests received",
1591 "Creating %u records for name `%s'\n",
1594 if ((
GNUNET_NO ==
nc->GSN_database->lookup_records (
nc->GSN_database->cls,
1604 "Name `%s' does not exist, no deletion required\n",
1621 unsigned int rd_clean_off;
1622 unsigned int rd_nf_count;
1627 for (
unsigned int i = 0; i <
rd_count; i++)
1629 rd_clean[rd_clean_off] =
rd[i];
1656 "Error normalizing record set: `%s'\n",
1662 "%u/%u records before tombstone\n", rd_nf_count,
1674 rd_nf[rd_nf_count].expiration_time =
1675 lctx.exp.abs_value_us;
1676 rd_nf[rd_nf_count].data = NULL;
1677 rd_nf[rd_nf_count].data_size = 0;
1689 res =
nc->GSN_database->store_records (
nc->GSN_database->cls,
1700 (1 == rd_nf_count) &&
1705 "Client tried to remove non-existant record\n");
1733 uint16_t rd_set_count;
1746 key_len = ntohs (rp_msg->
key_len);
1748 body_len = rp_msg_len -
sizeof (*rp_msg);
1749 rs_off =
sizeof (*rp_msg) + key_len;
1750 rs_len = rp_msg_len - rs_off;
1756 (kb_read != key_len))
1759 "Error reading private key\n");
1764 "Received NAMESTORE_RECORD_STORE message\n");
1767 buf = (
const char *) rp_msg + rs_off;
1768 for (
int i = 0; i < rd_set_count; i++)
1804 txr_msg->
ec = htonl (ec);
1826 switch (ntohs (tx_msg->
control))
1829 ret =
nc->GSN_database->transaction_begin (
nc->GSN_database->cls,
1837 "Databse backend error: `%s'", emsg);
1844 ret =
nc->GSN_database->transaction_commit (
nc->GSN_database->cls,
1853 "Databse backend error: `%s'", emsg);
1861 if ((
nc != sa->
nc) ||
1878 ret =
nc->GSN_database->transaction_rollback (
nc->GSN_database->cls,
1887 "Databse backend error: `%s'", emsg);
1895 if ((
nc != sa->
nc) ||
1902 "Discarding uncommited StoreActivity\n");
1911 "Unknown control type %u\n", ntohs (tx_msg->
control));
1971 "Found result for zone-to-name lookup: `%s'\n",
1997 ztnr_msg->
ec = htonl (ztn_ctx->
ec);
1998 ztnr_msg->
rd_len = htons (rd_ser_len);
2005 name_tmp = (
char *) &ztnr_msg[1] +
key_len;
2055 "Error parsing private key.\n");
2060 pkey_len = ntohs (ztn_msg->
pkey_len);
2067 (kb_read != pkey_len))
2070 "Error parsing public key.\n");
2091 "Found no result for zone-to-name lookup.\n");
2157 if (0 == proc->
limit)
2163 proc->
zi->
seq = seq;
2191 memset (&proc, 0,
sizeof(proc));
2193 "Asked to return up to %llu records at position %llu\n",
2194 (
unsigned long long) limit,
2195 (
unsigned long long) zi->
seq);
2204 nc->GSN_database->iterate_records (
nc->GSN_database->cls,
2218 "NAMESTORE iteration delay (μs/record)",
2221 if (0 == proc.
limit)
2223 "Returned %llu results, more results available\n",
2224 (
unsigned long long) limit);
2238 key_len = ntohs (zis_msg->
key_len);
2240 if (
size < key_len +
sizeof(*zis_msg))
2266 "Received ZONE_ITERATION_START message\n");
2267 key_len = ntohs (zis_msg->
key_len);
2276 (kb_read != key_len))
2308 "Received ZONE_ITERATION_STOP message\n");
2310 for (zi =
nc->op_head; NULL != zi; zi = zi->
next)
2341 "Received ZONE_ITERATION_NEXT message\n");
2343 "Iteration NEXT messages received",
2348 for (zi =
nc->op_head; NULL != zi; zi = zi->
next)
2372 "Unblocking zone monitor %p\n",
zm);
2373 while ((NULL != sa) && (
zm->limit >
zm->iteration_cnt))
2381 if (
zm->limit >
zm->iteration_cnt)
2384 if (NULL !=
zm->sa_wait_warning)
2387 zm->sa_wait_warning = NULL;
2393 if (NULL !=
zm->sa_wait_warning)
2395 zm->sa_wait_warning =
2414 "Synching zone monitor %p\n",
zm);
2420 zm->iteration_cnt = 0;
2421 if ((
zm->limit > 0) && (
zm->sa_waiting))
2459 "Monitor notifications sent",
2468 zm->iteration_cnt--;
2472 if ((0 ==
zm->iteration_cnt) && (0 !=
zm->limit))
2489 key_len = ntohs (zis_msg->
key_len);
2491 if (
size < key_len +
sizeof(*zis_msg))
2517 "Received ZONE_MONITOR_START message\n");
2520 key_len = ntohs (zis_msg->
key_len);
2528 (kb_read != key_len))
2531 "Error reading private key\n");
2545 if (
zm->in_first_iteration)
2567 zm->iteration_cnt =
zm->limit / 2;
2569 zm->iteration_cnt =
zm->limit;
2574 "Running iteration\n");
2576 ret =
nc->GSN_database->iterate_records (
nc->GSN_database->cls,
2592 "Zone empty... syncing\n");
2614 "Received ZONE_MONITOR_NEXT message with limit %llu\n",
2615 (
unsigned long long) inc);
2626 if (
zm->limit + inc < zm->
limit)
2633 if ((
zm->in_first_iteration) && (
zm->limit == inc))
2641 if ((
zm->limit >
zm->iteration_cnt) && (
zm->sa_waiting))
2647 if (NULL !=
zm->sa_wait_warning)
2650 zm->sa_wait_warning =
2695 "Could not load database backend `%s'\n",
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
#define GNUNET_GNSRECORD_TYPE_NICK
GNS nick names.
#define GNUNET_GNSRECORD_TYPE_TOMBSTONE
Record type to indicate a previously delete record (PRIVATE only)
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NAMESTORE_UNKNOWN
Unknown namestore error.
@ GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID
Record data invalid.
@ GNUNET_EC_NAMESTORE_BACKEND_FAILED
There was an error in the database backend.
@ GNUNET_EC_NAMESTORE_LABEL_INVALID
Label invalid or malformed.
@ GNUNET_EC_NONE
No error (success).
@ GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND
Record not found.
@ GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND
Zone not found.
@ GNUNET_EC_NAMESTORE_RECORD_TOO_BIG
Record size exceeds maximum limit.
@ GNUNET_EC_NAMESTORE_STORE_FAILED
Failed to store the given records.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static size_t data_size
Number of bytes in data.
static int start
Set if we are to start default services (including ARM).
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * zone
Name of the zone being managed.
static const struct GNUNET_IDENTITY_PrivateKey * zone_key
Private key of the zone.
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.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static struct GNUNET_TIME_Relative duration
How long do we run the test?
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
static void get_existing_rd_exp(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check if set contains a tombstone, store if necessary.
static void handle_zone_to_name_it(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Zone to name iterator.
static enum GNUNET_GenericReturnValue check_iteration_start(void *cls, const struct ZoneIterationStartMessage *zis_msg)
static void send_tx_response(int rid, enum GNUNET_ErrorCode ec, struct NamestoreClient *nc)
static int return_orphaned
Returned orphaned records?
static void lookup_it(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *private_key, const char *label, unsigned int rd_count_nf, const struct GNUNET_GNSRECORD_Data *rd_nf)
Function called by the namestore plugin when we are trying to lookup a record as part of handle_recor...
GNUNET_SERVICE_MAIN("namestore", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(tx_control, GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL, struct TxControlMessage, NULL), GNUNET_MQ_hd_var_size(record_store, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, struct RecordStoreMessage, NULL), GNUNET_MQ_hd_var_size(record_lookup, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, struct LabelLookupMessage, NULL), GNUNET_MQ_hd_var_size(zone_to_name, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, struct ZoneToNameMessage, NULL), GNUNET_MQ_hd_var_size(iteration_start, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, struct ZoneIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, struct ZoneIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, struct ZoneIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(monitor_start, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, struct ZoneMonitorStartMessage, NULL), GNUNET_MQ_hd_fixed_size(monitor_next, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, struct ZoneMonitorNextMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void handle_iteration_start(void *cls, const struct ZoneIterationStartMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message.
static struct StoreActivity * sa_tail
Tail of DLL of monitor-blocked store activities.
static void handle_iteration_stop(void *cls, const struct ZoneIterationStopMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message.
static void run_zone_iteration_round(struct ZoneIteration *zi, uint64_t limit)
Perform the next round of the zone iteration.
static void monitor_unblock(struct ZoneMonitor *zm)
Function called when the monitor is ready for more data, and we should thus unblock PUT operations th...
static void handle_record_store(void *cls, const struct RecordStoreMessage *rp_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
static enum GNUNET_ErrorCode store_record_set(struct NamestoreClient *nc, const struct GNUNET_IDENTITY_PrivateKey *private_key, const struct RecordSet *rd_set, ssize_t *len)
static void monitor_sync(struct ZoneMonitor *zm)
Send 'sync' message to zone monitor, we're now in sync.
static void handle_monitor_next(void *cls, const struct ZoneMonitorNextMessage *nm)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message.
static struct GNUNET_NotificationContext * monitor_nc
Notification context shared by all monitors.
struct GNUNET_NAMESTORE_PluginFunctions * GSN_database
Database handle for service.
static void monitor_iterate_cb(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
A GNUNET_NAMESTORE_RecordIterator for monitors.
static void cleanup_task(void *cls)
Task run during shutdown.
static char * db_lib_name
Name of the database plugin.
static int check_record_store(void *cls, const struct RecordStoreMessage *rp_msg)
Checks a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
static void lookup_nick_it(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the records for the GNUNET_GNS_EMPTY_LABEL_AT label in the zone.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static void handle_tx_control(void *cls, const struct TxControlMessage *tx_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL message.
static void merge_with_nick_records(const struct GNUNET_GNSRECORD_Data *nick_rd, unsigned int rd2_length, const struct GNUNET_GNSRECORD_Data *rd2, unsigned int *rdc_res, struct GNUNET_GNSRECORD_Data **rd_res)
Merge the nick record nick_rd with the rest of the record set given in rd2.
static struct StoreActivity * sa_head
Head of DLL of monitor-blocked store activities.
static void handle_record_lookup(void *cls, const struct LabelLookupMessage *ll_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
static void free_store_activity(struct StoreActivity *sa)
Release memory used by sa.
static void handle_zone_to_name(void *cls, const struct ZoneToNameMessage *ztn_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message.
static int continue_store_activity(struct StoreActivity *sa, int call_continue)
Continue processing the sa.
static struct ZoneMonitor * monitor_head
First active zone monitor.
static int check_record_lookup(void *cls, const struct LabelLookupMessage *ll_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
static void cache_nick(const struct GNUNET_IDENTITY_PrivateKey *zone, const struct GNUNET_GNSRECORD_Data *nick)
Add entry to the cache for zone and nick.
static void zone_iteration_done_client_continue(struct ZoneIteration *zi)
Function called once we are done with the zone iteration and allow the zone iteration client to send ...
static int send_lookup_response_with_filter(struct NamestoreClient *nc, uint32_t request_id, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, enum GNUNET_GNSRECORD_Filter filter)
Generate a struct LookupNameResponseMessage and send it to the given client using the given notificat...
#define MONITOR_STALL_WARN_DELAY
If a monitor takes more than 1 minute to process an event, print a warning.
static enum GNUNET_GenericReturnValue check_zone_to_name(void *cls, const struct ZoneToNameMessage *zis_msg)
static void monitor_iteration_next(void *cls)
Obtain the next datum during the zone monitor's zone initial iteration.
static const struct GNUNET_CONFIGURATION_Handle * GSN_cfg
Configuration handle.
static void send_store_response(struct NamestoreClient *nc, enum GNUNET_ErrorCode ec, uint32_t rid)
Send response to the store request to the client.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Add a client to our list of active clients.
static void handle_monitor_start(void *cls, const struct ZoneMonitorStartMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message.
#define NC_SIZE
Size of the cache used by get_nick_record()
static const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.
static struct ZoneMonitor * monitor_tail
Last active zone monitor.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static struct NickCache nick_cache[16]
We cache nick records to reduce DB load.
static void handle_iteration_next(void *cls, const struct ZoneIterationNextMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message.
static void warn_monitor_slow(void *cls)
Print a warning that one of our monitors is no longer reacting.
static enum GNUNET_GenericReturnValue check_monitor_start(void *cls, const struct ZoneMonitorStartMessage *zis_msg)
static void zone_iterate_proc(void *cls, uint64_t seq, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process results for zone iteration from database.
static struct GNUNET_GNSRECORD_Data * get_nick_record(const struct GNUNET_IDENTITY_PrivateKey *zone)
Return the NICK record for the zone (if it exists).
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process namestore requests.
static void iteration_start()
Plugin API for the namestore database backend.
API that can be used to store naming information on a GNUnet node;.
API to create, modify and access statistics.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * GNUNET_GNSRECORD_string_normalize(const char *src)
Normalize a UTF-8 string to a GNS name.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_label_check(const char *label, char **emsg)
Check label for invalid characters.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
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.
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.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_IDENTITY_PublicKey *z)
Convert a zone to a string (for printing debug messages).
GNUNET_GNSRECORD_Filter
Filter for GNUNET_GNSRECORD_normalize_record_set().
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_normalize_record_set(const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public, unsigned int *rd_count_public, struct GNUNET_TIME_Absolute *expiry, enum GNUNET_GNSRECORD_Filter filter, char **emsg)
Normalize namestore records: Check for consistency and expirations.
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
@ GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE
Filter private records.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
ssize_t GNUNET_IDENTITY_write_private_key_to_buffer(const struct GNUNET_IDENTITY_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PrivateKey to a compact buffer.
ssize_t GNUNET_IDENTITY_private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Get the compacted length of a GNUNET_IDENTITY_PrivateKey.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PrivateKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PrivateKey from a compact buffer.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_log(kind,...)
#define GNUNET_NZL(l)
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length).
#define GNUNET_LOG_CALL_STATUS
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
int GNUNET_get_log_call_status(int caller_level, const char *comp, const char *file, const char *function, int line)
Decides whether a particular logging call should or should not be allowed to be made.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
@ GNUNET_NAMESTORE_TX_COMMIT
@ GNUNET_NAMESTORE_TX_ROLLBACK
@ GNUNET_NAMESTORE_TX_BEGIN
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END
Service to client: end of list of results.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT
Return status message for control message.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
Service to client: here is a (plaintext) record you requested.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
Service to client: result of zone-to-name lookup.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
Service to client: result of store operation.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
Client to service: next record(s) in iteration please.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
Client to service: please start iteration; receives "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPON...
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
Client to service: stop iterating.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
Service to client: lookup label.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
Client to service: store records (as authority)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
Client to service: I am now ready for the next (set of) monitor events.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL
Message type for Begin, Commit or Rollback.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
Client to service: start monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" — forever).
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
Client to service: "reverse" lookup for zone name based on zone key.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC
Service to client: you're now in sync.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
Client to service: lookup label.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
common internal definitions for namestore service
static unsigned int size
Size of the "table".
static int zone_to_name(void *cls, const struct GNUNET_HashCode *key, void *value)
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle to a message queue.
struct returned by the initialization function of the plugin
enum GNUNET_GenericReturnValue(* lookup_records)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Lookup records in the datastore for which we are the authority.
void * cls
Closure to pass to all plugin functions.
struct GNUNET_IDENTITY_PrivateKey zone
Monitored zone.
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
enum GNUNET_GNSRECORD_Filter filter
Record set filter for this monitor.
The notification context is the key datastructure for a convenience API used for transmission of noti...
struct GNUNET_MQ_Handle * mq
Our connection to the PEERINFO service.
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP.
uint16_t key_len
Length of the zone key.
uint16_t is_edit_request
GNUNET_YES if this lookup corresponds to an edit request.
uint16_t filter
The record filter.
uint16_t label_len
Length of the name.
uint16_t rd_len
Length of serialized record data.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
uint16_t reserved
Reserved (alignment)
uint16_t key_len
Length of the zone key.
uint16_t rd_count
Number of records contained.
uint16_t name_len
Name length.
int16_t found
Was the label found in the database?? GNUNET_YES or GNUNET_NO.
struct GNUNET_TIME_Absolute exp
The expiration of the existing records or tombstone.
int only_tombstone
Whether the existing record set consists only of a tombstone (e.g.
int in_transaction
GNUNET_YES if this nc has begun a transaction which is uncommited.
struct ZoneIteration * op_head
Head of the DLL of Zone iteration operations in progress initiated by this client.
struct GNUNET_NAMESTORE_PluginFunctions * GSN_database
Database handle for client.
char * db_lib_name
Name of loaded plugin (neeed for cleanup)
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct GNUNET_SERVICE_Client * client
The client.
struct ZoneIteration * op_tail
Tail of the DLL of Zone iteration operations in progress initiated by this client.
Entry in list of cached nick resolutions.
struct GNUNET_GNSRECORD_Data * rd
Cached record data.
struct GNUNET_TIME_Absolute last_used
Timestamp when this cache entry was used last.
struct GNUNET_IDENTITY_PrivateKey zone
Zone the cache entry is for.
struct GNUNET_GNSRECORD_Data * nick
The nick for the zone.
char * res_rd
The record result.
const char * label
The label to look up.
int found
If a record set was found or not.
unsigned int res_rd_count
The number of found records.
ssize_t rd_ser_len
The length of the serialized records.
enum GNUNET_GNSRECORD_Filter filter
The record filter.
Record is returned from the namestore (as authority).
uint16_t rd_len
Length of serialized record data.
uint16_t name_len
Name length.
uint16_t rd_count
Number of records contained.
struct GNUNET_TIME_AbsoluteNBO expire
Expiration time if the record result (if any).
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
uint16_t key_len
Length of the zone key.
uint16_t rd_len
Length of serialized record data.
uint16_t rd_count
Number of records contained.
uint16_t name_len
Name length.
Store a record to the namestore (as authority).
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE.
uint16_t rd_set_count
Number of record sets.
uint16_t key_len
Length of the zone key.
Response to a record storage request.
uint32_t ec
GNUNET_ErrorCode.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE.
Information for an ongoing handle_record_store() operation.
struct StoreActivity * next
Kept in a DLL.
uint32_t rid
The request ID.
const struct RecordSet * rs
Copy of the original record set (as data fields in rd will point into it!).
uint16_t rd_set_count
The number of records in this activity.
struct GNUNET_IDENTITY_PrivateKey private_key
The zone private key.
struct NamestoreClient * nc
Which client triggered the store activity?
int uncommited
Wheather or not this store action is already commited.
uint16_t rd_set_pos
The currently processed record.
struct StoreActivity * prev
Kept in a DLL.
struct ZoneMonitor * zm_pos
Next zone monitor that still needs to be notified about this PUT.
Send a transaction control message.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL.
uint16_t control
The type of control message to send.
Result of a transaction control message.
uint32_t ec
Of type GNUNET_ErrorCode.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT.
Ask for next result of zone iteration for the given operation.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT.
uint64_t limit
Number of records to return to the iterator in one shot (before GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_IT...
Context for record remove operations passed from run_zone_iteration_round to zone_iterate_proc as clo...
struct ZoneIteration * zi
The zone iteration handle.
int run_again
Skip a result and run again unless GNUNET_NO.
uint64_t limit
Number of results left to be returned in this iteration.
Start a zone iteration for the given zone.
uint16_t key_len
Length of the zone key.
uint16_t filter
Record set filter control flags.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START.
Stop zone iteration for the given operation.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP.
A namestore iteration operation.
struct NamestoreClient * nc
Namestore client which intiated this zone iteration.
uint64_t seq
Last sequence number in the zone iteration used to address next result of the zone iteration in the s...
struct GNUNET_GNSRECORD_Data * nick
The nick to add to the records.
struct GNUNET_IDENTITY_PrivateKey zone
Key of the zone we are iterating over.
enum GNUNET_GNSRECORD_Filter filter
The record set filter.
int send_end
Set to GNUNET_YES if the last iteration exhausted the limit set by the client and we should send the ...
uint32_t request_id
The operation id for the zone iteration in the response for the client.
unsigned int cache_ops
Number of pending cache operations triggered by this zone iteration which we need to wait for before ...
struct ZoneIteration * prev
Previous element in the DLL.
uint32_t offset
Offset of the zone iteration used to address next result of the zone iteration in the store.
struct ZoneIteration * next
Next element in the DLL.
Ask for next result of zone iteration for the given operation.
uint64_t limit
Number of records to return to the iterator in one shot (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_M...
uint32_t iterate_first
GNUNET_YES to first iterate over all records, GNUNET_NO to only monitor changes.o
uint16_t filter
Record set filter control flags.
uint16_t key_len
Length of the zone key.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START.
struct GNUNET_SCHEDULER_Task * sa_wait_warning
Task to warn about slow monitors.
struct GNUNET_IDENTITY_PrivateKey zone
Private key of the zone.
struct GNUNET_TIME_Absolute sa_waiting_start
Since when are we blocked on this monitor?
int in_first_iteration
Are we (still) in the initial iteration pass?
enum GNUNET_GNSRECORD_Filter filter
The record set filter.
struct ZoneMonitor * prev
Previous element in the DLL.
int sa_waiting
Is there a store activity waiting for this monitor? We only raise the flag when it happens and search...
uint64_t iteration_cnt
How many more requests may we receive from the iterator before it is at the limit we gave it?...
uint64_t limit
Current limit of how many more messages we are allowed to queue to this monitor.
uint64_t seq
Last sequence number in the zone iteration used to address next result of the zone iteration in the s...
struct GNUNET_SCHEDULER_Task * task
Task active during initial iteration.
struct NamestoreClient * nc
Namestore client which intiated this zone monitor.
int run_again
Run again because we skipped an orphan.
struct ZoneMonitor * next
Next element in the DLL.
Context for record remove operations passed from handle_zone_to_name to handle_zone_to_name_it as clo...
struct NamestoreClient * nc
Namestore client.
uint32_t rid
Request id (to be used in the response to the client).
enum GNUNET_ErrorCode ec
Set to GNUNET_OK on success, GNUNET_SYSERR on error.
Lookup a name for a zone hash.
uint16_t pkey_len
Length of the public value zone key.
uint16_t key_len
Length of the zone key.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME.
Respone for zone to name lookup.
uint16_t name_len
Length of the name.
int32_t ec
result in NBO: GNUNET_EC_NONE on success, GNUNET_EC_NAMESTORE_NO_RESULTS if there were no results.
uint16_t key_len
Length of the zone key.
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
uint16_t rd_count
Number of records contained.
uint16_t rd_len
Length of serialized record data.