qdevice-net-instance.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2015 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 <prio.h>
  40. #include <cmap.h>
  41. #include <votequorum.h>
  42. #include "dynar.h"
  43. #include "send-buffer-list.h"
  44. #include "tlv.h"
  45. #include "timer-list.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. enum qdevice_net_instance_state {
  50. QDEVICE_NET_INSTANCE_STATE_WAITING_PREINIT_REPLY,
  51. QDEVICE_NET_INSTANCE_STATE_WAITING_STARTTLS_BEING_SENT,
  52. QDEVICE_NET_INSTANCE_STATE_WAITING_INIT_REPLY,
  53. QDEVICE_NET_INSTANCE_STATE_WAITING_SET_OPTION_REPLY,
  54. QDEVICE_NET_INSTANCE_STATE_WAITING_VOTEQUORUM_CMAP_EVENTS,
  55. };
  56. struct qdevice_net_instance {
  57. PRFileDesc *socket;
  58. size_t initial_send_size;
  59. size_t initial_receive_size;
  60. size_t max_receive_size;
  61. size_t min_send_size;
  62. struct dynar receive_buffer;
  63. struct send_buffer_list send_buffer_list;
  64. int skipping_msg;
  65. size_t msg_already_received_bytes;
  66. enum qdevice_net_instance_state state;
  67. uint32_t last_msg_seq_num;
  68. uint32_t echo_request_expected_msg_seq_num;
  69. uint32_t echo_reply_received_msg_seq_num;
  70. enum tlv_tls_supported tls_supported;
  71. int using_tls;
  72. uint32_t node_id;
  73. uint32_t heartbeat_interval; /* Heartbeat interval during normal operation */
  74. uint32_t sync_heartbeat_interval; /* Heartbeat interval during corosync sync */
  75. uint32_t cast_vote_timer_interval; /* Timer for cast vote */
  76. struct timer_list_entry *cast_vote_timer;
  77. enum tlv_vote cast_vote_timer_vote;
  78. const char *host_addr;
  79. uint16_t host_port;
  80. const char *cluster_name;
  81. enum tlv_decision_algorithm_type decision_algorithm;
  82. struct timer_list main_timer_list;
  83. struct timer_list_entry *echo_request_timer;
  84. int schedule_disconnect;
  85. cmap_handle_t cmap_handle;
  86. votequorum_handle_t votequorum_handle;
  87. PRFileDesc *votequorum_poll_fd;
  88. votequorum_ring_id_t last_received_votequorum_ring_id;
  89. };
  90. extern int qdevice_net_instance_init(struct qdevice_net_instance *instance,
  91. size_t initial_receive_size, size_t initial_send_size, size_t min_send_size,
  92. size_t max_send_buffers, size_t max_receive_size,
  93. enum tlv_tls_supported tls_supported, uint32_t node_id,
  94. enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
  95. uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
  96. const char *host_addr, uint16_t host_port, const char *cluster_name);
  97. extern int qdevice_net_instance_destroy(struct qdevice_net_instance *instance);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* _QDEVICE_NET_INSTANCE_H_ */