mar_clm.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (C) 2006 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.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 MontaVista Software, 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 AIS_MAR_CLM_H_DEFINED
  35. #define AIS_MAR_CLM_H_DEFINED
  36. #include "saAis.h"
  37. #include "saClm.h"
  38. #include "mar_gen.h"
  39. #define MAR_CLM_MAX_ADDRESS_LENGTH 64
  40. typedef enum {
  41. MAR_CLM_AF_INET = 1,
  42. MAR_CLM_AF_INET6 = 2
  43. } mar_clm_node_address_family_t;
  44. /*
  45. * Marshalling the SaClmNodeAdressT data structure
  46. */
  47. typedef struct {
  48. unsigned short length __attribute__((aligned(8)));
  49. mar_clm_node_address_family_t family __attribute__((aligned(8)));
  50. unsigned char value[MAR_CLM_MAX_ADDRESS_LENGTH] __attribute__((aligned(8)));
  51. } mar_clm_node_address_t;
  52. static inline void marshall_from_mar_clm_node_address_t (
  53. SaClmNodeAddressT *dest,
  54. mar_clm_node_address_t *src)
  55. {
  56. dest->family = src->family;
  57. dest->length = src->length;
  58. memcpy (dest->value, src->value, SA_CLM_MAX_ADDRESS_LENGTH);
  59. }
  60. static inline void marshall_to_mar_clm_node_address_t (
  61. mar_clm_node_address_t *dest,
  62. SaClmNodeAddressT *src)
  63. {
  64. dest->family = src->family;
  65. dest->length = src->length;
  66. memcpy (dest->value, src->value, SA_CLM_MAX_ADDRESS_LENGTH);
  67. }
  68. /*
  69. * Marshalling the SaClmClusterNodeT data structure
  70. */
  71. typedef struct {
  72. unsigned int node_id __attribute__((aligned(8)));
  73. mar_clm_node_address_t node_address __attribute__((aligned(8)));
  74. mar_name_t node_name __attribute__((aligned(8)));
  75. unsigned int member __attribute__((aligned(8)));
  76. unsigned long long boot_timestamp __attribute__((aligned(8)));
  77. unsigned long long initial_view_number __attribute__((aligned(8)));
  78. } mar_clm_cluster_node_t;
  79. static inline void marshall_to_mar_clm_cluster_node_t (
  80. mar_clm_cluster_node_t *dest,
  81. SaClmClusterNodeT *src)
  82. {
  83. dest->node_id = src->nodeId;
  84. marshall_to_mar_clm_node_address_t (&dest->node_address,
  85. &src->nodeAddress);
  86. marshall_to_mar_name_t (&dest->node_name, &src->nodeName);
  87. dest->member = src->member;
  88. dest->boot_timestamp = src->bootTimestamp;
  89. dest->initial_view_number = src->initialViewNumber;
  90. }
  91. static inline void marshall_from_mar_clm_cluster_node_t (
  92. SaClmClusterNodeT *dest,
  93. mar_clm_cluster_node_t *src)
  94. {
  95. dest->nodeId = src->node_id;
  96. marshall_from_mar_clm_node_address_t (&dest->nodeAddress,
  97. &src->node_address);
  98. marshall_from_mar_name_t (&dest->nodeName, &src->node_name);
  99. dest->member = src->member;
  100. dest->bootTimestamp = src->boot_timestamp;
  101. dest->initialViewNumber = src->initial_view_number;
  102. }
  103. typedef enum {
  104. MAR_NODE_NO_CHANGE = 1,
  105. MAR_NODE_JOINED = 2,
  106. MAR_NODE_LEFT = 3,
  107. MAR_NODE_RECONFIGURED = 4
  108. } mar_clm_cluster_change_t;
  109. /*
  110. * Marshalling the SaClmClusterNotificationT data structure
  111. */
  112. typedef struct {
  113. mar_clm_cluster_node_t cluster_node __attribute__((aligned(8)));
  114. mar_clm_cluster_change_t cluster_change __attribute__((aligned(8)));
  115. } mar_clm_cluster_notification_t;
  116. static inline void marshall_to_mar_clm_cluster_notification_t (
  117. mar_clm_cluster_notification_t *dest,
  118. SaClmClusterNotificationT *src)
  119. {
  120. marshall_to_mar_clm_cluster_node_t (&dest->cluster_node,
  121. &src->clusterNode);
  122. dest->cluster_change = src->clusterChange;
  123. }
  124. static inline void marshall_from_mar_clm_cluster_notification_t (
  125. SaClmClusterNotificationT *dest,
  126. mar_clm_cluster_notification_t *src)
  127. {
  128. marshall_from_mar_clm_cluster_node_t (&dest->clusterNode,
  129. &src->cluster_node);
  130. dest->clusterChange = src->cluster_change;
  131. }
  132. typedef struct {
  133. unsigned long long view_number __attribute__((aligned(8)));
  134. unsigned int number_of_items __attribute__((aligned(8)));
  135. unsigned long long notification __attribute__((aligned(8)));
  136. } mar_clm_cluster_notification_buffer_t;
  137. static inline void marshall_to_mar_cluster_notification_buffer_t (
  138. mar_clm_cluster_notification_buffer_t *dest,
  139. SaClmClusterNotificationBufferT *src)
  140. {
  141. dest->view_number = src->viewNumber;
  142. dest->number_of_items = src->numberOfItems;
  143. memcpy (&dest->notification, &src->notification,
  144. sizeof (SaClmClusterNotificationBufferT *));
  145. }
  146. static inline void marshall_from_mar_cluster_notification_buffer_t (
  147. SaClmClusterNotificationBufferT *dest,
  148. mar_clm_cluster_notification_buffer_t *src)
  149. {
  150. dest->viewNumber = src->view_number;
  151. dest->numberOfItems = src->number_of_items;
  152. memcpy (&dest->notification, &src->notification,
  153. sizeof (SaClmClusterNotificationBufferT *));
  154. }
  155. #endif /* AIS_MAR_CLM_H_DEFINED */