14 #include <sys/types.h> 17 #include <libxml/tree.h> 59 const char *reply_to,
const char *sender_system,
60 const char *recipient_node,
const char *recipient_system,
61 const char *task, xmlNode *
data)
63 static unsigned int message_counter = 0U;
65 xmlNode *message = NULL;
66 char *message_id = NULL;
70 && !pcmk__str_empty(sender_system)
71 && !pcmk__str_empty(task),
74 if (reply_to == NULL) {
77 (
unsigned long long) time(NULL),
79 reply_to = message_id;
151 crm_warn(
"Cannot reply to invalid message: No message type specified");
159 crm_trace(
"Creating a reply for a non-request original message");
164 host_from, sys_from, operation,
data);
183 GHashTable *commands = g_hash_table_new(g_str_hash, g_str_equal);
185 if (handlers != NULL) {
188 for (i = 0; handlers[i].
command != NULL; ++i) {
189 g_hash_table_insert(commands, (gpointer) handlers[i].command,
190 handlers[i].handler);
192 if (handlers[i].handler != NULL) {
194 g_hash_table_insert(commands, (gpointer)
"", handlers[i].handler);
214 CRM_CHECK((request != NULL) && (request->
op != NULL) && (handlers != NULL),
223 handler = g_hash_table_lookup(handlers, request->
op);
224 if (handler == NULL) {
225 handler = g_hash_table_lookup(handlers,
"");
226 if (handler == NULL) {
227 crm_info(
"Ignoring %s request from %s %s with no handler",
228 request->
op, pcmk__request_origin_type(request),
229 pcmk__request_origin(request));
234 return (*handler)(request);
#define CRM_CHECK(expr, failure_action)
xmlNode * pcmk__new_message_as(const char *origin, enum pcmk_ipc_server server, const char *reply_to, const char *sender_system, const char *recipient_node, const char *recipient_system, const char *task, xmlNode *data)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
#define PCMK__VALUE_RESPONSE
enum pcmk_ipc_server type
GHashTable * pcmk__register_handlers(const pcmk__server_command_t handlers[])
#define PCMK_XA_REFERENCE
pcmk__client_t * ipc_client
const char * pcmk__server_message_type(enum pcmk_ipc_server server)
void pcmk__reset_request(pcmk__request_t *request)
#define PCMK__XA_CRM_HOST_TO
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
#define PCMK__XA_CRM_SYS_TO
#define PCMK__XA_CRM_TASK
pcmk__action_result_t result
#define crm_warn(fmt, args...)
pcmk_ipc_server
Available IPC interfaces.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Wrappers for and extensions to libxml2.
enum pcmk_ipc_server pcmk__parse_server(const char *text)
#define PCMK__XA_CRM_SYS_FROM
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
xmlNode * pcmk__new_reply_as(const char *origin, const xmlNode *original_request, xmlNode *data)
xmlNode * pcmk__process_request(pcmk__request_t *request, GHashTable *handlers)
void pcmk__reset_result(pcmk__action_result_t *result)
#define PCMK__VALUE_REQUEST
#define crm_info(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1