pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ipcs_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-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_IPCS__H
11 # define CRM_COMMON_IPCS__H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 # include <stdbool.h>
18 # include <qb/qbipcs.h>
19 # ifdef HAVE_GNUTLS_GNUTLS_H
20 # undef KEYFILE
21 # include <gnutls/gnutls.h>
22 # endif
23 
24 # include <crm/common/ipc.h>
25 # include <crm/common/mainloop.h>
26 
28 
32 # ifdef HAVE_GNUTLS_GNUTLS_H
33  PCMK__CLIENT_TLS = 3,
34 # endif
35 };
36 
38  /* Shared */
39  char *buffer;
40  size_t buffer_size;
41  size_t buffer_offset;
45 
46  /* CIB-only */
48  char *token;
49 
50  /* TLS only */
51 # ifdef HAVE_GNUTLS_GNUTLS_H
52  gnutls_session_t *tls_session;
53  bool tls_handshake_complete;
54 # endif
55 };
56 
58  pcmk__client_proxied = 0x00001, /* ipc_proxy code only */
59  pcmk__client_privileged = 0x00002, /* root or cluster user */
60 };
61 
63  uint pid;
64 
65  uid_t uid;
66  gid_t gid;
67 
68  char *id;
69  char *name;
70  char *user;
71 
72  /* Provided for server use (not used by library) */
73  /* @TODO merge options, flags, and kind (reserving lower bits for server) */
74  long long options;
75 
77  uint32_t flags;
78  void *userdata;
79 
81  GQueue *event_queue;
82 
83  /* Depending on the value of kind, only some of the following
84  * will be populated/valid
85  */
87 
88  qb_ipcs_connection_t *ipcs; /* IPC */
89 
90  struct pcmk__remote_s *remote; /* TCP/TLS */
91 
92  unsigned int queue_backlog; /* IPC queue length after last flush */
93  unsigned int queue_max; /* Evict client whose queue grows this big */
94 };
95 
96 guint pcmk__ipc_client_count(void);
97 void pcmk__foreach_ipc_client(GHFunc func, gpointer user_data);
98 void pcmk__foreach_ipc_client_remove(GHRFunc func, gpointer user_data);
99 
100 void pcmk__client_cleanup(void);
101 
102 pcmk__client_t *pcmk__find_client(qb_ipcs_connection_t *c);
103 pcmk__client_t *pcmk__find_client_by_id(const char *id);
104 const char *pcmk__client_name(pcmk__client_t *c);
105 const char *pcmk__client_type_str(enum pcmk__client_type client_type);
106 
108 pcmk__client_t *pcmk__new_client(qb_ipcs_connection_t *c, uid_t uid, gid_t gid);
110 void pcmk__drop_all_clients(qb_ipcs_service_t *s);
111 bool pcmk__set_client_queue_max(pcmk__client_t *client, const char *qmax);
112 
113 void pcmk__ipc_send_ack_as(const char *function, int line, pcmk__client_t *c,
114  uint32_t request, uint32_t flags, const char *tag);
115 #define pcmk__ipc_send_ack(c, req, flags, tag) \
116  pcmk__ipc_send_ack_as(__FUNCTION__, __LINE__, (c), (req), (flags), (tag))
117 
118 int pcmk__ipc_prepare_iov(uint32_t request, xmlNode *message,
119  uint32_t max_send_size,
120  struct iovec **result, ssize_t *bytes);
121 int pcmk__ipc_send_xml(pcmk__client_t *c, uint32_t request, xmlNode *message,
122  uint32_t flags);
123 int pcmk__ipc_send_iov(pcmk__client_t *c, struct iovec *iov, uint32_t flags);
124 xmlNode *pcmk__client_data2xml(pcmk__client_t *c, void *data,
125  uint32_t *id, uint32_t *flags);
126 
127 int pcmk__client_pid(qb_ipcs_connection_t *c);
128 
129 void pcmk__serve_attrd_ipc(qb_ipcs_service_t **ipcs,
130  struct qb_ipcs_service_handlers *cb);
131 void pcmk__serve_fenced_ipc(qb_ipcs_service_t **ipcs,
132  struct qb_ipcs_service_handlers *cb);
133 qb_ipcs_service_t *pcmk__serve_controld_ipc(struct qb_ipcs_service_handlers *cb);
134 
135 void pcmk__serve_based_ipc(qb_ipcs_service_t **ipcs_ro,
136  qb_ipcs_service_t **ipcs_rw,
137  qb_ipcs_service_t **ipcs_shm,
138  struct qb_ipcs_service_handlers *ro_cb,
139  struct qb_ipcs_service_handlers *rw_cb);
140 
141 void pcmk__stop_based_ipc(qb_ipcs_service_t *ipcs_ro,
142  qb_ipcs_service_t *ipcs_rw,
143  qb_ipcs_service_t *ipcs_shm);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif
xmlNode * pcmk__client_data2xml(pcmk__client_t *c, void *data, uint32_t *id, uint32_t *flags)
Definition: ipc.c:577
int pcmk__client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:556
pcmk__client_flags
Definition: ipcs_internal.h:57
void pcmk__client_cleanup(void)
Definition: ipc.c:298
pcmk__client_t * pcmk__find_client(qb_ipcs_connection_t *c)
Definition: ipc.c:236
void pcmk__ipc_send_ack_as(const char *function, int line, pcmk__client_t *c, uint32_t request, uint32_t flags, const char *tag)
Definition: ipc.c:958
const char * pcmk__client_type_str(enum pcmk__client_type client_type)
Definition: ipc.c:281
size_t buffer_offset
Definition: ipcs_internal.h:41
void pcmk__foreach_ipc_client(GHFunc func, gpointer user_data)
Definition: ipc.c:211
struct mainloop_io_s mainloop_io_t
Definition: mainloop.h:32
void pcmk__foreach_ipc_client_remove(GHRFunc func, gpointer user_data)
Definition: ipc.c:228
GQueue * event_queue
Definition: ipcs_internal.h:81
Wrappers for and extensions to glib mainloop.
void gnutls_session_t
Definition: cib_remote.c:44
guint pcmk__ipc_client_count(void)
Definition: ipc.c:196
void pcmk__drop_all_clients(qb_ipcs_service_t *s)
Definition: ipc.c:312
void pcmk__serve_attrd_ipc(qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
Definition: ipc.c:1051
pcmk__client_t * pcmk__find_client_by_id(const char *id)
Definition: ipc.c:247
qb_ipcs_service_t * pcmk__serve_controld_ipc(struct qb_ipcs_service_handlers *cb)
Definition: ipc.c:1037
int pcmk__ipc_prepare_iov(uint32_t request, xmlNode *message, uint32_t max_send_size, struct iovec **result, ssize_t *bytes)
Definition: ipc.c:773
size_t buffer_size
Definition: ipcs_internal.h:40
int pcmk__ipc_send_iov(pcmk__client_t *c, struct iovec *iov, uint32_t flags)
Definition: ipc.c:859
int pcmk__ipc_send_xml(pcmk__client_t *c, uint32_t request, xmlNode *message, uint32_t flags)
Definition: ipc.c:936
mainloop_io_t * source
Definition: ipcs_internal.h:44
bool pcmk__set_client_queue_max(pcmk__client_t *client, const char *qmax)
Definition: ipc.c:540
void pcmk__free_client(pcmk__client_t *c)
Definition: ipc.c:489
const char * pcmk__client_name(pcmk__client_t *c)
Definition: ipc.c:267
char data[0]
Definition: internal.h:90
pcmk__client_t * pcmk__new_client(qb_ipcs_connection_t *c, uid_t uid, gid_t gid)
Definition: ipc.c:408
Wrappers for and extensions to libqb IPC.
uint32_t flags
Definition: ipcs_internal.h:77
long long options
Definition: ipcs_internal.h:74
unsigned int queue_max
Definition: ipcs_internal.h:93
struct pcmk__remote_s * remote
Definition: ipcs_internal.h:90
enum pcmk__client_type kind
Definition: ipcs_internal.h:86
void pcmk__serve_fenced_ipc(qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
Definition: ipc.c:1072
void pcmk__serve_based_ipc(qb_ipcs_service_t **ipcs_ro, qb_ipcs_service_t **ipcs_rw, qb_ipcs_service_t **ipcs_shm, struct qb_ipcs_service_handlers *ro_cb, struct qb_ipcs_service_handlers *rw_cb)
Definition: ipc.c:985
unsigned int queue_backlog
Definition: ipcs_internal.h:92
qb_ipcs_connection_t * ipcs
Definition: ipcs_internal.h:88
pcmk__client_t * pcmk__new_unauth_client(void *key)
Allocate a new pcmk__client_t object and generate its ID.
Definition: ipc.c:399
pcmk__client_type
Definition: ipcs_internal.h:29
uint64_t flags
Definition: remote.c:149
void pcmk__stop_based_ipc(qb_ipcs_service_t *ipcs_ro, qb_ipcs_service_t *ipcs_rw, qb_ipcs_service_t *ipcs_shm)
Definition: ipc.c:1019