pacemaker  2.1.0-7c3f660
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ipc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2020 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef CRM_COMMON_IPC__H
11 # define CRM_COMMON_IPC__H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
24 #include <sys/uio.h>
25 #include <qb/qbipcc.h>
26 #include <crm/common/xml.h>
27 
28 /*
29  * Message creation utilities
30  *
31  * These are used for both IPC messages and cluster layer messages. However,
32  * since this is public API, they stay in this header for backward
33  * compatibility.
34  */
35 
36 #define create_reply(request, xml_response_data) \
37  create_reply_adv(request, xml_response_data, __func__)
38 
39 xmlNode *create_reply_adv(xmlNode *request, xmlNode *xml_response_data,
40  const char *origin);
41 
42 #define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from) \
43  create_request_adv(task, xml_data, host_to, sys_to, sys_from, uuid_from, \
44  __func__)
45 
46 xmlNode *create_request_adv(const char *task, xmlNode *xml_data,
47  const char *host_to, const char *sys_to,
48  const char *sys_from, const char *uuid_from,
49  const char *origin);
50 
51 
52 /*
53  * The library supports two methods of creating IPC connections. The older code
54  * allows connecting to any arbitrary IPC name. The newer code only allows
55  * connecting to one of the Pacemaker daemons.
56  *
57  * As daemons are converted to use the new model, the old functions should be
58  * considered deprecated for use with those daemons. Once all daemons are
59  * converted, the old functions should be officially deprecated as public API
60  * and eventually made internal API.
61  */
62 
63 /*
64  * Pacemaker daemon IPC
65  */
66 
76 };
77 
84 };
85 
91 };
92 
95 
110 typedef void (*pcmk_ipc_callback_t)(pcmk_ipc_api_t *api,
111  enum pcmk_ipc_event event_type,
112  crm_exit_t status,
113  void *event_data, void *user_data);
114 
116 
118 
120 
122 
123 int pcmk_poll_ipc(pcmk_ipc_api_t *api, int timeout_ms);
124 
126 
128  void *user_data);
129 
130 const char *pcmk_ipc_name(pcmk_ipc_api_t *api, bool for_log);
131 
133 
134 int pcmk_ipc_purge_node(pcmk_ipc_api_t *api, const char *node_name,
135  uint32_t nodeid);
136 
137 
138 /*
139  * Generic IPC API (to eventually be deprecated as public API and made internal)
140  */
141 
142 /* *INDENT-OFF* */
144 {
145  crm_ipc_flags_none = 0x00000000,
146 
147  crm_ipc_compressed = 0x00000001, /* Message has been compressed */
148 
149  crm_ipc_proxied = 0x00000100, /* _ALL_ replies to proxied connections need to be sent as events */
150  crm_ipc_client_response = 0x00000200, /* A Response is expected in reply */
151 
152  // These are options for Pacemaker's internal use only (pcmk__ipc_send_*())
153  crm_ipc_server_event = 0x00010000, /* Send an Event instead of a Response */
154  crm_ipc_server_free = 0x00020000, /* Free the iovec after sending */
155  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.*/
156 
157  crm_ipc_server_info = 0x00100000, /* Log failures as LOG_INFO */
158  crm_ipc_server_error = 0x00200000, /* Log failures as LOG_ERR */
159 };
160 /* *INDENT-ON* */
161 
162 typedef struct crm_ipc_s crm_ipc_t;
163 
164 crm_ipc_t *crm_ipc_new(const char *name, size_t max_size);
165 bool crm_ipc_connect(crm_ipc_t * client);
166 void crm_ipc_close(crm_ipc_t * client);
167 void crm_ipc_destroy(crm_ipc_t * client);
168 void pcmk_free_ipc_event(struct iovec *event);
169 
170 int crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags,
171  int32_t ms_timeout, xmlNode ** reply);
172 
173 int crm_ipc_get_fd(crm_ipc_t * client);
174 bool crm_ipc_connected(crm_ipc_t * client);
175 int crm_ipc_ready(crm_ipc_t * client);
176 long crm_ipc_read(crm_ipc_t * client);
177 const char *crm_ipc_buffer(crm_ipc_t * client);
178 uint32_t crm_ipc_buffer_flags(crm_ipc_t * client);
179 const char *crm_ipc_name(crm_ipc_t * client);
180 unsigned int crm_ipc_default_buffer_size(void);
181 
217 int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid,
218  pid_t *gotpid, uid_t *gotuid, gid_t *gotgid);
219 
220 /* This is controller-specific but is declared in this header for C API
221  * backward compatibility.
222  */
223 xmlNode *create_hello_message(const char *uuid, const char *client_name,
224  const char *major_version, const char *minor_version);
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
230 #endif
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
Definition: ipc_client.c:792
void(* pcmk_ipc_callback_t)(pcmk_ipc_api_t *api, enum pcmk_ipc_event event_type, crm_exit_t status, void *event_data, void *user_data)
Callback function type for Pacemaker daemon IPC APIs.
Definition: ipc.h:110
enum pcmk_ipc_dispatch dispatch_type
Scheduler.
Definition: ipc.h:75
int pcmk_connect_ipc(pcmk_ipc_api_t *api, enum pcmk_ipc_dispatch dispatch_type)
Connect to a Pacemaker daemon via IPC.
Definition: ipc_client.c:452
Launcher.
Definition: ipc.h:74
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc_client.c:901
int pcmk_new_ipc_api(pcmk_ipc_api_t **api, enum pcmk_ipc_server server)
Create a new object for using Pacemaker daemon IPC.
Definition: ipc_client.c:47
void pcmk_dispatch_ipc(pcmk_ipc_api_t *api)
Dispatch available messages on an IPC connection (without main loop)
Definition: ipc_client.c:391
xmlNode * create_reply_adv(xmlNode *request, xmlNode *xml_response_data, const char *origin)
Create a Pacemaker reply (for IPC or cluster layer)
Definition: messages.c:102
int pcmk_ipc_purge_node(pcmk_ipc_api_t *api, const char *node_name, uint32_t nodeid)
Ask a Pacemaker daemon to purge a node from its peer cache.
Definition: ipc_client.c:692
enum crm_exit_e crm_exit_t
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc_client.c:1011
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Create XML for a controller IPC &quot;hello&quot; message.
Definition: ipc_controld.c:633
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc_client.c:1063
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc_client.c:1056
int pcmk_poll_ipc(pcmk_ipc_api_t *api, int timeout_ms)
Check whether an IPC connection has data available (without main loop)
Definition: ipc_client.c:361
CIB manager.
Definition: ipc.h:70
Caller will poll and dispatch IPC.
Definition: ipc.h:89
pcmk_ipc_server
Available IPC interfaces.
Definition: ipc.h:68
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:162
pcmk_ipc_callback_t cb
const char * pcmk_ipc_name(pcmk_ipc_api_t *api, bool for_log)
Get the IPC name used with an IPC API connection.
Definition: ipc_client.c:241
Wrappers for and extensions to libxml2.
unsigned int crm_ipc_default_buffer_size(void)
Return pacemaker&#39;s default IPC buffer size.
Definition: ipc_common.c:62
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc_client.c:875
void pcmk_free_ipc_event(struct iovec *event)
Free an I/O vector created by pcmk__ipc_prepare_iov()
Definition: ipc_server.c:280
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc_client.c:915
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
Definition: ipc_client.c:947
pcmk_ipc_dispatch
How IPC replies should be dispatched.
Definition: ipc.h:87
Notification from daemon.
Definition: ipc.h:83
pcmk_ipc_event
Possible event types that an IPC event callback can be called for.
Definition: ipc.h:79
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc_client.c:1077
Attach IPC to GMainLoop for dispatch.
Definition: ipc.h:88
Termination of IPC connection.
Definition: ipc.h:81
Executor.
Definition: ipc.h:72
Controller.
Definition: ipc.h:71
Sending a command will wait for any reply.
Definition: ipc.h:90
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Send an IPC XML message.
Definition: ipc_client.c:1150
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)
Create a Pacemaker request (for IPC or cluster layer)
Definition: messages.c:40
void pcmk_free_ipc_api(pcmk_ipc_api_t *api)
Free the contents of an IPC API object.
Definition: ipc_client.c:200
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Create a new (legacy) object for using Pacemaker daemon IPC.
Definition: ipc_client.c:745
Fencer.
Definition: ipc.h:73
Daemon&#39;s reply to client IPC request.
Definition: ipc.h:82
Result of asynchronous connection attempt.
Definition: ipc.h:80
Attribute manager.
Definition: ipc.h:69
enum pcmk_ipc_server server
char * name
Definition: pcmk_fence.c:31
void pcmk_register_ipc_callback(pcmk_ipc_api_t *api, pcmk_ipc_callback_t cb, void *user_data)
Register a callback for IPC API events.
Definition: ipc_client.c:561
crm_ipc_flags
Definition: ipc.h:143
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc_client.c:862
void pcmk_disconnect_ipc(pcmk_ipc_api_t *api)
Disconnect an IPC API instance.
Definition: ipc_client.c:511
uint64_t flags
Definition: remote.c:149
int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid, pid_t *gotpid, uid_t *gotuid, gid_t *gotgid)
Check the authenticity of the IPC socket peer process (legacy)
Definition: ipc_client.c:1382
bool pcmk_ipc_is_connected(pcmk_ipc_api_t *api)
Check whether an IPC API connection is active.
Definition: ipc_client.c:281