1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
34 enum client_type {
35 CRM_CLIENT_IPC = 1,
36 CRM_CLIENT_TCP = 2,
37 # ifdef HAVE_GNUTLS_GNUTLS_H
38 CRM_CLIENT_TLS = 3,
39 # endif
40 };
41
42 struct crm_remote_s {
43
44 char *buffer;
45 size_t buffer_size;
46 size_t buffer_offset;
47 int auth_timeout;
48 int tcp_socket;
49 mainloop_io_t *source;
50
51
52 bool authenticated;
53 char *token;
54
55
56 # ifdef HAVE_GNUTLS_GNUTLS_H
57 gnutls_session_t *tls_session;
58 bool tls_handshake_complete;
59 # endif
60 };
61
62 enum crm_client_flags
63 {
64 crm_client_flag_ipc_proxied = 0x00001,
65 crm_client_flag_ipc_privileged = 0x00002,
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
79
80 long long options;
81
82 int request_id;
83 uint32_t flags;
84 void *userdata;
85
86 int event_timer;
87 GList *event_queue;
88
89
90
91
92 enum client_type kind;
93
94 qb_ipcs_connection_t *ipcs;
95
96 struct crm_remote_s *remote;
97
98 unsigned int queue_backlog;
99 unsigned int queue_max;
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);
113 void crm_client_destroy(crm_client_t * c);
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
117 void crm_ipcs_send_ack(crm_client_t * c, uint32_t request, uint32_t flags,
118 const char *tag, const char *function, int line);
119
120
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