33 #define INIT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 35 #define LOG(kind, ...) GNUNET_log_from (kind, "arm-monitor-api", __VA_ARGS__) 96 "Connecting to ARM service for monitoring after delay\n");
135 const char *
name = (
const char *) &msg[1];
138 if ((0 == sl) || (
'\0' != name[sl - 1]))
161 "Received notification from ARM for service `%s' with status %d\n",
162 (
const char *) &res[1],
void(* GNUNET_ARM_ServiceMonitorCallback)(void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
Function called in when a status update arrives.
struct GNUNET_MessageHeader * msg
#define GNUNET_MESSAGE_TYPE_ARM_STATUS
Status update from ARM.
void * service_status_cls
Closure for service_status.
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.
struct GNUNET_TIME_Relative retry_backoff
Current delay we use for re-trying to connect to core.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Status update from ARM to client.
GNUNET_MQ_Error
Error codes for the queue.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void reconnect_arm_monitor_later(struct GNUNET_ARM_MonitorHandle *h)
Close down any existing connection to the ARM service and try re-establishing it later.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle for interacting with ARM.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
struct GNUNET_MessageHeader header
Reply to client, of type is GNUNET_MESSAGE_TYPE_ARM_STATUS.
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.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_ARM_MonitorHandle * GNUNET_ARM_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ServiceMonitorCallback cont, void *cont_cls)
Setup a context for monitoring ARM, then start connecting to the ARM service for monitoring using tha...
Message handler for a specific message type.
static int check_monitor_notify(void *cls, const struct GNUNET_ARM_StatusMessage *msg)
Check notification messages received from ARM is well-formed.
struct GNUNET_MQ_Envelope * env
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
void GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Handle to a message queue.
uint32_t status
Status from the 'enum GNUNET_ARM_ServiceStatus'.
#define GNUNET_MESSAGE_TYPE_ARM_MONITOR
Request to ARM to notify client of service status changes.
Entry in list of pending tasks.
struct GNUNET_MQ_Handle * mq
Our control connection to the ARM service.
static void reconnect_arm_monitor_task(void *cls)
Task scheduled to try to re-connect to arm.
static void handle_monitor_notify(void *cls, const struct GNUNET_ARM_StatusMessage *res)
Handler for notification messages received from ARM.
GNUNET_ARM_ServiceMonitorStatus
Statuses of services.
GNUNET_ARM_ServiceMonitorCallback service_status
Callback to invoke on status updates.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
static int reconnect_arm_monitor(struct GNUNET_ARM_MonitorHandle *h)
Connect to the ARM service for monitoring.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.