pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ipcs.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2018 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 
27 typedef struct crm_client_s crm_client_t;
28 
32 # ifdef HAVE_GNUTLS_GNUTLS_H
33  CRM_CLIENT_TLS = 3,
34 # endif
35 };
36 
37 struct crm_remote_s {
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 {
59  crm_client_flag_ipc_proxied = 0x00001, /* ipc_proxy code only */
60  crm_client_flag_ipc_privileged = 0x00002, /* root or cluster user */
61 };
62 
63 struct crm_client_s {
64  uint pid;
65 
66  uid_t uid;
67  gid_t gid;
68 
69  char *id;
70  char *name;
71  char *user;
72 
73  /* Provided for server use (not used by library) */
74  /* @TODO merge options, flags, and kind (reserving lower bits for server) */
75  long long options;
76 
78  uint32_t flags;
79  void *userdata;
80 
82  GQueue *event_queue;
83 
84  /* Depending on the value of kind, only some of the following
85  * will be populated/valid
86  */
88 
89  qb_ipcs_connection_t *ipcs; /* IPC */
90 
91  struct crm_remote_s *remote; /* TCP/TLS */
92 
93  unsigned int queue_backlog; /* IPC queue length after last flush */
94  unsigned int queue_max; /* Evict client whose queue grows this big */
95 };
96 
97 extern GHashTable *client_connections;
98 
99 void crm_client_init(void);
100 void crm_client_cleanup(void);
101 
102 crm_client_t *crm_client_get(qb_ipcs_connection_t * c);
103 crm_client_t *crm_client_get_by_id(const char *id);
104 const char *crm_client_name(crm_client_t * c);
106 
107 crm_client_t *crm_client_alloc(void *key);
108 crm_client_t *crm_client_new(qb_ipcs_connection_t * c, uid_t uid, gid_t gid);
110 void crm_client_disconnect_all(qb_ipcs_service_t *s);
111 bool crm_set_client_queue_max(crm_client_t *client, const char *qmax);
112 
113 void crm_ipcs_send_ack(crm_client_t * c, uint32_t request, uint32_t flags,
114  const char *tag, const char *function, int line);
115 
116 /* when max_send_size is 0, default ipc buffer size is used */
117 ssize_t crm_ipc_prepare(uint32_t request, xmlNode * message, struct iovec ** result, uint32_t max_send_size);
118 ssize_t crm_ipcs_send(crm_client_t * c, uint32_t request, xmlNode * message, enum crm_ipc_flags flags);
119 ssize_t crm_ipcs_sendv(crm_client_t * c, struct iovec *iov, enum crm_ipc_flags flags);
120 xmlNode *crm_ipcs_recv(crm_client_t * c, void *data, size_t size, uint32_t * id, uint32_t * flags);
121 
122 int crm_ipcs_client_pid(qb_ipcs_connection_t * c);
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif
void crm_client_destroy(crm_client_t *c)
Definition: ipc.c:450
client_type
Definition: ipcs.h:29
size_t buffer_offset
Definition: ipcs.h:41
GQueue * event_queue
Definition: ipcs.h:82
crm_client_t * crm_client_alloc(void *key)
Allocate a new crm_client_t object and generate its ID.
Definition: ipc.c:356
void crm_client_disconnect_all(qb_ipcs_service_t *s)
Definition: ipc.c:274
mainloop_io_t * source
Definition: ipcs.h:44
uid_t uid
Definition: ipcs.h:66
uint32_t flags
Definition: ipcs.h:78
qb_ipcs_connection_t * ipcs
Definition: ipcs.h:89
uint32_t size
Definition: internal.h:86
int request_id
Definition: ipcs.h:77
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
Definition: ipc.c:524
struct mainloop_io_s mainloop_io_t
Definition: mainloop.h:32
char * buffer
Definition: ipcs.h:39
unsigned int queue_max
Definition: ipcs.h:94
struct crm_remote_s * remote
Definition: ipcs.h:91
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
Definition: ipc.c:190
char * user
Definition: ipcs.h:71
Wrappers for and extensions to glib mainloop.
void crm_client_init(void)
Definition: ipc.c:252
char * token
Definition: ipcs.h:48
void crm_ipcs_send_ack(crm_client_t *c, uint32_t request, uint32_t flags, const char *tag, const char *function, int line)
Definition: ipc.c:867
const char * crm_client_type_text(enum client_type client_type)
Definition: ipc.c:235
void gnutls_session_t
Definition: cib_remote.c:42
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
Definition: ipc.c:844
unsigned int queue_backlog
Definition: ipcs.h:93
int auth_timeout
Definition: ipcs.h:42
void * userdata
Definition: ipcs.h:79
long long options
Definition: ipcs.h:75
uint pid
Definition: ipcs.h:64
int event_timer
Definition: ipcs.h:81
size_t buffer_size
Definition: ipcs.h:40
gid_t gid
Definition: ipcs.h:67
crm_client_t * crm_client_get_by_id(const char *id)
Definition: ipc.c:201
crm_client_flags
Definition: ipcs.h:57
GHashTable * client_connections
Definition: ipc.c:187
char data[0]
Definition: internal.h:92
ssize_t crm_ipc_prepare(uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
Definition: ipc.c:697
void crm_client_cleanup(void)
Definition: ipc.c:261
char * id
Definition: ipcs.h:69
bool crm_set_client_queue_max(crm_client_t *client, const char *qmax)
Raise IPC eviction threshold for a client, if allowed.
Definition: ipc.c:500
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:514
Wrappers for and extensions to libqb IPC.
const char * crm_client_name(crm_client_t *c)
Definition: ipc.c:221
bool authenticated
Definition: ipcs.h:47
enum client_type kind
Definition: ipcs.h:87
crm_client_t * crm_client_new(qb_ipcs_connection_t *c, uid_t uid, gid_t gid)
Definition: ipc.c:365
int tcp_socket
Definition: ipcs.h:43
char * name
Definition: ipcs.h:70
crm_ipc_flags
Definition: ipc.h:39
ssize_t crm_ipcs_sendv(crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
Definition: ipc.c:771
uint64_t flags
Definition: remote.c:148