45 #include <sys/types.h> 46 #include <sys/socket.h> 47 #include <sys/select.h> 51 #include <qb/qbipcc.h> 66 qb_ipcc_connection_t *
c;
76 static void cfg_inst_free (
void *inst);
92 error =
hdb_error_to_cs (hdb_handle_create (&cfg_hdb,
sizeof (
struct cfg_inst), cfg_handle));
94 goto error_no_destroy;
97 error =
hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (
void *)&cfg_inst));
104 if (cfg_inst->
c == NULL) {
106 goto error_put_destroy;
113 (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
118 (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
120 (void)hdb_handle_destroy (&cfg_hdb, *cfg_handle);
128 int32_t *selection_fd)
133 error =
hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (
void *)&cfg_inst));
134 if (error !=
CS_OK) {
140 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
155 struct qb_ipc_response_header *dispatch_data;
160 if (error !=
CS_OK) {
172 dispatch_data = (
struct qb_ipc_response_header *)dispatch_buf;
197 if (error !=
CS_OK) {
211 switch (dispatch_data->id) {
217 res_lib_cfg_testshutdown = (
struct res_lib_cfg_testshutdown *)dispatch_data;
242 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
247 static void cfg_inst_free (
void *inst)
250 qb_ipcc_disconnect(cfg_inst->
c);
260 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (
void *)&cfg_inst));
261 if (error !=
CS_OK) {
269 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
275 (void)hdb_handle_destroy (&cfg_hdb, cfg_handle);
277 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
285 char ***interface_names,
287 unsigned int *interface_count)
296 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (
void *)&cfg_inst));
297 if (error !=
CS_OK) {
301 req_lib_cfg_ringstatusget.header.size =
sizeof (
struct req_lib_cfg_ringstatusget);
304 iov.iov_base = (
void *)&req_lib_cfg_ringstatusget,
305 iov.iov_len = sizeof (
struct req_lib_cfg_ringstatusget),
310 &res_lib_cfg_ringstatusget,
313 *interface_count = res_lib_cfg_ringstatusget.interface_count;
314 *interface_names = malloc (
sizeof (
char *) * *interface_count);
315 if (*interface_names == NULL) {
318 memset (*interface_names, 0,
sizeof (
char *) * *interface_count);
320 *status = malloc (
sizeof (
char *) * *interface_count);
321 if (*status == NULL) {
323 goto error_free_interface_names_array;
325 memset (*status, 0,
sizeof (
char *) * *interface_count);
327 for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
328 (*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
329 if ((*(interface_names))[i] == NULL) {
331 goto error_free_interface_names;
335 for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
336 (*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
337 if ((*(status))[i] == NULL) {
339 goto error_free_status;
345 for (j = 0; j < i; j++) {
346 free ((*(status))[j]);
348 i = *interface_count;
350 error_free_interface_names:
351 for (j = 0; j < i; j++) {
352 free ((*(interface_names))[j]);
357 error_free_interface_names_array:
358 free (*interface_names);
361 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
376 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (
void *)&cfg_inst));
377 if (error !=
CS_OK) {
381 req_lib_cfg_ringreenable.header.size =
sizeof (
struct req_lib_cfg_ringreenable);
384 iov.iov_base = (
void *)&req_lib_cfg_ringreenable,
385 iov.iov_len = sizeof (
struct req_lib_cfg_ringreenable);
390 &res_lib_cfg_ringreenable,
393 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
415 if (error !=
CS_OK) {
420 req_lib_cfg_killnode.header.size =
sizeof (
struct req_lib_cfg_killnode);
421 req_lib_cfg_killnode.nodeid =
nodeid;
422 strcpy((
char *)req_lib_cfg_killnode.reason.value, reason);
423 req_lib_cfg_killnode.reason.length = strlen(reason)+1;
425 iov.iov_base = (
void *)&req_lib_cfg_killnode;
426 iov.iov_len =
sizeof (
struct req_lib_cfg_killnode);
431 &res_lib_cfg_killnode,
434 error = res_lib_cfg_killnode.header.error;
436 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
438 return (error ==
CS_OK ? res_lib_cfg_killnode.header.error : error);
454 if (error !=
CS_OK) {
459 req_lib_cfg_tryshutdown.header.size =
sizeof (
struct req_lib_cfg_tryshutdown);
462 iov.iov_base = (
void *)&req_lib_cfg_tryshutdown;
463 iov.iov_len =
sizeof (req_lib_cfg_tryshutdown);
468 &res_lib_cfg_tryshutdown,
471 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
473 return (error ==
CS_OK ? res_lib_cfg_tryshutdown.header.error : error);
489 if (error !=
CS_OK) {
494 req_lib_cfg_replytoshutdown.header.size =
sizeof (
struct req_lib_cfg_replytoshutdown);
497 iov.iov_base = (
void *)&req_lib_cfg_replytoshutdown;
498 iov.iov_len =
sizeof (
struct req_lib_cfg_replytoshutdown);
503 &res_lib_cfg_replytoshutdown,
523 const char *addr_buf;
528 if (error !=
CS_OK) {
532 req_lib_cfg_get_node_addrs.header.size =
sizeof (req_lib_cfg_get_node_addrs);
536 iov.iov_base = (
char *)&req_lib_cfg_get_node_addrs;
537 iov.iov_len =
sizeof (req_lib_cfg_get_node_addrs);
543 res_lib_cfg_get_node_addrs = (
struct res_lib_cfg_get_node_addrs *)response_buf;
545 if (error !=
CS_OK) {
549 if (res_lib_cfg_get_node_addrs->
family == AF_INET)
550 addrlen =
sizeof(
struct sockaddr_in);
551 if (res_lib_cfg_get_node_addrs->
family == AF_INET6)
552 addrlen =
sizeof(
struct sockaddr_in6);
554 for (i = 0, addr_buf = (
char *)res_lib_cfg_get_node_addrs->
addrs;
555 i < max_addrs && i<res_lib_cfg_get_node_addrs->
num_addrs;
557 struct sockaddr_in *in;
558 struct sockaddr_in6 *in6;
562 if (res_lib_cfg_get_node_addrs->
family == AF_INET) {
563 in = (
struct sockaddr_in *)addrs[i].address;
564 in->sin_family = AF_INET;
565 memcpy(&in->sin_addr, addr_buf,
sizeof(
struct in_addr));
567 if (res_lib_cfg_get_node_addrs->
family == AF_INET6) {
568 in6 = (
struct sockaddr_in6 *)addrs[i].address;
569 in6->sin6_family = AF_INET6;
570 memcpy(&in6->sin6_addr, addr_buf,
sizeof(
struct in6_addr));
573 *num_addrs = res_lib_cfg_get_node_addrs->
num_addrs;
574 errno = error = res_lib_cfg_get_node_addrs->header.error;
577 hdb_handle_put (&cfg_hdb, cfg_handle);
584 unsigned int *local_nodeid)
592 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (
void *)&cfg_inst));
593 if (error !=
CS_OK) {
597 req_lib_cfg_local_get.header.size =
sizeof (
struct qb_ipc_request_header);
600 iov.iov_base = (
void *)&req_lib_cfg_local_get;
601 iov.iov_len =
sizeof (
struct req_lib_cfg_local_get);
607 &res_lib_cfg_local_get,
610 if (error !=
CS_OK) {
614 error = res_lib_cfg_local_get.header.error;
616 *local_nodeid = res_lib_cfg_local_get.local_nodeid;
619 (void)hdb_handle_put (&cfg_hdb, handle);
633 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (
void *)&cfg_inst));
634 if (error !=
CS_OK) {
638 req_lib_cfg_reload_config.header.size =
sizeof (
struct qb_ipc_request_header);
641 iov.iov_base = (
void *)&req_lib_cfg_reload_config;
642 iov.iov_len =
sizeof (
struct req_lib_cfg_reload_config);
648 &res_lib_cfg_reload_config,
651 if (error !=
CS_OK) {
655 error = res_lib_cfg_reload_config.header.error;
658 (void)hdb_handle_put (&cfg_hdb, handle);
cs_error_t corosync_cfg_kill_node(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, const char *reason)
corosync_cfg_kill_node
cs_error_t hdb_error_to_cs(int res)
The res_lib_cfg_replytoshutdown struct.
cs_error_t corosync_cfg_local_get(corosync_cfg_handle_t handle, unsigned int *local_nodeid)
corosync_cfg_local_get
struct corosync_cfg_shutdown_callback_t
The res_lib_cfg_testshutdown struct.
cs_error_t corosync_cfg_ring_status_get(corosync_cfg_handle_t cfg_handle, char ***interface_names, char ***status, unsigned int *interface_count)
corosync_cfg_ring_status_get
The req_lib_cfg_ringreenable struct.
cs_error_t corosync_cfg_fd_get(corosync_cfg_handle_t cfg_handle, int32_t *selection_fd)
corosync_cfg_fd_get
cs_error_t corosync_cfg_initialize(corosync_cfg_handle_t *cfg_handle, const corosync_cfg_callbacks_t *cfg_callbacks)
corosync_cfg_initialize
The res_lib_cfg_get_node_addrs struct.
corosync_cfg_callbacks_t callbacks
The req_lib_cfg_get_node_addrs struct.
corosync_cfg_shutdown_flags_t
Shutdown types.
cs_error_t corosync_cfg_reload_config(corosync_cfg_handle_t handle)
corosync_cfg_reload_config
uint64_t corosync_cfg_handle_t
The req_lib_cfg_reload_config struct.
#define IPC_RESPONSE_SIZE
cs_error_t corosync_cfg_finalize(corosync_cfg_handle_t cfg_handle)
corosync_cfg_finalize
#define IPC_DISPATCH_SIZE
The res_lib_cfg_local_get struct.
The res_lib_cfg_killnode struct.
cs_error_t corosync_cfg_replyto_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_reply_flags_t response)
corosync_cfg_replyto_shutdown
corosync_cfg_shutdown_callback_t corosync_cfg_shutdown_callback
The req_lib_cfg_tryshutdown struct.
cs_error_t corosync_cfg_dispatch(corosync_cfg_handle_t cfg_handle, cs_dispatch_flags_t dispatch_flags)
corosync_cfg_dispatch
The res_lib_cfg_ringreenable struct.
cs_error_t
The cs_error_t enum.
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
The req_lib_cfg_replytoshutdown struct.
The res_lib_cfg_tryshutdown struct.
DECLARE_HDB_DATABASE(cfg_hdb, cfg_inst_free)
corosync_cfg_shutdown_reply_flags_t
enum corosync_cfg_shutdown_reply_flags_t
The req_lib_cfg_ringstatusget struct.
cs_error_t corosync_cfg_try_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_flags_t flags)
corosync_cfg_try_shutdown
#define CS_MAX_NAME_LENGTH
The res_lib_cfg_ringstatusget struct.
cs_error_t corosync_cfg_get_node_addrs(corosync_cfg_handle_t cfg_handle, int nodeid, size_t max_addrs, int *num_addrs, corosync_cfg_node_address_t *addrs)
corosync_cfg_get_node_addrs
The res_lib_cfg_reload_config struct.
cs_error_t corosync_cfg_ring_reenable(corosync_cfg_handle_t cfg_handle)
corosync_cfg_ring_reenable
#define CS_IPC_TIMEOUT_MS
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
The req_lib_cfg_killnode struct.
The req_lib_cfg_local_get struct.