pacemaker  2.0.1-15814c6c0d
Scalable High-Availability cluster resource manager
ipc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2018 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This source code is licensed under the GNU Lesser General Public License
5  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
6  */
7 
8 #ifndef CRM_COMMON_IPC__H
9 # define CRM_COMMON_IPC__H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
21 #include <sys/uio.h>
22 #include <qb/qbipcc.h>
23 #include <crm/common/xml.h>
24 
25 /* clplumbing based IPC */
26 
27 # define create_reply(request, xml_response_data) create_reply_adv(request, xml_response_data, __FUNCTION__);
28 xmlNode *create_reply_adv(xmlNode * request, xmlNode * xml_response_data, const char *origin);
29 
30 # define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from) create_request_adv(task, xml_data, host_to, sys_to, sys_from, uuid_from, __FUNCTION__)
31 
32 xmlNode *create_request_adv(const char *task, xmlNode * xml_data, const char *host_to,
33  const char *sys_to, const char *sys_from, const char *uuid_from,
34  const char *origin);
35 
36 /* *INDENT-OFF* */
38 {
39  crm_ipc_flags_none = 0x00000000,
40 
41  crm_ipc_compressed = 0x00000001, /* Message has been compressed */
42 
43  crm_ipc_proxied = 0x00000100, /* _ALL_ replies to proxied connections need to be sent as events */
44  crm_ipc_client_response = 0x00000200, /* A Response is expected in reply */
45 
46  /* These options are just options for crm_ipcs_sendv() */
47  crm_ipc_server_event = 0x00010000, /* Send an Event instead of a Response */
48  crm_ipc_server_free = 0x00020000, /* Free the iovec after sending */
49  crm_ipc_proxied_relay_response = 0x00040000, /* all replies to proxied connections are sent as events, this flag preserves whether the event should be treated as an actual event, or a response.*/
50 
51  crm_ipc_server_info = 0x00100000, /* Log failures as LOG_INFO */
52  crm_ipc_server_error = 0x00200000, /* Log failures as LOG_ERR */
53 };
54 /* *INDENT-ON* */
55 
56 typedef struct crm_ipc_s crm_ipc_t;
57 
58 crm_ipc_t *crm_ipc_new(const char *name, size_t max_size);
59 bool crm_ipc_connect(crm_ipc_t * client);
60 void crm_ipc_close(crm_ipc_t * client);
61 void crm_ipc_destroy(crm_ipc_t * client);
62 void pcmk_free_ipc_event(struct iovec *event);
63 
64 int crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags,
65  int32_t ms_timeout, xmlNode ** reply);
66 
67 int crm_ipc_get_fd(crm_ipc_t * client);
68 bool crm_ipc_connected(crm_ipc_t * client);
69 int crm_ipc_ready(crm_ipc_t * client);
70 long crm_ipc_read(crm_ipc_t * client);
71 const char *crm_ipc_buffer(crm_ipc_t * client);
73 const char *crm_ipc_name(crm_ipc_t * client);
74 unsigned int crm_ipc_default_buffer_size(void);
75 
76 /* Utils */
77 xmlNode *create_hello_message(const char *uuid, const char *client_name,
78  const char *major_version, const char *minor_version);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
Definition: ipc.c:938
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc.c:1007
xmlNode * create_reply_adv(xmlNode *request, xmlNode *xml_response_data, const char *origin)
Definition: ipc.c:118
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc.c:1116
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Definition: ipc.c:1400
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc.c:1170
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc.c:1163
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:56
Wrappers for and extensions to libxml2.
unsigned int crm_ipc_default_buffer_size(void)
Definition: ipc.c:56
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc.c:984
void pcmk_free_ipc_event(struct iovec *event)
Free an I/O vector created by crm_ipc_prepare()
Definition: ipc.c:410
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc.c:1021
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
Definition: ipc.c:1053
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc.c:1184
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Definition: ipc.c:1266
xmlNode * create_request_adv(const char *task, xmlNode *xml_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin)
Definition: ipc.c:73
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Definition: ipc.c:910
#define uint32_t
Definition: stdint.in.h:158
crm_ipc_flags
Definition: ipc.h:37
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc.c:969
uint64_t flags
Definition: remote.c:148
#define int32_t
Definition: stdint.in.h:157