API for accessing the ARM service. More...
#include "platform.h"#include "gnunet_util_lib.h"#include "gnunet_arm_service.h"#include "gnunet_protocols.h"#include "arm.h"Go to the source code of this file.
Data Structures | |
| struct | GNUNET_ARM_Operation |
| Entry in a doubly-linked list of operations awaiting for replies (in-order) from the ARM service. More... | |
| struct | GNUNET_ARM_Handle |
| Handle for interacting with ARM. More... | |
Macros | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "arm-api", __VA_ARGS__) |
Functions | |
| static enum GNUNET_GenericReturnValue | reconnect_arm (struct GNUNET_ARM_Handle *h) |
| Connect to arm. | |
| static void | reconnect_arm_task (void *cls) |
| Task scheduled to try to re-connect to arm. | |
| static void | reconnect_arm_later (struct GNUNET_ARM_Handle *h) |
| Close down any existing connection to the ARM service and try re-establishing it later. | |
| static struct GNUNET_ARM_Operation * | find_op_by_id (struct GNUNET_ARM_Handle *h, uint64_t id) |
| Find a control message by its unique ID. | |
| static void | handle_arm_result (void *cls, const struct GNUNET_ARM_ResultMessage *res) |
| Handler for ARM replies. | |
| static const char * | pool_get (const char *pool_start, size_t pool_size, size_t str_index) |
| Read from a string pool. | |
| static enum GNUNET_GenericReturnValue | check_arm_list_result (void *cls, const struct GNUNET_ARM_ListResultMessage *lres) |
| Check that list result message is well-formed. | |
| static void | handle_arm_list_result (void *cls, const struct GNUNET_ARM_ListResultMessage *lres) |
| Handler for ARM list replies. | |
| static void | handle_confirm (void *cls, const struct GNUNET_MessageHeader *msg) |
| Receive confirmation from test, ARM service is up. | |
| 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 creation of the message queue. | |
| struct GNUNET_ARM_Handle * | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls) |
| Set up a context for communicating with ARM, then start connecting to the ARM service using that context. | |
| void | GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h) |
| Disconnect from the ARM service (if connected) and destroy the context. | |
| static enum GNUNET_ARM_Result | start_arm_service (struct GNUNET_ARM_Handle *h, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_FileHandle *sigfd) |
| A client specifically requested starting of ARM itself. | |
| void | GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation *op) |
| Abort an operation. | |
| static struct GNUNET_ARM_Operation * | change_service (struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cb, void *cb_cls, uint16_t type) |
| Start or stop a service. | |
| static void | notify_running (void *cls) |
| Task run to notify application that ARM is already up. | |
| static void | notify_starting (void *cls) |
| Task run to notify application that ARM is being started. | |
| struct GNUNET_ARM_Operation * | GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls) |
| Request for a service to be started. | |
| struct GNUNET_ARM_Operation * | GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls) |
| Request a service to be stopped. | |
| struct GNUNET_ARM_Operation * | GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, GNUNET_ARM_ServiceListCallback cont, void *cont_cls) |
| Request a list of running services. | |
API for accessing the ARM service.
Definition in file arm_api.c.
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "arm-api", __VA_ARGS__) |
|
static |
Connect to arm.
| h | arm handle |
Definition at line 519 of file arm_api.c.
References GNUNET_ARM_Handle::cfg, GNUNET_ARM_Handle::conn_status, GNUNET_ARM_Handle::conn_status_cls, GNUNET_ARM_Handle::currently_up, env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT, GNUNET_MESSAGE_TYPE_ARM_RESULT, GNUNET_MESSAGE_TYPE_ARM_TEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, h, handlers, LOG, GNUNET_ARM_Handle::mq, and mq_error_handler().
Referenced by GNUNET_ARM_connect(), GNUNET_ARM_request_service_start(), and reconnect_arm_task().
|
static |
Task scheduled to try to re-connect to arm.
| cls | the struct GNUNET_ARM_Handle |
Definition at line 183 of file arm_api.c.
References h, reconnect_arm(), and GNUNET_ARM_Handle::reconnect_task.
Referenced by reconnect_arm_later().
|
static |
Close down any existing connection to the ARM service and try re-establishing it later.
| h | our handle |
Definition at line 199 of file arm_api.c.
References GNUNET_ARM_Handle::conn_status, GNUNET_ARM_Handle::conn_status_cls, GNUNET_ARM_Operation::cont_cls, GNUNET_ARM_Handle::currently_up, GNUNET_ARM_operation_cancel(), GNUNET_ARM_REQUEST_DISCONNECTED, GNUNET_assert, GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, GNUNET_ARM_Operation::list_cont, GNUNET_ARM_Handle::mq, op, GNUNET_ARM_Handle::operation_pending_head, reconnect_arm_task(), GNUNET_ARM_Handle::reconnect_task, GNUNET_ARM_Operation::result_cont, and GNUNET_ARM_Handle::retry_backoff.
Referenced by mq_error_handler().
|
static |
Find a control message by its unique ID.
| h | ARM handle |
| id | unique message ID to use for the lookup |
Definition at line 243 of file arm_api.c.
References h, GNUNET_ARM_Handle::operation_pending_head, and result.
Referenced by handle_arm_list_result(), and handle_arm_result().
|
static |
Handler for ARM replies.
| cls | our struct GNUNET_ARM_Handle |
| res | the message received from the arm service |
Definition at line 262 of file arm_api.c.
References GNUNET_ARM_Operation::cont_cls, find_op_by_id(), GNUNET_ARM_operation_cancel(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_STOPPING, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_ntohll(), GNUNET_YES, h, id, GNUNET_ARM_Operation::is_arm_stop, LOG, op, GNUNET_ARM_Handle::operation_pending_head, GNUNET_ARM_Handle::operation_pending_tail, res, result, GNUNET_ARM_Operation::result_cont, and GNUNET_ARM_Handle::thm.
|
static |
Read from a string pool.
| pool_start | start of the string pool |
| pool_size | size of the string pool |
| str_index | index into the string pool |
Definition at line 325 of file arm_api.c.
References end.
Referenced by check_arm_list_result(), and handle_arm_list_result().
|
static |
Check that list result message is well-formed.
| cls | our struct GNUNET_ARM_Handle |
| lres | the message received from the arm service |
Definition at line 350 of file arm_api.c.
References GNUNET_ARM_ListResultMessage::arm_msg, GNUNET_ARM_ServiceInfoMessage::binary_index, GNUNET_ARM_ListResultMessage::count, GNUNET_break_op, GNUNET_NO, GNUNET_OK, GNUNET_ARM_Message::header, GNUNET_ARM_ServiceInfoMessage::name_index, pool_get(), and GNUNET_MessageHeader::size.
|
static |
Handler for ARM list replies.
| cls | our struct GNUNET_ARM_Handle |
| lres | the message received from the arm service |
Definition at line 399 of file arm_api.c.
References GNUNET_ARM_ListResultMessage::arm_msg, GNUNET_ARM_ServiceInfo::binary, GNUNET_ARM_ServiceInfoMessage::binary_index, GNUNET_ARM_Operation::cont_cls, GNUNET_ARM_ListResultMessage::count, find_op_by_id(), GNUNET_ARM_operation_cancel(), GNUNET_ARM_REQUEST_SENT_OK, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ntohll(), GNUNET_TIME_absolute_ntoh(), h, GNUNET_ARM_Message::header, id, GNUNET_ARM_ServiceInfoMessage::last_exit_status, GNUNET_ARM_ServiceInfoMessage::last_started_at, list, GNUNET_ARM_Operation::list_cont, LOG, name, GNUNET_ARM_ServiceInfo::name, GNUNET_ARM_ServiceInfoMessage::name_index, op, pool_get(), GNUNET_ARM_Message::request_id, GNUNET_ARM_ServiceInfoMessage::restart_at, GNUNET_MessageHeader::size, and GNUNET_ARM_ServiceInfoMessage::status.
|
static |
Receive confirmation from test, ARM service is up.
| cls | closure with the struct GNUNET_ARM_Handle |
| msg | message received |
Definition at line 466 of file arm_api.c.
References GNUNET_ARM_Handle::conn_status, GNUNET_ARM_Handle::conn_status_cls, GNUNET_ARM_Handle::currently_up, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_YES, h, LOG, and msg.
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
| cls | closure with the struct GNUNET_ARM_Handle * |
| error | error code |
Definition at line 492 of file arm_api.c.
References GNUNET_ARM_Operation::cont_cls, GNUNET_ARM_Handle::currently_up, GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_STOPPED, GNUNET_free, GNUNET_NO, h, op, reconnect_arm_later(), GNUNET_ARM_Operation::result_cont, and GNUNET_ARM_Handle::thm.
Referenced by reconnect_arm().
|
static |
A client specifically requested starting of ARM itself.
Starts the ARM service.
| h | the handle with configuration details |
| std_inheritance | inheritance of std streams |
| sigfd | socket to pass to ARM for signalling |
Definition at line 654 of file arm_api.c.
References GNUNET_ARM_Handle::cfg, config, GNUNET_DISK_FileHandle::fd, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_START_FAILED, GNUNET_ARM_RESULT_STARTING, GNUNET_asprintf(), GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_config_missing(), GNUNET_NO, GNUNET_OK, GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_process_destroy(), GNUNET_OS_project_data_gnunet(), GNUNET_OS_start_process_s(), GNUNET_strdup, GNUNET_YES, and h.
Referenced by GNUNET_ARM_request_service_start().
|
static |
Start or stop a service.
| h | handle to ARM |
| service_name | name of the service |
| cb | callback to invoke when service is ready |
| cb_cls | closure for cb |
| type | type of the request |
Definition at line 832 of file arm_api.c.
References GNUNET_ARM_Operation::cont_cls, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_htonll(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, h, GNUNET_ARM_Operation::h, GNUNET_ARM_Operation::id, GNUNET_ARM_Handle::mq, msg, op, GNUNET_ARM_Handle::operation_pending_head, GNUNET_ARM_Handle::operation_pending_tail, GNUNET_ARM_Handle::request_id_counter, GNUNET_ARM_Operation::result_cont, service_name, and type.
Referenced by GNUNET_ARM_request_service_start(), and GNUNET_ARM_request_service_stop().
|
static |
Task run to notify application that ARM is already up.
| cls | the operation that asked ARM to be started |
Definition at line 878 of file arm_api.c.
References GNUNET_ARM_Operation::async, GNUNET_ARM_Handle::conn_status, GNUNET_ARM_Handle::conn_status_cls, GNUNET_ARM_Operation::cont_cls, GNUNET_ARM_Handle::currently_up, GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, h, GNUNET_ARM_Operation::h, op, GNUNET_ARM_Handle::operation_pending_head, GNUNET_ARM_Handle::operation_pending_tail, and GNUNET_ARM_Operation::result_cont.
Referenced by GNUNET_ARM_request_service_start().
|
static |
Task run to notify application that ARM is being started.
| cls | the operation that asked ARM to be started |
Definition at line 905 of file arm_api.c.
References GNUNET_ARM_Operation::async, GNUNET_ARM_Operation::cont_cls, GNUNET_ARM_REQUEST_SENT_OK, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_file_close(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, GNUNET_ARM_Operation::h, LOG, op, GNUNET_ARM_Handle::operation_pending_head, GNUNET_ARM_Handle::operation_pending_tail, GNUNET_ARM_Operation::result_cont, GNUNET_ARM_Operation::rfd, and GNUNET_ARM_Operation::starting_ret.
Referenced by GNUNET_ARM_request_service_start().