mar_clm.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2006 Red Hat, Inc.
  3. * Copyright (C) 2006 Sun Microsystems, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef AIS_MAR_CLM_H_DEFINED
  36. #define AIS_MAR_CLM_H_DEFINED
  37. #include "swab.h"
  38. #include "saAis.h"
  39. #include "saClm.h"
  40. #include "mar_gen.h"
  41. #define MAR_CLM_MAX_ADDRESS_LENGTH 64
  42. typedef enum {
  43. MAR_CLM_AF_INET = 1,
  44. MAR_CLM_AF_INET6 = 2
  45. } mar_clm_node_address_family_t;
  46. /*
  47. * Marshalling the SaClmNodeAdressT data structure
  48. */
  49. typedef struct {
  50. unsigned short length __attribute__((aligned(8)));
  51. mar_clm_node_address_family_t family __attribute__((aligned(8)));
  52. unsigned char value[MAR_CLM_MAX_ADDRESS_LENGTH] __attribute__((aligned(8)));
  53. } mar_clm_node_address_t;
  54. static inline void swab_mar_clm_node_address_t(mar_clm_node_address_t *to_swab)
  55. {
  56. swab_mar_uint16_t (&to_swab->length);
  57. swab_mar_uint32_t (&to_swab->family);
  58. }
  59. static inline void marshall_from_mar_clm_node_address_t (
  60. SaClmNodeAddressT *dest,
  61. mar_clm_node_address_t *src)
  62. {
  63. dest->family = src->family;
  64. dest->length = src->length;
  65. memcpy (dest->value, src->value, SA_CLM_MAX_ADDRESS_LENGTH);
  66. }
  67. static inline void marshall_to_mar_clm_node_address_t (
  68. mar_clm_node_address_t *dest,
  69. SaClmNodeAddressT *src)
  70. {
  71. dest->family = src->family;
  72. dest->length = src->length;
  73. memcpy (dest->value, src->value, SA_CLM_MAX_ADDRESS_LENGTH);
  74. }
  75. /*
  76. * Marshalling the SaClmClusterNodeT data structure
  77. */
  78. typedef struct {
  79. mar_uint32_t node_id __attribute__((aligned(8)));
  80. mar_clm_node_address_t node_address __attribute__((aligned(8)));
  81. mar_name_t node_name __attribute__((aligned(8)));
  82. mar_uint32_t member __attribute__((aligned(8)));
  83. mar_uint64_t boot_timestamp __attribute__((aligned(8)));
  84. mar_uint64_t initial_view_number __attribute__((aligned(8)));
  85. } mar_clm_cluster_node_t;
  86. static inline void swab_mar_clm_cluster_node_t(mar_clm_cluster_node_t *to_swab)
  87. {
  88. swab_mar_uint32_t (&to_swab->node_id);
  89. swab_mar_uint32_t (&to_swab->member);
  90. swab_mar_clm_node_address_t (&to_swab->node_address);
  91. swab_mar_name_t (&to_swab->node_name);
  92. swab_mar_uint64_t (&to_swab->boot_timestamp);
  93. swab_mar_uint64_t (&to_swab->initial_view_number);
  94. }
  95. static inline void marshall_to_mar_clm_cluster_node_t (
  96. mar_clm_cluster_node_t *dest,
  97. SaClmClusterNodeT *src)
  98. {
  99. dest->node_id = src->nodeId;
  100. marshall_to_mar_clm_node_address_t (&dest->node_address,
  101. &src->nodeAddress);
  102. marshall_to_mar_name_t (&dest->node_name, &src->nodeName);
  103. dest->member = src->member;
  104. dest->boot_timestamp = src->bootTimestamp;
  105. dest->initial_view_number = src->initialViewNumber;
  106. }
  107. static inline void marshall_from_mar_clm_cluster_node_t (
  108. SaClmClusterNodeT *dest,
  109. mar_clm_cluster_node_t *src)
  110. {
  111. dest->nodeId = src->node_id;
  112. marshall_from_mar_clm_node_address_t (&dest->nodeAddress,
  113. &src->node_address);
  114. marshall_from_mar_name_t (&dest->nodeName, &src->node_name);
  115. dest->member = src->member;
  116. dest->bootTimestamp = src->boot_timestamp;
  117. dest->initialViewNumber = src->initial_view_number;
  118. }
  119. typedef enum {
  120. MAR_NODE_NO_CHANGE = 1,
  121. MAR_NODE_JOINED = 2,
  122. MAR_NODE_LEFT = 3,
  123. MAR_NODE_RECONFIGURED = 4
  124. } mar_clm_cluster_change_t;
  125. /*
  126. * Marshalling the SaClmClusterNotificationT data structure
  127. */
  128. typedef struct {
  129. mar_clm_cluster_node_t cluster_node __attribute__((aligned(8)));
  130. mar_clm_cluster_change_t cluster_change __attribute__((aligned(8)));
  131. } mar_clm_cluster_notification_t;
  132. static inline void marshall_to_mar_clm_cluster_notification_t (
  133. mar_clm_cluster_notification_t *dest,
  134. SaClmClusterNotificationT *src)
  135. {
  136. marshall_to_mar_clm_cluster_node_t (&dest->cluster_node,
  137. &src->clusterNode);
  138. dest->cluster_change = src->clusterChange;
  139. }
  140. static inline void marshall_from_mar_clm_cluster_notification_t (
  141. SaClmClusterNotificationT *dest,
  142. mar_clm_cluster_notification_t *src)
  143. {
  144. marshall_from_mar_clm_cluster_node_t (&dest->clusterNode,
  145. &src->cluster_node);
  146. dest->clusterChange = src->cluster_change;
  147. }
  148. typedef struct {
  149. unsigned long long view_number __attribute__((aligned(8)));
  150. unsigned int number_of_items __attribute__((aligned(8)));
  151. unsigned long long notification __attribute__((aligned(8)));
  152. } mar_clm_cluster_notification_buffer_t;
  153. static inline void marshall_to_mar_cluster_notification_buffer_t (
  154. mar_clm_cluster_notification_buffer_t *dest,
  155. SaClmClusterNotificationBufferT *src)
  156. {
  157. dest->view_number = src->viewNumber;
  158. dest->number_of_items = src->numberOfItems;
  159. memcpy (&dest->notification, &src->notification,
  160. sizeof (SaClmClusterNotificationBufferT *));
  161. }
  162. static inline void marshall_from_mar_cluster_notification_buffer_t (
  163. SaClmClusterNotificationBufferT *dest,
  164. mar_clm_cluster_notification_buffer_t *src)
  165. {
  166. dest->viewNumber = src->view_number;
  167. dest->numberOfItems = src->number_of_items;
  168. memcpy (&dest->notification, &src->notification,
  169. sizeof (SaClmClusterNotificationBufferT *));
  170. }
  171. #endif /* AIS_MAR_CLM_H_DEFINED */