pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
ipc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2024 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 PCMK__CRM_COMMON_IPC__H
11 #define PCMK__CRM_COMMON_IPC__H
12 
13 
14 #include <sys/uio.h>
15 #include <qb/qbipcc.h>
16 #include <crm/common/xml.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
29 /*
30  * The library supports two methods of creating IPC connections. The older code
31  * allows connecting to any arbitrary IPC name. The newer code only allows
32  * connecting to one of the Pacemaker daemons.
33  *
34  * As daemons are converted to use the new model, the old functions should be
35  * considered deprecated for use with those daemons. Once all daemons are
36  * converted, the old functions should be officially deprecated as public API
37  * and eventually made internal API.
38  */
39 
40 /*
41  * Pacemaker daemon IPC
42  */
43 
44 /* @COMPAT This is also used internally for cluster message types, but it's not
45  * worth the hassle of redefining this public API just to change the name.
46  */
57 };
58 
59 // NOTE: sbd (as of at least 1.5.2) uses this enum
63 
64  // NOTE: sbd (as of at least 1.5.2) uses this value
66 
67  // NOTE: sbd (as of at least 1.5.2) uses this value
69 
71 };
72 
78 };
79 
80 // NOTE: sbd (as of at least 1.5.2) uses this
83 
98 typedef void (*pcmk_ipc_callback_t)(pcmk_ipc_api_t *api,
99  enum pcmk_ipc_event event_type,
100  crm_exit_t status,
101  void *event_data, void *user_data);
102 
103 // NOTE: sbd (as of at least 1.5.2) uses this
105 
106 // NOTE: sbd (as of at least 1.5.2) uses this
108 
109 // NOTE: sbd (as of at least 1.5.2) uses this
111 
113 
114 int pcmk_poll_ipc(const pcmk_ipc_api_t *api, int timeout_ms);
115 
117 
118 // NOTE: sbd (as of at least 1.5.2) uses this
120  void *user_data);
121 
122 const char *pcmk_ipc_name(const pcmk_ipc_api_t *api, bool for_log);
123 
125 
126 int pcmk_ipc_purge_node(pcmk_ipc_api_t *api, const char *node_name,
127  uint32_t nodeid);
128 
129 
130 /*
131  * Generic IPC API (to eventually be deprecated as public API and made internal)
132  */
133 
134 /* *INDENT-OFF* */
136 {
137  crm_ipc_flags_none = 0x00000000,
138 
139  crm_ipc_compressed = 0x00000001, /* Message has been compressed */
140 
141  crm_ipc_proxied = 0x00000100, /* _ALL_ replies to proxied connections need to be sent as events */
142  crm_ipc_client_response = 0x00000200, /* A Response is expected in reply */
143 
144  // These are options for Pacemaker's internal use only (pcmk__ipc_send_*())
145  crm_ipc_server_event = 0x00010000, /* Send an Event instead of a Response */
146  crm_ipc_server_free = 0x00020000, /* Free the iovec after sending */
147  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.*/
148 };
149 /* *INDENT-ON* */
150 
151 typedef struct crm_ipc_s crm_ipc_t;
152 
153 crm_ipc_t *crm_ipc_new(const char *name, size_t max_size);
154 void crm_ipc_close(crm_ipc_t * client);
155 void crm_ipc_destroy(crm_ipc_t * client);
156 void pcmk_free_ipc_event(struct iovec *event);
157 
158 int crm_ipc_send(crm_ipc_t *client, const xmlNode *message,
159  enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply);
160 
161 int crm_ipc_get_fd(crm_ipc_t * client);
162 bool crm_ipc_connected(crm_ipc_t * client);
163 int crm_ipc_ready(crm_ipc_t * client);
164 long crm_ipc_read(crm_ipc_t * client);
165 const char *crm_ipc_buffer(crm_ipc_t * client);
166 uint32_t crm_ipc_buffer_flags(crm_ipc_t * client);
167 const char *crm_ipc_name(crm_ipc_t * client);
168 unsigned int crm_ipc_default_buffer_size(void);
169 
205 int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid,
206  pid_t *gotpid, uid_t *gotuid, gid_t *gotgid);
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif
enum pcmk_ipc_dispatch dispatch_type
Scheduler.
Definition: ipc.h:56
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:561
const char * name
Definition: cib.c:26
Launcher.
Definition: ipc.h:55
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc_client.c:1014
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:46
void pcmk_dispatch_ipc(pcmk_ipc_api_t *api)
Dispatch available messages on an IPC connection (without main loop)
Definition: ipc_client.c:429
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:791
enum crm_exit_e crm_exit_t
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc_client.c:1118
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc_client.c:1173
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc_client.c:1166
int pcmk_poll_ipc(const pcmk_ipc_api_t *api, int timeout_ms)
Check whether an IPC connection has data available (without main loop)
Definition: ipc_client.c:389
CIB manager.
Definition: ipc.h:51
Caller will poll and dispatch IPC.
Definition: ipc.h:76
pcmk_ipc_server
Available IPC interfaces.
Definition: ipc.h:48
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:151
pcmk_ipc_callback_t cb
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:88
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc_client.c:966
void pcmk_free_ipc_event(struct iovec *event)
Free an I/O vector created by pcmk__ipc_prepare_iov()
Definition: ipc_server.c:259
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:98
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc_client.c:1028
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
Definition: ipc_client.c:1060
pcmk_ipc_dispatch
How IPC replies should be dispatched.
Definition: ipc.h:74
Notification from daemon.
Definition: ipc.h:70
pcmk_ipc_event
Possible event types that an IPC event callback can be called for.
Definition: ipc.h:61
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc_client.c:1187
Attach IPC to GMainLoop for dispatch.
Definition: ipc.h:75
Termination of IPC connection.
Definition: ipc.h:65
Executor.
Definition: ipc.h:53
Controller.
Definition: ipc.h:52
Sending a command will wait for any reply.
Definition: ipc.h:77
Unknown or invalid.
Definition: ipc.h:49
void pcmk_free_ipc_api(pcmk_ipc_api_t *api)
Free the contents of an IPC API object.
Definition: ipc_client.c:206
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:844
const char * pcmk_ipc_name(const pcmk_ipc_api_t *api, bool for_log)
Get the IPC name used with an IPC API connection.
Definition: ipc_client.c:247
Fencer.
Definition: ipc.h:54
Daemon&#39;s reply to client IPC request.
Definition: ipc.h:68
Result of asynchronous connection attempt.
Definition: ipc.h:62
Attribute manager.
Definition: ipc.h:50
enum pcmk_ipc_server server
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:635
int crm_ipc_send(crm_ipc_t *client, const xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Send an IPC XML message.
Definition: ipc_client.c:1260
crm_ipc_flags
Definition: ipc.h:135
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc_client.c:953
void pcmk_disconnect_ipc(pcmk_ipc_api_t *api)
Disconnect an IPC API instance.
Definition: ipc_client.c:584
uint64_t flags
Definition: remote.c:211
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:1532
bool pcmk_ipc_is_connected(pcmk_ipc_api_t *api)
Check whether an IPC API connection is active.
Definition: ipc_client.c:277