qdevice-net-instance.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (c) 2015-2016 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 "send-buffer-list.h"
  44. #include "tlv.h"
  45. #include "timer-list.h"
  46. #include "qdevice-net-disconnect-reason.h"
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. enum qdevice_net_instance_state {
  51. QDEVICE_NET_INSTANCE_STATE_WAITING_CONNECT,
  52. QDEVICE_NET_INSTANCE_STATE_WAITING_PREINIT_REPLY,
  53. QDEVICE_NET_INSTANCE_STATE_WAITING_STARTTLS_BEING_SENT,
  54. QDEVICE_NET_INSTANCE_STATE_WAITING_INIT_REPLY,
  55. QDEVICE_NET_INSTANCE_STATE_WAITING_SET_OPTION_REPLY,
  56. QDEVICE_NET_INSTANCE_STATE_WAITING_VOTEQUORUM_CMAP_EVENTS,
  57. };
  58. struct qdevice_net_instance {
  59. PRFileDesc *socket;
  60. size_t initial_send_size;
  61. size_t initial_receive_size;
  62. size_t max_receive_size;
  63. size_t min_send_size;
  64. struct dynar receive_buffer;
  65. struct send_buffer_list send_buffer_list;
  66. int skipping_msg;
  67. size_t msg_already_received_bytes;
  68. enum qdevice_net_instance_state state;
  69. uint32_t last_msg_seq_num;
  70. uint32_t echo_request_expected_msg_seq_num;
  71. uint32_t echo_reply_received_msg_seq_num;
  72. enum tlv_tls_supported tls_supported;
  73. int using_tls;
  74. uint32_t heartbeat_interval; /* Adjusted heartbeat interval during normal operation */
  75. uint32_t sync_heartbeat_interval; /* Adjusted heartbeat interval during corosync sync */
  76. uint32_t cast_vote_timer_interval; /* Timer for cast vote */
  77. uint32_t connect_timeout;
  78. struct timer_list_entry *cast_vote_timer;
  79. enum tlv_vote cast_vote_timer_vote;
  80. const char *host_addr;
  81. uint16_t host_port;
  82. const char *cluster_name;
  83. enum tlv_decision_algorithm_type decision_algorithm;
  84. struct timer_list main_timer_list;
  85. struct timer_list_entry *echo_request_timer;
  86. int schedule_disconnect;
  87. PRFileDesc *votequorum_poll_fd;
  88. PRFileDesc *cmap_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. };
  97. extern int qdevice_net_instance_init(struct qdevice_net_instance *instance,
  98. size_t initial_receive_size, size_t initial_send_size, size_t min_send_size,
  99. size_t max_send_buffers, size_t max_receive_size,
  100. enum tlv_tls_supported tls_supported,
  101. enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
  102. uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
  103. const char *host_addr, uint16_t host_port, const char *cluster_name,
  104. const struct tlv_tie_breaker *tie_breaker, uint32_t connect_timeout,
  105. int cmap_fd, int votequorum_fd);
  106. extern void qdevice_net_instance_clean(struct qdevice_net_instance *instance);
  107. extern int qdevice_net_instance_destroy(struct qdevice_net_instance *instance);
  108. extern int qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance);
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. #endif /* _QDEVICE_NET_INSTANCE_H_ */