pacemaker  1.1.18-7fdfbbe
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 (C) 2013 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef CRM_COMMON_IPCS__H
20 # define CRM_COMMON_IPCS__H
21 
22 # include <stdbool.h>
23 # include <qb/qbipcs.h>
24 # ifdef HAVE_GNUTLS_GNUTLS_H
25 # undef KEYFILE
26 # include <gnutls/gnutls.h>
27 # endif
28 
29 # include <crm/common/ipc.h>
30 # include <crm/common/mainloop.h>
31 
32 typedef struct crm_client_s crm_client_t;
33 
37 # ifdef HAVE_GNUTLS_GNUTLS_H
38  CRM_CLIENT_TLS = 3,
39 # endif
40 };
41 
42 struct crm_remote_s {
43  /* Shared */
44  char *buffer;
45  size_t buffer_size;
46  size_t buffer_offset;
50 
51  /* CIB-only */
53  char *token;
54 
55  /* TLS only */
56 # ifdef HAVE_GNUTLS_GNUTLS_H
57  gnutls_session_t *tls_session;
58  bool tls_handshake_complete;
59 # endif
60 };
61 
63 {
64  crm_client_flag_ipc_proxied = 0x00001, /* ipc_proxy code only */
65  crm_client_flag_ipc_privileged = 0x00002, /* root or cluster user */
66 };
67 
68 struct crm_client_s {
69  uint pid;
70 
71  uid_t uid;
72  gid_t gid;
73 
74  char *id;
75  char *name;
76  char *user;
77 
78  /* Provided for server use (not used by library) */
79  /* @TODO merge options, flags, and kind (reserving lower bits for server) */
80  long long options;
81 
84  void *userdata;
85 
87  GList *event_queue; /* @TODO use GQueue instead */
88 
89  /* Depending on the value of kind, only some of the following
90  * will be populated/valid
91  */
93 
94  qb_ipcs_connection_t *ipcs; /* IPC */
95 
96  struct crm_remote_s *remote; /* TCP/TLS */
97 
98  unsigned int queue_backlog; /* IPC queue length after last flush */
99  unsigned int queue_max; /* Evict client whose queue grows this big */
100 };
101 
102 extern GHashTable *client_connections;
103 
104 void crm_client_init(void);
105 void crm_client_cleanup(void);
106 
107 crm_client_t *crm_client_get(qb_ipcs_connection_t * c);
108 crm_client_t *crm_client_get_by_id(const char *id);
109 const char *crm_client_name(crm_client_t * c);
110 
111 crm_client_t *crm_client_alloc(void *key);
112 crm_client_t *crm_client_new(qb_ipcs_connection_t * c, uid_t uid, gid_t gid);
114 void crm_client_disconnect_all(qb_ipcs_service_t *s);
115 bool crm_set_client_queue_max(crm_client_t *client, const char *qmax);
116 
118  const char *tag, const char *function, int line);
119 
120 /* when max_send_size is 0, default ipc buffer size is used */
121 ssize_t crm_ipc_prepare(uint32_t request, xmlNode * message, struct iovec ** result, uint32_t max_send_size);
122 ssize_t crm_ipcs_send(crm_client_t * c, uint32_t request, xmlNode * message, enum crm_ipc_flags flags);
123 ssize_t crm_ipcs_sendv(crm_client_t * c, struct iovec *iov, enum crm_ipc_flags flags);
124 xmlNode *crm_ipcs_recv(crm_client_t * c, void *data, size_t size, uint32_t * id, uint32_t * flags);
125 
126 int crm_ipcs_client_pid(qb_ipcs_connection_t * c);
127 
128 #endif
void crm_client_destroy(crm_client_t *c)
Definition: ipc.c:366
client_type
Definition: ipcs.h:34
size_t buffer_offset
Definition: ipcs.h:46
crm_client_t * crm_client_alloc(void *key)
Allocate a new crm_client_t object and generate its ID.
Definition: ipc.c:304
void crm_client_disconnect_all(qb_ipcs_service_t *s)
Definition: ipc.c:274
mainloop_io_t * source
Definition: ipcs.h:49
uid_t uid
Definition: ipcs.h:71
uint32_t flags
Definition: ipcs.h:83
qb_ipcs_connection_t * ipcs
Definition: ipcs.h:94
uint32_t size
Definition: internal.h:52
int request_id
Definition: ipcs.h:82
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
Definition: ipc.c:445
struct mainloop_io_s mainloop_io_t
Definition: mainloop.h:35
char * buffer
Definition: ipcs.h:44
unsigned int queue_max
Definition: ipcs.h:99
struct crm_remote_s * remote
Definition: ipcs.h:96
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
Definition: ipc.c:207
char * user
Definition: ipcs.h:76
Wrappers for and extensions to glib mainloop.
void crm_client_init(void)
Definition: ipc.c:252
char * token
Definition: ipcs.h:53
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:786
void gnutls_session_t
Definition: cib_remote.c:52
GList * event_queue
Definition: ipcs.h:87
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
Definition: ipc.c:761
unsigned int queue_backlog
Definition: ipcs.h:98
int auth_timeout
Definition: ipcs.h:47
void * userdata
Definition: ipcs.h:84
long long options
Definition: ipcs.h:80
uint pid
Definition: ipcs.h:69
int event_timer
Definition: ipcs.h:86
size_t buffer_size
Definition: ipcs.h:45
gid_t gid
Definition: ipcs.h:72
crm_client_t * crm_client_get_by_id(const char *id)
Definition: ipc.c:218
crm_client_flags
Definition: ipcs.h:62
GHashTable * client_connections
Definition: ipc.c:204
#define uint32_t
Definition: stdint.in.h:158
char data[0]
Definition: internal.h:58
ssize_t crm_ipc_prepare(uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
Definition: ipc.c:609
void crm_client_cleanup(void)
Definition: ipc.c:261
char * id
Definition: ipcs.h:74
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:421
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:435
Wrappers for and extensions to libqb IPC.
const char * crm_client_name(crm_client_t *c)
Definition: ipc.c:238
bool authenticated
Definition: ipcs.h:52
enum client_type kind
Definition: ipcs.h:92
crm_client_t * crm_client_new(qb_ipcs_connection_t *c, uid_t uid, gid_t gid)
Definition: ipc.c:315
int tcp_socket
Definition: ipcs.h:48
char * name
Definition: ipcs.h:75
crm_ipc_flags
Definition: ipc.h:41
ssize_t crm_ipcs_sendv(crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
Definition: ipc.c:688
uint64_t flags
Definition: remote.c:156