qdevice-net-instance.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (c) 2015-2017 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Jan Friesse (jfriesse@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the Red Hat, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _QDEVICE_NET_INSTANCE_H_
  35. #define _QDEVICE_NET_INSTANCE_H_
  36. #include <sys/types.h>
  37. #include <stdlib.h>
  38. #include <stdint.h>
  39. #include "nss-sock.h"
  40. #include "qdevice-instance.h"
  41. #include "dynar.h"
  42. #include "node-list.h"
  43. #include "pr-poll-array.h"
  44. #include "qdevice-net-disconnect-reason.h"
  45. #include "send-buffer-list.h"
  46. #include "tlv.h"
  47. #include "timer-list.h"
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. enum qdevice_net_instance_state {
  52. QDEVICE_NET_INSTANCE_STATE_WAITING_CONNECT,
  53. QDEVICE_NET_INSTANCE_STATE_SENDING_PREINIT_REPLY,
  54. QDEVICE_NET_INSTANCE_STATE_WAITING_PREINIT_REPLY,
  55. QDEVICE_NET_INSTANCE_STATE_WAITING_STARTTLS_BEING_SENT,
  56. QDEVICE_NET_INSTANCE_STATE_WAITING_INIT_REPLY,
  57. QDEVICE_NET_INSTANCE_STATE_WAITING_VOTEQUORUM_CMAP_EVENTS,
  58. };
  59. struct qdevice_net_instance {
  60. PRFileDesc *socket;
  61. struct dynar receive_buffer;
  62. struct send_buffer_list send_buffer_list;
  63. int skipping_msg;
  64. size_t msg_already_received_bytes;
  65. enum qdevice_net_instance_state state;
  66. uint32_t last_msg_seq_num;
  67. uint32_t echo_request_expected_msg_seq_num;
  68. uint32_t echo_reply_received_msg_seq_num;
  69. enum tlv_tls_supported tls_supported;
  70. int using_tls;
  71. int tls_client_cert_sent;
  72. uint32_t heartbeat_interval; /* Adjusted heartbeat interval during normal operation */
  73. uint32_t sync_heartbeat_interval; /* Adjusted heartbeat interval during corosync sync */
  74. uint32_t cast_vote_timer_interval; /* Timer for cast vote */
  75. uint32_t connect_timeout;
  76. struct timer_list_entry *cast_vote_timer;
  77. enum tlv_vote cast_vote_timer_vote;
  78. int cast_vote_timer_paused;
  79. const char *host_addr;
  80. uint16_t host_port;
  81. const char *cluster_name;
  82. enum tlv_decision_algorithm_type decision_algorithm;
  83. struct timer_list main_timer_list;
  84. struct timer_list_entry *echo_request_timer;
  85. int schedule_disconnect;
  86. PRFileDesc *votequorum_poll_fd;
  87. PRFileDesc *cmap_poll_fd;
  88. PRFileDesc *ipc_socket_poll_fd;
  89. struct tlv_ring_id last_sent_ring_id;
  90. struct tlv_tie_breaker tie_breaker;
  91. void *algorithm_data;
  92. enum qdevice_net_disconnect_reason disconnect_reason;
  93. struct qdevice_instance *qdevice_instance_ptr;
  94. struct nss_sock_non_blocking_client non_blocking_client;
  95. struct timer_list_entry *connect_timer;
  96. int force_ip_version;
  97. struct pr_poll_array poll_array;
  98. time_t last_echo_reply_received_time;
  99. time_t connected_since_time;
  100. const struct qdevice_advanced_settings *advanced_settings;
  101. PRFileDesc *heuristics_pipe_cmd_send_poll_fd;
  102. PRFileDesc *heuristics_pipe_cmd_recv_poll_fd;
  103. PRFileDesc *heuristics_pipe_log_recv_poll_fd;
  104. struct timer_list_entry *regular_heuristics_timer;
  105. int server_supports_heuristics;
  106. enum tlv_heuristics latest_regular_heuristics_result;
  107. enum tlv_heuristics latest_connect_heuristics_result;
  108. enum tlv_heuristics latest_vq_heuristics_result;
  109. enum tlv_heuristics latest_heuristics_result;
  110. };
  111. extern int qdevice_net_instance_init(struct qdevice_net_instance *instance,
  112. enum tlv_tls_supported tls_supported,
  113. enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
  114. uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
  115. const char *host_addr, uint16_t host_port, const char *cluster_name,
  116. const struct tlv_tie_breaker *tie_breaker, uint32_t connect_timeout, int force_ip_version,
  117. int cmap_fd, int votequorum_fd, int local_socket_fd,
  118. const struct qdevice_advanced_settings *advanced_settings,
  119. int heuristics_pipe_cmd_send_fd, int heuristics_pipe_cmd_recv_fd,
  120. int heuristics_pipe_log_recv_fd);
  121. extern void qdevice_net_instance_clean(struct qdevice_net_instance *instance);
  122. extern int qdevice_net_instance_destroy(struct qdevice_net_instance *instance);
  123. extern int qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance);
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif /* _QDEVICE_NET_INSTANCE_H_ */