totem.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Red Hat, Inc.
  4. * Copyright (c) 2006 Sun Microsystems, Inc.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * All rights reserved.
  9. *
  10. * This software licensed under BSD license, the text of which follows:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  21. * contributors may be used to endorse or promote products derived from this
  22. * software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  34. * THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #ifndef TOTEM_H_DEFINED
  37. #define TOTEM_H_DEFINED
  38. #include "totemip.h"
  39. #include "../include/swab.h"
  40. #define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
  41. #define PROCESSOR_COUNT_MAX 384
  42. #define FRAME_SIZE_MAX 9000
  43. #define TRANSMITS_ALLOWED 16
  44. #define SEND_THREADS_MAX 16
  45. #define INTERFACE_MAX 2
  46. /*
  47. * Array location of various timeouts as
  48. * specified in openais.conf. The last enum
  49. * specifies the size of the timeouts array and
  50. * needs to remain the last item in the list.
  51. */
  52. enum {
  53. TOTEM_RETRANSMITS_BEFORE_LOSS,
  54. TOTEM_TOKEN,
  55. TOTEM_RETRANSMIT_TOKEN,
  56. TOTEM_HOLD_TOKEN,
  57. TOTEM_JOIN,
  58. TOTEM_CONSENSUS,
  59. TOTEM_MERGE,
  60. TOTEM_DOWNCHECK,
  61. TOTEM_FAIL_RECV_CONST,
  62. MAX_TOTEM_TIMEOUTS /* Last item */
  63. } totem_timeout_types;
  64. struct totem_interface {
  65. struct totem_ip_address bindnet;
  66. struct totem_ip_address boundto;
  67. struct totem_ip_address mcast_addr;
  68. uint16_t ip_port;
  69. };
  70. struct totem_logging_configuration {
  71. void (*log_printf) (char *, int, int, char *, ...) __attribute__((format(printf, 4, 5)));
  72. int log_level_security;
  73. int log_level_error;
  74. int log_level_warning;
  75. int log_level_notice;
  76. int log_level_debug;
  77. };
  78. struct totem_config {
  79. int version;
  80. /*
  81. * network
  82. */
  83. struct totem_interface *interfaces;
  84. int interface_count;
  85. unsigned int node_id;
  86. /*
  87. * key information
  88. */
  89. unsigned char private_key[128];
  90. int private_key_len;
  91. /*
  92. * Totem configuration parameters
  93. */
  94. unsigned int token_timeout;
  95. unsigned int token_retransmit_timeout;
  96. unsigned int token_hold_timeout;
  97. unsigned int token_retransmits_before_loss_const;
  98. unsigned int join_timeout;
  99. unsigned int send_join_timeout;
  100. unsigned int consensus_timeout;
  101. unsigned int merge_timeout;
  102. unsigned int downcheck_timeout;
  103. unsigned int fail_to_recv_const;
  104. unsigned int seqno_unchanged_const;
  105. unsigned int rrp_token_expired_timeout;
  106. unsigned int rrp_problem_count_timeout;
  107. unsigned int rrp_problem_count_threshold;
  108. char rrp_mode[64];
  109. struct totem_logging_configuration totem_logging_configuration;
  110. unsigned int secauth;
  111. unsigned int net_mtu;
  112. unsigned int threads;
  113. unsigned int heartbeat_failures_allowed;
  114. unsigned int max_network_delay;
  115. unsigned int window_size;
  116. unsigned int max_messages;
  117. char *vsf_type;
  118. };
  119. enum totem_configuration_type {
  120. TOTEM_CONFIGURATION_REGULAR,
  121. TOTEM_CONFIGURATION_TRANSITIONAL
  122. };
  123. enum totem_callback_token_type {
  124. TOTEM_CALLBACK_TOKEN_RECEIVED = 1,
  125. TOTEM_CALLBACK_TOKEN_SENT = 2
  126. };
  127. struct memb_ring_id {
  128. struct totem_ip_address rep;
  129. unsigned long long seq;
  130. } __attribute__((packed));
  131. typedef struct memb_ring_id memb_ring_id_t;
  132. static inline void swab_memb_ring_id_t (memb_ring_id_t *to_swab)
  133. {
  134. swab_totem_ip_address_t (&to_swab->rep);
  135. to_swab->seq = swab64 (to_swab->seq);
  136. }
  137. static inline void memb_ring_id_copy(
  138. memb_ring_id_t *out, memb_ring_id_t *in)
  139. {
  140. totemip_copy (&out->rep, &in->rep);
  141. out->seq = in->seq;
  142. }
  143. static inline void memb_ring_id_copy_endian_convert(
  144. memb_ring_id_t *out, memb_ring_id_t *in)
  145. {
  146. totemip_copy_endian_convert (&out->rep, &in->rep);
  147. out->seq = swab64 (in->seq);
  148. }
  149. #endif /* TOTEM_H_DEFINED */