qdevice-net-instance.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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_VOTEQUORUM_CMAP_EVENTS,
  56. };
  57. struct qdevice_net_instance {
  58. PRFileDesc *socket;
  59. size_t initial_send_size;
  60. size_t initial_receive_size;
  61. size_t max_receive_size;
  62. size_t min_send_size;
  63. struct dynar receive_buffer;
  64. struct send_buffer_list send_buffer_list;
  65. int skipping_msg;
  66. size_t msg_already_received_bytes;
  67. enum qdevice_net_instance_state state;
  68. uint32_t last_msg_seq_num;
  69. uint32_t echo_request_expected_msg_seq_num;
  70. uint32_t echo_reply_received_msg_seq_num;
  71. enum tlv_tls_supported tls_supported;
  72. int using_tls;
  73. uint32_t heartbeat_interval; /* Adjusted heartbeat interval during normal operation */
  74. uint32_t sync_heartbeat_interval; /* Adjusted heartbeat interval during corosync sync */
  75. uint32_t cast_vote_timer_interval; /* Timer for cast vote */
  76. uint32_t connect_timeout;
  77. struct timer_list_entry *cast_vote_timer;
  78. enum tlv_vote cast_vote_timer_vote;
  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. struct tlv_ring_id last_sent_ring_id;
  89. struct tlv_tie_breaker tie_breaker;
  90. void *algorithm_data;
  91. enum qdevice_net_disconnect_reason disconnect_reason;
  92. struct qdevice_instance *qdevice_instance_ptr;
  93. struct nss_sock_non_blocking_client non_blocking_client;
  94. struct timer_list_entry *connect_timer;
  95. };
  96. extern int qdevice_net_instance_init(struct qdevice_net_instance *instance,
  97. size_t initial_receive_size, size_t initial_send_size, size_t min_send_size,
  98. size_t max_send_buffers, size_t max_receive_size,
  99. enum tlv_tls_supported tls_supported,
  100. enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
  101. uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
  102. const char *host_addr, uint16_t host_port, const char *cluster_name,
  103. const struct tlv_tie_breaker *tie_breaker, uint32_t connect_timeout,
  104. int cmap_fd, int votequorum_fd);
  105. extern void qdevice_net_instance_clean(struct qdevice_net_instance *instance);
  106. extern int qdevice_net_instance_destroy(struct qdevice_net_instance *instance);
  107. extern int qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance);
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif /* _QDEVICE_NET_INSTANCE_H_ */