pacemaker  2.0.2-debe490
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-2019 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 
23 #include <sys/uio.h>
24 #include <qb/qbipcc.h>
25 #include <crm/common/xml.h>
26 
27 /* clplumbing based IPC */
28 
29 # define create_reply(request, xml_response_data) create_reply_adv(request, xml_response_data, __FUNCTION__);
30 xmlNode *create_reply_adv(xmlNode * request, xmlNode * xml_response_data, const char *origin);
31 
32 # 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__)
33 
34 xmlNode *create_request_adv(const char *task, xmlNode * xml_data, const char *host_to,
35  const char *sys_to, const char *sys_from, const char *uuid_from,
36  const char *origin);
37 
38 /* *INDENT-OFF* */
40 {
41  crm_ipc_flags_none = 0x00000000,
42 
43  crm_ipc_compressed = 0x00000001, /* Message has been compressed */
44 
45  crm_ipc_proxied = 0x00000100, /* _ALL_ replies to proxied connections need to be sent as events */
46  crm_ipc_client_response = 0x00000200, /* A Response is expected in reply */
47 
48  /* These options are just options for crm_ipcs_sendv() */
49  crm_ipc_server_event = 0x00010000, /* Send an Event instead of a Response */
50  crm_ipc_server_free = 0x00020000, /* Free the iovec after sending */
51  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.*/
52 
53  crm_ipc_server_info = 0x00100000, /* Log failures as LOG_INFO */
54  crm_ipc_server_error = 0x00200000, /* Log failures as LOG_ERR */
55 };
56 /* *INDENT-ON* */
57 
58 typedef struct crm_ipc_s crm_ipc_t;
59 
60 crm_ipc_t *crm_ipc_new(const char *name, size_t max_size);
61 bool crm_ipc_connect(crm_ipc_t * client);
62 void crm_ipc_close(crm_ipc_t * client);
63 void crm_ipc_destroy(crm_ipc_t * client);
64 void pcmk_free_ipc_event(struct iovec *event);
65 
66 int crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags,
67  int32_t ms_timeout, xmlNode ** reply);
68 
69 int crm_ipc_get_fd(crm_ipc_t * client);
70 bool crm_ipc_connected(crm_ipc_t * client);
71 int crm_ipc_ready(crm_ipc_t * client);
72 long crm_ipc_read(crm_ipc_t * client);
73 const char *crm_ipc_buffer(crm_ipc_t * client);
74 uint32_t crm_ipc_buffer_flags(crm_ipc_t * client);
75 const char *crm_ipc_name(crm_ipc_t * client);
76 unsigned int crm_ipc_default_buffer_size(void);
77 
113 int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid,
114  pid_t *gotpid, uid_t *gotuid, gid_t *gotgid);
115 
116 /* Utils */
117 xmlNode *create_hello_message(const char *uuid, const char *client_name,
118  const char *major_version, const char *minor_version);
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
Definition: ipc.c:955
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc.c:1061
xmlNode * create_reply_adv(xmlNode *request, xmlNode *xml_response_data, const char *origin)
Definition: ipc.c:133
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc.c:1170
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Definition: ipc.c:1580
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc.c:1224
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc.c:1217
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:58
Wrappers for and extensions to libxml2.
unsigned int crm_ipc_default_buffer_size(void)
Definition: ipc.c:71
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc.c:1038
void pcmk_free_ipc_event(struct iovec *event)
Free an I/O vector created by crm_ipc_prepare()
Definition: ipc.c:425
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc.c:1075
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
Definition: ipc.c:1107
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc.c:1238
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Definition: ipc.c:1320
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:88
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Definition: ipc.c:925
crm_ipc_flags
Definition: ipc.h:39
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc.c:1023
uint64_t flags
Definition: remote.c:148
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.
Definition: ipc.c:1452