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));
102 cfg_inst->finalize = 0;
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) {
138 error =
qb_to_cs_error (qb_ipcc_fd_get (cfg_inst->c, selection_fd));
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;
225 if (cfg_inst->finalize) {
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) {
268 if (cfg_inst->finalize) {
269 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
273 cfg_inst->finalize = 1;
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 if (error !=
CS_OK) {
314 goto exit_handle_put;
317 *interface_count = res_lib_cfg_ringstatusget.interface_count;
318 *interface_names = malloc (
sizeof (
char *) * *interface_count);
319 if (*interface_names == NULL) {
322 memset (*interface_names, 0,
sizeof (
char *) * *interface_count);
324 *status = malloc (
sizeof (
char *) * *interface_count);
325 if (*status == NULL) {
327 goto error_free_interface_names_array;
329 memset (*status, 0,
sizeof (
char *) * *interface_count);
331 for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
332 (*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
333 if ((*(interface_names))[i] == NULL) {
335 goto error_free_interface_names;
339 for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
340 (*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
341 if ((*(status))[i] == NULL) {
343 goto error_free_status;
346 goto exit_handle_put;
349 for (j = 0; j < i; j++) {
350 free ((*(status))[j]);
352 i = *interface_count;
354 error_free_interface_names:
355 for (j = 0; j < i; j++) {
356 free ((*(interface_names))[j]);
361 error_free_interface_names_array:
362 free (*interface_names);
365 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
380 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (
void *)&cfg_inst));
381 if (error !=
CS_OK) {
385 req_lib_cfg_ringreenable.header.size =
sizeof (
struct req_lib_cfg_ringreenable);
388 iov.iov_base = (
void *)&req_lib_cfg_ringreenable,
389 iov.iov_len = sizeof (
struct req_lib_cfg_ringreenable);
394 &res_lib_cfg_ringreenable,
397 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
419 if (error !=
CS_OK) {
424 req_lib_cfg_killnode.header.size =
sizeof (
struct req_lib_cfg_killnode);
425 req_lib_cfg_killnode.nodeid =
nodeid;
426 strcpy((
char *)req_lib_cfg_killnode.reason.value, reason);
427 req_lib_cfg_killnode.reason.length = strlen(reason)+1;
429 iov.iov_base = (
void *)&req_lib_cfg_killnode;
430 iov.iov_len =
sizeof (
struct req_lib_cfg_killnode);
435 &res_lib_cfg_killnode,
438 error = res_lib_cfg_killnode.header.error;
440 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
442 return (error ==
CS_OK ? res_lib_cfg_killnode.header.error : error);
458 if (error !=
CS_OK) {
463 req_lib_cfg_tryshutdown.header.size =
sizeof (
struct req_lib_cfg_tryshutdown);
466 iov.iov_base = (
void *)&req_lib_cfg_tryshutdown;
467 iov.iov_len =
sizeof (req_lib_cfg_tryshutdown);
472 &res_lib_cfg_tryshutdown,
475 (void)hdb_handle_put (&cfg_hdb, cfg_handle);
477 return (error ==
CS_OK ? res_lib_cfg_tryshutdown.header.error : error);
493 if (error !=
CS_OK) {
498 req_lib_cfg_replytoshutdown.header.size =
sizeof (
struct req_lib_cfg_replytoshutdown);
501 iov.iov_base = (
void *)&req_lib_cfg_replytoshutdown;
502 iov.iov_len =
sizeof (
struct req_lib_cfg_replytoshutdown);
507 &res_lib_cfg_replytoshutdown,
527 const char *addr_buf;
532 if (error !=
CS_OK) {
536 req_lib_cfg_get_node_addrs.header.size =
sizeof (req_lib_cfg_get_node_addrs);
540 iov.iov_base = (
char *)&req_lib_cfg_get_node_addrs;
541 iov.iov_len =
sizeof (req_lib_cfg_get_node_addrs);
547 res_lib_cfg_get_node_addrs = (
struct res_lib_cfg_get_node_addrs *)response_buf;
549 if (error !=
CS_OK) {
553 if (res_lib_cfg_get_node_addrs->
family == AF_INET)
554 addrlen =
sizeof(
struct sockaddr_in);
555 if (res_lib_cfg_get_node_addrs->
family == AF_INET6)
556 addrlen =
sizeof(
struct sockaddr_in6);
558 for (i = 0, addr_buf = (
char *)res_lib_cfg_get_node_addrs->
addrs;
559 i < max_addrs && i<res_lib_cfg_get_node_addrs->
num_addrs;
561 struct sockaddr_in *in;
562 struct sockaddr_in6 *in6;
566 if (res_lib_cfg_get_node_addrs->
family == AF_INET) {
567 in = (
struct sockaddr_in *)addrs[i].address;
568 in->sin_family = AF_INET;
569 memcpy(&in->sin_addr, addr_buf,
sizeof(
struct in_addr));
571 if (res_lib_cfg_get_node_addrs->
family == AF_INET6) {
572 in6 = (
struct sockaddr_in6 *)addrs[i].address;
573 in6->sin6_family = AF_INET6;
574 memcpy(&in6->sin6_addr, addr_buf,
sizeof(
struct in6_addr));
577 *num_addrs = res_lib_cfg_get_node_addrs->
num_addrs;
578 errno = error = res_lib_cfg_get_node_addrs->header.error;
581 hdb_handle_put (&cfg_hdb, cfg_handle);
588 unsigned int *local_nodeid)
596 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (
void *)&cfg_inst));
597 if (error !=
CS_OK) {
601 req_lib_cfg_local_get.header.size =
sizeof (
struct qb_ipc_request_header);
604 iov.iov_base = (
void *)&req_lib_cfg_local_get;
605 iov.iov_len =
sizeof (
struct req_lib_cfg_local_get);
611 &res_lib_cfg_local_get,
614 if (error !=
CS_OK) {
618 error = res_lib_cfg_local_get.header.error;
620 *local_nodeid = res_lib_cfg_local_get.local_nodeid;
623 (void)hdb_handle_put (&cfg_hdb, handle);
637 error =
hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (
void *)&cfg_inst));
638 if (error !=
CS_OK) {
642 req_lib_cfg_reload_config.header.size =
sizeof (
struct qb_ipc_request_header);
645 iov.iov_base = (
void *)&req_lib_cfg_reload_config;
646 iov.iov_len =
sizeof (
struct req_lib_cfg_reload_config);
652 &res_lib_cfg_reload_config,
655 if (error !=
CS_OK) {
659 error = res_lib_cfg_reload_config.header.error;
662 (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.