32#define LOG(kind, ...) GNUNET_log_from (kind, "peerstore-monitor-api", \
125 if (NULL !=
mc->sync_cb)
126 mc->sync_cb (
mc->sync_cb_cls);
161 mc->callback (
mc->callback_cls,
163 _ (
"Received a malformed response from service."));
167 mc->callback (
mc->callback_cls,
record, NULL);
205 mc->error_cb (
mc->error_cb_cls);
215 key_len = strlen (
mc->key) + 1;
216 if (NULL !=
mc->sub_system)
217 ss_size = strlen (
mc->sub_system) + 1;
220 htons (key_len) + htons (ss_size),
223 if (NULL !=
mc->peer)
228 if (NULL !=
mc->sub_system)
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static void error_cb(void *cls)
Function called if lookup fails.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
struct GNUNET_HashCode key
The key used in the DHT.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static int result
Global testing status.
API to the peerstore service.
Constants for network protocols.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_log(kind,...)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
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)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
void GNUNET_PEERSTORE_monitor_stop(struct GNUNET_PEERSTORE_Monitor *zm)
Stop monitoring.
struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, int iterate_first, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Request watching a given key The monitoring can be filtered to contain only records matching peer and...
void GNUNET_PEERSTORE_monitor_next(struct GNUNET_PEERSTORE_Monitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).
void(* GNUNET_PEERSTORE_Processor)(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Function called by PEERSTORE for each matching record.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_SYNC
Monitor sync.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_NEXT
Monitor next request.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_MONITOR_START
Monitor request.
#define GNUNET_MESSAGE_TYPE_PEERSTORE_RECORD
Record result message.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
static void reconnect(struct GNUNET_PEERSTORE_Monitor *mc)
static int check_result(void *cls, const struct PeerstoreRecordMessage *msg)
When a response for iterate request is received, check the message is well-formed.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error err)
static void handle_sync(void *cls, const struct GNUNET_MessageHeader *msg)
static void handle_result(void *cls, const struct PeerstoreRecordMessage *msg)
When a response to monitor is received.
struct GNUNET_PEERSTORE_Record * PEERSTORE_parse_record_message(const struct PeerstoreRecordMessage *srm)
Parses a message carrying a record.
void PEERSTORE_destroy_record(struct GNUNET_PEERSTORE_Record *record)
Free any memory allocated for this record.
Helper peerstore functions.
Handle to a message queue.
Message handler for a specific message type.
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
void * error_cb_cls
Closure for error_cb.
struct GNUNET_MQ_Handle * mq
MQ.
void * callback_cls
Closure for callback.
const struct GNUNET_PeerIdentity * peer
The peer we are watching for values.
int iterate_first
Iterate first flag.
GNUNET_PEERSTORE_Processor callback
Callback with each record received.
struct GNUNET_PEERSTORE_Monitor * next
Kept in a DLL.
const char * key
The key we like to watch for values.
GNUNET_SCHEDULER_TaskCallback sync_cb
Sync CB.
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
char * sub_system
The sub system requested the watch.
void * sync_cb_cls
Sync CB cls.
const struct GNUNET_CONFIGURATION_Handle * cfg
CFG.
struct GNUNET_PEERSTORE_Monitor * prev
Kept in a DLL.
struct GNUNET_HashCode keyhash
Hash of the combined key.
The identity of the host (wraps the signing key of the peer).
uint64_t limit
Number of records to return.
uint16_t iterate_first
GNUNET_YES if iterate first, GNUNET_NO otherwise
struct GNUNET_PeerIdentity peer
Peer Identity.
uint16_t peer_set
GNUNET_YES if peer id value set, GNUNET_NO otherwise
uint16_t key_size
Size of the key string Allocated at position 1 after this struct.
uint16_t sub_system_size
Size of the sub_system string Allocated at position 0 after this struct.
Message carrying a PEERSTORE record message.